Skip to content

Commit c336161

Browse files
Jakub Kicinskiborkmann
authored andcommitted
net: dummy: remove fake SR-IOV functionality
netdevsim driver seems like a better place for fake SR-IOV functionality. Remove the code previously added to dummy. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Acked-by: Phil Sutter <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 7957922 commit c336161

File tree

1 file changed

+1
-214
lines changed

1 file changed

+1
-214
lines changed

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);

0 commit comments

Comments
 (0)