Skip to content

Commit a21cf0a

Browse files
daniellertsdavem330
authored andcommitted
devlink: Add a new devlink port lanes attribute and pass to netlink
Add a new devlink port attribute that indicates the port's number of lanes. Drivers are expected to set it via devlink_port_attrs_set(), before registering the port. The attribute is not passed to user space in case the number of lanes is invalid (0). Signed-off-by: Danielle Ratson <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 622d3e9 commit a21cf0a

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,7 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
21342134
int err;
21352135

21362136
attrs.split = split;
2137+
attrs.lanes = lanes;
21372138
attrs.flavour = flavour;
21382139
attrs.phys.port_number = port_number;
21392140
attrs.phys.split_subport_number = split_port_subnumber;

include/net/devlink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ struct devlink_port_pci_vf_attrs {
6868
* struct devlink_port_attrs - devlink port object
6969
* @flavour: flavour of the port
7070
* @split: indicates if this is split port
71+
* @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
7172
* @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
7273
*/
7374
struct devlink_port_attrs {
7475
u8 split:1;
76+
u32 lanes;
7577
enum devlink_port_flavour flavour;
7678
struct netdev_phys_item_id switch_id;
7779
union {

include/uapi/linux/devlink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ enum devlink_attr {
455455

456456
DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */
457457

458+
DEVLINK_ATTR_PORT_LANES, /* u32 */
459+
458460
/* add new attributes above here, update the policy in devlink.c */
459461

460462
__DEVLINK_ATTR_MAX,

net/core/devlink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
530530

531531
if (!devlink_port->attrs_set)
532532
return 0;
533+
if (attrs->lanes) {
534+
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_LANES, attrs->lanes))
535+
return -EMSGSIZE;
536+
}
533537
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
534538
return -EMSGSIZE;
535539
switch (devlink_port->attrs.flavour) {

0 commit comments

Comments
 (0)