Netdev List
 help / color / mirror / Atom feed
* [net-next PATCH v2 0/3] i40e/i40evf: Fixes for netpoll
@ 2015-09-24 16:04 Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 1/3] i40e/i40evf: Fix handling of napi budget Alexander Duyck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Duyck @ 2015-09-24 16:04 UTC (permalink / raw)
  To: netdev, intel-wired-lan; +Cc: jeffrey.t.kirsher

The following patch series is meant to address the fact that i40e and
i40evf had several issues in regards to netpoll.  First was the fact that
they were forcing their budgets to increase to 1.  Second was the fact they
were incorrectly thinking they were in NAPI context when they weren't.
Finally, I also noticed that i40evf didn't even support netpoll so I went
through and added support for it.

These patches are compile tested only since I don't actually have access to
the i40e hardware.

---

Alexander Duyck (3):
      i40e/i40evf: Fix handling of napi budget
      i40e/i40evf: Drop useless "IN_NETPOLL" flag
      i40evf: Add support for netpoll


 drivers/net/ethernet/intel/i40e/i40e.h          |    1 -
 drivers/net/ethernet/intel/i40e/i40e_main.c     |    2 --
 drivers/net/ethernet/intel/i40e/i40e_txrx.c     |   12 +++++------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c   |   12 +++++------
 drivers/net/ethernet/intel/i40evf/i40evf.h      |    2 --
 drivers/net/ethernet/intel/i40evf/i40evf_main.c |   26 +++++++++++++++++++++++
 6 files changed, 38 insertions(+), 17 deletions(-)

--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [net-next PATCH v2 1/3] i40e/i40evf: Fix handling of napi budget
  2015-09-24 16:04 [net-next PATCH v2 0/3] i40e/i40evf: Fixes for netpoll Alexander Duyck
@ 2015-09-24 16:04 ` Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 2/3] i40e/i40evf: Drop useless "IN_NETPOLL" flag Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 3/3] i40evf: Add support for netpoll Alexander Duyck
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Duyck @ 2015-09-24 16:04 UTC (permalink / raw)
  To: netdev, intel-wired-lan; +Cc: jeffrey.t.kirsher

The polling routine for i40e was rounding up the budget for Rx cleanup to
1.  This is incorrect as the netpoll poll call is expecting no Rx to be
processed as the budget passed was 0.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |    5 +++++
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c |    5 +++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index d51b8edebfee..66b1fd26f0fc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1923,6 +1923,10 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)
 		ring->arm_wb = false;
 	}
 
+	/* Handle case where we are called by netpoll with a budget of 0 */
+	if (budget <= 0)
+		goto tx_only;
+
 	/* We attempt to distribute budget to each Rx queue fairly, but don't
 	 * allow the budget to go below 1 because that would exit polling early.
 	 */
@@ -1939,6 +1943,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)
 
 	/* If work not completed, return budget and polling will return */
 	if (!clean_complete) {
+tx_only:
 		if (arm_wb)
 			i40e_force_wb(vsi, q_vector);
 		return budget;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index 7b20f53a414a..c60e9cf016c2 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -1367,6 +1367,10 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
 		ring->arm_wb = false;
 	}
 
+	/* Handle case where we are called by netpoll with a budget of 0 */
+	if (budget <= 0)
+		goto tx_only;
+
 	/* We attempt to distribute budget to each Rx queue fairly, but don't
 	 * allow the budget to go below 1 because that would exit polling early.
 	 */
@@ -1383,6 +1387,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
 
 	/* If work not completed, return budget and polling will return */
 	if (!clean_complete) {
+tx_only:
 		if (arm_wb)
 			i40e_force_wb(vsi, q_vector);
 		return budget;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net-next PATCH v2 2/3] i40e/i40evf: Drop useless "IN_NETPOLL" flag
  2015-09-24 16:04 [net-next PATCH v2 0/3] i40e/i40evf: Fixes for netpoll Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 1/3] i40e/i40evf: Fix handling of napi budget Alexander Duyck
@ 2015-09-24 16:04 ` Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 3/3] i40evf: Add support for netpoll Alexander Duyck
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Duyck @ 2015-09-24 16:04 UTC (permalink / raw)
  To: netdev, intel-wired-lan; +Cc: jeffrey.t.kirsher

The code in i40e and i40evf is using an "IN_NETPOLL" flag that has never
added any value due to the fact that the Rx clean-up is handled in NAPI.
As such the flag was set, the queue was scheduled via NAPI, and then polled
from the netpoll controller and if any Rx packets were processed the were
processed in the wrong context.

In addition the flag itself just added an unneeded conditional to the
hot-path so it can safely be dropped and save us a few instructions.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
 drivers/net/ethernet/intel/i40e/i40e.h        |    1 -
 drivers/net/ethernet/intel/i40e/i40e_main.c   |    2 --
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |    7 +------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c |    7 +------
 drivers/net/ethernet/intel/i40evf/i40evf.h    |    2 --
 5 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index e1cd8ac19dfc..e87d96788af2 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -308,7 +308,6 @@ struct i40e_pf {
 #ifdef I40E_FCOE
 #define I40E_FLAG_FCOE_ENABLED			BIT_ULL(11)
 #endif /* I40E_FCOE */
-#define I40E_FLAG_IN_NETPOLL			BIT_ULL(12)
 #define I40E_FLAG_16BYTE_RX_DESC_ENABLED	BIT_ULL(13)
 #define I40E_FLAG_CLEAN_ADMINQ			BIT_ULL(14)
 #define I40E_FLAG_FILTER_SYNC			BIT_ULL(15)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index f048002ad928..56fd4ddbb9a8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -3749,14 +3749,12 @@ static void i40e_netpoll(struct net_device *netdev)
 	if (test_bit(__I40E_DOWN, &vsi->state))
 		return;
 
-	pf->flags |= I40E_FLAG_IN_NETPOLL;
 	if (pf->flags & I40E_FLAG_MSIX_ENABLED) {
 		for (i = 0; i < vsi->num_q_vectors; i++)
 			i40e_msix_clean_rings(0, vsi->q_vectors[i]);
 	} else {
 		i40e_intr(pf->pdev->irq, netdev);
 	}
-	pf->flags &= ~I40E_FLAG_IN_NETPOLL;
 }
 #endif
 
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 66b1fd26f0fc..fe4ce5a807a3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1345,16 +1345,11 @@ static void i40e_receive_skb(struct i40e_ring *rx_ring,
 			     struct sk_buff *skb, u16 vlan_tag)
 {
 	struct i40e_q_vector *q_vector = rx_ring->q_vector;
-	struct i40e_vsi *vsi = rx_ring->vsi;
-	u64 flags = vsi->back->flags;
 
 	if (vlan_tag & VLAN_VID_MASK)
 		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
 
-	if (flags & I40E_FLAG_IN_NETPOLL)
-		netif_rx(skb);
-	else
-		napi_gro_receive(&q_vector->napi, skb);
+	napi_gro_receive(&q_vector->napi, skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index c60e9cf016c2..cff9b47a5ebc 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -822,16 +822,11 @@ static void i40e_receive_skb(struct i40e_ring *rx_ring,
 			     struct sk_buff *skb, u16 vlan_tag)
 {
 	struct i40e_q_vector *q_vector = rx_ring->q_vector;
-	struct i40e_vsi *vsi = rx_ring->vsi;
-	u64 flags = vsi->back->flags;
 
 	if (vlan_tag & VLAN_VID_MASK)
 		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
 
-	if (flags & I40E_FLAG_IN_NETPOLL)
-		netif_rx(skb);
-	else
-		napi_gro_receive(&q_vector->napi, skb);
+	napi_gro_receive(&q_vector->napi, skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h b/drivers/net/ethernet/intel/i40evf/i40evf.h
index 132f03a0f87b..e18e4132b61b 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf.h
+++ b/drivers/net/ethernet/intel/i40evf/i40evf.h
@@ -211,7 +211,6 @@ struct i40evf_adapter {
 #define I40EVF_FLAG_RX_1BUF_CAPABLE              BIT(1)
 #define I40EVF_FLAG_RX_PS_CAPABLE                BIT(2)
 #define I40EVF_FLAG_RX_PS_ENABLED                BIT(3)
-#define I40EVF_FLAG_IN_NETPOLL                   BIT(4)
 #define I40EVF_FLAG_IMIR_ENABLED                 BIT(5)
 #define I40EVF_FLAG_MQ_CAPABLE                   BIT(6)
 #define I40EVF_FLAG_NEED_LINK_UPDATE             BIT(7)
@@ -224,7 +223,6 @@ struct i40evf_adapter {
 /* duplicates for common code */
 #define I40E_FLAG_FDIR_ATR_ENABLED		 0
 #define I40E_FLAG_DCB_ENABLED			 0
-#define I40E_FLAG_IN_NETPOLL			 I40EVF_FLAG_IN_NETPOLL
 #define I40E_FLAG_RX_CSUM_ENABLED                I40EVF_FLAG_RX_CSUM_ENABLED
 #define I40E_FLAG_WB_ON_ITR_CAPABLE		I40EVF_FLAG_WB_ON_ITR_CAPABLE
 #define I40E_FLAG_OUTER_UDP_CSUM_CAPABLE	I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net-next PATCH v2 3/3] i40evf: Add support for netpoll
  2015-09-24 16:04 [net-next PATCH v2 0/3] i40e/i40evf: Fixes for netpoll Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 1/3] i40e/i40evf: Fix handling of napi budget Alexander Duyck
  2015-09-24 16:04 ` [net-next PATCH v2 2/3] i40e/i40evf: Drop useless "IN_NETPOLL" flag Alexander Duyck
@ 2015-09-24 16:04 ` Alexander Duyck
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Duyck @ 2015-09-24 16:04 UTC (permalink / raw)
  To: netdev, intel-wired-lan; +Cc: jeffrey.t.kirsher

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c |   26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 429a46c2a2f7..5e1336321c2f 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -444,6 +444,29 @@ out:
 	return err;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/**
+ * i40evf_netpoll - A Polling 'interrupt'handler
+ * @netdev: network interface device structure
+ *
+ * This is used by netconsole to send skbs without having to re-enable
+ * interrupts.  It's not called while the normal interrupt routine is executing.
+ **/
+static void i40evf_netpoll(struct net_device *netdev)
+{
+	struct i40evf_adapter *adapter = netdev_priv(netdev);
+	int q_vectors = adapter->num_msix_vectors - NONQ_VECS;
+	int i;
+
+	/* if interface is down do nothing */
+	if (test_bit(__I40E_DOWN, &adapter->vsi.state))
+		return;
+
+	for (i = 0; i < q_vectors; i++)
+		i40evf_msix_clean_rings(0, adapter->q_vector[i]);
+}
+
+#endif
 /**
  * i40evf_request_traffic_irqs - Initialize MSI-X interrupts
  * @adapter: board private structure
@@ -2049,6 +2072,9 @@ static const struct net_device_ops i40evf_netdev_ops = {
 	.ndo_tx_timeout		= i40evf_tx_timeout,
 	.ndo_vlan_rx_add_vid	= i40evf_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= i40evf_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= i40evf_netpoll,
+#endif
 };
 
 /**

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-24 16:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-24 16:04 [net-next PATCH v2 0/3] i40e/i40evf: Fixes for netpoll Alexander Duyck
2015-09-24 16:04 ` [net-next PATCH v2 1/3] i40e/i40evf: Fix handling of napi budget Alexander Duyck
2015-09-24 16:04 ` [net-next PATCH v2 2/3] i40e/i40evf: Drop useless "IN_NETPOLL" flag Alexander Duyck
2015-09-24 16:04 ` [net-next PATCH v2 3/3] i40evf: Add support for netpoll Alexander Duyck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox