-
Notifications
You must be signed in to change notification settings - Fork 55
Add tlp inject command #345
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
Add tlp inject command #345
Conversation
| } | ||
| if (num_dwords > 132) { | ||
| fprintf(stderr, "TLP data cannot exceed 132 dwords \n"); | ||
| free(raw_tlp_dwords); |
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 change is not mentioned in the commit message. The free() call looks a bit suspicious but its removal should probably have some comments with it.
| .dest_port = port_id, | ||
| .tlp_type = tlp_type, | ||
| .tlp_length = tlp_length, | ||
| .ecrc = ecrc |
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.
For multi-byte field, need to handle endianness properly on input/output data.
lib/diag.c
Outdated
| }; | ||
| for (int i = 0; i < tlp_in.tlp_length; i++) | ||
| { | ||
| tlp_in.raw_tlp_data[i] = *(raw_tlp_data + i); |
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.
Need to convert to the target endianness that the MRPC defined from host endianness.
| ptr = str; | ||
| for (int i = 0; i < *num_dwords; i++) { | ||
| char *endptr; | ||
| (*dwords)[i] = (uint32_t)strtoul(ptr, &endptr, 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.
What if user incorrectly input value like '0x0102030405' which exceeds a DW size?
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.
Do we handle this somewhere else?
cli/diag.c
Outdated
| {"enable_ecrc", 'e', "", CFG_NONE, &cfg.ecrc, no_argument, | ||
| "Enable the ecrc to be included at the end of the input data (Default: disabled)"}, | ||
| {"tlp_data", 'd', "DW0 DW1 ... DW131", CFG_STRING, &cfg.raw_tlp_data, required_argument, | ||
| "DW to be sent as part of the raw TLP (Maximum 132 DWs)"}, |
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.
If we expect every DW must start with '0x', probably need to let user know.
cli/diag.c
Outdated
| fprintf(stderr, "Error with tlp data provided \n"); | ||
| return -1; | ||
| } | ||
| if (num_dwords > 132) { |
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.
132 is used multiple times, please use a macro instead.
|
As a rule of thumb, if you've made corrections to a commit, consider squashing it and performing a hard push. It's better to avoid introducing additional commits to rectify an earlier one within the same pull request. |
ffde207 to
d5a6069
Compare
lib/diag.c
Outdated
| .ecrc = ecrc | ||
| }; | ||
| for (int i = 0; i < tlp_in.tlp_length; i++) | ||
| { |
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.
Style nit: '{' should be on the same line of 'for'
inc/switchtec/diag.h
Outdated
| uint32_t tlp_type; | ||
| uint32_t tlp_length; | ||
| uint32_t ecrc; | ||
| uint32_t raw_tlp_data[132]; |
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 need the macro TLP_MAX_DWS in the header and replace this '132' instance as well.
37b9a20 to
31ad75e
Compare
TLP injection command added to use the defined MRPC interface to send a raw TLP to a given destination port. User defined type and enable the ecrc. Raw tlp data is accepted as a string of characters and converted to appropriate dword type and sent as part of new structure defined by spec. Up to 132 dwords of raw tlp data can be sent a time, this limit is defined by a macro in the switchtec header file.
31ad75e to
f4fe1db
Compare
No description provided.