Skip to content

Commit a0f49b5

Browse files
daniellertsdavem330
authored andcommitted
devlink: Add a new devlink port split ability attribute and pass to netlink
Add a new attribute that indicates the split ability of devlink port. Drivers are expected to set it via devlink_port_attrs_set(), before registering the port. 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 1b604ef commit a0f49b5

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

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

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

21362136
attrs.split = split;
21372137
attrs.lanes = lanes;
2138+
attrs.splittable = splittable;
21382139
attrs.flavour = flavour;
21392140
attrs.phys.port_number = port_number;
21402141
attrs.phys.split_subport_number = split_port_subnumber;

drivers/net/ethernet/netronome/nfp/nfp_devlink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
367367
return ret;
368368

369369
attrs.split = eth_port.is_split;
370+
attrs.splittable = !attrs.split;
370371
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
371372
attrs.phys.port_number = eth_port.label_port;
372373
attrs.phys.split_subport_number = eth_port.label_subport;

include/net/devlink.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ 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+
* @splittable: indicates if the port can be split.
7172
* @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
7273
* @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
7374
*/
7475
struct devlink_port_attrs {
75-
u8 split:1;
76+
u8 split:1,
77+
splittable:1;
7678
u32 lanes;
7779
enum devlink_port_flavour flavour;
7880
struct netdev_phys_item_id switch_id;

include/uapi/linux/devlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ enum devlink_attr {
456456
DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */
457457

458458
DEVLINK_ATTR_PORT_LANES, /* u32 */
459+
DEVLINK_ATTR_PORT_SPLITTABLE, /* u8 */
459460

460461
/* add new attributes above here, update the policy in devlink.c */
461462

net/core/devlink.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
534534
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_LANES, attrs->lanes))
535535
return -EMSGSIZE;
536536
}
537+
if (nla_put_u8(msg, DEVLINK_ATTR_PORT_SPLITTABLE, attrs->splittable))
538+
return -EMSGSIZE;
537539
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
538540
return -EMSGSIZE;
539541
switch (devlink_port->attrs.flavour) {
@@ -7547,6 +7549,7 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
75477549
ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);
75487550
if (ret)
75497551
return;
7552+
WARN_ON(attrs->splittable && attrs->split);
75507553
}
75517554
EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
75527555

0 commit comments

Comments
 (0)