@@ -3833,6 +3833,30 @@ static void pr_out_port_pfvfsf_num(struct dl *dl, struct nlattr **tb)
}
}
+static const char *port_function_state(uint8_t state)
+{
+ switch (state) {
+ case DEVLINK_PORT_FN_STATE_INACTIVE:
+ return "inactive";
+ case DEVLINK_PORT_FN_STATE_ACTIVE:
+ return "active";
+ default:
+ return "unknown";
+ }
+}
+
+static const char *port_function_opstate(uint8_t state)
+{
+ switch (state) {
+ case DEVLINK_PORT_FN_OPSTATE_DETACHED:
+ return "detached";
+ case DEVLINK_PORT_FN_OPSTATE_ATTACHED:
+ return "attached";
+ default:
+ return "unknown";
+ }
+}
+
static void pr_out_port_function(struct dl *dl, struct nlattr **tb_port)
{
struct nlattr *tb[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1] = {};
@@ -3849,16 +3873,31 @@ static void pr_out_port_function(struct dl *dl, struct nlattr **tb_port)
if (err != MNL_CB_OK)
return;
- if (!tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR])
- return;
-
- len = mnl_attr_get_payload_len(tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]);
- data = mnl_attr_get_payload(tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]);
-
pr_out_object_start(dl, "function");
check_indent_newline(dl);
- print_string(PRINT_ANY, "hw_addr", "hw_addr %s",
- ll_addr_n2a(data, len, 0, hw_addr, sizeof(hw_addr)));
+
+ if (tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]) {
+ len = mnl_attr_get_payload_len(tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]);
+ data = mnl_attr_get_payload(tb[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR]);
+
+ print_string(PRINT_ANY, "hw_addr", "hw_addr %s",
+ ll_addr_n2a(data, len, 0, hw_addr, sizeof(hw_addr)));
+ }
+ if (tb[DEVLINK_PORT_FN_ATTR_STATE]) {
+ uint8_t state;
+
+ state = mnl_attr_get_u8(tb[DEVLINK_PORT_FN_ATTR_STATE]);
+
+ print_string(PRINT_ANY, "state", " state %s", port_function_state(state));
+ }
+ if (tb[DEVLINK_PORT_FN_ATTR_OPSTATE]) {
+ uint8_t state;
+
+ state = mnl_attr_get_u8(tb[DEVLINK_PORT_FN_ATTR_OPSTATE]);
+
+ print_string(PRINT_ANY, "opstate", " opstate %s", port_function_opstate(state));
+ }
+
if (!dl->json_output)
__pr_out_indent_dec();
pr_out_object_end(dl);