From 357ab2939dbddfb6849c55be9de577db078d9037 Mon Sep 17 00:00:00 2001
From: Madalin Bucur <madalin.bucur@nxp.com>
Date: Fri, 12 Oct 2018 16:56:57 +0300
Subject: [PATCH] sdk_dpaa: remove FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE

Remove FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE and record the
receive CPU in skb queue mapping to maintain the same CPU
for tx in forwarding scenarios.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/sdk_dpaa/Kconfig           | 13 +------------
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c        |  2 +-
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h        | 12 ++----------
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c |  3 +--
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h |  2 +-
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c     |  2 ++
 6 files changed, 8 insertions(+), 26 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_dpaa/Kconfig
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/Kconfig
@@ -96,17 +96,6 @@ config FSL_DPAA_1588
         help
          Enable IEEE1588 support code.
 
-config FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
-	bool "Use driver's Tx queue selection mechanism"
-	default y
-	depends on FSL_SDK_DPAA_ETH
-	help
-	  The DPAA-Ethernet driver defines a ndo_select_queue() callback for optimal selection
-	  of the egress FQ. That will override the XPS support for this netdevice.
-	  If for whatever reason you want to be in control of the egress FQ-to-CPU selection and mapping,
-	  or simply don't want to use the driver's ndo_select_queue() callback, then unselect this
-	  and use the standard XPS support instead.
-
 config FSL_DPAA_ETH_MAX_BUF_COUNT
 	int "Maximum nuber of buffers in private bpool"
 	depends on FSL_SDK_DPAA_ETH
@@ -178,7 +167,7 @@ config FSL_DPAA_ETH_DEBUG
 
 config FSL_DPAA_DBG_LOOP
 	bool "DPAA Ethernet Debug loopback"
-	depends on FSL_DPAA_ETH_DEBUGFS && FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+	depends on FSL_DPAA_ETH_DEBUGFS
 	default n
 	help
 	  This option allows to divert all received traffic on a certain interface A towards a
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
@@ -678,7 +678,7 @@ static const struct net_device_ops dpa_p
 	.ndo_get_stats64 = dpa_get_stats64,
 	.ndo_set_mac_address = dpa_set_mac_address,
 	.ndo_validate_addr = eth_validate_addr,
-#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+#ifdef CONFIG_FMAN_PFC
 	.ndo_select_queue = dpa_select_queue,
 #endif
 	.ndo_set_rx_mode = dpa_set_rx_mode,
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
@@ -635,23 +635,15 @@ static inline void _dpa_assign_wq(struct
 	}
 }
 
-#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
-/* Use in lieu of skb_get_queue_mapping() */
 #ifdef CONFIG_FMAN_PFC
+/* Use in lieu of skb_get_queue_mapping() */
 #define dpa_get_queue_mapping(skb) \
 	(((skb)->priority < CONFIG_FMAN_PFC_COS_COUNT) ? \
 		((skb)->priority * dpa_num_cpus + smp_processor_id()) : \
 		((CONFIG_FMAN_PFC_COS_COUNT - 1) * \
 			dpa_num_cpus + smp_processor_id()));
-
 #else
-#define dpa_get_queue_mapping(skb) \
-	raw_smp_processor_id()
-#endif
-#else
-/* Use the queue selected by XPS */
-#define dpa_get_queue_mapping(skb) \
-	skb_get_queue_mapping(skb)
+#define dpa_get_queue_mapping(skb) skb_get_queue_mapping(skb)
 #endif
 
 #ifdef CONFIG_PTP_1588_CLOCK_DPAA
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c
@@ -841,14 +841,13 @@ bool dpa_bpid2pool_use(int bpid)
 	return false;
 }
 
-#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+#ifdef CONFIG_FMAN_PFC
 u16 dpa_select_queue(struct net_device *net_dev, struct sk_buff *skb,
 		     struct net_device *sb_dev,
 		     select_queue_fallback_t fallback)
 {
 	return dpa_get_queue_mapping(skb);
 }
-EXPORT_SYMBOL(dpa_select_queue);
 #endif
 
 struct dpa_fq *dpa_fq_alloc(struct device *dev,
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.h
@@ -172,7 +172,7 @@ struct dpa_bp *dpa_bpid2pool(int bpid);
 void dpa_bpid2pool_map(int bpid, struct dpa_bp *dpa_bp);
 bool dpa_bpid2pool_use(int bpid);
 void dpa_bp_drain(struct dpa_bp *bp);
-#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+#ifdef CONFIG_FMAN_PFC
 u16 dpa_select_queue(struct net_device *net_dev, struct sk_buff *skb,
 		     struct net_device *sb_dev,
 		     select_queue_fallback_t fallback);
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
@@ -648,6 +648,8 @@ void __hot _dpa_rx(struct net_device *ne
 	}
 #endif
 
+	skb_record_rx_queue(skb, raw_smp_processor_id());
+
 	if (use_gro) {
 		gro_result_t gro_result;
 		const struct qman_portal_config *pc =
