dsa: set devlink port attrs for dsa ports

Set the attrs and allow to expose port flavour to user via devlink.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2018-05-18 09:29:03 +02:00 committed by David S. Miller
parent 08474c1a9d
commit da07739248

View File

@ -270,7 +270,28 @@ static int dsa_port_setup(struct dsa_port *dp)
case DSA_PORT_TYPE_UNUSED:
break;
case DSA_PORT_TYPE_CPU:
/* dp->index is used now as port_number. However
* CPU ports should have separate numbering
* independent from front panel port numbers.
*/
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_CPU,
dp->index, false, 0);
err = dsa_port_link_register_of(dp);
if (err) {
dev_err(ds->dev, "failed to setup link for port %d.%d\n",
ds->index, dp->index);
return err;
}
break;
case DSA_PORT_TYPE_DSA:
/* dp->index is used now as port_number. However
* DSA ports should have separate numbering
* independent from front panel port numbers.
*/
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_DSA,
dp->index, false, 0);
err = dsa_port_link_register_of(dp);
if (err) {
dev_err(ds->dev, "failed to setup link for port %d.%d\n",
@ -279,6 +300,9 @@ static int dsa_port_setup(struct dsa_port *dp)
}
break;
case DSA_PORT_TYPE_USER:
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_PHYSICAL,
dp->index, false, 0);
err = dsa_slave_create(dp);
if (err)
dev_err(ds->dev, "failed to create slave for port %d.%d\n",