Skip to content
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

Merged
merged 2 commits into from
Sep 10, 2018
Merged

Fix port binding commands issues. #42

merged 2 commits into from
Sep 10, 2018

Conversation

ghost
Copy link

@ghost ghost commented Sep 4, 2018

The output of command port-bind-info does not display strings for
bind state and port binding commands use wrong condition for error
check.

@ghost ghost requested review from lsgunth, kelvin-cao and wesleywesley September 4, 2018 14:16
cli/main.c Outdated
int state = (status.bind_state & 0xF0) >> 4;

switch (result) {
case 0:
Copy link
Collaborator

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.

Copy link
Author

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) {
Copy link
Collaborator

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.

Copy link
Author

@ghost ghost Sep 5, 2018

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.

Copy link
Collaborator

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.

Copy link
Author

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);
Copy link
Collaborator

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()

Copy link
Author

@ghost ghost Sep 5, 2018

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.

Copy link
Collaborator

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.

Copy link
Author

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

@ghost ghost force-pushed the bugfix_bind_info branch 3 times, most recently from 401582d to 6a6b075 Compare September 6, 2018 09:34
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,
Copy link
Collaborator

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?

Copy link
Collaborator

@lsgunth lsgunth left a 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.

JoeyZhang-Microsemi added 2 commits September 7, 2018 03:31
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.
@ghost
Copy link
Author

ghost commented Sep 7, 2018

Thanks for the review. I has split the commit.

Thanks
Joey

@wesleywesley wesleywesley merged commit fcbb05a into devel Sep 10, 2018
@wesleywesley
Copy link
Contributor

Following enum overlap the system error number:

ERR_PHYC_PORT_ARDY_BIND = 0x00000001,
ERR_LOGC_PORT_ARDY_BIND = 0x00000002,

ERR_BIND_CHECK_FAIL = 0x0000000d,

Which lead to false prompt in case of non-port-bind related commands by following code in switchtec_strerror function:

case ERR_PHYC_PORT_ARDY_BIND:
	msg = "Physical port already bound"; break; 
case ERR_LOGC_PORT_ARDY_BIND: 
	msg = "Logical bridge instance already bound"; break; 
    …
case ERR_BIND_CHECK_FAIL: 
	msg = "Port bind checking failed"; break; 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants