Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Add generic ndo_select_queue functions

This patch adds a generic version of the ndo_select_queue functions for
either returning 0 or selecting a queue based on the processor ID. This is
generally meant to just reduce the number of functions we have to change
in the future when we have to deal with ndo_select_queue changes.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Alexander Duyck and committed by
Jeff Kirsher
a4ea8a3d eadec877

+22 -26
+1 -9
drivers/net/ethernet/lantiq_etop.c
··· 563 563 spin_unlock_irqrestore(&priv->lock, flags); 564 564 } 565 565 566 - static u16 567 - ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb, 568 - void *accel_priv, select_queue_fallback_t fallback) 569 - { 570 - /* we are currently only using the first queue */ 571 - return 0; 572 - } 573 - 574 566 static int 575 567 ltq_etop_init(struct net_device *dev) 576 568 { ··· 633 641 .ndo_set_mac_address = ltq_etop_set_mac_address, 634 642 .ndo_validate_addr = eth_validate_addr, 635 643 .ndo_set_rx_mode = ltq_etop_set_multicast_list, 636 - .ndo_select_queue = ltq_etop_select_queue, 644 + .ndo_select_queue = dev_pick_tx_zero, 637 645 .ndo_init = ltq_etop_init, 638 646 .ndo_tx_timeout = ltq_etop_tx_timeout, 639 647 };
+1 -8
drivers/net/ethernet/ti/netcp_core.c
··· 1889 1889 return err; 1890 1890 } 1891 1891 1892 - static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb, 1893 - void *accel_priv, 1894 - select_queue_fallback_t fallback) 1895 - { 1896 - return 0; 1897 - } 1898 - 1899 1892 static int netcp_setup_tc(struct net_device *dev, enum tc_setup_type type, 1900 1893 void *type_data) 1901 1894 { ··· 1965 1972 .ndo_vlan_rx_add_vid = netcp_rx_add_vid, 1966 1973 .ndo_vlan_rx_kill_vid = netcp_rx_kill_vid, 1967 1974 .ndo_tx_timeout = netcp_ndo_tx_timeout, 1968 - .ndo_select_queue = netcp_select_queue, 1975 + .ndo_select_queue = dev_pick_tx_zero, 1969 1976 .ndo_setup_tc = netcp_setup_tc, 1970 1977 }; 1971 1978
+1 -8
drivers/staging/netlogic/xlr_net.c
··· 290 290 return NETDEV_TX_OK; 291 291 } 292 292 293 - static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb, 294 - void *accel_priv, 295 - select_queue_fallback_t fallback) 296 - { 297 - return (u16)smp_processor_id(); 298 - } 299 - 300 293 static void xlr_hw_set_mac_addr(struct net_device *ndev) 301 294 { 302 295 struct xlr_net_priv *priv = netdev_priv(ndev); ··· 396 403 .ndo_open = xlr_net_open, 397 404 .ndo_stop = xlr_net_stop, 398 405 .ndo_start_xmit = xlr_net_start_xmit, 399 - .ndo_select_queue = xlr_net_select_queue, 406 + .ndo_select_queue = dev_pick_tx_cpu_id, 400 407 .ndo_set_mac_address = xlr_net_set_mac_addr, 401 408 .ndo_set_rx_mode = xlr_set_rx_mode, 402 409 .ndo_get_stats64 = xlr_stats,
+4
include/linux/netdevice.h
··· 2567 2567 void dev_close_many(struct list_head *head, bool unlink); 2568 2568 void dev_disable_lro(struct net_device *dev); 2569 2569 int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb); 2570 + u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb, 2571 + void *accel_priv, select_queue_fallback_t fallback); 2572 + u16 dev_pick_tx_cpu_id(struct net_device *dev, struct sk_buff *skb, 2573 + void *accel_priv, select_queue_fallback_t fallback); 2570 2574 int dev_queue_xmit(struct sk_buff *skb); 2571 2575 int dev_queue_xmit_accel(struct sk_buff *skb, struct net_device *sb_dev); 2572 2576 int dev_direct_xmit(struct sk_buff *skb, u16 queue_id);
+14
net/core/dev.c
··· 3617 3617 #endif 3618 3618 } 3619 3619 3620 + u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb, 3621 + void *accel_priv, select_queue_fallback_t fallback) 3622 + { 3623 + return 0; 3624 + } 3625 + EXPORT_SYMBOL(dev_pick_tx_zero); 3626 + 3627 + u16 dev_pick_tx_cpu_id(struct net_device *dev, struct sk_buff *skb, 3628 + void *accel_priv, select_queue_fallback_t fallback) 3629 + { 3630 + return (u16)raw_smp_processor_id() % dev->real_num_tx_queues; 3631 + } 3632 + EXPORT_SYMBOL(dev_pick_tx_cpu_id); 3633 + 3620 3634 static u16 ___netdev_pick_tx(struct net_device *dev, struct sk_buff *skb, 3621 3635 struct net_device *sb_dev) 3622 3636 {
+1 -1
net/packet/af_packet.c
··· 277 277 278 278 static u16 __packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb) 279 279 { 280 - return (u16) raw_smp_processor_id() % dev->real_num_tx_queues; 280 + return dev_pick_tx_cpu_id(dev, skb, NULL, NULL); 281 281 } 282 282 283 283 static u16 packet_pick_tx_queue(struct sk_buff *skb)