Commit a21cf0a8 authored by Danielle Ratson's avatar Danielle Ratson Committed by David S. Miller

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: default avatarDanielle Ratson <danieller@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 622d3e92
...@@ -2134,6 +2134,7 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port, ...@@ -2134,6 +2134,7 @@ static int __mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
int err; int err;
attrs.split = split; attrs.split = split;
attrs.lanes = lanes;
attrs.flavour = flavour; attrs.flavour = flavour;
attrs.phys.port_number = port_number; attrs.phys.port_number = port_number;
attrs.phys.split_subport_number = split_port_subnumber; attrs.phys.split_subport_number = split_port_subnumber;
......
...@@ -68,10 +68,12 @@ struct devlink_port_pci_vf_attrs { ...@@ -68,10 +68,12 @@ struct devlink_port_pci_vf_attrs {
* struct devlink_port_attrs - devlink port object * struct devlink_port_attrs - devlink port object
* @flavour: flavour of the port * @flavour: flavour of the port
* @split: indicates if this is split port * @split: indicates if this is split port
* @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 * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
*/ */
struct devlink_port_attrs { struct devlink_port_attrs {
u8 split:1; u8 split:1;
u32 lanes;
enum devlink_port_flavour flavour; enum devlink_port_flavour flavour;
struct netdev_phys_item_id switch_id; struct netdev_phys_item_id switch_id;
union { union {
......
...@@ -455,6 +455,8 @@ enum devlink_attr { ...@@ -455,6 +455,8 @@ enum devlink_attr {
DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */ DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */
DEVLINK_ATTR_PORT_LANES, /* u32 */
/* add new attributes above here, update the policy in devlink.c */ /* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX, __DEVLINK_ATTR_MAX,
......
...@@ -530,6 +530,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg, ...@@ -530,6 +530,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
if (!devlink_port->attrs_set) if (!devlink_port->attrs_set)
return 0; return 0;
if (attrs->lanes) {
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_LANES, attrs->lanes))
return -EMSGSIZE;
}
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour)) if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
return -EMSGSIZE; return -EMSGSIZE;
switch (devlink_port->attrs.flavour) { switch (devlink_port->attrs.flavour) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment