-
Notifications
You must be signed in to change notification settings - Fork 355
Add Quanta OEM code: ipmitool for DIMM slot readable feature #5
Conversation
lib/ipmi_oem.c
Outdated
@@ -40,6 +40,8 @@ | |||
static int ipmi_oem_supermicro(struct ipmi_intf * intf); | |||
static int ipmi_oem_ibm(struct ipmi_intf * intf); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this empty line between ibm and quanta.
lib/ipmi_sel.c
Outdated
return NULL; | ||
} else if (rsp->ccode > 0) { | ||
lprintf(LOG_ERR, " Error getting system info: %s", | ||
val2str(rsp->ccode, completion_code_vals)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use tabs to indent to lprintf
level, then spaces to align val2str
to LOG_ERR
or to the opening double quote. Please see https://github.com/ipmitool/ipmitool/wiki/Coding-Standards regarding indentation and alignment.
lib/ipmi_sel.c
Outdated
snprintf(desc, SIZE_OF_DESC, "CPU%d_%c%d", | ||
(data3 & 0xC0)>> 6, | ||
((data3 & 0x38) >> 3)+0x41, | ||
(data3 & 0x07)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent/align according to https://github.com/ipmitool/ipmitool/wiki/Coding-Standards
lib/helper.c
Outdated
@@ -1026,3 +1026,40 @@ ipmi_get_oem_id(struct ipmi_intf *intf) | |||
|
|||
return oem_id; | |||
} | |||
|
|||
uint16_t | |||
ipmi_get_qct_paltform_id(struct ipmi_intf *intf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't belong here. It must go to lib/ipmi_quantaoem.c
just like it is done for sunoem, kontronoem, et al.
include/ipmitool/ipmi.h
Outdated
@@ -250,6 +250,7 @@ struct ipmi_rs { | |||
#define IPMI_BMC_SLAVE_ADDR 0x20 | |||
#define IPMI_REMOTE_SWID 0x81 | |||
|
|||
#define IPMI_NETFN_QCTOEM 0x36 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't belong here and must go to include/ipmitool/ipmi_quantaoem.h
just like it is done for sunoem, et al.
Hi, Mr. Amelkin: Thanks for your advice, I have fixed the typo and move Quanta's code to new files. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the comments and make sure that your code compiles without warnings (warnings from existing header files do not count of course).
include/ipmitool/ipmi_quantaoem.h
Outdated
@@ -0,0 +1,47 @@ | |||
/* | |||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to put your new code under Oracle's copyright?
The disclaimer below isn't even attributed to Oracle and mentions SUN instead. I guess you borrowed it from some of the files with broken copyright/license statement.
Originally, it was a standard 2-clause BSD license (https://opensource.org/licenses/BSD-2-Clause).
Unless you work for Oracle, I think you need to use a copyright/license statement like the one used in lib/create_pen_list
. Probably you want to specify Quanta or yourself as the copyright owner.
lib/ipmi_quantaoem.c
Outdated
@@ -0,0 +1,176 @@ | |||
/* | |||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Oracle?
lib/ipmi_quantaoem.c
Outdated
req.msg.netfn = IPMI_NETFN_QCTOEM; | ||
req.msg.cmd = 0x65; | ||
req.msg.data = msg_data; | ||
req.msg.data_len = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use sizeof()
in such cases. There must be no way for discrepancy to sneak in later when someone decides to change the size of the structure but forgets to update the magic number here. Although this scenario is unlikely in this particular case, it's just a good habit to avoid duplicating data (and code) whenever possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to fix this. Use sizeof(msg_data)
.
lib/ipmi_quantaoem.c
Outdated
|
||
memset(&req, 0, sizeof(req)); | ||
req.msg.netfn = IPMI_NETFN_QCTOEM; | ||
req.msg.cmd = 0x65; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use "magic number". Define a descriptive macro, e.g. QUANTA_GET_PLATFORM_ID
.
lib/ipmi_quantaoem.c
Outdated
return 0; | ||
} | ||
oem_id = rsp->data[0]; | ||
lprintf(LOG_DEBUG,"Platform ID: %x", oem_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of having a 16-bit uint16_t oem_id
to assign an 8-bit value to it and then print using an integer (32- or 64-bit) conversion specifier %x
?
Besides, it looks like it is actually platform_id
, not oem_id
(which would be IPMI_OEM_QUANTA).
lib/ipmi_sel.c
Outdated
@@ -1244,6 +1244,9 @@ ipmi_get_oem_desc(struct ipmi_intf * intf, struct sel_event_record * rec) | |||
case IPMI_OEM_SUPERMICRO_47488: | |||
desc = get_supermicro_evt_desc(intf, rec); | |||
break; | |||
case IPMI_OEM_QUANTA: | |||
desc = get_quanta_evt_desc(intf, rec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You get warning: implicit declaration of function ‘get_quanta_evt_desc’
here, and also (as a result) warning: implicit declaration of function ‘get_quanta_evt_desc’
. Please fix.
lib/ipmi_quantaoem.c
Outdated
int data2; | ||
int data3; | ||
int sensor_type; | ||
uint8_t i = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is unused.
lib/ipmi_quantaoem.c
Outdated
snprintf(desc, SIZE_OF_DESC, "CPU%d_%c%d", | ||
(data3 & 0xC0)>> 6, | ||
((data3 & 0x38) >> 3)+0x41, | ||
(data3 & 0x07)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are all these magic numbers? Macros with descriptive names are required.
lib/ipmi_quantaoem.c
Outdated
/* check the platform type */ | ||
oem_id = ipmi_get_qct_platform_id(intf); | ||
|
||
if(oem_id == 0x02) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 0x02
? A descriptive macro please.
lib/ipmi_quantaoem.c
Outdated
struct ipmi_rs *rsp; | ||
struct ipmi_rq req; | ||
char *desc = NULL; | ||
int chipset_type = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is never used.
@qctbmc, will you please fix it? It's out of sync with master already and the longer you wait, the more out of sync it will get. |
Hi, Mr. Amelkin: Sorry to reply late, I already sync with master code and modify Quanta's code from your comment. Thanks |
lib/ipmi_quantaoem.c
Outdated
@@ -60,16 +61,18 @@ | |||
#include <ipmitool/ipmi_quantaoem.h> | |||
#include <ipmitool/ipmi_raw.h> | |||
|
|||
#define SIZE_OF_DESC 128 /* Max Size of the description String to be displyed for the Each sel entry */ | |||
#define SIZE_OF_DESC 128 /* Max Size of the description String to be displyed for the Each sel entry */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why so many spaces before and after macro name? Doesn't look aligned to anything.
Anyway, please avoid "pretty" formatting. It tends to deteriorate over time and is hard to maintain.
There is a clause on this in Coding Standards.
lib/ipmi_quantaoem.c
Outdated
req.msg.netfn = IPMI_NETFN_QCTOEM; | ||
req.msg.cmd = 0x65; | ||
req.msg.data = msg_data; | ||
req.msg.data_len = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to fix this. Use sizeof(msg_data)
.
lib/ipmi_quantaoem.c
Outdated
/* Check for the Standard Event type == 0x6F */ | ||
if (rec->sel_type.standard_type.event_type != 0x6F) { | ||
return NULL; | ||
} | ||
/* Allocate mem for te Description string */ | ||
desc = malloc(sizeof(char) *SIZE_OF_DESC); | ||
desc = malloc(sizeof(char) * SIZE_OF_DESC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(char)
is useless here. Your SIZE_OF_DESC
is already in bytes. Size of a char is by definition 1 byte.
lib/ipmi_quantaoem.c
Outdated
if (desc == NULL) { | ||
lprintf(LOG_ERR, "ipmitool: malloc failure"); | ||
return NULL; | ||
} | ||
memset(desc, '\0', SIZE_OF_DESC); | ||
memset(desc, '0', SIZE_OF_DESC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'\0'
was 0x00, now '0'
is 0x30. Is this really what you wanted? I thought you were going to set all bytes to 0
, not to '0'
. There is a difference.
include/ipmitool/ipmi_quantaoem.h
Outdated
{ | ||
GRANTLY = 0, | ||
PURLEY = 2 | ||
} Code_Base; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call this enum type in an oem-specific way in order to avoid potential conflicts. And please don't use CamelCase in this project please. I've updated the Coding Standards on this topic.
Call it, for example, oem_qct_platform_id_t
or oem_qct_platform_t
.
lib/ipmi_quantaoem.c
Outdated
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* Copyright (c) 2018 Quanta Computer Inc. All Rights Reserved. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trailing space (and the one below) must not be here.
include/ipmitool/ipmi_quantaoem.h
Outdated
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE | ||
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE | ||
* THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGES. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please in future avoid such re-formatting as they appear like major changes when in fact you only moved the line breaks.
Please remove the trailing whitespaces in this new block.
Please make sure your committed code doesn't contain traling whitespaces (including tabs) anywhere.
lib/ipmi_quantaoem.c
Outdated
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace again. Here and below.
lib/ipmi_quantaoem.c
Outdated
@@ -80,7 +83,7 @@ ipmi_get_qct_platform_id(struct ipmi_intf *intf) | |||
|
|||
memset(&req, 0, sizeof(req)); | |||
req.msg.netfn = IPMI_NETFN_QCTOEM; | |||
req.msg.cmd = 0x65; | |||
req.msg.cmd = BMC_GET_OEM_INFO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace here.
lib/ipmi_quantaoem.c
Outdated
(data3 & 0xC0)>> 6, | ||
((data3 & 0x38) >> 3)+0x41, | ||
(data3 & 0x07)); | ||
CPU_NUM( data ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace
Also, your 'Update from ipmitool master' commit is not the right way to rebase to master.
During the interactive rebase, drop your 'Update' commit, then resolve all
Test that you can do
|
Hi, Mr. Amelkin: Thanks for your great advice, I re-sync master ipmitool code and add my modify code. Thanks |
lib/ipmi_quantaoem.c
Outdated
#define CHANNEL_NUM(x) (CHANNEL_BASE + CHANNEL_OFFSET(x)) | ||
|
||
#define DIMM_MASK 0x07 | ||
#define DIMM_NUM(x) ((x) & CPU_MASK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CPU_MASK
? Really?
lib/ipmi_quantaoem.c
Outdated
#define CHANNEL_BASE 0x41 | ||
#define CHANNEL_SHIFT 3 | ||
#define CHANNEL_MASK 0x07 | ||
#define CHANNEL_OFFSET(x) (((x) >> CHANNEL_SHIFT) & CHANNEL_MASK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use TABs for spaces or alignment! TABs are only for block level indentation.
You have lots of TABs throughout your code (in all files) where spaces must be used. This is not the only place. I will not comment the rest. Please fix them all. And get rid of all trailing whitespace (spaces and TABs alike).
lib/ipmi_quantaoem.c
Outdated
msg_data[0] = 0x4C; | ||
msg_data[1] = 0x1C; | ||
msg_data[2] = 0x00; | ||
msg_data[3] = 0x02; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these magic numbers? Please use descriptive macros instead.
lib/ipmi_quantaoem.c
Outdated
lprintf(LOG_ERR, "Get Platform ID command failed"); | ||
return 0; | ||
} | ||
if (rsp->ccode > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's uint8_t
, and can't be negative, so this check is basically for non-zero. Hence, please use if (rsp->ccode) {
.
lib/ipmi_quantaoem.c
Outdated
return 0; | ||
} | ||
if (rsp->ccode > 0) { | ||
lprintf(LOG_ERR, "Get Platform ID command failed: %#x %s", rsp->ccode, val2str(rsp->ccode, completion_code_vals)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap to fit into 80 characters, align the wrapped line with spaces to the opening parenthesis.
lib/ipmi_quantaoem.c
Outdated
#define GET_PLATFORM_ID_DATA_SIZE 4 | ||
|
||
uint8_t | ||
oem_qct_get_qct_platform_id(struct ipmi_intf *intf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally up to you, but I'd remove the second qct
here.
lib/ipmi_quantaoem.c
Outdated
sensor_type = rec->sel_type.standard_type.sensor_type; | ||
switch (sensor_type) { | ||
case SENSOR_TYPE_MEMORY: | ||
memset(&req, 0, sizeof (req)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to Coding Standards on switch
formatting. This is NOT the way.
lib/ipmi_quantaoem.c
Outdated
if (desc != NULL) { | ||
free(desc); | ||
desc = NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do Linux-kernel-style centralized cleanup, see here
lib/ipmi_quantaoem.c
Outdated
/* check the platform type */ | ||
platform_id = oem_qct_get_qct_platform_id(intf); | ||
if(OEM_QCT_PLATFORM_PURLEY == platform_id) { | ||
snprintf(desc, SIZE_OF_DESC, "CPU%d_%c%d", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an indent? Doesn't look so. TAB is required.
Hi, Mr. Amelkin: Thanks for your great advice, I re-sync master ipmitool code and add my modify code. Thanks |
Ok, I have fixed some more minor issues and merged this. |
I am very sceptical about this patch, it gives me wrong DIMM locations for UE/CE (vs. the technical PDF QCT support gave me) (server is T22HF-1U). |
@JPlanche, well, I believe the code was sumbitted by Quanta Cloud Technology BMC team, so I assumed they know what they do about their products. If you think there is a bug, please submit your own PR with a fix or at least create a separate issue. Commenting a merged PR is quite useless in terms of getting the problem fixed. You may reference this PR from your issue or new PR if you want though. |
Hi, Mr. Amelkin:
I posted ticket with https://sourceforge.net/p/ipmitool/bugs/511/ on SourceForge.
I have forked ipmitool and try "Pull Request" to request merge to "ipmitool" code.
Thank you