From patchwork Mon Mar 20 10:15:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 21992 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 985F6CF80; Mon, 20 Mar 2017 11:16:07 +0100 (CET) Received: from nbfkord-smmo01.seg.att.com (nbfkord-smmo01.seg.att.com [209.65.160.76]) by dpdk.org (Postfix) with ESMTP id 439EF69C5 for ; Mon, 20 Mar 2017 11:15:51 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo01.seg.att.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id 7dbafc85.2ab221a88940.553589.00-2482.1325624.nbfkord-smmo01.seg.att.com (envelope-from ); Mon, 20 Mar 2017 10:15:51 +0000 (UTC) X-MXL-Hash: 58cfabd77cb94b98-60b6903512ba6b3ba5e910e1393fc79e54e8148b Received: from unknown [12.187.104.26] by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with SMTP id fcbafc85.0.553578.00-2386.1325557.nbfkord-smmo01.seg.att.com (envelope-from ); Mon, 20 Mar 2017 10:15:43 +0000 (UTC) X-MXL-Hash: 58cfabcf20c92691-7d1e5ed769280fcd241dd9d093497f67bc9f4e76 Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 20 Mar 2017 03:15:35 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Mon, 20 Mar 2017 03:15:34 -0700 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id v2KAFXKi027535; Mon, 20 Mar 2017 10:15:33 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id v2KAFX9L002212; Mon, 20 Mar 2017 10:15:33 GMT From: Andrew Rybchenko To: CC: Ferruh Yigit Date: Mon, 20 Mar 2017 10:15:07 +0000 Message-ID: <1490004919-2177-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1490004919-2177-1-git-send-email-arybchenko@solarflare.com> References: <1488438439-14776-1-git-send-email-arybchenko@solarflare.com> <1490004919-2177-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-AnalysisOut: [v=2.1 cv=Tung8Wjh c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=6Iz7jQTuP9IA:10 a=zRKbQ67AAAAA:8 a=NBRxDur1BiBNGs4rI] X-AnalysisOut: [_8A:9 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.3432967784; CM=0.500; S=0.343(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH v2 01/13] net/sfc: use different callbacks for event queues X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/sfc/sfc_ev.c | 107 +++++++++++++++++++++++++++++++++++++++++++++-- drivers/net/sfc/sfc_ev.h | 19 +++++---- 2 files changed, 114 insertions(+), 12 deletions(-) diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index 412645a..bb22001 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -71,6 +71,18 @@ sfc_ev_initialized(void *arg) } 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) { @@ -144,6 +156,16 @@ sfc_ev_rx(void *arg, __rte_unused uint32_t label, uint32_t id, } 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; @@ -198,6 +220,16 @@ sfc_ev_exception(void *arg, __rte_unused uint32_t code, } 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; @@ -213,6 +245,16 @@ sfc_ev_rxq_flush_done(void *arg, __rte_unused uint32_t rxq_hw_index) } 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; @@ -228,6 +270,16 @@ sfc_ev_rxq_flush_failed(void *arg, __rte_unused uint32_t rxq_hw_index) } 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; @@ -283,6 +335,16 @@ sfc_ev_timer(void *arg, uint32_t index) } 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; @@ -314,17 +376,47 @@ sfc_ev_link_change(void *arg, efx_link_mode_t link_mode) 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, }; @@ -336,7 +428,7 @@ sfc_ev_qpoll(struct sfc_evq *evq) /* 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; @@ -427,6 +519,14 @@ sfc_ev_qstart(struct sfc_adapter *sa, unsigned int sw_index) 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 */ @@ -485,6 +585,7 @@ sfc_ev_qstop(struct sfc_adapter *sa, unsigned int sw_index) 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 5bb2be4..359958e 100644 --- a/drivers/net/sfc/sfc_ev.h +++ b/drivers/net/sfc/sfc_ev.h @@ -56,17 +56,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 {