Skip to content

Commit 2ee87db

Browse files
committed
Merge branch 'nfp-get_phys_port_name-for-representors-and-SR-IOV-reorder'
Jakub Kicinski says: ==================== nfp: get_phys_port_name for representors and SR-IOV reorder This series starts by making the error message if FW cannot be located easier to understand. Then I move some functions from PCI probe files into library code (nfpcore) where they belong, and remove one function which is never used. Next few patches equip representors with nfp_port structure and make their NDOs fully shared (not defined in apps), thanks to which we can easily determine which netdevs are NFP's by comparing the NDO pointers. 10th patch makes use of the shared NDOs and nfp_ports to deliver netdev-type independent .ndo_get_phys_port_name() implementation. Patches 11 and 12 reorder the nfp_app SR-IOV callbacks with enabling SR-IOV VFs. Unfortunately due to how PCI subsystem works we can't guarantee being able to disable SR-IOV at exit or that it will be disabled when we first probe... We must therefore make sure FW is able to deal with being loaded while SR-IOV is already on. Patch 13 fixes potential deadlock when enabling SR-IOV happens at the same time as port state refresh. Note that this can't happen at this point, since Flower doesn't refresh ports... but lockdep doesn't know about such details and we will have to deal with this sooner or later anyway. Last but not least a new Kconfig is added to make sure those who don't care about flower offloads have a way of not including the code in their kernels. Thanks to nfp_app separation this costs us a single ifdef and excluding flower files from the build. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ed9208b + 57ae676 commit 2ee87db

File tree

19 files changed

+388
-226
lines changed

19 files changed

+388
-226
lines changed

drivers/net/ethernet/netronome/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ config NFP
2525
cards working as a advanced Ethernet NIC. It works with both
2626
SR-IOV physical and virtual functions.
2727

28+
config NFP_APP_FLOWER
29+
bool "NFP4000/NFP6000 TC Flower offload support"
30+
depends on NFP
31+
depends on NET_SWITCHDEV
32+
---help---
33+
Enable driver support for TC Flower offload on NFP4000 and NFP6000.
34+
Say Y, if you are planning to make use of TC Flower offload
35+
either directly, with Open vSwitch, or any other way. Note that
36+
TC Flower offload requires specific FW to work.
37+
2838
config NFP_DEBUG
2939
bool "Debug support for Netronome(R) NFP4000/NFP6000 NIC drivers"
3040
depends on NFP

drivers/net/ethernet/netronome/nfp/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ nfp-objs := \
2727
nfp_port.o \
2828
bpf/main.o \
2929
bpf/offload.o \
30-
flower/cmsg.o \
31-
flower/main.o \
3230
nic/main.o
3331

32+
ifeq ($(CONFIG_NFP_APP_FLOWER),y)
33+
nfp-objs += \
34+
flower/cmsg.o \
35+
flower/main.o
36+
endif
37+
3438
ifeq ($(CONFIG_BPF_SYSCALL),y)
3539
nfp-objs += \
3640
bpf/verifier.o \

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ nfp_flower_cmsg_alloc(struct nfp_app *app, unsigned int size,
7979
return skb;
8080
}
8181

82-
int nfp_flower_cmsg_portmod(struct net_device *netdev, bool carrier_ok)
82+
int nfp_flower_cmsg_portmod(struct nfp_repr *repr, bool carrier_ok)
8383
{
84-
struct nfp_repr *repr = netdev_priv(netdev);
8584
struct nfp_flower_cmsg_portmod *msg;
8685
struct sk_buff *skb;
8786

@@ -94,7 +93,7 @@ int nfp_flower_cmsg_portmod(struct net_device *netdev, bool carrier_ok)
9493
msg->portnum = cpu_to_be32(repr->dst->u.port_info.port_id);
9594
msg->reserved = 0;
9695
msg->info = carrier_ok;
97-
msg->mtu = cpu_to_be16(netdev->mtu);
96+
msg->mtu = cpu_to_be16(repr->netdev->mtu);
9897

9998
nfp_ctrl_tx(repr->app->ctrl, skb);
10099

drivers/net/ethernet/netronome/nfp/flower/cmsg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ nfp_flower_cmsg_pcie_port(u8 nfp_pcie, enum nfp_flower_cmsg_port_vnic_type type,
110110
NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT);
111111
}
112112

113-
int nfp_flower_cmsg_portmod(struct net_device *netdev, bool carrier_ok);
113+
int nfp_flower_cmsg_portmod(struct nfp_repr *repr, bool carrier_ok);
114114
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb);
115115

116116
#endif

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

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -104,51 +104,30 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id)
104104
return reprs->reprs[port];
105105
}
106106

107-
static void
108-
nfp_flower_repr_netdev_get_stats64(struct net_device *netdev,
109-
struct rtnl_link_stats64 *stats)
110-
{
111-
struct nfp_repr *repr = netdev_priv(netdev);
112-
enum nfp_repr_type type;
113-
u32 port_id;
114-
u8 port = 0;
115-
116-
port_id = repr->dst->u.port_info.port_id;
117-
type = nfp_flower_repr_get_type_and_port(repr->app, port_id, &port);
118-
nfp_repr_get_stats64(repr->app, type, port, stats);
119-
}
120-
121-
static int nfp_flower_repr_netdev_open(struct net_device *netdev)
107+
static int
108+
nfp_flower_repr_netdev_open(struct nfp_app *app, struct nfp_repr *repr)
122109
{
123110
int err;
124111

125-
err = nfp_flower_cmsg_portmod(netdev, true);
112+
err = nfp_flower_cmsg_portmod(repr, true);
126113
if (err)
127114
return err;
128115

129-
netif_carrier_on(netdev);
130-
netif_tx_wake_all_queues(netdev);
116+
netif_carrier_on(repr->netdev);
117+
netif_tx_wake_all_queues(repr->netdev);
131118

132119
return 0;
133120
}
134121

135-
static int nfp_flower_repr_netdev_stop(struct net_device *netdev)
122+
static int
123+
nfp_flower_repr_netdev_stop(struct nfp_app *app, struct nfp_repr *repr)
136124
{
137-
netif_carrier_off(netdev);
138-
netif_tx_disable(netdev);
125+
netif_carrier_off(repr->netdev);
126+
netif_tx_disable(repr->netdev);
139127

140-
return nfp_flower_cmsg_portmod(netdev, false);
128+
return nfp_flower_cmsg_portmod(repr, false);
141129
}
142130

143-
static const struct net_device_ops nfp_flower_repr_netdev_ops = {
144-
.ndo_open = nfp_flower_repr_netdev_open,
145-
.ndo_stop = nfp_flower_repr_netdev_stop,
146-
.ndo_start_xmit = nfp_repr_xmit,
147-
.ndo_get_stats64 = nfp_flower_repr_netdev_get_stats64,
148-
.ndo_has_offload_stats = nfp_repr_has_offload_stats,
149-
.ndo_get_offload_stats = nfp_repr_get_offload_stats,
150-
};
151-
152131
static void nfp_flower_sriov_disable(struct nfp_app *app)
153132
{
154133
nfp_reprs_clean_and_free_by_type(app, NFP_REPR_TYPE_VF);
@@ -162,14 +141,19 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
162141
u8 nfp_pcie = nfp_cppcore_pcie_unit(app->pf->cpp);
163142
struct nfp_flower_priv *priv = app->priv;
164143
struct nfp_reprs *reprs, *old_reprs;
144+
enum nfp_port_type port_type;
165145
const u8 queue = 0;
166146
int i, err;
167147

148+
port_type = repr_type == NFP_REPR_TYPE_PF ? NFP_PORT_PF_PORT :
149+
NFP_PORT_VF_PORT;
150+
168151
reprs = nfp_reprs_alloc(cnt);
169152
if (!reprs)
170153
return -ENOMEM;
171154

172155
for (i = 0; i < cnt; i++) {
156+
struct nfp_port *port;
173157
u32 port_id;
174158

175159
reprs->reprs[i] = nfp_repr_alloc(app);
@@ -178,15 +162,24 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
178162
goto err_reprs_clean;
179163
}
180164

165+
port = nfp_port_alloc(app, port_type, reprs->reprs[i]);
166+
if (repr_type == NFP_REPR_TYPE_PF) {
167+
port->pf_id = i;
168+
} else {
169+
port->pf_id = 0; /* For now we only support 1 PF */
170+
port->vf_id = i;
171+
}
172+
181173
eth_hw_addr_random(reprs->reprs[i]);
182174

183175
port_id = nfp_flower_cmsg_pcie_port(nfp_pcie, vnic_type,
184176
i, queue);
185177
err = nfp_repr_init(app, reprs->reprs[i],
186-
&nfp_flower_repr_netdev_ops,
187-
port_id, NULL, priv->nn->dp.netdev);
188-
if (err)
178+
port_id, port, priv->nn->dp.netdev);
179+
if (err) {
180+
nfp_port_free(port);
189181
goto err_reprs_clean;
182+
}
190183

191184
nfp_info(app->cpp, "%s%d Representor(%s) created\n",
192185
repr_type == NFP_REPR_TYPE_PF ? "PF" : "VF", i,
@@ -260,7 +253,6 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
260253

261254
cmsg_port_id = nfp_flower_cmsg_phys_port(phys_port);
262255
err = nfp_repr_init(app, reprs->reprs[phys_port],
263-
&nfp_flower_repr_netdev_ops,
264256
cmsg_port_id, port, priv->nn->dp.netdev);
265257
if (err) {
266258
nfp_port_free(port);
@@ -296,26 +288,16 @@ static int nfp_flower_start(struct nfp_app *app)
296288
NFP_REPR_TYPE_PF, 1);
297289
}
298290

299-
static void nfp_flower_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
300-
{
301-
kfree(app->priv);
302-
app->priv = NULL;
303-
}
304-
305291
static int nfp_flower_vnic_init(struct nfp_app *app, struct nfp_net *nn,
306292
unsigned int id)
307293
{
308-
struct nfp_flower_priv *priv;
294+
struct nfp_flower_priv *priv = app->priv;
309295

310296
if (id > 0) {
311297
nfp_warn(app->cpp, "FlowerNIC doesn't support more than one data vNIC\n");
312298
goto err_invalid_port;
313299
}
314300

315-
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
316-
if (!priv)
317-
return -ENOMEM;
318-
app->priv = priv;
319301
priv->nn = nn;
320302

321303
eth_hw_addr_random(nn->dp.netdev);
@@ -347,9 +329,19 @@ static int nfp_flower_init(struct nfp_app *app)
347329
return -EINVAL;
348330
}
349331

332+
app->priv = kzalloc(sizeof(struct nfp_flower_priv), GFP_KERNEL);
333+
if (!app->priv)
334+
return -ENOMEM;
335+
350336
return 0;
351337
}
352338

339+
static void nfp_flower_clean(struct nfp_app *app)
340+
{
341+
kfree(app->priv);
342+
app->priv = NULL;
343+
}
344+
353345
const struct nfp_app_type app_flower = {
354346
.id = NFP_APP_FLOWER_NIC,
355347
.name = "flower",
@@ -358,9 +350,12 @@ const struct nfp_app_type app_flower = {
358350
.extra_cap = nfp_flower_extra_cap,
359351

360352
.init = nfp_flower_init,
353+
.clean = nfp_flower_clean,
361354

362355
.vnic_init = nfp_flower_vnic_init,
363-
.vnic_clean = nfp_flower_vnic_clean,
356+
357+
.repr_open = nfp_flower_repr_netdev_open,
358+
.repr_stop = nfp_flower_repr_netdev_stop,
364359

365360
.start = nfp_flower_start,
366361
.stop = nfp_flower_stop,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
static const struct nfp_app_type *apps[] = {
4444
&app_nic,
4545
&app_bpf,
46+
#ifdef CONFIG_NFP_APP_FLOWER
4647
&app_flower,
48+
#endif
4749
};
4850

4951
const char *nfp_app_mip_name(struct nfp_app *app)

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct sk_buff;
4747
struct nfp_app;
4848
struct nfp_cpp;
4949
struct nfp_pf;
50+
struct nfp_repr;
5051
struct nfp_net;
5152

5253
enum nfp_app_id {
@@ -66,10 +67,13 @@ extern const struct nfp_app_type app_flower;
6667
* @ctrl_has_meta: control messages have prepend of type:5/port:CTRL
6768
*
6869
* Callbacks
69-
* @init: perform basic app checks
70+
* @init: perform basic app checks and init
71+
* @clean: clean app state
7072
* @extra_cap: extra capabilities string
7173
* @vnic_init: init vNICs (assign port types, etc.)
7274
* @vnic_clean: clean up app's vNIC state
75+
* @repr_open: representor netdev open callback
76+
* @repr_stop: representor netdev stop callback
7377
* @start: start application logic
7478
* @stop: stop application logic
7579
* @ctrl_msg_rx: control message handler
@@ -88,13 +92,17 @@ struct nfp_app_type {
8892
bool ctrl_has_meta;
8993

9094
int (*init)(struct nfp_app *app);
95+
void (*clean)(struct nfp_app *app);
9196

9297
const char *(*extra_cap)(struct nfp_app *app, struct nfp_net *nn);
9398

9499
int (*vnic_init)(struct nfp_app *app, struct nfp_net *nn,
95100
unsigned int id);
96101
void (*vnic_clean)(struct nfp_app *app, struct nfp_net *nn);
97102

103+
int (*repr_open)(struct nfp_app *app, struct nfp_repr *repr);
104+
int (*repr_stop)(struct nfp_app *app, struct nfp_repr *repr);
105+
98106
int (*start)(struct nfp_app *app);
99107
void (*stop)(struct nfp_app *app);
100108

@@ -144,6 +152,12 @@ static inline int nfp_app_init(struct nfp_app *app)
144152
return app->type->init(app);
145153
}
146154

155+
static inline void nfp_app_clean(struct nfp_app *app)
156+
{
157+
if (app->type->clean)
158+
app->type->clean(app);
159+
}
160+
147161
static inline int nfp_app_vnic_init(struct nfp_app *app, struct nfp_net *nn,
148162
unsigned int id)
149163
{
@@ -156,6 +170,20 @@ static inline void nfp_app_vnic_clean(struct nfp_app *app, struct nfp_net *nn)
156170
app->type->vnic_clean(app, nn);
157171
}
158172

173+
static inline int nfp_app_repr_open(struct nfp_app *app, struct nfp_repr *repr)
174+
{
175+
if (!app->type->repr_open)
176+
return -EINVAL;
177+
return app->type->repr_open(app, repr);
178+
}
179+
180+
static inline int nfp_app_repr_stop(struct nfp_app *app, struct nfp_repr *repr)
181+
{
182+
if (!app->type->repr_stop)
183+
return -EINVAL;
184+
return app->type->repr_stop(app, repr);
185+
}
186+
159187
static inline int nfp_app_start(struct nfp_app *app, struct nfp_net *ctrl)
160188
{
161189
app->ctrl = ctrl;

0 commit comments

Comments
 (0)