[dpdk-dev,01/13] net/sfc: callbacks should depend on EvQ usage

Message ID 1488438439-14776-2-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko March 2, 2017, 7:07 a.m. UTC
  Use different sets of libefx EvQ callbacks for management,
transmit and receive event queue. It makes event handling
more robust against unexpected events.

Also it is required for alternative datapath support.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ev.c | 107 +++++++++++++++++++++++++++++++++++++++++++++--
 drivers/net/sfc/sfc_ev.h |  19 +++++----
 2 files changed, 114 insertions(+), 12 deletions(-)
  

Comments

Ferruh Yigit March 4, 2017, 9:04 p.m. UTC | #1
On 3/2/2017 7:07 AM, Andrew Rybchenko wrote:
> Use different sets of libefx EvQ callbacks for management,
> transmit and receive event queue. It makes event handling
> more robust against unexpected events.
> 
> Also it is required for alternative datapath support.
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Can you please update patch titles to start with a verb to describe what
patch does. Most of the patches in this patchset already this way, but
some are not.

For example, this patch title can be something like:
"net/sfc: use different callbacks for EvQ"

Thanks,
ferruh
  

Patch

diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index f717faa..c0f2218 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -69,6 +69,18 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_rx(void *arg, uint32_t label, uint32_t id,
+	      uint32_t size, uint16_t flags)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa,
+		"EVQ %u unexpected Rx event label=%u id=%#x size=%u flags=%#x",
+		evq->evq_index, label, id, size, flags);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_rx(void *arg, __rte_unused uint32_t label, uint32_t id,
 	  uint32_t size, uint16_t flags)
 {
@@ -142,6 +154,16 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_tx(void *arg, uint32_t label, uint32_t id)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa, "EVQ %u unexpected Tx event label=%u id=%#x",
+		evq->evq_index, label, id);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_tx(void *arg, __rte_unused uint32_t label, uint32_t id)
 {
 	struct sfc_evq *evq = arg;
@@ -196,6 +218,16 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_rxq_flush_done(void *arg, uint32_t rxq_hw_index)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa, "EVQ %u unexpected RxQ %u flush done",
+		evq->evq_index, rxq_hw_index);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_rxq_flush_done(void *arg, __rte_unused uint32_t rxq_hw_index)
 {
 	struct sfc_evq *evq = arg;
@@ -211,6 +243,16 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_rxq_flush_failed(void *arg, uint32_t rxq_hw_index)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa, "EVQ %u unexpected RxQ %u flush failed",
+		evq->evq_index, rxq_hw_index);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_rxq_flush_failed(void *arg, __rte_unused uint32_t rxq_hw_index)
 {
 	struct sfc_evq *evq = arg;
@@ -226,6 +268,16 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_txq_flush_done(void *arg, uint32_t txq_hw_index)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa, "EVQ %u unexpected TxQ %u flush done",
+		evq->evq_index, txq_hw_index);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_txq_flush_done(void *arg, __rte_unused uint32_t txq_hw_index)
 {
 	struct sfc_evq *evq = arg;
@@ -281,6 +333,16 @@ 
 }
 
 static boolean_t
+sfc_ev_nop_link_change(void *arg, __rte_unused efx_link_mode_t link_mode)
+{
+	struct sfc_evq *evq = arg;
+
+	sfc_err(evq->sa, "EVQ %u unexpected link change event",
+		evq->evq_index);
+	return B_TRUE;
+}
+
+static boolean_t
 sfc_ev_link_change(void *arg, efx_link_mode_t link_mode)
 {
 	struct sfc_evq *evq = arg;
@@ -312,17 +374,47 @@ 
 
 static const efx_ev_callbacks_t sfc_ev_callbacks = {
 	.eec_initialized	= sfc_ev_initialized,
+	.eec_rx			= sfc_ev_nop_rx,
+	.eec_tx			= sfc_ev_nop_tx,
+	.eec_exception		= sfc_ev_exception,
+	.eec_rxq_flush_done	= sfc_ev_nop_rxq_flush_done,
+	.eec_rxq_flush_failed	= sfc_ev_nop_rxq_flush_failed,
+	.eec_txq_flush_done	= sfc_ev_nop_txq_flush_done,
+	.eec_software		= sfc_ev_software,
+	.eec_sram		= sfc_ev_sram,
+	.eec_wake_up		= sfc_ev_wake_up,
+	.eec_timer		= sfc_ev_timer,
+	.eec_link_change	= sfc_ev_link_change,
+};
+
+static const efx_ev_callbacks_t sfc_ev_callbacks_rx = {
+	.eec_initialized	= sfc_ev_initialized,
 	.eec_rx			= sfc_ev_rx,
-	.eec_tx			= sfc_ev_tx,
+	.eec_tx			= sfc_ev_nop_tx,
 	.eec_exception		= sfc_ev_exception,
 	.eec_rxq_flush_done	= sfc_ev_rxq_flush_done,
 	.eec_rxq_flush_failed	= sfc_ev_rxq_flush_failed,
+	.eec_txq_flush_done	= sfc_ev_nop_txq_flush_done,
+	.eec_software		= sfc_ev_software,
+	.eec_sram		= sfc_ev_sram,
+	.eec_wake_up		= sfc_ev_wake_up,
+	.eec_timer		= sfc_ev_timer,
+	.eec_link_change	= sfc_ev_nop_link_change,
+};
+
+static const efx_ev_callbacks_t sfc_ev_callbacks_tx = {
+	.eec_initialized	= sfc_ev_initialized,
+	.eec_rx			= sfc_ev_nop_rx,
+	.eec_tx			= sfc_ev_tx,
+	.eec_exception		= sfc_ev_exception,
+	.eec_rxq_flush_done	= sfc_ev_nop_rxq_flush_done,
+	.eec_rxq_flush_failed	= sfc_ev_nop_rxq_flush_failed,
 	.eec_txq_flush_done	= sfc_ev_txq_flush_done,
 	.eec_software		= sfc_ev_software,
 	.eec_sram		= sfc_ev_sram,
 	.eec_wake_up		= sfc_ev_wake_up,
 	.eec_timer		= sfc_ev_timer,
-	.eec_link_change	= sfc_ev_link_change,
+	.eec_link_change	= sfc_ev_nop_link_change,
 };
 
 
@@ -334,7 +426,7 @@ 
 
 	/* Synchronize the DMA memory for reading not required */
 
-	efx_ev_qpoll(evq->common, &evq->read_ptr, &sfc_ev_callbacks, evq);
+	efx_ev_qpoll(evq->common, &evq->read_ptr, evq->callbacks, evq);
 
 	if (unlikely(evq->exception) && sfc_adapter_trylock(evq->sa)) {
 		struct sfc_adapter *sa = evq->sa;
@@ -425,6 +517,14 @@ 
 	if (rc != 0)
 		goto fail_ev_qcreate;
 
+	SFC_ASSERT(evq->rxq == NULL || evq->txq == NULL);
+	if (evq->rxq != 0)
+		evq->callbacks = &sfc_ev_callbacks_rx;
+	else if (evq->txq != 0)
+		evq->callbacks = &sfc_ev_callbacks_tx;
+	else
+		evq->callbacks = &sfc_ev_callbacks;
+
 	evq->init_state = SFC_EVQ_STARTING;
 
 	/* Wait for the initialization event */
@@ -483,6 +583,7 @@ 
 		return;
 
 	evq->init_state = SFC_EVQ_INITIALIZED;
+	evq->callbacks = NULL;
 	evq->read_ptr = 0;
 	evq->exception = B_FALSE;
 
diff --git a/drivers/net/sfc/sfc_ev.h b/drivers/net/sfc/sfc_ev.h
index 346e3ec..41a37f4 100644
--- a/drivers/net/sfc/sfc_ev.h
+++ b/drivers/net/sfc/sfc_ev.h
@@ -54,17 +54,18 @@  enum sfc_evq_state {
 
 struct sfc_evq {
 	/* Used on datapath */
-	efx_evq_t		*common;
-	unsigned int		read_ptr;
-	boolean_t		exception;
-	efsys_mem_t		mem;
-	struct sfc_rxq		*rxq;
-	struct sfc_txq		*txq;
+	efx_evq_t			*common;
+	const efx_ev_callbacks_t	*callbacks;
+	unsigned int			read_ptr;
+	boolean_t			exception;
+	efsys_mem_t			mem;
+	struct sfc_rxq			*rxq;
+	struct sfc_txq			*txq;
 
 	/* Not used on datapath */
-	struct sfc_adapter	*sa;
-	unsigned int		evq_index;
-	enum sfc_evq_state	init_state;
+	struct sfc_adapter		*sa;
+	unsigned int			evq_index;
+	enum sfc_evq_state		init_state;
 };
 
 struct sfc_evq_info {