-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CMIS] Return the CDB status value for the caller to check the status… #485
Conversation
@@ -1282,7 +1282,7 @@ def get_module_fw_info(self): | |||
return {'status': False, 'info': "CDB Not supported", 'result': None} | |||
|
|||
# get fw info (CMD 0100h) | |||
rpllen, rpl_chkcode, rpl = self.cdb.get_fw_info() | |||
rpllen, rpl_chkcode, rpl = self.cdb.get_fw_info()['rpl'] |
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.
@xinyulin Can we check for the value of self.cdb.get_fw_info()['status']
and take appropriate action?
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.
@mihirpat1 I have added the check and corresponding actions in the get_module_fw_mgmt_feature() and get_module_fw_info() functions. Could you please review them again? Thanks.
04560e3
to
a66b757
Compare
@@ -1281,7 +1284,7 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |||
elapsedtime = time.time()-starttime | |||
logger.info('Get module FW upgrade features time: %.2f s\n' %elapsedtime) | |||
logger.info(txt) | |||
return {'status': True, 'info': txt, 'feature': (startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength)} | |||
return {'status': True, 'info': txt, 'result': (startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength)} |
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.
change the field from feature
to result
will break the method caller!
e.g. https://github.com/sonic-net/sonic-utilities/blob/84cb00a4b2d7e8fb2bcab259367836fa11a17d0a/sfputil/main.py#L1528
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.
@rqx110 thanks for your review and comment, I will change it back to feature.
2556588
to
ef46a57
Compare
@@ -1277,7 +1280,7 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |||
|
|||
else: | |||
txt += 'Reply payload check code error\n' | |||
return {'status': False, 'info': txt, 'result': None} | |||
return {'status': False, 'info': txt, 'feature': None} |
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.
@mihirpat1 As suggested by rqx110, I should ensure that get_module_fw_mgmt_feature() returns a dictionary with the key 'feature' instead of 'result'; otherwise, other callers may not function properly. To ensure consistency in the output dictionary keys, I have also corrected the key to 'feature' for error cases.
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.
@xinyulin Can you please test FW download + run + commit if not already tested with the changes?
''' | ||
cmd = bytearray(b'\x00\x00\x00\x00\x02\x00\x00\x00\x00\x10') | ||
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd) | ||
self.write_cdb(cmd) | ||
status = self.cdb1_chkstatus() | ||
if (status != 0x1): |
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.
@xinyulin Can you please revert this unrelated change to avoid increasing line history (agreed that the version without parenthesis is more pythonic though). Please do the same for similar changes in the diff.
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.
Sure, I have reverted it.
@@ -1277,7 +1280,7 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |||
|
|||
else: | |||
txt += 'Reply payload check code error\n' | |||
return {'status': False, 'info': txt, 'result': None} | |||
return {'status': False, 'info': txt, 'feature': None} |
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.
@xinyulin Can we log an error with the value of status here?
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 error will be logged with the following format in the latest commit
else:
txt += 'Status or reply payload check code error\n'
logger.info(txt)
logger.info('Fail to get fw mgnt feature, cdb status: 0x{}\n'.format(status))
return {'status': False, 'info': txt, 'feature': None}
The new commit has been tested with firmware download, run, and commit flows without any errors. Could you please review it to see if anything is missing.
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.
In my opinion, there is no need to log here. The method caller will make the judgment and log the result.
for example:
https://github.com/sonic-net/sonic-utilities/blob/f50587a1ff65bb489231bfe45cec805fb32dbf00/sfputil/main.py#L1526-L1531
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.
@rqx110 I think capturing the status
and rpl_chkcode
as part of logs will help in providing more datapoints to debug in case of an error.
… and perform the corresponding actions Signed-off-by: xinyu <[email protected]>
…ent feature command Signed-off-by: xinyu <[email protected]>
ef46a57
to
7b098c7
Compare
return {'status': False, 'info': txt, 'result': None} | ||
txt += 'Status or reply payload check code error\n' | ||
logger.info(txt) | ||
logger.info('Fail to get fw mgnt feature, cdb status: 0x{}\n'.format(status)) |
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.
logger.info('Fail to get fw mgnt feature, cdb status: 0x{}\n'.format(status)) | |
logger.info('Fail to get fw mgmt feature, cdb status: {:#x}\n'.format(status)) |
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.
@xinyulin Can you please log the value of rpl_chkcode
?
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.
Sure. both rpl_chkcode and check result are recorded in the new commit.
return {'status': False, 'info': txt, 'result': None} | ||
txt += 'Status or reply payload check code error\n' | ||
logger.info(txt) | ||
logger.info('Fail to get fw mgnt feature, cdb status: {:#x} rpl_chkcode: {:#x}, {:#x}\n'.format(status, self.cdb.cdb_chkcode(rpl), rpl_chkcode)) |
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.
First, mgnt
should mgmt
Second, missing ',' after cdb status: {:#x}
Third, the message rpl_chkcode: {:#x}, {:#x}
is not very clear. When leaving the code, do you know what the first and second values represent?
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.
@rqx110 Thank you for the review. I have added more details and corrected the incorrect abbreviation.
…er data when an error occurs Signed-off-by: xinyu <[email protected]>
4a1b685
to
4d919c8
Compare
return {'status': False, 'info': txt, 'result': None} | ||
txt += 'Status or reply payload check code error\n' | ||
logger.info(txt) | ||
logger.info('Fail to get fw mgmt feature, cdb status: {:#x}, cdb_chkcode: {:#x}, rpl_chkcode: {:#x}\n'.format(status, self.cdb.cdb_chkcode(rpl), rpl_chkcode)) |
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.
logger.info('Fail to get fw mgmt feature, cdb status: {:#x}, cdb_chkcode: {:#x}, rpl_chkcode: {:#x}\n'.format(status, self.cdb.cdb_chkcode(rpl), rpl_chkcode)) | |
logger.error('Fail to get fw mgmt feature, cdb status: {:#x}, cdb_chkcode: {:#x}, rpl_chkcode: {:#x}\n'.format(status, self.cdb.cdb_chkcode(rpl), rpl_chkcode)) |
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.
@mihirpat1 Thanks for the suggestion, I have modified it accordingly.
…ature Signed-off-by: xinyu <[email protected]>
@bingwang-ms could you take this to 202405. This is for improved debugging. |
@bingwang-ms MSFT ADO - 26804772 |
sonic-net#485) * [CMIS] Return the CDB status value for the caller to check the status and perform the corresponding actions Signed-off-by: xinyu <[email protected]> * [CMIS] Log an error when failing to retrieve the CDB firmware management feature command Signed-off-by: xinyu <[email protected]> * [CMIS] Log get fw mgmt feature RPL check code result to provide clearer data when an error occurs Signed-off-by: xinyu <[email protected]> * [CMIS] Chagne log level from info to error for fail to get fw mgmt feature Signed-off-by: xinyu <[email protected]> --------- Signed-off-by: xinyu <[email protected]>
Cherry-pick PR to 202405: #496 |
#485) * [CMIS] Return the CDB status value for the caller to check the status and perform the corresponding actions Signed-off-by: xinyu <[email protected]> * [CMIS] Log an error when failing to retrieve the CDB firmware management feature command Signed-off-by: xinyu <[email protected]> * [CMIS] Log get fw mgmt feature RPL check code result to provide clearer data when an error occurs Signed-off-by: xinyu <[email protected]> * [CMIS] Chagne log level from info to error for fail to get fw mgmt feature Signed-off-by: xinyu <[email protected]> --------- Signed-off-by: xinyu <[email protected]>
Description
This PR unifies all CDB API calls to return CDB status, allowing the caller to check the command status returned from the module and perform corresponding actions.
Motivation and Context
Modified the following CDB APIs to return a dictionary with CDB status as the first element and RPL result as the second element.
The caller can first check the CDB status to ensure the command was processed successfully, then retrieve the data from the reply payload (RPL).
How Has This Been Tested?
Tested with Cisco8111 and Credo C1 cable