ipmi_intf.h was missing a couple of declarations for the functions
used by fru, sdr and hpmfwupg modules. Add those declarations
to ipmi_intf.h and remove local declarations.
This fixes a couple of compilation warnings.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Swap calls to free() with calls to free_n() to leverage helper method
and handle clearing pointers after freeing in one step.
Signed-off-by: Patrick Venture <venture@google.com>
Check against FRU_AREA_MAXIMUM_BLOCK_SZ instead of FRU_BLOCK_SZ
when checking if the write chunk needs to be reduced.
Apparently, that was the original intention, and then there
was just a typo. In other places the same check is done properly.
Signed-off-by: Patrick Venture <venture@google.com>
Change ipmi_fru_query_new_value to return the bool type
instead of an int that's being used as a boolean value.
Signed-off-by: Patrick Venture <venture@google.com>
Add fru_cc_rq2big helper method to reduce duplicate
code checking for specific size-based IPMI response
codes.
Signed-off-by: Patrick Venture <venture@google.com>
Cleanup style in method ipmi_fru_oemkontron_get as well as add inverted
logic checks to reduce indentation.
Signed-off-by: Patrick Venture <venture@google.com>
Fixup the following array bounds checking bugs:
[lib/ipmi_fru.c:1003]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1127]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1262]: (style) Array index 'i' is
used before limits check.
Signed-off-by: Patrick Venture <venture@google.com>
Move static objects declared in headers to the source files where
they're used.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Patrick Venture <venture@google.com>
Cleanup all unused-parameter warnings. Each warning was examined to
verify it wasn't simply a case of a build macro difference.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Patrick Venture <venture@google.com>
Several functions were passed a struct ipmi_intf* even though it was
unused. This removes the unused parameters and changes calls and
signatures.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Handle all date/time stamps uniformly, taking in account the host
endianness. Respect the local time zone and the '-Z' option for
all ipmitool commands. Unify the date and time formatting.
Add correct handling of IPMI timestamps 'since system startup'
and for 'unspecified' timestamps.
Partially resolvesipmitool/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Remove all direct comparisons to 'NULL' for pointers.
Replace them with boolean-like 'if (ptr)' and 'if (!ptr)'.
This makes conditions shorter and easier to read.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Make code better readable by replacing `if (rsp->ccode > 0)`
and 'if (rsp->ccode != 0)' with just `if (rsp->ccode)` as
rsp->ccode is anyway an unsigned byte and can't be negative.
Also replace 'if (rsp->ccode == 0)' with 'if (!rsp->ccode)'.
All these changes make lines shorter and easier to read as
a non-zero ccode is an indication of some failure, and so !ccode
naturally reads as 'no error'.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Add ARRAY_SIZE() macro.
Use the new macro in all places where array size is calculated by
means of sizeof(array)/sizeof(array[0]).
Fix minor bugs and warnings in the affected code.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Added an option -Z to display all dates in UTC.
Resolvesipmitool/ipmitool#19
Change-Id: Iac3a61190eefde12d95c892af26072ec01f60474
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
A segmentation fault was trigged by executing 'ipmitool fru internaluse 1 info'.
A memset() was attempted on the address of a pointer, not on the pointer itself.
The erroneous memset() is removed with this commit because it duplicates
the memset() in line 4072.
Resolvesipmitool/ipmitool#9
Signed-off-by: Kylix Lo <kylix0713@gmail.com>
The get_fru_area_str() function is used to decode FRU area
fields into text. Areas may be encoded as text, binary,
BCDplus or 6-bit ASCII. Decoding of 6-bit ASCII and BCDplus
was broken. There was an error in the formulas used to
calculate the resulting string length, plus the decoding
formulas for BCDplus was wrong.
For BCDplus the resulting length was considered equal
the encoded data length, while in fact it's twice as big.
Only one character instead of two was being extracted from
a single input byte while two nibbles must have been taken
into account.
For 6-bit ASCII rounding of 3 to 4 bytes conversion was done
improperly adding 2 to the original length instead of the
result of multiplication.
PICMG 3.1 R2.0 introduces new a new Link Class field in the FRU
Link Descriptors which is the upper 4 bits of the Link Type field.
This new Link Class field specifies SERDES lanes with 10.3125Gbd
signalling rate.
It also introduces the new Base-KX and Base-KX4 types which are the
new IEEE replacements for the PICMG 3.0 Base-BX and Base-BX4 types.
This patch decodes these new types and fields and will print out
proper descriptions for each one based on PICMG 3.1 R2.0
Targets as a problem with editing FRUs (like ipmitool ....
fru edit 0 field b 0 "blahblah") where the header (multirecord area offset) is
not correctly updated.
It is supposed to modify the header offset to muti-record area if any of
the three previous areas has been edited.
Remark: this has to occur before the new header crc is calculated.
Thats the reson the modification is not close to the actual movement of the
data. Maybe it would be nicer to change the order in the code here. But
I do not want to add undesired behaviour, thus keeping a clear and small
patch.
Editing a fru without resizing it caused the checksum being incorrect and not
being updated. This fix changes this, so the checksum is now being correctly
calculated and written to the right place.
1. Warnings about "FRU Area Length" based on uninitialized (malloc'd) memory
contents (due to fru->max_read_size not being initialized, left at 0) and
fru_data not being zeroed after malloc() in ipmi_fru_set_field_string().
2. "fru edit" commands for any field index other than 0 would fail (with "Field
not found !" error) due to a couple offset and length calculation errors (for
all the supported "area" types) in ipmi_fru_set_field_string().
3. "fru edit" commands would corrupt the FRU Inventory Area due to incorrect
"source offset" value being specified in write_fru_area() call in
impi_fru_set_field_string().
Commit for Rob Swindell
This patch adds basic long message support for PICMG-based systems according to
the HPM.2 specification.
It also introduces APIs for setting inbound and outbound messages sizes per
selected interface.
This APIs are used in LAN and LAN+ interfaces to set autonomously detected
inbound and outbound message sizes.
The newly introduced APIs also replace the existing message size detection code
in several ipmitool commands in order to leverage the advantages of long message
support (HPM.1 upgrade, SDR acquring, FRU inventory read and write).
The Kontron-specific long message support is moved under a OEM option.
Commit for Dmitry Bazhenov