-
Notifications
You must be signed in to change notification settings - Fork 48
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
Fix port binding commands issues. #42
Conversation
cli/main.c
Outdated
int state = (status.bind_state & 0xF0) >> 4; | ||
|
||
switch (result) { | ||
case 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.
We should probably have an enum for these case values somewhere.
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.
I agree it. Thanks
cli/main.c
Outdated
@@ -940,23 +962,19 @@ static int port_bind_info(int argc, char **argv) | |||
|
|||
ret = switchtec_bind_info(cfg.dev, &bind_status, cfg.phy_port); | |||
|
|||
if (ret < 0) { | |||
printf("bind_info_error: %f", ret); | |||
if (ret > 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.
You still need to handle the case where switchtec_bind_info() returns less than zero (indicating an error submitting the command or something like that.
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.
The function switchtec_bind_info()/switchtec_bind()/switchtec_unbind() cannot return a value that is less than zero. If the return value is bigger than zero, it indicates a error.
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.
That's wrong. switchtec_bind_info() calls switchtec_cmd() and returns the result. switchtec_cmd() can always return negative numbers.
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.
Fixed it. Thanks
cli/main.c
Outdated
if (ret < 0) { | ||
printf("bind_info_error: %f", ret); | ||
if (ret > 0) { | ||
printf("bind_info_error: %d\n", ret); |
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.
Probably should also be using switchtec_perror()
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.
Because same error codes were used by different MRPC commands and have different meaning in firmware. so we just display the error code now.
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.
Well returning a number is incredibly user unfriendly. You should fix that and decode the number into a useful error message. If you can use switchtec_perror() that would be great, if not you should create something else. switchtec_bind_perror() or something.
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.
Use the switchtec_perror() to handle the errorno. Thanks
401582d
to
6a6b075
Compare
struct switchtec_bind_status_in sub_cmd_id = { | ||
.sub_cmd = MRPC_PORT_INFO, | ||
.phys_port_id = phy_port | ||
}; | ||
|
||
ret = switchtec_cmd(dev, MRPC_PORTPARTP2P, &sub_cmd_id, | ||
return switchtec_cmd(dev, MRPC_PORTPARTP2P, &sub_cmd_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.
Nice clean up, but can this be another commit?
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.
Looks good, but I think it should be two commits.
The output of command port-bind-info does not display strings for bind state. Port binding commands use wrong condition to check error and do not display strings for error code.
6a6b075
to
8fe9019
Compare
Thanks for the review. I has split the commit. Thanks |
Following enum overlap the system error number: ERR_PHYC_PORT_ARDY_BIND = 0x00000001, Which lead to false prompt in case of non-port-bind related commands by following code in switchtec_strerror function:
|
The output of command port-bind-info does not display strings for
bind state and port binding commands use wrong condition for error
check.