devlink: Add a new devlink port split ability attribute and pass to netlink
authorDanielle Ratson <danieller@mellanox.com>
Thu, 9 Jul 2020 13:18:20 +0000 (16:18 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Jul 2020 20:15:30 +0000 (13:15 -0700)
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 <danieller@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/netronome/nfp/nfp_devlink.c
include/net/devlink.h
include/uapi/linux/devlink.h
net/core/devlink.c

index f85f5d88d331d18880982eb9ae3ffe2408b9d2cd..8b3791d73c99e0cb5ffdb412d25fb66827b928e4 100644 (file)
@@ -2135,6 +2135,7 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
 
        attrs.split = split;
        attrs.lanes = lanes;
+       attrs.splittable = splittable;
        attrs.flavour = flavour;
        attrs.phys.port_number = port_number;
        attrs.phys.split_subport_number = split_port_subnumber;
index 71f4e624b3db91a70ea3b96beaf562a1e7550e16..b6a10565309ad3e237e038ae45720e398f8fd3c0 100644 (file)
@@ -367,6 +367,7 @@ int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
                return ret;
 
        attrs.split = eth_port.is_split;
+       attrs.splittable = !attrs.split;
        attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
        attrs.phys.port_number = eth_port.label_port;
        attrs.phys.split_subport_number = eth_port.label_subport;
index 91a9f8770d08b6bde897dcefa9312b47d3c253d7..746bed538664234b8d7bdc940279037b7c58a523 100644 (file)
@@ -68,11 +68,13 @@ struct devlink_port_pci_vf_attrs {
  * struct devlink_port_attrs - devlink port object
  * @flavour: flavour of the port
  * @split: indicates if this is split port
+ * @splittable: indicates if the port can be split.
  * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
  * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
  */
 struct devlink_port_attrs {
-       u8 split:1;
+       u8 split:1,
+          splittable:1;
        u32 lanes;
        enum devlink_port_flavour flavour;
        struct netdev_phys_item_id switch_id;
index f741ab8d9cf049ff7b17db30bd95380cc3c92cfa..cfef4245ea5aa79a3720a09474c55af08fa783af 100644 (file)
@@ -456,6 +456,7 @@ enum devlink_attr {
        DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER,  /* string */
 
        DEVLINK_ATTR_PORT_LANES,                        /* u32 */
+       DEVLINK_ATTR_PORT_SPLITTABLE,                   /* u8 */
 
        /* add new attributes above here, update the policy in devlink.c */
 
index 7f26d1054974dc4106b4fbcd969d1b267dc391bb..94c797b74378276d37cd712ade88b732b56d7790 100644 (file)
@@ -534,6 +534,8 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
                if (nla_put_u32(msg, DEVLINK_ATTR_PORT_LANES, attrs->lanes))
                        return -EMSGSIZE;
        }
+       if (nla_put_u8(msg, DEVLINK_ATTR_PORT_SPLITTABLE, attrs->splittable))
+               return -EMSGSIZE;
        if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
                return -EMSGSIZE;
        switch (devlink_port->attrs.flavour) {
@@ -7547,6 +7549,7 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
        ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);
        if (ret)
                return;
+       WARN_ON(attrs->splittable && attrs->split);
 }
 EXPORT_SYMBOL_GPL(devlink_port_attrs_set);