Skip to content

Commit d671965

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2017-12-03 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Addition of a software model for BPF offloads in order to ease testing code changes in that area and make semantics more clear. This is implemented in a new driver called netdevsim, which can later also be extended for other offloads. SR-IOV support is added as well to netdevsim. BPF kernel selftests for offloading are added so we can track basic functionality as well as exercising all corner cases around BPF offloading, from Jakub. 2) Today drivers have to drop the reference on BPF progs they hold due to XDP on device teardown themselves. Change this in order to make XDP handling inside the drivers less error prone, and move disabling XDP to the core instead, also from Jakub. 3) Misc set of BPF verifier improvements and cleanups as preparatory work for upcoming BPF-to-BPF calls. Among others, this set also improves liveness marking such that pruning can be slightly more effective. Register and stack liveness information is now included in the verifier log as well, from Alexei. 4) nfp JIT improvements in order to identify load/store sequences in the BPF prog e.g. coming from memcpy lowering and optimizing them through the NPU's command push pull (CPP) instruction, from Jiong. 5) Cleanups to test_cgrp2_attach2.c BPF sample code in oder to remove bpf_prog_attach() magic values and replacing them with actual proper attach flag instead, from David. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f4d4c49 + 6720f10 commit d671965

File tree

31 files changed

+2362
-443
lines changed

31 files changed

+2362
-443
lines changed

MAINTAINERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9599,6 +9599,11 @@ NETWORKING [WIRELESS]
95999599
96009600
Q: http://patchwork.kernel.org/project/linux-wireless/list/
96019601

9602+
NETDEVSIM
9603+
M: Jakub Kicinski <[email protected]>
9604+
S: Maintained
9605+
F: drivers/net/netdevsim/*
9606+
96029607
NETXEN (1/10) GbE SUPPORT
96039608
M: Manish Chopra <[email protected]>
96049609
M: Rahul Verma <[email protected]>

drivers/net/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,15 @@ config THUNDERBOLT_NET
497497

498498
source "drivers/net/hyperv/Kconfig"
499499

500+
config NETDEVSIM
501+
tristate "Simulated networking device"
502+
depends on DEBUG_FS
503+
help
504+
This driver is a developer testing tool and software model that can
505+
be used to test various control path networking APIs, especially
506+
HW-offload related.
507+
508+
To compile this driver as a module, choose M here: the module
509+
will be called netdevsim.
510+
500511
endif # NETDEVICES

drivers/net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ obj-$(CONFIG_FUJITSU_ES) += fjes/
7878

7979
thunderbolt-net-y += thunderbolt.o
8080
obj-$(CONFIG_THUNDERBOLT_NET) += thunderbolt-net.o
81+
obj-$(CONFIG_NETDEVSIM) += netdevsim/

drivers/net/dummy.c

Lines changed: 1 addition & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -42,48 +42,7 @@
4242
#define DRV_NAME "dummy"
4343
#define DRV_VERSION "1.0"
4444

45-
#undef pr_fmt
46-
#define pr_fmt(fmt) DRV_NAME ": " fmt
47-
4845
static int numdummies = 1;
49-
static int num_vfs;
50-
51-
struct vf_data_storage {
52-
u8 vf_mac[ETH_ALEN];
53-
u16 pf_vlan; /* When set, guest VLAN config not allowed. */
54-
u16 pf_qos;
55-
__be16 vlan_proto;
56-
u16 min_tx_rate;
57-
u16 max_tx_rate;
58-
u8 spoofchk_enabled;
59-
bool rss_query_enabled;
60-
u8 trusted;
61-
int link_state;
62-
};
63-
64-
struct dummy_priv {
65-
struct vf_data_storage *vfinfo;
66-
};
67-
68-
static int dummy_num_vf(struct device *dev)
69-
{
70-
return num_vfs;
71-
}
72-
73-
static struct bus_type dummy_bus = {
74-
.name = "dummy",
75-
.num_vf = dummy_num_vf,
76-
};
77-
78-
static void release_dummy_parent(struct device *dev)
79-
{
80-
}
81-
82-
static struct device dummy_parent = {
83-
.init_name = "dummy",
84-
.bus = &dummy_bus,
85-
.release = release_dummy_parent,
86-
};
8746

8847
/* fake multicast ability */
8948
static void set_multicast_list(struct net_device *dev)
@@ -133,25 +92,10 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
13392

13493
static int dummy_dev_init(struct net_device *dev)
13594
{
136-
struct dummy_priv *priv = netdev_priv(dev);
137-
13895
dev->dstats = netdev_alloc_pcpu_stats(struct pcpu_dstats);
13996
if (!dev->dstats)
14097
return -ENOMEM;
14198

142-
priv->vfinfo = NULL;
143-
144-
if (!num_vfs)
145-
return 0;
146-
147-
dev->dev.parent = &dummy_parent;
148-
priv->vfinfo = kcalloc(num_vfs, sizeof(struct vf_data_storage),
149-
GFP_KERNEL);
150-
if (!priv->vfinfo) {
151-
free_percpu(dev->dstats);
152-
return -ENOMEM;
153-
}
154-
15599
return 0;
156100
}
157101

@@ -169,117 +113,6 @@ static int dummy_change_carrier(struct net_device *dev, bool new_carrier)
169113
return 0;
170114
}
171115

172-
static int dummy_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
173-
{
174-
struct dummy_priv *priv = netdev_priv(dev);
175-
176-
if (!is_valid_ether_addr(mac) || (vf >= num_vfs))
177-
return -EINVAL;
178-
179-
memcpy(priv->vfinfo[vf].vf_mac, mac, ETH_ALEN);
180-
181-
return 0;
182-
}
183-
184-
static int dummy_set_vf_vlan(struct net_device *dev, int vf,
185-
u16 vlan, u8 qos, __be16 vlan_proto)
186-
{
187-
struct dummy_priv *priv = netdev_priv(dev);
188-
189-
if ((vf >= num_vfs) || (vlan > 4095) || (qos > 7))
190-
return -EINVAL;
191-
192-
priv->vfinfo[vf].pf_vlan = vlan;
193-
priv->vfinfo[vf].pf_qos = qos;
194-
priv->vfinfo[vf].vlan_proto = vlan_proto;
195-
196-
return 0;
197-
}
198-
199-
static int dummy_set_vf_rate(struct net_device *dev, int vf, int min, int max)
200-
{
201-
struct dummy_priv *priv = netdev_priv(dev);
202-
203-
if (vf >= num_vfs)
204-
return -EINVAL;
205-
206-
priv->vfinfo[vf].min_tx_rate = min;
207-
priv->vfinfo[vf].max_tx_rate = max;
208-
209-
return 0;
210-
}
211-
212-
static int dummy_set_vf_spoofchk(struct net_device *dev, int vf, bool val)
213-
{
214-
struct dummy_priv *priv = netdev_priv(dev);
215-
216-
if (vf >= num_vfs)
217-
return -EINVAL;
218-
219-
priv->vfinfo[vf].spoofchk_enabled = val;
220-
221-
return 0;
222-
}
223-
224-
static int dummy_set_vf_rss_query_en(struct net_device *dev, int vf, bool val)
225-
{
226-
struct dummy_priv *priv = netdev_priv(dev);
227-
228-
if (vf >= num_vfs)
229-
return -EINVAL;
230-
231-
priv->vfinfo[vf].rss_query_enabled = val;
232-
233-
return 0;
234-
}
235-
236-
static int dummy_set_vf_trust(struct net_device *dev, int vf, bool val)
237-
{
238-
struct dummy_priv *priv = netdev_priv(dev);
239-
240-
if (vf >= num_vfs)
241-
return -EINVAL;
242-
243-
priv->vfinfo[vf].trusted = val;
244-
245-
return 0;
246-
}
247-
248-
static int dummy_get_vf_config(struct net_device *dev,
249-
int vf, struct ifla_vf_info *ivi)
250-
{
251-
struct dummy_priv *priv = netdev_priv(dev);
252-
253-
if (vf >= num_vfs)
254-
return -EINVAL;
255-
256-
ivi->vf = vf;
257-
memcpy(&ivi->mac, priv->vfinfo[vf].vf_mac, ETH_ALEN);
258-
ivi->vlan = priv->vfinfo[vf].pf_vlan;
259-
ivi->qos = priv->vfinfo[vf].pf_qos;
260-
ivi->spoofchk = priv->vfinfo[vf].spoofchk_enabled;
261-
ivi->linkstate = priv->vfinfo[vf].link_state;
262-
ivi->min_tx_rate = priv->vfinfo[vf].min_tx_rate;
263-
ivi->max_tx_rate = priv->vfinfo[vf].max_tx_rate;
264-
ivi->rss_query_en = priv->vfinfo[vf].rss_query_enabled;
265-
ivi->trusted = priv->vfinfo[vf].trusted;
266-
ivi->vlan_proto = priv->vfinfo[vf].vlan_proto;
267-
268-
return 0;
269-
}
270-
271-
static int dummy_set_vf_link_state(struct net_device *dev, int vf, int state)
272-
{
273-
struct dummy_priv *priv = netdev_priv(dev);
274-
275-
if (vf >= num_vfs)
276-
return -EINVAL;
277-
278-
priv->vfinfo[vf].link_state = state;
279-
280-
return 0;
281-
}
282-
283116
static const struct net_device_ops dummy_netdev_ops = {
284117
.ndo_init = dummy_dev_init,
285118
.ndo_uninit = dummy_dev_uninit,
@@ -289,14 +122,6 @@ static const struct net_device_ops dummy_netdev_ops = {
289122
.ndo_set_mac_address = eth_mac_addr,
290123
.ndo_get_stats64 = dummy_get_stats64,
291124
.ndo_change_carrier = dummy_change_carrier,
292-
.ndo_set_vf_mac = dummy_set_vf_mac,
293-
.ndo_set_vf_vlan = dummy_set_vf_vlan,
294-
.ndo_set_vf_rate = dummy_set_vf_rate,
295-
.ndo_set_vf_spoofchk = dummy_set_vf_spoofchk,
296-
.ndo_set_vf_trust = dummy_set_vf_trust,
297-
.ndo_get_vf_config = dummy_get_vf_config,
298-
.ndo_set_vf_link_state = dummy_set_vf_link_state,
299-
.ndo_set_vf_rss_query_en = dummy_set_vf_rss_query_en,
300125
};
301126

302127
static void dummy_get_drvinfo(struct net_device *dev,
@@ -323,13 +148,6 @@ static const struct ethtool_ops dummy_ethtool_ops = {
323148
.get_ts_info = dummy_get_ts_info,
324149
};
325150

326-
static void dummy_free_netdev(struct net_device *dev)
327-
{
328-
struct dummy_priv *priv = netdev_priv(dev);
329-
330-
kfree(priv->vfinfo);
331-
}
332-
333151
static void dummy_setup(struct net_device *dev)
334152
{
335153
ether_setup(dev);
@@ -338,7 +156,6 @@ static void dummy_setup(struct net_device *dev)
338156
dev->netdev_ops = &dummy_netdev_ops;
339157
dev->ethtool_ops = &dummy_ethtool_ops;
340158
dev->needs_free_netdev = true;
341-
dev->priv_destructor = dummy_free_netdev;
342159

343160
/* Fill in device structure with ethernet-generic values. */
344161
dev->flags |= IFF_NOARP;
@@ -370,7 +187,6 @@ static int dummy_validate(struct nlattr *tb[], struct nlattr *data[],
370187

371188
static struct rtnl_link_ops dummy_link_ops __read_mostly = {
372189
.kind = DRV_NAME,
373-
.priv_size = sizeof(struct dummy_priv),
374190
.setup = dummy_setup,
375191
.validate = dummy_validate,
376192
};
@@ -379,16 +195,12 @@ static struct rtnl_link_ops dummy_link_ops __read_mostly = {
379195
module_param(numdummies, int, 0);
380196
MODULE_PARM_DESC(numdummies, "Number of dummy pseudo devices");
381197

382-
module_param(num_vfs, int, 0);
383-
MODULE_PARM_DESC(num_vfs, "Number of dummy VFs per dummy device");
384-
385198
static int __init dummy_init_one(void)
386199
{
387200
struct net_device *dev_dummy;
388201
int err;
389202

390-
dev_dummy = alloc_netdev(sizeof(struct dummy_priv),
391-
"dummy%d", NET_NAME_ENUM, dummy_setup);
203+
dev_dummy = alloc_netdev(0, "dummy%d", NET_NAME_ENUM, dummy_setup);
392204
if (!dev_dummy)
393205
return -ENOMEM;
394206

@@ -407,21 +219,6 @@ static int __init dummy_init_module(void)
407219
{
408220
int i, err = 0;
409221

410-
if (num_vfs) {
411-
err = bus_register(&dummy_bus);
412-
if (err < 0) {
413-
pr_err("registering dummy bus failed\n");
414-
return err;
415-
}
416-
417-
err = device_register(&dummy_parent);
418-
if (err < 0) {
419-
pr_err("registering dummy parent device failed\n");
420-
bus_unregister(&dummy_bus);
421-
return err;
422-
}
423-
}
424-
425222
rtnl_lock();
426223
err = __rtnl_link_register(&dummy_link_ops);
427224
if (err < 0)
@@ -437,22 +234,12 @@ static int __init dummy_init_module(void)
437234
out:
438235
rtnl_unlock();
439236

440-
if (err && num_vfs) {
441-
device_unregister(&dummy_parent);
442-
bus_unregister(&dummy_bus);
443-
}
444-
445237
return err;
446238
}
447239

448240
static void __exit dummy_cleanup_module(void)
449241
{
450242
rtnl_link_unregister(&dummy_link_ops);
451-
452-
if (num_vfs) {
453-
device_unregister(&dummy_parent);
454-
bus_unregister(&dummy_bus);
455-
}
456243
}
457244

458245
module_init(dummy_init_module);

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7800,8 +7800,6 @@ static void bnxt_remove_one(struct pci_dev *pdev)
78007800
bnxt_dcb_free(bp);
78017801
kfree(bp->edev);
78027802
bp->edev = NULL;
7803-
if (bp->xdp_prog)
7804-
bpf_prog_put(bp->xdp_prog);
78057803
bnxt_cleanup_pci(bp);
78067804
free_netdev(dev);
78077805
}

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,9 +4308,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
43084308
{
43094309
mlx5e_ipsec_cleanup(priv);
43104310
mlx5e_vxlan_cleanup(priv);
4311-
4312-
if (priv->channels.params.xdp_prog)
4313-
bpf_prog_put(priv->channels.params.xdp_prog);
43144311
}
43154312

43164313
static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)

0 commit comments

Comments
 (0)