Skip to content

Commit dba730f

Browse files
ctrld: usb: Add option to ignore EIDs in the config JSON
We support ignoring EIDs returned by the bridge's routing table by supplying the `-z` parameter. This parameter is typically included in the systemd environment file. The above method does not work well for templated control daemon services (such as USB) if we have the need to ignore different set of EIDs for a given instance of the service. Therefore, this commit adds support to supply an array of decimal EIDs in the USB config JSON, which when supplied, will override any ignore EIDs in the -z parameter. Since the JSON has separate sections for every control daemon instance, this method can be used to supply unique ignore list per instance. Fixes JIRA https://jirasw.nvidia.com/browse/DGXOPENBMC-17580 Tested: Tested this on HGXB300 setup by temporarily overriding the USB config JSON as follows: ``` "1-1-1-2": { "eid_type" : "static", "own_eid" : 8, "bridge_eid" : 70, "bridge_pool_start" : 57, "ignore_eids" : [58, 59, 60], "vendor_id" : "0x0955", "product_id" : "0xCF11", "recovery_vendor_id": "0x0955", "recovery_product_id": "0xCF1F", "reset_gpio_name": "MCU2_RST_N-O", "recovery_gpio_name": "MCU2_RECOV_N-O", "_comment" : "CX8 MCU openbmc#2: CX8_3/CX8_1" } ``` Then, upon restarting the specific control daemon instance: ``` May 08 10:54:20 hgxb300 systemd[1]: Started MCTP USB control daemon. May 08 10:54:20 hgxb300 mctp-usb-ctrl 1-1-1-2[27536]: parse_command_line: No. of EIDs to ignore: 8 May 08 10:54:20 hgxb300 mctp-usb-ctrl 1-1-1-2[27536]: parse_command_line: Verbose level:1 May 08 10:54:20 hgxb300 mctp-usb-ctrl 1-1-1-2[27536]: parse_command_line: EID to ignore: 58 May 08 10:54:20 hgxb300 mctp-usb-ctrl 1-1-1-2[27536]: parse_command_line: EID to ignore: 59 May 08 10:54:20 hgxb300 mctp-usb-ctrl 1-1-1-2[27536]: parse_command_line: EID to ignore: 60 ``` The EIDs to ignore get overridden to 58, 59 and 60. The discovery output now shows: ``` root@hgxb300:~# busctl tree xyz.openbmc_project.MCTP.Control.USB1_1_1_2 `- /xyz `- /xyz/openbmc_project `- /xyz/openbmc_project/mctp |- /xyz/openbmc_project/mctp/0 | |- /xyz/openbmc_project/mctp/0/57 | `- /xyz/openbmc_project/mctp/0/70 `- /xyz/openbmc_project/mctp/USB1_1_1_2 ``` Also verified that other service instance are not impacted as they continue to use the global ignore list. Signed-off-by: Santosh Puranik <[email protected]>
1 parent 3439f0c commit dba730f

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

ctrld/mctp-ctrl.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,11 +1332,6 @@ static void parse_command_line(int argc, char *const *argv,
13321332
sizeof(cmdline->ignore_eids[0]));
13331333
MCTP_CTRL_INFO("%s: No. of EIDs to ignore: %d\n",
13341334
__func__, cmdline->ignore_eids_len);
1335-
for (int i = 0; i < cmdline->ignore_eids_len; ++i) {
1336-
MCTP_CTRL_INFO("%s: EID to ignore: %d\n",
1337-
__func__,
1338-
cmdline->ignore_eids[i]);
1339-
}
13401335
break;
13411336
case 'u':
13421337
set_uuid_str(cmdline->uuid_str, optarg, UUID_STR_LEN);
@@ -1562,6 +1557,10 @@ static void parse_command_line(int argc, char *const *argv,
15621557
default:
15631558
break;
15641559
}
1560+
for (int i = 0; i < cmdline->ignore_eids_len; ++i) {
1561+
MCTP_CTRL_INFO("%s: EID to ignore: %d\n", __func__,
1562+
cmdline->ignore_eids[i]);
1563+
}
15651564
free(config_json_file_path);
15661565
}
15671566

mctp-json.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,37 @@ int mctp_json_usb_get_params_ctrl(mctp_cmdline_args_t *cmdline,
11421142
usb->perform_device_reset = json_object_get_boolean(attr);
11431143
}
11441144

1145+
/* Parse optional ignore_eids array */
1146+
attr = json_object_object_get(obj, "ignore_eids");
1147+
if (attr != NULL) {
1148+
size_t num_eids = json_object_array_length(attr);
1149+
size_t i;
1150+
1151+
/* Initialize ignore_eids array */
1152+
memset(cmdline->ignore_eids, 0, sizeof(cmdline->ignore_eids));
1153+
cmdline->ignore_eids_len = 0;
1154+
1155+
/* Copy valid EIDs (0-255) to the array */
1156+
for (i = 0; i < num_eids && i < MCTP_MAX_IGNORE_EID_LEN; i++) {
1157+
int eid = json_object_get_int(
1158+
json_object_array_get_idx(attr, i));
1159+
if (eid >= 0 && eid <= 255) {
1160+
cmdline->ignore_eids[cmdline->ignore_eids_len++] =
1161+
(uint8_t)eid;
1162+
} else {
1163+
MCTP_ERR(
1164+
"Invalid EID value %d in ignore_eids array (must be 0-255)\n",
1165+
eid);
1166+
}
1167+
}
1168+
1169+
if (i < num_eids) {
1170+
MCTP_ERR(
1171+
"Warning: Some ignore_eids were truncated (max %d allowed)\n",
1172+
MCTP_MAX_IGNORE_EID_LEN);
1173+
}
1174+
}
1175+
11451176
exit:
11461177
json_object_put(json);
11471178
return rc;

0 commit comments

Comments
 (0)