]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: Add generic ndo_select_queue functions
authorAlexander Duyck <alexander.h.duyck@intel.com>
Mon, 9 Jul 2018 16:19:54 +0000 (12:19 -0400)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 9 Jul 2018 20:15:34 +0000 (13:15 -0700)
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>
drivers/net/ethernet/lantiq_etop.c
drivers/net/ethernet/ti/netcp_core.c
drivers/staging/netlogic/xlr_net.c
include/linux/netdevice.h
net/core/dev.c
net/packet/af_packet.c

index afc81006944059837b5cbbdaaaa26d9dc87d82a0..7a637b51c7d2302b63f2eb579adea4e0459e7430 100644 (file)
@@ -563,14 +563,6 @@ ltq_etop_set_multicast_list(struct net_device *dev)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static u16
-ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb,
-                     void *accel_priv, select_queue_fallback_t fallback)
-{
-       /* we are currently only using the first queue */
-       return 0;
-}
-
 static int
 ltq_etop_init(struct net_device *dev)
 {
@@ -641,7 +633,7 @@ static const struct net_device_ops ltq_eth_netdev_ops = {
        .ndo_set_mac_address = ltq_etop_set_mac_address,
        .ndo_validate_addr = eth_validate_addr,
        .ndo_set_rx_mode = ltq_etop_set_multicast_list,
-       .ndo_select_queue = ltq_etop_select_queue,
+       .ndo_select_queue = dev_pick_tx_zero,
        .ndo_init = ltq_etop_init,
        .ndo_tx_timeout = ltq_etop_tx_timeout,
 };
index 6ebf110cd5947ed8950a454aadf9f8d447a7ad8a..a1d335a3c5e43884348b5d96a9bc9eaed92f0bcb 100644 (file)
@@ -1889,13 +1889,6 @@ static int netcp_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
        return err;
 }
 
-static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb,
-                             void *accel_priv,
-                             select_queue_fallback_t fallback)
-{
-       return 0;
-}
-
 static int netcp_setup_tc(struct net_device *dev, enum tc_setup_type type,
                          void *type_data)
 {
@@ -1972,7 +1965,7 @@ static const struct net_device_ops netcp_netdev_ops = {
        .ndo_vlan_rx_add_vid    = netcp_rx_add_vid,
        .ndo_vlan_rx_kill_vid   = netcp_rx_kill_vid,
        .ndo_tx_timeout         = netcp_ndo_tx_timeout,
-       .ndo_select_queue       = netcp_select_queue,
+       .ndo_select_queue       = dev_pick_tx_zero,
        .ndo_setup_tc           = netcp_setup_tc,
 };
 
index e461168313bf95c66e56afff9fba720d9b23c41a..4e6611e4c59beb9cd74d0ec18ea4b6851d5e9f3f 100644 (file)
@@ -290,13 +290,6 @@ static netdev_tx_t xlr_net_start_xmit(struct sk_buff *skb,
        return NETDEV_TX_OK;
 }
 
-static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb,
-                               void *accel_priv,
-                               select_queue_fallback_t fallback)
-{
-       return (u16)smp_processor_id();
-}
-
 static void xlr_hw_set_mac_addr(struct net_device *ndev)
 {
        struct xlr_net_priv *priv = netdev_priv(ndev);
@@ -403,7 +396,7 @@ static const struct net_device_ops xlr_netdev_ops = {
        .ndo_open = xlr_net_open,
        .ndo_stop = xlr_net_stop,
        .ndo_start_xmit = xlr_net_start_xmit,
-       .ndo_select_queue = xlr_net_select_queue,
+       .ndo_select_queue = dev_pick_tx_cpu_id,
        .ndo_set_mac_address = xlr_net_set_mac_addr,
        .ndo_set_rx_mode = xlr_set_rx_mode,
        .ndo_get_stats64 = xlr_stats,
index fda0bcda7a423ae75126cdc044643d96a5573b10..46f4c44ce3e4a79acc289d9ee437fc4cad835e1f 100644 (file)
@@ -2567,6 +2567,10 @@ void dev_close(struct net_device *dev);
 void dev_close_many(struct list_head *head, bool unlink);
 void dev_disable_lro(struct net_device *dev);
 int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
+u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb,
+                    void *accel_priv, select_queue_fallback_t fallback);
+u16 dev_pick_tx_cpu_id(struct net_device *dev, struct sk_buff *skb,
+                      void *accel_priv, select_queue_fallback_t fallback);
 int dev_queue_xmit(struct sk_buff *skb);
 int dev_queue_xmit_accel(struct sk_buff *skb, struct net_device *sb_dev);
 int dev_direct_xmit(struct sk_buff *skb, u16 queue_id);
index 09a7cc2f3c55b22592a3cf684e0860e3561c89ef..b5e538032d5e4cace1bd4948e249f5e00958e311 100644 (file)
@@ -3617,6 +3617,20 @@ static int get_xps_queue(struct net_device *dev, struct net_device *sb_dev,
 #endif
 }
 
+u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb,
+                    void *accel_priv, select_queue_fallback_t fallback)
+{
+       return 0;
+}
+EXPORT_SYMBOL(dev_pick_tx_zero);
+
+u16 dev_pick_tx_cpu_id(struct net_device *dev, struct sk_buff *skb,
+                      void *accel_priv, select_queue_fallback_t fallback)
+{
+       return (u16)raw_smp_processor_id() % dev->real_num_tx_queues;
+}
+EXPORT_SYMBOL(dev_pick_tx_cpu_id);
+
 static u16 ___netdev_pick_tx(struct net_device *dev, struct sk_buff *skb,
                             struct net_device *sb_dev)
 {
index 47931ebfaef3b8277d145bb804e44e1831aaa2c6..f37d087ae652db771ee469623d64be8e2007e250 100644 (file)
@@ -277,7 +277,7 @@ static bool packet_use_direct_xmit(const struct packet_sock *po)
 
 static u16 __packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb)
 {
-       return (u16) raw_smp_processor_id() % dev->real_num_tx_queues;
+       return dev_pick_tx_cpu_id(dev, skb, NULL, NULL);
 }
 
 static u16 packet_pick_tx_queue(struct sk_buff *skb)