Skip to content

Commit 929d6c1

Browse files
ffainellidavem330
authored andcommitted
net: dsa: Implement ndo_get_port_parent_id()
DSA implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid of switchdev_ops eventually, ease that migration by implementing a ndo_get_port_parent_id() function which returns what switchdev_port_attr_get() would do. Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7870a7b commit 929d6c1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/dsa/slave.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,18 +362,23 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
362362
return err;
363363
}
364364

365-
static int dsa_slave_port_attr_get(struct net_device *dev,
366-
struct switchdev_attr *attr)
365+
static int dsa_slave_get_port_parent_id(struct net_device *dev,
366+
struct netdev_phys_item_id *ppid)
367367
{
368368
struct dsa_port *dp = dsa_slave_to_port(dev);
369369
struct dsa_switch *ds = dp->ds;
370370
struct dsa_switch_tree *dst = ds->dst;
371371

372+
ppid->id_len = sizeof(dst->index);
373+
memcpy(&ppid->id, &dst->index, ppid->id_len);
374+
375+
return 0;
376+
}
377+
378+
static int dsa_slave_port_attr_get(struct net_device *dev,
379+
struct switchdev_attr *attr)
380+
{
372381
switch (attr->id) {
373-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
374-
attr->u.ppid.id_len = sizeof(dst->index);
375-
memcpy(&attr->u.ppid.id, &dst->index, attr->u.ppid.id_len);
376-
break;
377382
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
378383
attr->u.brport_flags_support = 0;
379384
break;
@@ -1046,6 +1051,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
10461051
.ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
10471052
.ndo_setup_tc = dsa_slave_setup_tc,
10481053
.ndo_get_stats64 = dsa_slave_get_stats64,
1054+
.ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
10491055
};
10501056

10511057
static const struct switchdev_ops dsa_slave_switchdev_ops = {

0 commit comments

Comments
 (0)