Skip to content

Commit c4bf245

Browse files
ffainellidavem330
authored andcommitted
liquidio: Implement ndo_get_port_parent_id()
Liquidio only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a great candidate to be converted to use the ndo_get_port_parent_id() NDO instead of implementing switchdev_port_attr_get(). 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 52d5254 commit c4bf245

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <linux/firmware.h>
2222
#include <net/vxlan.h>
2323
#include <linux/kthread.h>
24-
#include <net/switchdev.h>
2524
#include "liquidio_common.h"
2625
#include "octeon_droq.h"
2726
#include "octeon_iq.h"
@@ -3184,32 +3183,21 @@ static const struct devlink_ops liquidio_devlink_ops = {
31843183
};
31853184

31863185
static int
3187-
lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)
3186+
liquidio_get_port_parent_id(struct net_device *dev,
3187+
struct netdev_phys_item_id *ppid)
31883188
{
31893189
struct lio *lio = GET_LIO(dev);
31903190
struct octeon_device *oct = lio->oct_dev;
31913191

31923192
if (oct->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
31933193
return -EOPNOTSUPP;
31943194

3195-
switch (attr->id) {
3196-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
3197-
attr->u.ppid.id_len = ETH_ALEN;
3198-
ether_addr_copy(attr->u.ppid.id,
3199-
(void *)&lio->linfo.hw_addr + 2);
3200-
break;
3201-
3202-
default:
3203-
return -EOPNOTSUPP;
3204-
}
3195+
ppid->id_len = ETH_ALEN;
3196+
ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
32053197

32063198
return 0;
32073199
}
32083200

3209-
static const struct switchdev_ops lio_pf_switchdev_ops = {
3210-
.switchdev_port_attr_get = lio_pf_switchdev_attr_get,
3211-
};
3212-
32133201
static int liquidio_get_vf_stats(struct net_device *netdev, int vfidx,
32143202
struct ifla_vf_stats *vf_stats)
32153203
{
@@ -3259,6 +3247,7 @@ static const struct net_device_ops lionetdevops = {
32593247
.ndo_set_vf_trust = liquidio_set_vf_trust,
32603248
.ndo_set_vf_link_state = liquidio_set_vf_link_state,
32613249
.ndo_get_vf_stats = liquidio_get_vf_stats,
3250+
.ndo_get_port_parent_id = liquidio_get_port_parent_id,
32623251
};
32633252

32643253
/** \brief Entry point for the liquidio module
@@ -3534,7 +3523,6 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
35343523
* netdev tasks.
35353524
*/
35363525
netdev->netdev_ops = &lionetdevops;
3537-
SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
35383526

35393527
retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
35403528
if (retval) {

drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "octeon_nic.h"
2626
#include "octeon_main.h"
2727
#include "octeon_network.h"
28-
#include <net/switchdev.h>
2928
#include "lio_vf_rep.h"
3029

3130
static int lio_vf_rep_open(struct net_device *ndev);
@@ -38,6 +37,8 @@ static int lio_vf_rep_phys_port_name(struct net_device *dev,
3837
static void lio_vf_rep_get_stats64(struct net_device *dev,
3938
struct rtnl_link_stats64 *stats64);
4039
static int lio_vf_rep_change_mtu(struct net_device *ndev, int new_mtu);
40+
static int lio_vf_get_port_parent_id(struct net_device *dev,
41+
struct netdev_phys_item_id *ppid);
4142

4243
static const struct net_device_ops lio_vf_rep_ndev_ops = {
4344
.ndo_open = lio_vf_rep_open,
@@ -47,6 +48,7 @@ static const struct net_device_ops lio_vf_rep_ndev_ops = {
4748
.ndo_get_phys_port_name = lio_vf_rep_phys_port_name,
4849
.ndo_get_stats64 = lio_vf_rep_get_stats64,
4950
.ndo_change_mtu = lio_vf_rep_change_mtu,
51+
.ndo_get_port_parent_id = lio_vf_get_port_parent_id,
5052
};
5153

5254
static int
@@ -443,31 +445,19 @@ lio_vf_rep_pkt_xmit(struct sk_buff *skb, struct net_device *ndev)
443445
return NETDEV_TX_OK;
444446
}
445447

446-
static int
447-
lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr)
448+
static int lio_vf_get_port_parent_id(struct net_device *dev,
449+
struct netdev_phys_item_id *ppid)
448450
{
449451
struct lio_vf_rep_desc *vf_rep = netdev_priv(dev);
450452
struct net_device *parent_ndev = vf_rep->parent_ndev;
451453
struct lio *lio = GET_LIO(parent_ndev);
452454

453-
switch (attr->id) {
454-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
455-
attr->u.ppid.id_len = ETH_ALEN;
456-
ether_addr_copy(attr->u.ppid.id,
457-
(void *)&lio->linfo.hw_addr + 2);
458-
break;
459-
460-
default:
461-
return -EOPNOTSUPP;
462-
}
455+
ppid->id_len = ETH_ALEN;
456+
ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
463457

464458
return 0;
465459
}
466460

467-
static const struct switchdev_ops lio_vf_rep_switchdev_ops = {
468-
.switchdev_port_attr_get = lio_vf_rep_attr_get,
469-
};
470-
471461
static void
472462
lio_vf_rep_fetch_stats(struct work_struct *work)
473463
{
@@ -524,7 +514,6 @@ lio_vf_rep_create(struct octeon_device *oct)
524514
ndev->min_mtu = LIO_MIN_MTU_SIZE;
525515
ndev->max_mtu = LIO_MAX_MTU_SIZE;
526516
ndev->netdev_ops = &lio_vf_rep_ndev_ops;
527-
SWITCHDEV_SET_OPS(ndev, &lio_vf_rep_switchdev_ops);
528517

529518
vf_rep = netdev_priv(ndev);
530519
memset(vf_rep, 0, sizeof(*vf_rep));

0 commit comments

Comments
 (0)