-
Notifications
You must be signed in to change notification settings - Fork 32
mctpd: update get msg type if vdm is registered #134
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,8 @@ static const char *conf_file_default = MCTPD_CONF_FILE_DEFAULT; | |
|
|
||
| static const mctp_eid_t eid_alloc_min = 0x08; | ||
| static const mctp_eid_t eid_alloc_max = 0xfe; | ||
| static const uint8_t MCTP_TYPE_VENDOR_PCIE = 0x7e; | ||
| static const uint8_t MCTP_TYPE_VENDOR_IANA = 0x7f; | ||
|
|
||
| // arbitrary sanity | ||
| static size_t MAX_PEER_SIZE = 1000000; | ||
|
|
@@ -981,6 +983,7 @@ static int handle_control_get_message_type_support( | |
| { | ||
| struct mctp_ctrl_resp_get_msg_type_support *resp = NULL; | ||
| struct mctp_ctrl_cmd_get_msg_type_support *req = NULL; | ||
| bool pcie_support = false, iana_support = false; | ||
| size_t i, resp_len, type_count; | ||
| uint8_t *resp_buf, *msg_types; | ||
| int rc; | ||
|
|
@@ -992,6 +995,21 @@ static int handle_control_get_message_type_support( | |
|
|
||
| req = (void *)buf; | ||
| type_count = ctx->num_supported_msg_types; | ||
| for (i = 0; i < ctx->num_supported_msg_types; i++) { | ||
| pcie_support |= (ctx->supported_msg_types[i].msg_type == | ||
| MCTP_TYPE_VENDOR_PCIE); | ||
| iana_support |= (ctx->supported_msg_types[i].msg_type == | ||
| MCTP_TYPE_VENDOR_IANA); | ||
| } | ||
|
|
||
| for (i = 0; i < ctx->num_supported_vdm_types; i++) { | ||
| pcie_support |= ctx->supported_vdm_types[i].format == | ||
| VID_FORMAT_PCIE; | ||
| iana_support |= ctx->supported_vdm_types[i].format == | ||
| VID_FORMAT_IANA; | ||
| } | ||
| type_count += (pcie_support + iana_support); | ||
|
|
||
| // Allocate extra space for the message types | ||
| resp_len = sizeof(*resp) + type_count; | ||
| resp_buf = malloc(resp_len); | ||
|
|
@@ -1004,13 +1022,19 @@ static int handle_control_get_message_type_support( | |
| mctp_ctrl_msg_hdr_init_resp(&resp->ctrl_hdr, req->ctrl_hdr); | ||
| resp->completion_code = MCTP_CTRL_CC_SUCCESS; | ||
|
|
||
| resp->msg_type_count = type_count; | ||
| // Append message types after msg_type_count | ||
| msg_types = (uint8_t *)(resp + 1); | ||
| for (i = 0; i < type_count; i++) { | ||
| for (i = 0; i < ctx->num_supported_msg_types; i++) { | ||
| msg_types[i] = ctx->supported_msg_types[i].msg_type; | ||
| } | ||
| if (pcie_support) { | ||
| msg_types[i++] = MCTP_TYPE_VENDOR_PCIE; | ||
| } | ||
| if (iana_support) { | ||
| msg_types[i++] = MCTP_TYPE_VENDOR_IANA; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if someone has already registered Doing the find (setting the booleans) and message construction (setting If you're taking the approach that 7e/7f do not appear in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think 7e or 7f can come in supported_message_types . |
||
|
|
||
| resp->msg_type_count = type_count; | ||
| rc = reply_message(ctx, sd, resp, resp_len, addr); | ||
| free(resp_buf); | ||
|
|
||
|
|
||
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.
Wouldn't this duplicate the entries for 0x7e/0x7f in the response?