diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 38b1190f3d26..1de0daa0f921 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -174,6 +174,18 @@ definitions: value: 1 - name: fw-activate + - + type: enum + name: reload-limit + entries: + - + name: unspec + doc: no constraints + - + name: no-reset + doc: >- + No reset allowed, no down time allowed, no link flap and no + configuration is lost. - type: enum name: param-cmode @@ -775,7 +787,7 @@ attribute-sets: - name: reload-limits type: bitfield32 - enum: reload-action + enum: reload-limit enum-as-flags: true - name: dev-stats @@ -793,6 +805,7 @@ attribute-sets: - name: reload-stats-limit type: u8 + enum: reload-limit - name: reload-stats-value type: u32 @@ -845,13 +858,14 @@ attribute-sets: name: linecard-supported-types type: nest nested-attributes: dl-linecard-supported-types - - # TODO: fill in the attributes in between - + - + name: nested-devlink + type: nest + multi-attr: true + nested-attributes: dl-nested-devlink - name: selftests type: nest - value: 176 nested-attributes: dl-selftest-id - name: rate-tx-priority @@ -898,7 +912,7 @@ attribute-sets: - name: parent-dev type: nest - nested-attributes: dl-parent-dev + nested-attributes: dl-nested-devlink doc: | Identifies the devlink instance which owns the parent rate node. Used with rate-set and rate-new to parent a rate object to a node on @@ -978,6 +992,49 @@ attribute-sets: type: bitfield32 enum: port-fn-attr-cap enum-as-flags: true + - + name: devlink + type: nest + nested-attributes: dl-nested-devlink + doc: Handle of the peer devlink instance instantiated for this function. + - + name: max-io-eqs + type: u32 + + - + name: dl-port-function-set + subset-of: dl-port-function + doc: | + Port function attributes that can be configured; opstate and the + devlink handle are read-only. + attributes: + - + name: hw-addr + - + name: state + - + name: caps + - + name: max-io-eqs + + - + name: dl-port-set + subset-of: devlink + doc: Attributes accepted by the port-set request. + attributes: + - + name: bus-name + - + name: dev-name + - + name: index + - + name: port-index + - + name: port-type + - + name: port-function + nested-attributes: dl-port-function-set - name: dl-dpipe-tables @@ -1008,6 +1065,8 @@ attribute-sets: name: dpipe-table-resource-id - name: dpipe-table-resource-units + - + name: pad - name: dl-dpipe-table-matches @@ -1042,6 +1101,8 @@ attribute-sets: name: dpipe-entry-action-values - name: dpipe-entry-counter + - + name: pad - name: dl-dpipe-entry-match-values @@ -1180,6 +1241,8 @@ attribute-sets: name: resource-unit - name: resource-occ + - + name: pad - name: dl-resource-list @@ -1207,6 +1270,7 @@ attribute-sets: attributes: - name: region-snapshot + multi-attr: true - name: dl-region-snapshot @@ -1221,6 +1285,7 @@ attribute-sets: attributes: - name: region-chunk + multi-attr: true - name: dl-region-chunk @@ -1230,6 +1295,8 @@ attribute-sets: name: region-chunk-data - name: region-chunk-addr + - + name: pad - name: dl-fmsg @@ -1270,6 +1337,8 @@ attribute-sets: name: health-reporter-auto-dump - name: health-reporter-burst-period + - + name: pad - name: dl-attr-stats @@ -1284,6 +1353,10 @@ attribute-sets: - name: stats-rx-dropped type: u64 + - + name: pad + type: pad + value: 61 - name: dl-trap-metadata @@ -1303,6 +1376,7 @@ attribute-sets: attributes: - name: linecard-type + multi-attr: true - name: dl-selftest-id @@ -1330,6 +1404,10 @@ attribute-sets: - name: dl-parent-dev subset-of: devlink + doc: | + Devlink handle accepted as the parent-dev input; the netns id the + kernel reports back is not accepted, the parent is always resolved + in the caller's netns. attributes: - name: bus-name @@ -1338,6 +1416,50 @@ attribute-sets: - name: index + - + name: dl-rate-set + subset-of: devlink + doc: Attributes accepted by the rate-set and rate-new requests. + attributes: + - + name: bus-name + - + name: dev-name + - + name: index + - + name: port-index + - + name: rate-node-name + - + name: rate-tx-share + - + name: rate-tx-max + - + name: rate-tx-priority + - + name: rate-tx-weight + - + name: rate-parent-node-name + - + name: rate-tc-bws + - + name: parent-dev + nested-attributes: dl-parent-dev + + - + name: dl-nested-devlink + subset-of: devlink + attributes: + - + name: bus-name + - + name: dev-name + - + name: index + - + name: netns-id + operations: enum-model: directional list: @@ -1363,6 +1485,7 @@ operations: - index - reload-failed - dev-stats + - nested-devlink dump: reply: *get-reply @@ -1388,13 +1511,12 @@ operations: request: attributes: *dev-id-attrs reply: - value: 3 # due to a bug, port dump returns DEVLINK_CMD_NEW attributes: *port-id-attrs - name: port-set doc: Set devlink port instances. - attribute-set: devlink + attribute-set: dl-port-set dont-validate: [strict] flags: [admin-perm] do: @@ -1901,7 +2023,7 @@ operations: post: devlink-nl-post-doit request: value: 42 - attributes: ®ion-id-attrs + attributes: - bus-name - dev-name - index @@ -1909,7 +2031,15 @@ operations: - region-name reply: ®ion-get-reply value: 42 - attributes: *region-id-attrs + attributes: + - bus-name + - dev-name + - index + - port-index + - region-name + - region-size + - region-max-snapshots + - region-snapshots dump: request: attributes: *dev-id-attrs @@ -1975,6 +2105,7 @@ operations: - index - port-index - region-name + - region-chunks - name: port-param-get @@ -2305,7 +2436,7 @@ operations: - name: rate-set doc: Set rate instances. - attribute-set: devlink + attribute-set: dl-rate-set dont-validate: [strict] flags: [admin-perm] do: @@ -2316,6 +2447,7 @@ operations: - bus-name - dev-name - index + - port-index - rate-node-name - rate-tx-share - rate-tx-max @@ -2328,7 +2460,7 @@ operations: - name: rate-new doc: Create rate instances. - attribute-set: devlink + attribute-set: dl-rate-set dont-validate: [strict] flags: [admin-perm] do: @@ -2374,14 +2506,22 @@ operations: post: devlink-nl-post-doit request: value: 78 - attributes: &linecard-id-attrs + attributes: - bus-name - dev-name - index - linecard-index reply: &linecard-get-reply value: 80 - attributes: *linecard-id-attrs + attributes: + - bus-name + - dev-name + - index + - linecard-index + - linecard-state + - linecard-type + - linecard-supported-types + - nested-devlink dump: request: attributes: *dev-id-attrs diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c index dec00133178d..9e1b4c081a7b 100644 --- a/net/devlink/netlink_gen.c +++ b/net/devlink/netlink_gen.c @@ -52,11 +52,11 @@ const struct nla_policy devlink_dl_parent_dev_nl_policy[DEVLINK_ATTR_INDEX + 1] [DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range), }; -const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1] = { +const struct nla_policy devlink_dl_port_function_set_nl_policy[DEVLINK_PORT_FN_ATTR_MAX_IO_EQS + 1] = { [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY, }, [DEVLINK_PORT_FN_ATTR_STATE] = NLA_POLICY_MAX(NLA_U8, 1), - [DEVLINK_PORT_FN_ATTR_OPSTATE] = NLA_POLICY_MAX(NLA_U8, 1), [DEVLINK_PORT_FN_ATTR_CAPS] = NLA_POLICY_BITFIELD32(15), + [DEVLINK_PORT_FN_ATTR_MAX_IO_EQS] = { .type = NLA_U32, }, }; const struct nla_policy devlink_dl_rate_tc_bws_nl_policy[DEVLINK_RATE_TC_ATTR_BW + 1] = { @@ -97,7 +97,7 @@ static const struct nla_policy devlink_port_set_nl_policy[DEVLINK_ATTR_INDEX + 1 [DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range), [DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, }, [DEVLINK_ATTR_PORT_TYPE] = NLA_POLICY_MAX(NLA_U16, 3), - [DEVLINK_ATTR_PORT_FUNCTION] = NLA_POLICY_NESTED(devlink_dl_port_function_nl_policy), + [DEVLINK_ATTR_PORT_FUNCTION] = NLA_POLICY_NESTED(devlink_dl_port_function_set_nl_policy), }; /* DEVLINK_CMD_PORT_NEW - do */ @@ -334,7 +334,7 @@ static const struct nla_policy devlink_reload_nl_policy[DEVLINK_ATTR_INDEX + 1] [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range), [DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, 1, 2), - [DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(6), + [DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(3), [DEVLINK_ATTR_NETNS_PID] = { .type = NLA_U32, }, [DEVLINK_ATTR_NETNS_FD] = { .type = NLA_U32, }, [DEVLINK_ATTR_NETNS_ID] = { .type = NLA_U32, }, @@ -618,6 +618,7 @@ static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_PARENT_DE [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range), + [DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, }, [DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, }, [DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64, }, [DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64, }, diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h index a70e0e4769aa..99ccacc693b7 100644 --- a/net/devlink/netlink_gen.h +++ b/net/devlink/netlink_gen.h @@ -14,7 +14,7 @@ /* Common nested types */ extern const struct nla_policy devlink_dl_parent_dev_nl_policy[DEVLINK_ATTR_INDEX + 1]; -extern const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1]; +extern const struct nla_policy devlink_dl_port_function_set_nl_policy[DEVLINK_PORT_FN_ATTR_MAX_IO_EQS + 1]; extern const struct nla_policy devlink_dl_rate_tc_bws_nl_policy[DEVLINK_RATE_TC_ATTR_BW + 1]; extern const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1]; diff --git a/net/devlink/port.c b/net/devlink/port.c index 1528f2d148df..803429d9a008 100644 --- a/net/devlink/port.c +++ b/net/devlink/port.c @@ -6,19 +6,6 @@ #include "devl_internal.h" -#define DEVLINK_PORT_FN_CAPS_VALID_MASK \ - (_BITUL(__DEVLINK_PORT_FN_ATTR_CAPS_MAX) - 1) - -static const struct nla_policy devlink_function_nl_policy[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1] = { - [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY }, - [DEVLINK_PORT_FN_ATTR_STATE] = - NLA_POLICY_RANGE(NLA_U8, DEVLINK_PORT_FN_STATE_INACTIVE, - DEVLINK_PORT_FN_STATE_ACTIVE), - [DEVLINK_PORT_FN_ATTR_CAPS] = - NLA_POLICY_BITFIELD32(DEVLINK_PORT_FN_CAPS_VALID_MASK), - [DEVLINK_PORT_FN_ATTR_MAX_IO_EQS] = { .type = NLA_U32 }, -}; - #define ASSERT_DEVLINK_PORT_REGISTERED(devlink_port) \ WARN_ON_ONCE(!(devlink_port)->registered) #define ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port) \ @@ -782,11 +769,11 @@ static int devlink_port_function_set(struct devlink_port *port, const struct nlattr *attr, struct netlink_ext_ack *extack) { - struct nlattr *tb[DEVLINK_PORT_FUNCTION_ATTR_MAX + 1]; + struct nlattr *tb[ARRAY_SIZE(devlink_dl_port_function_set_nl_policy)]; int err; - err = nla_parse_nested(tb, DEVLINK_PORT_FUNCTION_ATTR_MAX, attr, - devlink_function_nl_policy, extack); + err = nla_parse_nested(tb, ARRAY_SIZE(tb) - 1, attr, + devlink_dl_port_function_set_nl_policy, extack); if (err < 0) { NL_SET_ERR_MSG(extack, "Fail to parse port function attributes"); return err;