Skip to content

Commit a5084bb

Browse files
ffainellidavem330
authored andcommitted
nfp: Implement ndo_get_port_parent_id()
NFP 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(). Since NFP uses switchdev_port_same_parent_id() convert it to use netdev_port_same_parent_id(). 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 751302c commit a5084bb

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

drivers/net/ethernet/netronome/nfp/flower/action.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <linux/bitfield.h>
55
#include <net/pkt_cls.h>
6-
#include <net/switchdev.h>
76
#include <net/tc_act/tc_csum.h>
87
#include <net/tc_act/tc_gact.h>
98
#include <net/tc_act/tc_mirred.h>
@@ -138,7 +137,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
138137

139138
if (nfp_netdev_is_nfp_repr(in_dev)) {
140139
/* Confirm ingress and egress are on same device. */
141-
if (!switchdev_port_same_parent_id(in_dev, out_dev))
140+
if (!netdev_port_same_parent_id(in_dev, out_dev))
142141
return -EOPNOTSUPP;
143142
}
144143

drivers/net/ethernet/netronome/nfp/nfp_net_common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <linux/vmalloc.h>
3737
#include <linux/ktime.h>
3838

39-
#include <net/switchdev.h>
4039
#include <net/vxlan.h>
4140

4241
#include "nfpcore/nfp_nsp.h"
@@ -3531,6 +3530,7 @@ const struct net_device_ops nfp_net_netdev_ops = {
35313530
.ndo_udp_tunnel_add = nfp_net_add_vxlan_port,
35323531
.ndo_udp_tunnel_del = nfp_net_del_vxlan_port,
35333532
.ndo_bpf = nfp_net_xdp,
3533+
.ndo_get_port_parent_id = nfp_port_get_port_parent_id,
35343534
};
35353535

35363536
/**
@@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn)
38153815
netdev->netdev_ops = &nfp_net_netdev_ops;
38163816
netdev->watchdog_timeo = msecs_to_jiffies(5 * 1000);
38173817

3818-
SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
3819-
38203818
/* MTU range: 68 - hw-specific max */
38213819
netdev->min_mtu = ETH_MIN_MTU;
38223820
netdev->max_mtu = nn->max_mtu;

drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <linux/io-64-nonatomic-hi-lo.h>
66
#include <linux/lockdep.h>
77
#include <net/dst_metadata.h>
8-
#include <net/switchdev.h>
98

109
#include "nfpcore/nfp_cpp.h"
1110
#include "nfpcore/nfp_nsp.h"
@@ -273,6 +272,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
273272
.ndo_fix_features = nfp_repr_fix_features,
274273
.ndo_set_features = nfp_port_set_features,
275274
.ndo_set_mac_address = eth_mac_addr,
275+
.ndo_get_port_parent_id = nfp_port_get_port_parent_id,
276276
};
277277

278278
void
@@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
336336

337337
netdev->max_mtu = pf_netdev->max_mtu;
338338

339-
SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops);
340-
341339
/* Set features the lower device can support with representors */
342340
if (repr_cap & NFP_NET_CFG_CTRL_LIVE_ADDR)
343341
netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;

drivers/net/ethernet/netronome/nfp/nfp_port.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,22 @@ struct nfp_port *nfp_port_from_netdev(struct net_device *netdev)
3131
return NULL;
3232
}
3333

34-
static int
35-
nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr)
34+
int nfp_port_get_port_parent_id(struct net_device *netdev,
35+
struct netdev_phys_item_id *ppid)
3636
{
3737
struct nfp_port *port;
38+
const u8 *serial;
3839

3940
port = nfp_port_from_netdev(netdev);
4041
if (!port)
4142
return -EOPNOTSUPP;
4243

43-
switch (attr->id) {
44-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: {
45-
const u8 *serial;
46-
/* N.B: attr->u.ppid.id is binary data */
47-
attr->u.ppid.id_len = nfp_cpp_serial(port->app->cpp, &serial);
48-
memcpy(&attr->u.ppid.id, serial, attr->u.ppid.id_len);
49-
break;
50-
}
51-
default:
52-
return -EOPNOTSUPP;
53-
}
44+
ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial);
45+
memcpy(&ppid->id, serial, ppid->id_len);
5446

5547
return 0;
5648
}
5749

58-
const struct switchdev_ops nfp_port_switchdev_ops = {
59-
.switchdev_port_attr_get = nfp_port_attr_get,
60-
};
61-
6250
int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type,
6351
void *type_data)
6452
{

drivers/net/ethernet/netronome/nfp/nfp_port.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <net/devlink.h>
88

99
struct net_device;
10+
struct netdev_phys_item_id;
1011
struct nfp_app;
1112
struct nfp_pf;
1213
struct nfp_port;
@@ -90,7 +91,6 @@ struct nfp_port {
9091
};
9192

9293
extern const struct ethtool_ops nfp_port_ethtool_ops;
93-
extern const struct switchdev_ops nfp_port_switchdev_ops;
9494

9595
__printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...);
9696

@@ -106,6 +106,8 @@ int
106106
nfp_port_set_features(struct net_device *netdev, netdev_features_t features);
107107

108108
struct nfp_port *nfp_port_from_netdev(struct net_device *netdev);
109+
int nfp_port_get_port_parent_id(struct net_device *netdev,
110+
struct netdev_phys_item_id *ppid);
109111
struct nfp_port *
110112
nfp_port_from_id(struct nfp_pf *pf, enum nfp_port_type type, unsigned int id);
111113
struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port);

0 commit comments

Comments
 (0)