From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E9B4CA04E1; Tue, 22 Sep 2020 10:53:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50D4C1DAE4; Tue, 22 Sep 2020 10:50:48 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id E8B571D720 for ; Tue, 22 Sep 2020 10:50:18 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.150]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9622420067 for ; Tue, 22 Sep 2020 08:50:18 +0000 (UTC) Received: from us4-mdac16-60.at1.mdlocal (unknown [10.110.50.153]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9574B800A3 for ; Tue, 22 Sep 2020 08:50:18 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.12]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 34E52100052 for ; Tue, 22 Sep 2020 08:50:18 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id F235F40051 for ; Tue, 22 Sep 2020 08:50:17 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 22 Sep 2020 09:50:10 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 22 Sep 2020 09:50:10 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 08M8oAHd004696 for ; Tue, 22 Sep 2020 09:50:10 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 764F01613A9 for ; Tue, 22 Sep 2020 09:50:10 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 22 Sep 2020 09:49:21 +0100 Message-ID: <1600764594-14752-28-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1600764594-14752-1-git-send-email-arybchenko@solarflare.com> References: <1600764594-14752-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25674.003 X-TM-AS-Result: No-3.401100-8.000000-10 X-TMASE-MatchedRID: +vReUM/O/i9Ksq30PQsu2y2416nc3bQleouvej40T4iOSVCvVHWJJ3Io zGa69omdrdoLblq9S5ra/g/NGTW3MsMSd2wnXUfGRaPXfvn+kepn+sA9+u1YLajxqhyDxmYjUZG E0qUrJUWXWBKDe9c5qdJKpUv7pKTc/Nck001Q47ycnm0v4tsY40RJRb9jm/QS+nDqnR0MvOF5bB iV7e/VjIf14kDTy5+emxqPMoJgkAcHjsLHUSLAbZ4CIKY/Hg3Am4n49vyf9XFKdDgyPBo71yq2r l3dzGQ11gK47J5WPQ+zMOmPm6lcxws5u0gaVzXqd5/ZYA8mOG1g7WxwuTZHTHsJW3gF8MUi0n4V GO3SVN7VDDU1i7Tnjz1UJetxc2XzO7aFTaAW0lUjoqQAvYDmRwy1ivD0G5PCpKZI9GApJkyX7oP o2hrrKA== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.401100-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25674.003 X-MDID: 1600764618-Q9TfEycBQ7Ma Subject: [dpdk-dev] [PATCH 27/60] common/sfc_efx/base: move TxQ init/fini wrappers to generic 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" TxQ init/fini MCDI is similar on Riverhead and these functions should be reused to implement TxQ creation and destruction on Riverhead. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Vijay Kumar Srivastava --- drivers/common/sfc_efx/base/ef10_tx.c | 133 ------------------------- drivers/common/sfc_efx/base/efx_impl.h | 17 ++++ drivers/common/sfc_efx/base/efx_mcdi.c | 133 +++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 133 deletions(-) diff --git a/drivers/common/sfc_efx/base/ef10_tx.c b/drivers/common/sfc_efx/base/ef10_tx.c index e2f9ebac46..61c7e49fe8 100644 --- a/drivers/common/sfc_efx/base/ef10_tx.c +++ b/drivers/common/sfc_efx/base/ef10_tx.c @@ -20,139 +20,6 @@ #define EFX_TX_QSTAT_INCR(_etp, _stat) #endif -static __checkReturn efx_rc_t -efx_mcdi_init_txq( - __in efx_nic_t *enp, - __in uint32_t ndescs, - __in uint32_t target_evq, - __in uint32_t label, - __in uint32_t instance, - __in uint16_t flags, - __in efsys_mem_t *esmp) -{ - efx_mcdi_req_t req; - EFX_MCDI_DECLARE_BUF(payload, - MC_CMD_INIT_TXQ_IN_LEN(EF10_TXQ_MAXNBUFS), - MC_CMD_INIT_TXQ_OUT_LEN); - efx_qword_t *dma_addr; - uint64_t addr; - int npages; - int i; - efx_rc_t rc; - - EFSYS_ASSERT(EF10_TXQ_MAXNBUFS >= - efx_txq_nbufs(enp, enp->en_nic_cfg.enc_txq_max_ndescs)); - - if ((esmp == NULL) || - (EFSYS_MEM_SIZE(esmp) < efx_txq_size(enp, ndescs))) { - rc = EINVAL; - goto fail1; - } - - npages = efx_txq_nbufs(enp, ndescs); - if (MC_CMD_INIT_TXQ_IN_LEN(npages) > sizeof (payload)) { - rc = EINVAL; - goto fail2; - } - - req.emr_cmd = MC_CMD_INIT_TXQ; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_INIT_TXQ_IN_LEN(npages); - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_INIT_TXQ_OUT_LEN; - - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_SIZE, ndescs); - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_TARGET_EVQ, target_evq); - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_LABEL, label); - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_INSTANCE, instance); - - MCDI_IN_POPULATE_DWORD_9(req, INIT_TXQ_IN_FLAGS, - INIT_TXQ_IN_FLAG_BUFF_MODE, 0, - INIT_TXQ_IN_FLAG_IP_CSUM_DIS, - (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1, - INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, - (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1, - INIT_TXQ_EXT_IN_FLAG_INNER_IP_CSUM_EN, - (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0, - INIT_TXQ_EXT_IN_FLAG_INNER_TCP_CSUM_EN, - (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0, - INIT_TXQ_EXT_IN_FLAG_TSOV2_EN, (flags & EFX_TXQ_FATSOV2) ? 1 : 0, - INIT_TXQ_IN_FLAG_TCP_UDP_ONLY, 0, - INIT_TXQ_IN_CRC_MODE, 0, - INIT_TXQ_IN_FLAG_TIMESTAMP, 0); - - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_OWNER_ID, 0); - MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_PORT_ID, enp->en_vport_id); - - dma_addr = MCDI_IN2(req, efx_qword_t, INIT_TXQ_IN_DMA_ADDR); - addr = EFSYS_MEM_ADDR(esmp); - - for (i = 0; i < npages; i++) { - EFX_POPULATE_QWORD_2(*dma_addr, - EFX_DWORD_1, (uint32_t)(addr >> 32), - EFX_DWORD_0, (uint32_t)(addr & 0xffffffff)); - - dma_addr++; - addr += EFX_BUF_SIZE; - } - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail3; - } - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_fini_txq( - __in efx_nic_t *enp, - __in uint32_t instance) -{ - efx_mcdi_req_t req; - EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FINI_TXQ_IN_LEN, - MC_CMD_FINI_TXQ_OUT_LEN); - efx_rc_t rc; - - req.emr_cmd = MC_CMD_FINI_TXQ; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_FINI_TXQ_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_FINI_TXQ_OUT_LEN; - - MCDI_IN_SET_DWORD(req, FINI_TXQ_IN_INSTANCE, instance); - - efx_mcdi_execute_quiet(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - /* - * EALREADY is not an error, but indicates that the MC has rebooted and - * that the TXQ has already been destroyed. - */ - if (rc != EALREADY) - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - __checkReturn efx_rc_t ef10_tx_init( __in efx_nic_t *enp) diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 48f853cf91..7d470619e1 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1456,6 +1456,23 @@ efx_mcdi_fini_rxq( __in efx_nic_t *enp, __in uint32_t instance); +LIBEFX_INTERNAL +extern __checkReturn efx_rc_t +efx_mcdi_init_txq( + __in efx_nic_t *enp, + __in uint32_t ndescs, + __in uint32_t target_evq, + __in uint32_t label, + __in uint32_t instance, + __in uint16_t flags, + __in efsys_mem_t *esmp); + +LIBEFX_INTERNAL +extern __checkReturn efx_rc_t +efx_mcdi_fini_txq( + __in efx_nic_t *enp, + __in uint32_t instance); + #endif /* EFX_OPTS_EF10() */ #endif /* EFSYS_OPT_MCDI */ diff --git a/drivers/common/sfc_efx/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c index 8bf7c86c3a..a2ac053f0c 100644 --- a/drivers/common/sfc_efx/base/efx_mcdi.c +++ b/drivers/common/sfc_efx/base/efx_mcdi.c @@ -2867,6 +2867,139 @@ efx_mcdi_fini_rxq( return (rc); } + __checkReturn efx_rc_t +efx_mcdi_init_txq( + __in efx_nic_t *enp, + __in uint32_t ndescs, + __in uint32_t target_evq, + __in uint32_t label, + __in uint32_t instance, + __in uint16_t flags, + __in efsys_mem_t *esmp) +{ + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_INIT_TXQ_IN_LEN(EF10_TXQ_MAXNBUFS), + MC_CMD_INIT_TXQ_OUT_LEN); + efx_qword_t *dma_addr; + uint64_t addr; + int npages; + int i; + efx_rc_t rc; + + EFSYS_ASSERT(EF10_TXQ_MAXNBUFS >= + efx_txq_nbufs(enp, enp->en_nic_cfg.enc_txq_max_ndescs)); + + if ((esmp == NULL) || + (EFSYS_MEM_SIZE(esmp) < efx_txq_size(enp, ndescs))) { + rc = EINVAL; + goto fail1; + } + + npages = efx_txq_nbufs(enp, ndescs); + if (MC_CMD_INIT_TXQ_IN_LEN(npages) > sizeof (payload)) { + rc = EINVAL; + goto fail2; + } + + req.emr_cmd = MC_CMD_INIT_TXQ; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_INIT_TXQ_IN_LEN(npages); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_INIT_TXQ_OUT_LEN; + + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_SIZE, ndescs); + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_TARGET_EVQ, target_evq); + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_LABEL, label); + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_INSTANCE, instance); + + MCDI_IN_POPULATE_DWORD_9(req, INIT_TXQ_IN_FLAGS, + INIT_TXQ_IN_FLAG_BUFF_MODE, 0, + INIT_TXQ_IN_FLAG_IP_CSUM_DIS, + (flags & EFX_TXQ_CKSUM_IPV4) ? 0 : 1, + INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, + (flags & EFX_TXQ_CKSUM_TCPUDP) ? 0 : 1, + INIT_TXQ_EXT_IN_FLAG_INNER_IP_CSUM_EN, + (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0, + INIT_TXQ_EXT_IN_FLAG_INNER_TCP_CSUM_EN, + (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0, + INIT_TXQ_EXT_IN_FLAG_TSOV2_EN, (flags & EFX_TXQ_FATSOV2) ? 1 : 0, + INIT_TXQ_IN_FLAG_TCP_UDP_ONLY, 0, + INIT_TXQ_IN_CRC_MODE, 0, + INIT_TXQ_IN_FLAG_TIMESTAMP, 0); + + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_OWNER_ID, 0); + MCDI_IN_SET_DWORD(req, INIT_TXQ_IN_PORT_ID, enp->en_vport_id); + + dma_addr = MCDI_IN2(req, efx_qword_t, INIT_TXQ_IN_DMA_ADDR); + addr = EFSYS_MEM_ADDR(esmp); + + for (i = 0; i < npages; i++) { + EFX_POPULATE_QWORD_2(*dma_addr, + EFX_DWORD_1, (uint32_t)(addr >> 32), + EFX_DWORD_0, (uint32_t)(addr & 0xffffffff)); + + dma_addr++; + addr += EFX_BUF_SIZE; + } + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail3; + } + + return (0); + +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + + __checkReturn efx_rc_t +efx_mcdi_fini_txq( + __in efx_nic_t *enp, + __in uint32_t instance) +{ + efx_mcdi_req_t req; + EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FINI_TXQ_IN_LEN, + MC_CMD_FINI_TXQ_OUT_LEN); + efx_rc_t rc; + + req.emr_cmd = MC_CMD_FINI_TXQ; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_FINI_TXQ_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_FINI_TXQ_OUT_LEN; + + MCDI_IN_SET_DWORD(req, FINI_TXQ_IN_INSTANCE, instance); + + efx_mcdi_execute_quiet(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail1; + } + + return (0); + +fail1: + /* + * EALREADY is not an error, but indicates that the MC has rebooted and + * that the TXQ has already been destroyed. + */ + if (rc != EALREADY) + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + #endif /* EFX_OPTS_EF10() */ #endif /* EFSYS_OPT_MCDI */ -- 2.17.1