aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 3fe443be4b15..3295b94884ab 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5617,18 +5617,20 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
5617} 5617}
5618 5618
5619/** 5619/**
5620 * alloc_netdev_mq - allocate network device 5620 * alloc_netdev_mqs - allocate network device
5621 * @sizeof_priv: size of private data to allocate space for 5621 * @sizeof_priv: size of private data to allocate space for
5622 * @name: device name format string 5622 * @name: device name format string
5623 * @setup: callback to initialize device 5623 * @setup: callback to initialize device
5624 * @queue_count: the number of subqueues to allocate 5624 * @txqs: the number of TX subqueues to allocate
5625 * @rxqs: the number of RX subqueues to allocate
5625 * 5626 *
5626 * Allocates a struct net_device with private data area for driver use 5627 * Allocates a struct net_device with private data area for driver use
5627 * and performs basic initialization. Also allocates subquue structs 5628 * and performs basic initialization. Also allocates subquue structs
5628 * for each queue on the device at the end of the netdevice. 5629 * for each queue on the device.
5629 */ 5630 */
5630struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, 5631struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
5631 void (*setup)(struct net_device *), unsigned int queue_count) 5632 void (*setup)(struct net_device *),
5633 unsigned int txqs, unsigned int rxqs)
5632{ 5634{
5633 struct net_device *dev; 5635 struct net_device *dev;
5634 size_t alloc_size; 5636 size_t alloc_size;
@@ -5636,12 +5638,20 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
5636 5638
5637 BUG_ON(strlen(name) >= sizeof(dev->name)); 5639 BUG_ON(strlen(name) >= sizeof(dev->name));
5638 5640
5639 if (queue_count < 1) { 5641 if (txqs < 1) {
5640 pr_err("alloc_netdev: Unable to allocate device " 5642 pr_err("alloc_netdev: Unable to allocate device "
5641 "with zero queues.\n"); 5643 "with zero queues.\n");
5642 return NULL; 5644 return NULL;
5643 } 5645 }
5644 5646
5647#ifdef CONFIG_RPS
5648 if (rxqs < 1) {
5649 pr_err("alloc_netdev: Unable to allocate device "
5650 "with zero RX queues.\n");
5651 return NULL;
5652 }
5653#endif
5654
5645 alloc_size = sizeof(struct net_device); 5655 alloc_size = sizeof(struct net_device);
5646 if (sizeof_priv) { 5656 if (sizeof_priv) {
5647 /* ensure 32-byte alignment of private area */ 5657 /* ensure 32-byte alignment of private area */
@@ -5672,14 +5682,14 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
5672 5682
5673 dev_net_set(dev, &init_net); 5683 dev_net_set(dev, &init_net);
5674 5684
5675 dev->num_tx_queues = queue_count; 5685 dev->num_tx_queues = txqs;
5676 dev->real_num_tx_queues = queue_count; 5686 dev->real_num_tx_queues = txqs;
5677 if (netif_alloc_netdev_queues(dev)) 5687 if (netif_alloc_netdev_queues(dev))
5678 goto free_pcpu; 5688 goto free_pcpu;
5679 5689
5680#ifdef CONFIG_RPS 5690#ifdef CONFIG_RPS
5681 dev->num_rx_queues = queue_count; 5691 dev->num_rx_queues = rxqs;
5682 dev->real_num_rx_queues = queue_count; 5692 dev->real_num_rx_queues = rxqs;
5683 if (netif_alloc_rx_queues(dev)) 5693 if (netif_alloc_rx_queues(dev))
5684 goto free_pcpu; 5694 goto free_pcpu;
5685#endif 5695#endif
@@ -5707,7 +5717,7 @@ free_p:
5707 kfree(p); 5717 kfree(p);
5708 return NULL; 5718 return NULL;
5709} 5719}
5710EXPORT_SYMBOL(alloc_netdev_mq); 5720EXPORT_SYMBOL(alloc_netdev_mqs);
5711 5721
5712/** 5722/**
5713 * free_netdev - free network device 5723 * free_netdev - free network device