On 5/19/20 6:40 AM, Ido Schimmel wrote:
From: Danielle Ratson <daniel...@mellanox.com>

Add a new devlink port attribute that indicates the port's width.
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 width is invalid
(0).

Signed-off-by: Danielle Ratson <daniel...@mellanox.com>
Reviewed-by: Jiri Pirko <j...@mellanox.com>
Signed-off-by: Ido Schimmel <ido...@mellanox.com>
---

[...]

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c 
b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
index 273c889faaad..a21a10307ecc 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
@@ -82,7 +82,7 @@ int ionic_devlink_register(struct ionic *ionic)
                return 0;
devlink_port_attrs_set(&ionic->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
-                              0, false, 0, NULL, 0);
+                              0, false, 0, 0, NULL, 0);
        err = devlink_port_register(dl, &ionic->dl_port, 0);
        if (err)
                dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
for ionic
Acked-by: Shannon Nelson <snel...@pensando.io>

[...]

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 7b76e5fffc10..9887fba60a7a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -526,6 +526,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
if (!attrs->set)
                return 0;
+       if (attrs->width) {
+               if (nla_put_u32(msg, DEVLINK_ATTR_PORT_WIDTH, attrs->width))
+                       return -EMSGSIZE;
+       }
        if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
                return -EMSGSIZE;
        switch (devlink_port->attrs.flavour) {
@@ -7408,6 +7412,7 @@ static int __devlink_port_attrs_set(struct devlink_port 
*devlink_port,
   *    @split: indicates if this is split port
   *    @split_subport_number: if the port is split, this is the number
   *                           of subport.
+ *     @width: width of the port. 0 value is not passed to netlink.

A little more explanation here would help - basically something like
    @width: number of ways the port can be split.  0 value is not passed to netlink.

Is this always going to be an even number, or a power-of-2?  If so, perhaps that should be noted here.


Thanks,
sln


Reply via email to