From patchwork Tue Sep 8 09:14:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76884 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8EC44A04AA; Tue, 8 Sep 2020 11:15:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B91261BF8A; Tue, 8 Sep 2020 11:15:33 +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 1DD8EA3 for ; Tue, 8 Sep 2020 11:15:31 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.137]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9ACD420079 for ; Tue, 8 Sep 2020 09:15:30 +0000 (UTC) Received: from us4-mdac16-49.at1.mdlocal (unknown [10.110.50.132]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 7824B6009B for ; Tue, 8 Sep 2020 09:15:30 +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 BF547220127 for ; Tue, 8 Sep 2020 09:14:53 +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 88F084005E for ; Tue, 8 Sep 2020 09:14:53 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EncZ032402 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 370EB1613BE for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:22 +0100 Message-ID: <1599556475-27820-3-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-0.853500-8.000000-10 X-TMASE-MatchedRID: dOm6f3IdN8WQwZP6WaAvV6iUivh0j2PvB7lMZ4YsZk/RLEyE6G4DRHIo zGa69omdrdoLblq9S5oAhGIvsKa9H9ySVj0wBolS/ccgt/EtX/37H53q49PMQ5soi2XrUn/Jn6K dMrRsL14qtq5d3cxkNb8DM1m1CPUeFHYuCHN4jqb4w1LbY5qx4ToPjkyUEvAbnRSIJc2PdbhOe3 zVkrzFPOuDDCYVzFtxEVRfNh5z3mKDOkxatSZxIxIG1a6aK8YvI6KkAL2A5kcMtYrw9BuTwqSmS PRgKSZM0Hy8mOlvvF7vdCUIFuasqw== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.853500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556530-gV7PnRL3kHsl Subject: [dpdk-dev] [PATCH 01/14] net/sfc: include header with debug helpers directly 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" Avoid build failures on further restructuring. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.c | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/sfc/sfc_dp_tx.h | 1 + drivers/net/sfc/sfc_ef10.h | 2 ++ drivers/net/sfc/sfc_ef10_essb_rx.c | 1 + drivers/net/sfc/sfc_ef10_rx.c | 1 + drivers/net/sfc/sfc_ef10_rx_ev.h | 2 ++ drivers/net/sfc/sfc_ef10_tx.c | 1 + drivers/net/sfc/sfc_filter.c | 1 + drivers/net/sfc/sfc_flow.c | 1 + drivers/net/sfc/sfc_mcdi.c | 1 + drivers/net/sfc/sfc_port.c | 1 + 12 files changed, 14 insertions(+) diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index c19d81cc88..03ea5dc128 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -16,6 +16,7 @@ #include "efx.h" #include "sfc.h" +#include "sfc_debug.h" #include "sfc_log.h" #include "sfc_ev.h" #include "sfc_rx.h" diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index cf95ebaf90..cdff9be3ec 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -21,6 +21,7 @@ #include "efx.h" +#include "sfc_debug.h" #include "sfc_filter.h" #ifdef __cplusplus diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index dcad4fe585..77ae166885 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -12,6 +12,7 @@ #include +#include "sfc_debug.h" #include "sfc_dp.h" #include "sfc_debug.h" #include "sfc_tso.h" diff --git a/drivers/net/sfc/sfc_ef10.h b/drivers/net/sfc/sfc_ef10.h index f138e8d9b0..07c322f7a6 100644 --- a/drivers/net/sfc/sfc_ef10.h +++ b/drivers/net/sfc/sfc_ef10.h @@ -10,6 +10,8 @@ #ifndef _SFC_EF10_H #define _SFC_EF10_H +#include "sfc_debug.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c index 13b2b824e3..8238cc830d 100644 --- a/drivers/net/sfc/sfc_ef10_essb_rx.c +++ b/drivers/net/sfc/sfc_ef10_essb_rx.c @@ -18,6 +18,7 @@ #include "efx_types.h" #include "efx_regs_ef10.h" +#include "sfc_debug.h" #include "sfc_tweak.h" #include "sfc_dp_rx.h" #include "sfc_kvargs.h" diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c index 42e205e1bd..8c6ebaa2fa 100644 --- a/drivers/net/sfc/sfc_ef10_rx.c +++ b/drivers/net/sfc/sfc_ef10_rx.c @@ -21,6 +21,7 @@ #include "efx_regs.h" #include "efx_regs_ef10.h" +#include "sfc_debug.h" #include "sfc_tweak.h" #include "sfc_dp_rx.h" #include "sfc_kvargs.h" diff --git a/drivers/net/sfc/sfc_ef10_rx_ev.h b/drivers/net/sfc/sfc_ef10_rx_ev.h index a9896eae56..d15d24f4c1 100644 --- a/drivers/net/sfc/sfc_ef10_rx_ev.h +++ b/drivers/net/sfc/sfc_ef10_rx_ev.h @@ -16,6 +16,8 @@ #include "efx_regs.h" #include "efx_regs_ef10.h" +#include "sfc_debug.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index b91c8068b1..4d7da427cb 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -19,6 +19,7 @@ #include "efx_regs.h" #include "efx_regs_ef10.h" +#include "sfc_debug.h" #include "sfc_dp_tx.h" #include "sfc_tweak.h" #include "sfc_kvargs.h" diff --git a/drivers/net/sfc/sfc_filter.c b/drivers/net/sfc/sfc_filter.c index 7f4f7c47a5..05a9799230 100644 --- a/drivers/net/sfc/sfc_filter.c +++ b/drivers/net/sfc/sfc_filter.c @@ -12,6 +12,7 @@ #include "efx.h" #include "sfc.h" +#include "sfc_debug.h" #include "sfc_log.h" boolean_t diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index c8e6fb8bce..1a3c0d618b 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -18,6 +18,7 @@ #include "efx.h" #include "sfc.h" +#include "sfc_debug.h" #include "sfc_rx.h" #include "sfc_filter.h" #include "sfc_flow.h" diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 872e4e76b1..ec62ba95ff 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -14,6 +14,7 @@ #include "efx_regs_mcdi.h" #include "sfc.h" +#include "sfc_debug.h" #include "sfc_log.h" #include "sfc_ev.h" diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 32a0894a55..4de13267d5 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -10,6 +10,7 @@ #include "efx.h" #include "sfc.h" +#include "sfc_debug.h" #include "sfc_log.h" #include "sfc_kvargs.h" From patchwork Tue Sep 8 09:14:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76897 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1B1E1A04AA; Tue, 8 Sep 2020 11:17:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0753C1C1A8; Tue, 8 Sep 2020 11:16:09 +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 ABB451C0DB for ; Tue, 8 Sep 2020 11:16:03 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 51FD420065 for ; Tue, 8 Sep 2020 09:16:03 +0000 (UTC) Received: from us4-mdac16-41.at1.mdlocal (unknown [10.110.48.12]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id B9E3B800EC for ; Tue, 8 Sep 2020 09:16:02 +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 B28BA40131 for ; Tue, 8 Sep 2020 09:14:55 +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 2606340062 for ; Tue, 8 Sep 2020 09:14:55 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnCb032407 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 431FD1613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:23 +0100 Message-ID: <1599556475-27820-4-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-13.911400-8.000000-10 X-TMASE-MatchedRID: CzrRmG7Jh68kVMQcdgU2qW6HurDH4PpP+WsBL5B3ZTHfUZT83lbkED6P hj6DfZCEtZt7pZct9Kv+UA6OdqfdifV+NbN27IZWoprTEHvewAAEa8g1x8eqF1fLpI8fOvDuHfA CHvXeibIHQ6X2WXCI3iU+uzi8gTG2RZJ90/Q8Spmdx4sU8R+eYKld1ZriBTRLGukEjITkpiJdaO 8DxOlYWJgxtRFzQurYRXWLuHFe7bfyNWG6Utfmrz9B1SHosSXQljXTOadSXWkHZBaLwEXlKC2Ng sVnbGZK2B0q6PyRn98sXNQR30ZuabhYaHW9RIv/D3uYMxd01bdDMa/OS9k9gWPK/53RnQ7FXUHY lz+7vydSv1u9wBe+HVS0GixpdR65bOQiEknMHoEgCPGiZqtI8CKpn/iCVxz8KBVvFbsUM5XnDEj LKFGJ49zTdKYcHA6ApxUVxpAT4EFyOVk+FPzL10dwfgSciXneXccelkX/ubBPIi6bm6Wq5oI5IE vkmJtD1UVeRhm40I8HtbigP+IJHx8MyvfwOitdZacDbE73ZSmuWmaqaW5SP8eQfu6iwSfsb7Ah9 7+dVMHE0AQvp+oKYZ3uaNcnu0yTd3WlHgjh+h0h/RMTVV2425wE50C6MzyIrq9Rw9qmVpg56GdZ xUF9VkPZL5UZCKGfuKCwA5lSqrnHPqim4ABQknCO70QAsBdCV9/n5IZng2TmTInKzpSFSYZzi8n 5csaz3HbmaxD3kak7pHnzpyV/bnHxC4bPmCOyalRqQPhHMT66hgVvSdGKo9TSDdVx8njucb0X5x eTKWKng751ZztrlZbybMtrsqDzG86R6Zxt6qaeAiCmPx4NwBnUJ0Ek6yhjxEHRux+uk8jpP8tMO yYmaA== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--13.911400-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556562-yLOcrAl0dQj4 Subject: [dpdk-dev] [PATCH 02/14] net/sfc: introduce common driver library 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" Move libefx (base driver) into common driver. Prepare to add vDPA driver which will use the common driver as well. Signed-off-by: Andrew Rybchenko --- MAINTAINERS | 1 + drivers/common/Makefile | 4 + drivers/common/meson.build | 2 +- drivers/common/sfc_efx/Makefile | 111 ++++++++++++++++ .../{net/sfc => common/sfc_efx}/base/README | 0 .../sfc => common/sfc_efx}/base/ef10_ev.c | 0 .../sfc => common/sfc_efx}/base/ef10_evb.c | 0 .../sfc => common/sfc_efx}/base/ef10_filter.c | 0 .../sfc_efx}/base/ef10_firmware_ids.h | 0 .../sfc => common/sfc_efx}/base/ef10_image.c | 0 .../sfc => common/sfc_efx}/base/ef10_impl.h | 0 .../sfc => common/sfc_efx}/base/ef10_intr.c | 0 .../sfc => common/sfc_efx}/base/ef10_mac.c | 0 .../sfc => common/sfc_efx}/base/ef10_mcdi.c | 0 .../sfc => common/sfc_efx}/base/ef10_nic.c | 0 .../sfc => common/sfc_efx}/base/ef10_nvram.c | 0 .../sfc => common/sfc_efx}/base/ef10_phy.c | 0 .../sfc => common/sfc_efx}/base/ef10_proxy.c | 0 .../sfc => common/sfc_efx}/base/ef10_rx.c | 0 .../sfc_efx}/base/ef10_signed_image_layout.h | 0 .../sfc_efx}/base/ef10_tlv_layout.h | 0 .../sfc => common/sfc_efx}/base/ef10_tx.c | 0 .../sfc => common/sfc_efx}/base/ef10_vpd.c | 0 .../{net/sfc => common/sfc_efx}/base/efx.h | 0 .../sfc => common/sfc_efx}/base/efx_annote.h | 0 .../sfc => common/sfc_efx}/base/efx_bootcfg.c | 0 .../sfc => common/sfc_efx}/base/efx_check.h | 0 .../sfc => common/sfc_efx}/base/efx_crc32.c | 0 .../{net/sfc => common/sfc_efx}/base/efx_ev.c | 0 .../sfc => common/sfc_efx}/base/efx_evb.c | 0 .../sfc => common/sfc_efx}/base/efx_filter.c | 0 .../sfc => common/sfc_efx}/base/efx_hash.c | 0 .../sfc => common/sfc_efx}/base/efx_impl.h | 0 .../sfc => common/sfc_efx}/base/efx_intr.c | 0 .../sfc => common/sfc_efx}/base/efx_lic.c | 0 .../sfc => common/sfc_efx}/base/efx_mac.c | 0 .../sfc => common/sfc_efx}/base/efx_mcdi.c | 0 .../sfc => common/sfc_efx}/base/efx_mcdi.h | 0 .../sfc => common/sfc_efx}/base/efx_mon.c | 0 .../sfc => common/sfc_efx}/base/efx_nic.c | 0 .../sfc => common/sfc_efx}/base/efx_nvram.c | 0 .../sfc => common/sfc_efx}/base/efx_phy.c | 0 .../sfc => common/sfc_efx}/base/efx_phy_ids.h | 0 .../sfc => common/sfc_efx}/base/efx_port.c | 0 .../sfc => common/sfc_efx}/base/efx_proxy.c | 0 .../sfc => common/sfc_efx}/base/efx_regs.h | 0 .../sfc_efx}/base/efx_regs_ef10.h | 0 .../sfc_efx}/base/efx_regs_mcdi.h | 0 .../sfc_efx}/base/efx_regs_mcdi_aoe.h | 0 .../sfc_efx}/base/efx_regs_mcdi_strs.h | 0 .../sfc_efx}/base/efx_regs_pci.h | 0 .../{net/sfc => common/sfc_efx}/base/efx_rx.c | 0 .../sfc => common/sfc_efx}/base/efx_sram.c | 0 .../sfc => common/sfc_efx}/base/efx_tunnel.c | 0 .../{net/sfc => common/sfc_efx}/base/efx_tx.c | 0 .../sfc => common/sfc_efx}/base/efx_types.h | 0 .../sfc => common/sfc_efx}/base/efx_vpd.c | 0 .../sfc => common/sfc_efx}/base/hunt_impl.h | 0 .../sfc => common/sfc_efx}/base/hunt_nic.c | 0 .../sfc => common/sfc_efx}/base/mcdi_mon.c | 0 .../sfc => common/sfc_efx}/base/mcdi_mon.h | 0 .../sfc_efx}/base/medford2_impl.h | 0 .../sfc_efx}/base/medford2_nic.c | 0 .../sfc_efx}/base/medford_impl.h | 0 .../sfc => common/sfc_efx}/base/medford_nic.c | 0 .../sfc => common/sfc_efx}/base/meson.build | 0 .../sfc => common/sfc_efx}/base/siena_flash.h | 0 .../sfc => common/sfc_efx}/base/siena_impl.h | 0 .../sfc => common/sfc_efx}/base/siena_mac.c | 0 .../sfc => common/sfc_efx}/base/siena_mcdi.c | 0 .../sfc => common/sfc_efx}/base/siena_nic.c | 0 .../sfc => common/sfc_efx}/base/siena_nvram.c | 0 .../sfc => common/sfc_efx}/base/siena_phy.c | 0 .../sfc => common/sfc_efx}/base/siena_sram.c | 0 .../sfc => common/sfc_efx}/base/siena_vpd.c | 0 drivers/{net/sfc => common/sfc_efx}/efsys.h | 58 ++++----- drivers/common/sfc_efx/meson.build | 39 ++++++ .../sfc_efx/rte_common_sfc_efx_version.map | 122 ++++++++++++++++++ drivers/common/sfc_efx/sfc_efx.c | 23 ++++ drivers/common/sfc_efx/sfc_efx_debug.h | 29 +++++ drivers/common/sfc_efx/sfc_efx_log.h | 22 ++++ drivers/net/sfc/Makefile | 70 +--------- drivers/net/sfc/meson.build | 6 +- mk/rte.app.mk | 1 + 84 files changed, 386 insertions(+), 102 deletions(-) create mode 100644 drivers/common/sfc_efx/Makefile rename drivers/{net/sfc => common/sfc_efx}/base/README (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_ev.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_evb.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_filter.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_firmware_ids.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_image.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_intr.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mac.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_mcdi.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_nvram.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_phy.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_proxy.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_rx.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_signed_image_layout.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tlv_layout.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_tx.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/ef10_vpd.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_annote.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_bootcfg.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_check.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_crc32.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_ev.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_evb.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_filter.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_hash.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_intr.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_lic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_mac.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_mcdi.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_mon.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_nvram.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_phy_ids.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_port.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_proxy.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_ef10.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_aoe.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_mcdi_strs.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_regs_pci.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_rx.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_sram.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_tunnel.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_tx.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_types.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/efx_vpd.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/hunt_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/hunt_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/mcdi_mon.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/medford2_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/medford2_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/medford_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/medford_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/meson.build (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_flash.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_impl.h (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_mac.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_mcdi.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_nic.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_nvram.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_phy.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_sram.c (100%) rename drivers/{net/sfc => common/sfc_efx}/base/siena_vpd.c (100%) rename drivers/{net/sfc => common/sfc_efx}/efsys.h (93%) create mode 100644 drivers/common/sfc_efx/meson.build create mode 100644 drivers/common/sfc_efx/rte_common_sfc_efx_version.map create mode 100644 drivers/common/sfc_efx/sfc_efx.c create mode 100644 drivers/common/sfc_efx/sfc_efx_debug.h create mode 100644 drivers/common/sfc_efx/sfc_efx_log.h diff --git a/MAINTAINERS b/MAINTAINERS index ed163f5d59..ee20e261d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -872,6 +872,7 @@ F: doc/guides/nics/features/qede*.ini Solarflare sfc_efx M: Andrew Rybchenko +F: drivers/common/sfc_efx/ F: drivers/net/sfc/ F: doc/guides/nics/sfc_efx.rst F: doc/guides/nics/features/sfc_efx.ini diff --git a/drivers/common/Makefile b/drivers/common/Makefile index cfb6b4dc88..378ab4281c 100644 --- a/drivers/common/Makefile +++ b/drivers/common/Makefile @@ -36,4 +36,8 @@ ifneq (,$(findstring y,$(IAVF-y))) DIRS-y += iavf endif +ifeq ($(findstring y,$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)),y) +DIRS-y += sfc_efx +endif + include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/common/meson.build b/drivers/common/meson.build index 9ed4c04ba5..7ac1ca73a2 100644 --- a/drivers/common/meson.build +++ b/drivers/common/meson.build @@ -6,6 +6,6 @@ if is_windows endif std_deps = ['eal'] -drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat'] +drivers = ['cpt', 'dpaax', 'iavf', 'mvep', 'octeontx', 'octeontx2', 'qat', 'sfc_efx'] config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON' driver_name_fmt = 'rte_common_@0@' diff --git a/drivers/common/sfc_efx/Makefile b/drivers/common/sfc_efx/Makefile new file mode 100644 index 0000000000..0bd6a593e9 --- /dev/null +++ b/drivers/common/sfc_efx/Makefile @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright(c) 2019-2020 Xilinx, Inc. +# +# This software was jointly developed between OKTET Labs (under contract +# for Solarflare) and Solarflare Communications, Inc. + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_common_sfc_efx.a + +CFLAGS += -I$(SRCDIR)/base/ +CFLAGS += -I$(SRCDIR) +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +# Enable extra warnings +CFLAGS += -Wextra + +# More warnings not enabled by above aggregators +CFLAGS += -Wdisabled-optimization + +# Extra CFLAGS for base driver files +CFLAGS_BASE_DRIVER += -Wno-sign-compare +CFLAGS_BASE_DRIVER += -Wno-unused-parameter +CFLAGS_BASE_DRIVER += -Wno-unused-variable + +# Compiler and version dependent flags +ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) +CFLAGS += -Waggregate-return +CFLAGS += -Wnested-externs +CFLAGS_BASE_DRIVER += -Wno-empty-body +CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable +else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y) +CFLAGS += -Waggregate-return +CFLAGS += -Wbad-function-cast +CFLAGS_BASE_DRIVER += -Wno-empty-body +else ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y) +CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable +endif +LDLIBS += -lrte_eal + +# +# List of base driver object files for which +# special CFLAGS above should be applied +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) +$(foreach obj, $(BASE_DRIVER_OBJS), \ + $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER))) + +EXPORT_MAP := rte_common_sfc_efx_version.map + +# +# all source are stored in SRCS-y +# + +SRCS-y += sfc_efx.c + +VPATH += $(SRCDIR)/base + +SRCS-y += efx_bootcfg.c +SRCS-y += efx_crc32.c +SRCS-y += efx_ev.c +SRCS-y += efx_evb.c +SRCS-y += efx_filter.c +SRCS-y += efx_hash.c +SRCS-y += efx_intr.c +SRCS-y += efx_lic.c +SRCS-y += efx_mac.c +SRCS-y += efx_mcdi.c +SRCS-y += efx_mon.c +SRCS-y += efx_nic.c +SRCS-y += efx_nvram.c +SRCS-y += efx_phy.c +SRCS-y += efx_port.c +SRCS-y += efx_proxy.c +SRCS-y += efx_rx.c +SRCS-y += efx_sram.c +SRCS-y += efx_tunnel.c +SRCS-y += efx_tx.c +SRCS-y += efx_vpd.c +SRCS-y += mcdi_mon.c +SRCS-y += siena_mac.c +SRCS-y += siena_mcdi.c +SRCS-y += siena_nic.c +SRCS-y += siena_nvram.c +SRCS-y += siena_phy.c +SRCS-y += siena_sram.c +SRCS-y += siena_vpd.c +SRCS-y += ef10_ev.c +SRCS-y += ef10_evb.c +SRCS-y += ef10_filter.c +SRCS-y += ef10_intr.c +SRCS-y += ef10_image.c +SRCS-y += ef10_mac.c +SRCS-y += ef10_mcdi.c +SRCS-y += ef10_nic.c +SRCS-y += ef10_nvram.c +SRCS-y += ef10_phy.c +SRCS-y += ef10_proxy.c +SRCS-y += ef10_rx.c +SRCS-y += ef10_tx.c +SRCS-y += ef10_vpd.c +SRCS-y += hunt_nic.c +SRCS-y += medford_nic.c +SRCS-y += medford2_nic.c + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/sfc/base/README b/drivers/common/sfc_efx/base/README similarity index 100% rename from drivers/net/sfc/base/README rename to drivers/common/sfc_efx/base/README diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/common/sfc_efx/base/ef10_ev.c similarity index 100% rename from drivers/net/sfc/base/ef10_ev.c rename to drivers/common/sfc_efx/base/ef10_ev.c diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/common/sfc_efx/base/ef10_evb.c similarity index 100% rename from drivers/net/sfc/base/ef10_evb.c rename to drivers/common/sfc_efx/base/ef10_evb.c diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c similarity index 100% rename from drivers/net/sfc/base/ef10_filter.c rename to drivers/common/sfc_efx/base/ef10_filter.c diff --git a/drivers/net/sfc/base/ef10_firmware_ids.h b/drivers/common/sfc_efx/base/ef10_firmware_ids.h similarity index 100% rename from drivers/net/sfc/base/ef10_firmware_ids.h rename to drivers/common/sfc_efx/base/ef10_firmware_ids.h diff --git a/drivers/net/sfc/base/ef10_image.c b/drivers/common/sfc_efx/base/ef10_image.c similarity index 100% rename from drivers/net/sfc/base/ef10_image.c rename to drivers/common/sfc_efx/base/ef10_image.c diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h similarity index 100% rename from drivers/net/sfc/base/ef10_impl.h rename to drivers/common/sfc_efx/base/ef10_impl.h diff --git a/drivers/net/sfc/base/ef10_intr.c b/drivers/common/sfc_efx/base/ef10_intr.c similarity index 100% rename from drivers/net/sfc/base/ef10_intr.c rename to drivers/common/sfc_efx/base/ef10_intr.c diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/common/sfc_efx/base/ef10_mac.c similarity index 100% rename from drivers/net/sfc/base/ef10_mac.c rename to drivers/common/sfc_efx/base/ef10_mac.c diff --git a/drivers/net/sfc/base/ef10_mcdi.c b/drivers/common/sfc_efx/base/ef10_mcdi.c similarity index 100% rename from drivers/net/sfc/base/ef10_mcdi.c rename to drivers/common/sfc_efx/base/ef10_mcdi.c diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c similarity index 100% rename from drivers/net/sfc/base/ef10_nic.c rename to drivers/common/sfc_efx/base/ef10_nic.c diff --git a/drivers/net/sfc/base/ef10_nvram.c b/drivers/common/sfc_efx/base/ef10_nvram.c similarity index 100% rename from drivers/net/sfc/base/ef10_nvram.c rename to drivers/common/sfc_efx/base/ef10_nvram.c diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/common/sfc_efx/base/ef10_phy.c similarity index 100% rename from drivers/net/sfc/base/ef10_phy.c rename to drivers/common/sfc_efx/base/ef10_phy.c diff --git a/drivers/net/sfc/base/ef10_proxy.c b/drivers/common/sfc_efx/base/ef10_proxy.c similarity index 100% rename from drivers/net/sfc/base/ef10_proxy.c rename to drivers/common/sfc_efx/base/ef10_proxy.c diff --git a/drivers/net/sfc/base/ef10_rx.c b/drivers/common/sfc_efx/base/ef10_rx.c similarity index 100% rename from drivers/net/sfc/base/ef10_rx.c rename to drivers/common/sfc_efx/base/ef10_rx.c diff --git a/drivers/net/sfc/base/ef10_signed_image_layout.h b/drivers/common/sfc_efx/base/ef10_signed_image_layout.h similarity index 100% rename from drivers/net/sfc/base/ef10_signed_image_layout.h rename to drivers/common/sfc_efx/base/ef10_signed_image_layout.h diff --git a/drivers/net/sfc/base/ef10_tlv_layout.h b/drivers/common/sfc_efx/base/ef10_tlv_layout.h similarity index 100% rename from drivers/net/sfc/base/ef10_tlv_layout.h rename to drivers/common/sfc_efx/base/ef10_tlv_layout.h diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/common/sfc_efx/base/ef10_tx.c similarity index 100% rename from drivers/net/sfc/base/ef10_tx.c rename to drivers/common/sfc_efx/base/ef10_tx.c diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/common/sfc_efx/base/ef10_vpd.c similarity index 100% rename from drivers/net/sfc/base/ef10_vpd.c rename to drivers/common/sfc_efx/base/ef10_vpd.c diff --git a/drivers/net/sfc/base/efx.h b/drivers/common/sfc_efx/base/efx.h similarity index 100% rename from drivers/net/sfc/base/efx.h rename to drivers/common/sfc_efx/base/efx.h diff --git a/drivers/net/sfc/base/efx_annote.h b/drivers/common/sfc_efx/base/efx_annote.h similarity index 100% rename from drivers/net/sfc/base/efx_annote.h rename to drivers/common/sfc_efx/base/efx_annote.h diff --git a/drivers/net/sfc/base/efx_bootcfg.c b/drivers/common/sfc_efx/base/efx_bootcfg.c similarity index 100% rename from drivers/net/sfc/base/efx_bootcfg.c rename to drivers/common/sfc_efx/base/efx_bootcfg.c diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/common/sfc_efx/base/efx_check.h similarity index 100% rename from drivers/net/sfc/base/efx_check.h rename to drivers/common/sfc_efx/base/efx_check.h diff --git a/drivers/net/sfc/base/efx_crc32.c b/drivers/common/sfc_efx/base/efx_crc32.c similarity index 100% rename from drivers/net/sfc/base/efx_crc32.c rename to drivers/common/sfc_efx/base/efx_crc32.c diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/common/sfc_efx/base/efx_ev.c similarity index 100% rename from drivers/net/sfc/base/efx_ev.c rename to drivers/common/sfc_efx/base/efx_ev.c diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/common/sfc_efx/base/efx_evb.c similarity index 100% rename from drivers/net/sfc/base/efx_evb.c rename to drivers/common/sfc_efx/base/efx_evb.c diff --git a/drivers/net/sfc/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c similarity index 100% rename from drivers/net/sfc/base/efx_filter.c rename to drivers/common/sfc_efx/base/efx_filter.c diff --git a/drivers/net/sfc/base/efx_hash.c b/drivers/common/sfc_efx/base/efx_hash.c similarity index 100% rename from drivers/net/sfc/base/efx_hash.c rename to drivers/common/sfc_efx/base/efx_hash.c diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h similarity index 100% rename from drivers/net/sfc/base/efx_impl.h rename to drivers/common/sfc_efx/base/efx_impl.h diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/common/sfc_efx/base/efx_intr.c similarity index 100% rename from drivers/net/sfc/base/efx_intr.c rename to drivers/common/sfc_efx/base/efx_intr.c diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/common/sfc_efx/base/efx_lic.c similarity index 100% rename from drivers/net/sfc/base/efx_lic.c rename to drivers/common/sfc_efx/base/efx_lic.c diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c similarity index 100% rename from drivers/net/sfc/base/efx_mac.c rename to drivers/common/sfc_efx/base/efx_mac.c diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c similarity index 100% rename from drivers/net/sfc/base/efx_mcdi.c rename to drivers/common/sfc_efx/base/efx_mcdi.c diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/common/sfc_efx/base/efx_mcdi.h similarity index 100% rename from drivers/net/sfc/base/efx_mcdi.h rename to drivers/common/sfc_efx/base/efx_mcdi.h diff --git a/drivers/net/sfc/base/efx_mon.c b/drivers/common/sfc_efx/base/efx_mon.c similarity index 100% rename from drivers/net/sfc/base/efx_mon.c rename to drivers/common/sfc_efx/base/efx_mon.c diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/common/sfc_efx/base/efx_nic.c similarity index 100% rename from drivers/net/sfc/base/efx_nic.c rename to drivers/common/sfc_efx/base/efx_nic.c diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/common/sfc_efx/base/efx_nvram.c similarity index 100% rename from drivers/net/sfc/base/efx_nvram.c rename to drivers/common/sfc_efx/base/efx_nvram.c diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/common/sfc_efx/base/efx_phy.c similarity index 100% rename from drivers/net/sfc/base/efx_phy.c rename to drivers/common/sfc_efx/base/efx_phy.c diff --git a/drivers/net/sfc/base/efx_phy_ids.h b/drivers/common/sfc_efx/base/efx_phy_ids.h similarity index 100% rename from drivers/net/sfc/base/efx_phy_ids.h rename to drivers/common/sfc_efx/base/efx_phy_ids.h diff --git a/drivers/net/sfc/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c similarity index 100% rename from drivers/net/sfc/base/efx_port.c rename to drivers/common/sfc_efx/base/efx_port.c diff --git a/drivers/net/sfc/base/efx_proxy.c b/drivers/common/sfc_efx/base/efx_proxy.c similarity index 100% rename from drivers/net/sfc/base/efx_proxy.c rename to drivers/common/sfc_efx/base/efx_proxy.c diff --git a/drivers/net/sfc/base/efx_regs.h b/drivers/common/sfc_efx/base/efx_regs.h similarity index 100% rename from drivers/net/sfc/base/efx_regs.h rename to drivers/common/sfc_efx/base/efx_regs.h diff --git a/drivers/net/sfc/base/efx_regs_ef10.h b/drivers/common/sfc_efx/base/efx_regs_ef10.h similarity index 100% rename from drivers/net/sfc/base/efx_regs_ef10.h rename to drivers/common/sfc_efx/base/efx_regs_ef10.h diff --git a/drivers/net/sfc/base/efx_regs_mcdi.h b/drivers/common/sfc_efx/base/efx_regs_mcdi.h similarity index 100% rename from drivers/net/sfc/base/efx_regs_mcdi.h rename to drivers/common/sfc_efx/base/efx_regs_mcdi.h diff --git a/drivers/net/sfc/base/efx_regs_mcdi_aoe.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h similarity index 100% rename from drivers/net/sfc/base/efx_regs_mcdi_aoe.h rename to drivers/common/sfc_efx/base/efx_regs_mcdi_aoe.h diff --git a/drivers/net/sfc/base/efx_regs_mcdi_strs.h b/drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h similarity index 100% rename from drivers/net/sfc/base/efx_regs_mcdi_strs.h rename to drivers/common/sfc_efx/base/efx_regs_mcdi_strs.h diff --git a/drivers/net/sfc/base/efx_regs_pci.h b/drivers/common/sfc_efx/base/efx_regs_pci.h similarity index 100% rename from drivers/net/sfc/base/efx_regs_pci.h rename to drivers/common/sfc_efx/base/efx_regs_pci.h diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c similarity index 100% rename from drivers/net/sfc/base/efx_rx.c rename to drivers/common/sfc_efx/base/efx_rx.c diff --git a/drivers/net/sfc/base/efx_sram.c b/drivers/common/sfc_efx/base/efx_sram.c similarity index 100% rename from drivers/net/sfc/base/efx_sram.c rename to drivers/common/sfc_efx/base/efx_sram.c diff --git a/drivers/net/sfc/base/efx_tunnel.c b/drivers/common/sfc_efx/base/efx_tunnel.c similarity index 100% rename from drivers/net/sfc/base/efx_tunnel.c rename to drivers/common/sfc_efx/base/efx_tunnel.c diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/common/sfc_efx/base/efx_tx.c similarity index 100% rename from drivers/net/sfc/base/efx_tx.c rename to drivers/common/sfc_efx/base/efx_tx.c diff --git a/drivers/net/sfc/base/efx_types.h b/drivers/common/sfc_efx/base/efx_types.h similarity index 100% rename from drivers/net/sfc/base/efx_types.h rename to drivers/common/sfc_efx/base/efx_types.h diff --git a/drivers/net/sfc/base/efx_vpd.c b/drivers/common/sfc_efx/base/efx_vpd.c similarity index 100% rename from drivers/net/sfc/base/efx_vpd.c rename to drivers/common/sfc_efx/base/efx_vpd.c diff --git a/drivers/net/sfc/base/hunt_impl.h b/drivers/common/sfc_efx/base/hunt_impl.h similarity index 100% rename from drivers/net/sfc/base/hunt_impl.h rename to drivers/common/sfc_efx/base/hunt_impl.h diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/common/sfc_efx/base/hunt_nic.c similarity index 100% rename from drivers/net/sfc/base/hunt_nic.c rename to drivers/common/sfc_efx/base/hunt_nic.c diff --git a/drivers/net/sfc/base/mcdi_mon.c b/drivers/common/sfc_efx/base/mcdi_mon.c similarity index 100% rename from drivers/net/sfc/base/mcdi_mon.c rename to drivers/common/sfc_efx/base/mcdi_mon.c diff --git a/drivers/net/sfc/base/mcdi_mon.h b/drivers/common/sfc_efx/base/mcdi_mon.h similarity index 100% rename from drivers/net/sfc/base/mcdi_mon.h rename to drivers/common/sfc_efx/base/mcdi_mon.h diff --git a/drivers/net/sfc/base/medford2_impl.h b/drivers/common/sfc_efx/base/medford2_impl.h similarity index 100% rename from drivers/net/sfc/base/medford2_impl.h rename to drivers/common/sfc_efx/base/medford2_impl.h diff --git a/drivers/net/sfc/base/medford2_nic.c b/drivers/common/sfc_efx/base/medford2_nic.c similarity index 100% rename from drivers/net/sfc/base/medford2_nic.c rename to drivers/common/sfc_efx/base/medford2_nic.c diff --git a/drivers/net/sfc/base/medford_impl.h b/drivers/common/sfc_efx/base/medford_impl.h similarity index 100% rename from drivers/net/sfc/base/medford_impl.h rename to drivers/common/sfc_efx/base/medford_impl.h diff --git a/drivers/net/sfc/base/medford_nic.c b/drivers/common/sfc_efx/base/medford_nic.c similarity index 100% rename from drivers/net/sfc/base/medford_nic.c rename to drivers/common/sfc_efx/base/medford_nic.c diff --git a/drivers/net/sfc/base/meson.build b/drivers/common/sfc_efx/base/meson.build similarity index 100% rename from drivers/net/sfc/base/meson.build rename to drivers/common/sfc_efx/base/meson.build diff --git a/drivers/net/sfc/base/siena_flash.h b/drivers/common/sfc_efx/base/siena_flash.h similarity index 100% rename from drivers/net/sfc/base/siena_flash.h rename to drivers/common/sfc_efx/base/siena_flash.h diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/common/sfc_efx/base/siena_impl.h similarity index 100% rename from drivers/net/sfc/base/siena_impl.h rename to drivers/common/sfc_efx/base/siena_impl.h diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/common/sfc_efx/base/siena_mac.c similarity index 100% rename from drivers/net/sfc/base/siena_mac.c rename to drivers/common/sfc_efx/base/siena_mac.c diff --git a/drivers/net/sfc/base/siena_mcdi.c b/drivers/common/sfc_efx/base/siena_mcdi.c similarity index 100% rename from drivers/net/sfc/base/siena_mcdi.c rename to drivers/common/sfc_efx/base/siena_mcdi.c diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c similarity index 100% rename from drivers/net/sfc/base/siena_nic.c rename to drivers/common/sfc_efx/base/siena_nic.c diff --git a/drivers/net/sfc/base/siena_nvram.c b/drivers/common/sfc_efx/base/siena_nvram.c similarity index 100% rename from drivers/net/sfc/base/siena_nvram.c rename to drivers/common/sfc_efx/base/siena_nvram.c diff --git a/drivers/net/sfc/base/siena_phy.c b/drivers/common/sfc_efx/base/siena_phy.c similarity index 100% rename from drivers/net/sfc/base/siena_phy.c rename to drivers/common/sfc_efx/base/siena_phy.c diff --git a/drivers/net/sfc/base/siena_sram.c b/drivers/common/sfc_efx/base/siena_sram.c similarity index 100% rename from drivers/net/sfc/base/siena_sram.c rename to drivers/common/sfc_efx/base/siena_sram.c diff --git a/drivers/net/sfc/base/siena_vpd.c b/drivers/common/sfc_efx/base/siena_vpd.c similarity index 100% rename from drivers/net/sfc/base/siena_vpd.c rename to drivers/common/sfc_efx/base/siena_vpd.c diff --git a/drivers/net/sfc/efsys.h b/drivers/common/sfc_efx/efsys.h similarity index 93% rename from drivers/net/sfc/efsys.h rename to drivers/common/sfc_efx/efsys.h index c94e6c0b93..657b45e05d 100644 --- a/drivers/net/sfc/efsys.h +++ b/drivers/common/sfc_efx/efsys.h @@ -25,8 +25,8 @@ #include #include -#include "sfc_debug.h" -#include "sfc_log.h" +#include "sfc_efx_debug.h" +#include "sfc_efx_log.h" #ifdef __cplusplus extern "C" { @@ -224,8 +224,8 @@ typedef struct efsys_mem_s { volatile uint32_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_dword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_dword_t))); \ \ _addr = (volatile uint32_t *)(_base + (_offset)); \ (_edp)->ed_u32[0] = _addr[0]; \ @@ -242,8 +242,8 @@ typedef struct efsys_mem_s { volatile uint64_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_qword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_qword_t))); \ \ _addr = (volatile uint64_t *)(_base + (_offset)); \ (_eqp)->eq_u64[0] = _addr[0]; \ @@ -261,8 +261,8 @@ typedef struct efsys_mem_s { volatile __m128i *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_oword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_oword_t))); \ \ _addr = (volatile __m128i *)(_base + (_offset)); \ (_eop)->eo_u128[0] = _addr[0]; \ @@ -283,8 +283,8 @@ typedef struct efsys_mem_s { volatile uint32_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_dword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_dword_t))); \ \ EFSYS_PROBE2(mem_writed, unsigned int, (_offset), \ uint32_t, (_edp)->ed_u32[0]); \ @@ -301,8 +301,8 @@ typedef struct efsys_mem_s { volatile uint64_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_qword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_qword_t))); \ \ EFSYS_PROBE3(mem_writeq, unsigned int, (_offset), \ uint32_t, (_eqp)->eq_u32[1], \ @@ -320,8 +320,8 @@ typedef struct efsys_mem_s { volatile __m128i *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_oword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_oword_t))); \ \ \ EFSYS_PROBE5(mem_writeo, unsigned int, (_offset), \ @@ -386,8 +386,8 @@ typedef struct efsys_bar_s { volatile uint32_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_dword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_dword_t))); \ _NOTE(CONSTANTCONDITION); \ if (_lock) \ SFC_BAR_LOCK(_esbp); \ @@ -411,8 +411,8 @@ typedef struct efsys_bar_s { volatile uint64_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_qword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_qword_t))); \ \ SFC_BAR_LOCK(_esbp); \ \ @@ -434,8 +434,8 @@ typedef struct efsys_bar_s { volatile __m128i *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_oword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_oword_t))); \ \ _NOTE(CONSTANTCONDITION); \ if (_lock) \ @@ -465,8 +465,8 @@ typedef struct efsys_bar_s { volatile uint32_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_dword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_dword_t))); \ \ _NOTE(CONSTANTCONDITION); \ if (_lock) \ @@ -491,8 +491,8 @@ typedef struct efsys_bar_s { volatile uint64_t *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_qword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_qword_t))); \ \ SFC_BAR_LOCK(_esbp); \ \ @@ -526,8 +526,8 @@ typedef struct efsys_bar_s { volatile __m128i *_addr; \ \ _NOTE(CONSTANTCONDITION); \ - SFC_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ - sizeof(efx_oword_t))); \ + SFC_EFX_ASSERT(EFX_IS_P2ALIGNED(size_t, _offset, \ + sizeof(efx_oword_t))); \ \ _NOTE(CONSTANTCONDITION); \ if (_lock) \ @@ -625,7 +625,7 @@ typedef rte_spinlock_t efsys_lock_t; #define SFC_EFSYS_UNLOCK(_eslp) \ rte_spinlock_unlock((_eslp)) #define SFC_EFSYS_LOCK_ASSERT_OWNED(_eslp) \ - SFC_ASSERT(rte_spinlock_is_locked((_eslp))) + SFC_EFX_ASSERT(rte_spinlock_is_locked((_eslp))) typedef int efsys_lock_state_t; @@ -640,7 +640,7 @@ typedef int efsys_lock_state_t; #define EFSYS_UNLOCK(_lockp, _state) \ do { \ - SFC_ASSERT((_state) == EFSYS_LOCK_MAGIC); \ + SFC_EFX_ASSERT((_state) == EFSYS_LOCK_MAGIC); \ SFC_EFSYS_UNLOCK(_lockp); \ _NOTE(CONSTANTCONDITION); \ } while (B_FALSE) @@ -697,7 +697,7 @@ typedef uint64_t efsys_stat_t; #define EFSYS_ERR(_esip, _code, _dword0, _dword1) \ do { \ (void)(_esip); \ - SFC_GENERIC_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)", \ + SFC_EFX_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)", \ (_code), (_dword0), (_dword1)); \ _NOTE(CONSTANTCONDITION); \ } while (B_FALSE) diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build new file mode 100644 index 0000000000..8fab4df792 --- /dev/null +++ b/drivers/common/sfc_efx/meson.build @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright(c) 2019-2020 Xilinx, Inc. +# +# This software was jointly developed between OKTET Labs (under contract +# for Solarflare) and Solarflare Communications, Inc. + +if arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on x86_64' +endif + +extra_flags = [] + +# Enable more warnings +extra_flags += [ + '-Wdisabled-optimization' +] + +# Compiler and version dependent flags +extra_flags += [ + '-Waggregate-return', + '-Wbad-function-cast' +] + +foreach flag: extra_flags + if cc.has_argument(flag) + cflags += flag + endif +endforeach + +subdir('base') +objs = [base_objs] + +sources = files( + 'sfc_efx.c', +) + +includes += include_directories('base') diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map new file mode 100644 index 0000000000..0c719e8250 --- /dev/null +++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map @@ -0,0 +1,122 @@ +DPDK_21 { + global: + + efx_ev_fini; + efx_ev_init; + efx_ev_qcreate; + efx_ev_qdestroy; + efx_ev_qpoll; + efx_ev_qprime; + + efx_evb_fini; + efx_evb_init; + efx_evb_vswitch_create; + efx_evb_vswitch_destroy; + efx_evq_size; + + efx_family; + + efx_filter_fini; + efx_filter_init; + efx_filter_insert; + efx_filter_remove; + efx_filter_supported_filters; + + efx_intr_disable; + efx_intr_enable; + efx_intr_fatal; + efx_intr_fini; + efx_intr_init; + efx_intr_status_line; + efx_intr_status_message; + + efx_mac_addr_set; + efx_mac_drain; + efx_mac_fcntl_get; + efx_mac_fcntl_set; + efx_mac_filter_default_rxq_clear; + efx_mac_filter_default_rxq_set; + efx_mac_filter_get_all_ucast_mcast; + efx_mac_filter_set; + efx_mac_multicast_list_set; + efx_mac_pdu_set; + efx_mac_stat_name; + efx_mac_stats_clear; + efx_mac_stats_get_mask; + efx_mac_stats_periodic; + efx_mac_stats_update; + efx_mac_stats_upload; + + efx_mcdi_fini; + efx_mcdi_get_proxy_handle; + efx_mcdi_init; + efx_mcdi_new_epoch; + efx_mcdi_request_abort; + efx_mcdi_request_poll; + efx_mcdi_request_start; + + efx_nic_cfg_get; + efx_nic_create; + efx_nic_destroy; + efx_nic_fini; + efx_nic_get_fw_subvariant; + efx_nic_get_fw_version; + efx_nic_get_vi_pool; + efx_nic_init; + efx_nic_probe; + efx_nic_reset; + efx_nic_set_drv_limits; + efx_nic_set_fw_subvariant; + efx_nic_unprobe; + + efx_phy_adv_cap_get; + efx_phy_adv_cap_set; + + efx_port_fini; + efx_port_init; + efx_port_loopback_set; + efx_port_poll; + + efx_pseudo_hdr_hash_get; + efx_pseudo_hdr_pkt_length_get; + + efx_rx_fini; + efx_rx_hash_default_support_get; + efx_rx_init; + efx_rx_qcreate; + efx_rx_qcreate_es_super_buffer; + efx_rx_qdestroy; + efx_rx_qenable; + efx_rx_qflush; + efx_rx_qpost; + efx_rx_qpush; + efx_rx_scale_context_alloc; + efx_rx_scale_context_free; + efx_rx_scale_default_support_get; + efx_rx_scale_hash_flags_get; + efx_rx_scale_key_set; + efx_rx_scale_mode_set; + efx_rx_scale_tbl_set; + efx_rxq_size; + + efx_tunnel_config_udp_add; + efx_tunnel_config_udp_remove; + efx_tunnel_fini; + efx_tunnel_init; + efx_tunnel_reconfigure; + + efx_tx_fini; + efx_tx_init; + efx_tx_qcreate; + efx_tx_qdesc_dma_create; + efx_tx_qdesc_post; + efx_tx_qdesc_tso2_create; + efx_tx_qdesc_vlantci_create; + efx_tx_qdestroy; + efx_tx_qenable; + efx_tx_qflush; + efx_tx_qpush; + efx_txq_size; + + local: *; +}; diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c new file mode 100644 index 0000000000..0b8d5efee9 --- /dev/null +++ b/drivers/common/sfc_efx/sfc_efx.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#include + +#include "sfc_efx_log.h" + +uint32_t sfc_efx_logtype; + +RTE_INIT(sfc_efx_register_logtype) +{ + int ret; + + ret = rte_log_register_type_and_pick_level("pmd.common.sfc_efx", + RTE_LOG_NOTICE); + sfc_efx_logtype = (ret < 0) ? RTE_LOGTYPE_PMD : ret; +} diff --git a/drivers/common/sfc_efx/sfc_efx_debug.h b/drivers/common/sfc_efx/sfc_efx_debug.h new file mode 100644 index 0000000000..e0bdeeb5a4 --- /dev/null +++ b/drivers/common/sfc_efx/sfc_efx_debug.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#ifndef _SFC_EFX_DEBUG_H_ +#define _SFC_EFX_DEBUG_H_ + +#include + +#ifndef RTE_DEBUG_COMMON_SFC_EFX +#define RTE_DEBUG_COMMON_SFC_EFX 0 +#endif + +#ifdef RTE_DEBUG_COMMON_SFC_EFX +/* Avoid dependency from RTE_LOG_DP_LEVEL to be able to enable debug check + * in the driver only. + */ +#define SFC_EFX_ASSERT(exp) RTE_VERIFY(exp) +#else +/* If the driver debug is not enabled, follow DPDK debug/non-debug */ +#define SFC_EFX_ASSERT(exp) RTE_ASSERT(exp) +#endif + +#endif /* _SFC_EFX_DEBUG_H_ */ diff --git a/drivers/common/sfc_efx/sfc_efx_log.h b/drivers/common/sfc_efx/sfc_efx_log.h new file mode 100644 index 0000000000..f4417ffc30 --- /dev/null +++ b/drivers/common/sfc_efx/sfc_efx_log.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#ifndef _SFC_EFX_LOG_H_ +#define _SFC_EFX_LOG_H_ + +/** Generic driver log type */ +extern uint32_t sfc_efx_logtype; + +/** Log message, add a prefix and a line break */ +#define SFC_EFX_LOG(level, ...) \ + rte_log(RTE_LOG_ ## level, sfc_efx_logtype, \ + RTE_FMT("sfc_efx: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + RTE_FMT_TAIL(__VA_ARGS__ ,))) + +#endif /* _SFC_EFX_LOG_H_ */ diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index 20bf343814..648527f4b8 100644 --- a/drivers/net/sfc/Makefile +++ b/drivers/net/sfc/Makefile @@ -13,7 +13,8 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_sfc_efx.a -CFLAGS += -I$(SRCDIR)/base/ +CFLAGS += -I$(RTE_SDK)/drivers/common/sfc_efx/base +CFLAGS += -I$(RTE_SDK)/drivers/common/sfc_efx CFLAGS += -I$(SRCDIR) CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) @@ -26,39 +27,23 @@ CFLAGS += -Wextra # More warnings not enabled by above aggregators CFLAGS += -Wdisabled-optimization -# Extra CFLAGS for base driver files -CFLAGS_BASE_DRIVER += -Wno-sign-compare -CFLAGS_BASE_DRIVER += -Wno-unused-parameter -CFLAGS_BASE_DRIVER += -Wno-unused-variable - # Compiler and version dependent flags ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) CFLAGS += -Waggregate-return CFLAGS += -Wnested-externs -CFLAGS_BASE_DRIVER += -Wno-empty-body -CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y) CFLAGS += -Waggregate-return CFLAGS += -Wbad-function-cast -CFLAGS_BASE_DRIVER += -Wno-empty-body else ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y) -CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable # Suppress ICC false positive warning on 'bulk' may be used before its # value is set CFLAGS_sfc_ef10_tx.o += -diag-disable 3656 endif +LDLIBS += -lrte_common_sfc_efx LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs LDLIBS += -lrte_bus_pci -lrte_pci -# -# List of base driver object files for which -# special CFLAGS above should be applied -# -BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) -$(foreach obj, $(BASE_DRIVER_OBJS), \ - $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER))) - EXPORT_MAP := rte_pmd_sfc_version.map # @@ -81,53 +66,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_rx.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_essb_rx.c SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ef10_tx.c -VPATH += $(SRCDIR)/base - -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_bootcfg.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_crc32.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_ev.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_evb.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_filter.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_hash.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_intr.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_lic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mac.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mcdi.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mon.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nvram.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_phy.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_port.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_proxy.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_rx.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_sram.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_tunnel.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_tx.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_vpd.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += mcdi_mon.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mac.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mcdi.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nvram.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_phy.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_sram.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_vpd.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_ev.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_evb.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_filter.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_intr.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_image.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mac.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mcdi.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nvram.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_phy.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_proxy.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_rx.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_tx.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_vpd.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += hunt_nic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford_nic.c -SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford2_nic.c - include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build index 35c05ac1dd..26f0323738 100644 --- a/drivers/net/sfc/meson.build +++ b/drivers/net/sfc/meson.build @@ -33,9 +33,7 @@ foreach flag: extra_flags endif endforeach -subdir('base') -objs = [base_objs] - +deps += ['common_sfc_efx'] sources = files( 'sfc_ethdev.c', 'sfc_kvargs.c', @@ -54,5 +52,3 @@ sources = files( 'sfc_ef10_essb_rx.c', 'sfc_ef10_tx.c' ) - -includes += include_directories('base') diff --git a/mk/rte.app.mk b/mk/rte.app.mk index a544259970..d3c165f720 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -234,6 +234,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += -lrte_pmd_softnic endif _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += -lrte_pmd_sfc_efx +_LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += -lrte_common_sfc_efx _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += -lrte_pmd_szedata2 -lsze2 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFB_PMD) += -lrte_pmd_nfb _LDLIBS-$(CONFIG_RTE_LIBRTE_NFB_PMD) += $(shell command -v pkg-config > /dev/null 2>&1 && pkg-config --libs netcope-common) From patchwork Tue Sep 8 09:14:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76894 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2BE5A04AA; Tue, 8 Sep 2020 11:17:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6A3AD1C0DB; Tue, 8 Sep 2020 11:16:05 +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 38D511C0DB for ; Tue, 8 Sep 2020 11:16:03 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id CFCFA2007A for ; Tue, 8 Sep 2020 09:16:02 +0000 (UTC) Received: from us4-mdac16-49.at1.mdlocal (unknown [10.110.50.132]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 53AB6800E8 for ; Tue, 8 Sep 2020 09:16:02 +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 1AB2B40088 for ; Tue, 8 Sep 2020 09:14:54 +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 D79EB40070 for ; Tue, 8 Sep 2020 09:14:53 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnJR032410 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 4F6E41613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:24 +0100 Message-ID: <1599556475-27820-5-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-3.301400-8.000000-10 X-TMASE-MatchedRID: mukClXrIO7yl+yWhjYUl7aiUivh0j2PvaeMaKzvXUpkGmHr1eMxt2YB5 w6KBECW1rdoLblq9S5oAhGIvsKa9H6qrJ2yPRGzpRaPXfvn+keqkdO7TbvbzY7qE5Z6/nd2c0/e OwruG1unXTKZZmtmwut4PjuOlRMxlS62nMBX/dwP4KPASpfWnuVsP0tBwe3qDkY8eITaSJPhnml iDOiSLQ/GrOL7GbikWgePt/FBezHC8gVUkX0SvF854hX4xV6jOfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtHtexZ1+/9PmlF4DxSfZVrRpfT1NXwKroGus3x7d8v+9Po3Kbq748ZmwoV7uXtxn/NffI vuoK0copYoYq9+gIB0gFvgko9aNFhQAl75DFpaYAA9BapWXaJtG+KyfdrZrRf3e2vVbH8zBmH8z Zfront8C+ksT6a9fy X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.301400-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556562-8CnD5YJR2mdX Subject: [dpdk-dev] [PATCH 03/14] net/sfc: add dedicated header file with MCDI interface 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" MCDI helpers will be shared by net and vDPA drivers. Prepare to move it to common/sfc_efx. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 23 +--------------- drivers/net/sfc/sfc_mcdi.c | 1 + drivers/net/sfc/sfc_mcdi.h | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 drivers/net/sfc/sfc_mcdi.h diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index cdff9be3ec..a530b12a8e 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -23,6 +23,7 @@ #include "sfc_debug.h" #include "sfc_filter.h" +#include "sfc_mcdi.h" #ifdef __cplusplus extern "C" { @@ -86,25 +87,6 @@ enum sfc_dev_filter_mode { SFC_DEV_FILTER_NMODES }; -enum sfc_mcdi_state { - SFC_MCDI_UNINITIALIZED = 0, - SFC_MCDI_INITIALIZED, - SFC_MCDI_BUSY, - SFC_MCDI_COMPLETED, - - SFC_MCDI_NSTATES -}; - -struct sfc_mcdi { - rte_spinlock_t lock; - efsys_mem_t mem; - enum sfc_mcdi_state state; - efx_mcdi_transport_t transport; - uint32_t logtype; - uint32_t proxy_handle; - efx_rc_t proxy_result; -}; - struct sfc_intr { efx_intr_type_t type; rte_intr_callback_fn handler; @@ -384,9 +366,6 @@ void sfc_stop(struct sfc_adapter *sa); void sfc_schedule_restart(struct sfc_adapter *sa); -int sfc_mcdi_init(struct sfc_adapter *sa); -void sfc_mcdi_fini(struct sfc_adapter *sa); - int sfc_configure(struct sfc_adapter *sa); void sfc_close(struct sfc_adapter *sa); diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index ec62ba95ff..9a51b3e030 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -13,6 +13,7 @@ #include "efx_mcdi.h" #include "efx_regs_mcdi.h" +#include "sfc_mcdi.h" #include "sfc.h" #include "sfc_debug.h" #include "sfc_log.h" diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h new file mode 100644 index 0000000000..789a16d8bb --- /dev/null +++ b/drivers/net/sfc/sfc_mcdi.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2016-2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#ifndef _SFC_MCDI_H +#define _SFC_MCDI_H + +#include + +#include + +#include "efsys.h" +#include "efx.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +enum sfc_mcdi_state { + SFC_MCDI_UNINITIALIZED = 0, + SFC_MCDI_INITIALIZED, + SFC_MCDI_BUSY, + SFC_MCDI_COMPLETED, + + SFC_MCDI_NSTATES +}; + +struct sfc_mcdi { + rte_spinlock_t lock; + efsys_mem_t mem; + enum sfc_mcdi_state state; + efx_mcdi_transport_t transport; + uint32_t logtype; + uint32_t proxy_handle; + efx_rc_t proxy_result; +}; + + +struct sfc_adapter; + +int sfc_mcdi_init(struct sfc_adapter *sa); +void sfc_mcdi_fini(struct sfc_adapter *sa); + +#ifdef __cplusplus +} +#endif + +#endif /* _SFC_MCDI_H */ From patchwork Tue Sep 8 09:14:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76888 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 180ADA04AA; Tue, 8 Sep 2020 11:16:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 10BD31C116; Tue, 8 Sep 2020 11:15:50 +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 C810D1C10A for ; Tue, 8 Sep 2020 11:15:48 +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 C77D1200B7 for ; Tue, 8 Sep 2020 09:15:47 +0000 (UTC) Received: from us4-mdac16-63.at1.mdlocal (unknown [10.110.50.156]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 6BC31800B7 for ; Tue, 8 Sep 2020 09:15:47 +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 CB590100109 for ; Tue, 8 Sep 2020 09:14:54 +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 7F6784005E for ; Tue, 8 Sep 2020 09:14:54 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnRC032413 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 5B3541613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:25 +0100 Message-ID: <1599556475-27820-6-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-7.242100-8.000000-10 X-TMASE-MatchedRID: j2pOm8rChFuy9Uh/U28aL8mR5yDJkPg4SWg+u4ir2NOx6d2WO4Kt3eZ5 Gn23AeDZ8XVI39JCRnRuL3ESIrARlyHhSBQfglfsA9lly13c/gGVKmGUZ/Wnkf3ZlZEIBuK0ZSg PkksZfMCp5lIcUsiQ21CTGkEP+yMkT7Z+FYI5UyHknMSTG9lH+J7B58V0nMeKqPGqHIPGZiPSJJ cbp1Y+Wyv4WWlvjvWfYVCjcmRetW6Zka9ZOnvpYBcr91Fo5aW9GKyJtpoUCGYcCkgotCl7hM1qk z3j5LNsoPnutf4cqxVm1hdnVK4ua+BheOk5tfVp2Hlwa3CYC+T54F/2i/DwjQpCjqVELlwVgNs3 amZ3AUPVy1G1jO4I4qVV+UYNOXSTQ9tg+p38ZomeAiCmPx4NwBnUJ0Ek6yhjxEHRux+uk8jHUU+ U0ACZwDE63HM+4BUVvn9bsecRAaJAgzJhU+Pa36MxiyOOeSw4nqg/VrSZEiM= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.242100-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556547-l3Ic-bv_L6L4 Subject: [dpdk-dev] [PATCH 04/14] net/sfc: move MCDI helper interface to dedicated namespace 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" MCDI helpers will be moved to common/sfc_efx and it is better to do dummy renamings first before non-trivial changes. Existing functionality should be split into common and network driver specific parts. Prepare to do it. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 5 +- drivers/net/sfc/sfc_mcdi.c | 108 +++++++++++++++++++++---------------- drivers/net/sfc/sfc_mcdi.h | 22 +++----- 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index a530b12a8e..b3ac752334 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -220,7 +220,7 @@ struct sfc_adapter { rte_spinlock_t nic_lock; rte_atomic32_t restart_required; - struct sfc_mcdi mcdi; + struct sfc_efx_mcdi mcdi; struct sfc_intr intr; struct sfc_port port; struct sfc_filter filter; @@ -366,6 +366,9 @@ void sfc_stop(struct sfc_adapter *sa); void sfc_schedule_restart(struct sfc_adapter *sa); +int sfc_mcdi_init(struct sfc_adapter *sa); +void sfc_mcdi_fini(struct sfc_adapter *sa); + int sfc_configure(struct sfc_adapter *sa); void sfc_close(struct sfc_adapter *sa); diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 9a51b3e030..c97a33d558 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -19,12 +19,12 @@ #include "sfc_log.h" #include "sfc_ev.h" -#define SFC_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us in 1us units */ -#define SFC_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms in 1us units */ -#define SFC_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s in 1us units */ +#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us */ +#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms */ +#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s */ static void -sfc_mcdi_timeout(struct sfc_adapter *sa) +sfc_efx_mcdi_timeout(struct sfc_adapter *sa) { sfc_warn(sa, "MC TIMEOUT"); @@ -32,9 +32,9 @@ sfc_mcdi_timeout(struct sfc_adapter *sa) } static inline boolean_t -sfc_mcdi_proxy_event_available(struct sfc_adapter *sa) +sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa) { - struct sfc_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = &sa->mcdi; mcdi->proxy_handle = 0; mcdi->proxy_result = ETIMEDOUT; @@ -46,7 +46,7 @@ sfc_mcdi_proxy_event_available(struct sfc_adapter *sa) } static void -sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) +sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) { efx_nic_t *enp; unsigned int delay_total; @@ -54,22 +54,22 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) boolean_t aborted __rte_unused; delay_total = 0; - delay_us = SFC_MCDI_POLL_INTERVAL_MIN_US; + delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US; enp = sa->nic; do { boolean_t poll_completed; - poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) : + poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) : efx_mcdi_request_poll(enp); if (poll_completed) return; - if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) { + if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) { if (!proxy) { aborted = efx_mcdi_request_abort(enp); SFC_ASSERT(aborted); - sfc_mcdi_timeout(sa); + sfc_efx_mcdi_timeout(sa); } return; @@ -80,27 +80,28 @@ sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) delay_total += delay_us; /* Exponentially back off the poll frequency */ - RTE_BUILD_BUG_ON(SFC_MCDI_POLL_INTERVAL_MAX_US > UINT_MAX / 2); + RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US > + UINT_MAX / 2); delay_us *= 2; - if (delay_us > SFC_MCDI_POLL_INTERVAL_MAX_US) - delay_us = SFC_MCDI_POLL_INTERVAL_MAX_US; + if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US) + delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US; } while (1); } static void -sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) +sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = &sa->mcdi; uint32_t proxy_handle; rte_spinlock_lock(&mcdi->lock); - SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED); + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); efx_mcdi_request_start(sa->nic, emrp, B_FALSE); - sfc_mcdi_poll(sa, B_FALSE); + sfc_efx_mcdi_poll(sa, B_FALSE); if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) { /* @@ -109,7 +110,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) * a non-zero proxy handle (should be the same as * the value obtained above) and operation status */ - sfc_mcdi_poll(sa, B_TRUE); + sfc_efx_mcdi_poll(sa, B_TRUE); if ((mcdi->proxy_handle != 0) && (mcdi->proxy_handle != proxy_handle)) { @@ -121,7 +122,7 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) * request and poll for an ordinary MCDI response */ efx_mcdi_request_start(sa->nic, emrp, B_FALSE); - sfc_mcdi_poll(sa, B_FALSE); + sfc_efx_mcdi_poll(sa, B_FALSE); } else { emrp->emr_rc = mcdi->proxy_result; sfc_err(sa, "MCDI proxy authorization failed " @@ -134,20 +135,20 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) } static void -sfc_mcdi_ev_cpl(void *arg) +sfc_efx_mcdi_ev_cpl(void *arg) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_mcdi *mcdi __rte_unused; + struct sfc_efx_mcdi *mcdi __rte_unused; mcdi = &sa->mcdi; - SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED); + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); /* MCDI is polled, completions are not expected */ SFC_ASSERT(0); } static void -sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme) +sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; @@ -161,7 +162,7 @@ sfc_mcdi_exception(void *arg, efx_mcdi_exception_t eme) #define SFC_MCDI_LOG_BUF_SIZE 128 static size_t -sfc_mcdi_do_log(const struct sfc_adapter *sa, +sfc_efx_mcdi_do_log(const struct sfc_adapter *sa, char *buffer, void *data, size_t data_size, size_t pfxsize, size_t position) { @@ -190,7 +191,7 @@ sfc_mcdi_do_log(const struct sfc_adapter *sa, } static void -sfc_mcdi_logger(void *arg, efx_log_msg_t type, +sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, void *header, size_t header_size, void *data, size_t data_size) { @@ -215,9 +216,10 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type, pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:", type == EFX_LOG_MCDI_REQUEST ? "REQ" : type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???"); - start = sfc_mcdi_do_log(sa, buffer, header, header_size, - pfxsize, pfxsize); - start = sfc_mcdi_do_log(sa, buffer, data, data_size, pfxsize, start); + start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size, + pfxsize, pfxsize); + start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size, + pfxsize, start); if (start != pfxsize) { buffer[start] = '\0'; sfc_log_mcdi(sa, "%s", buffer); @@ -225,19 +227,19 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type, } static void -sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) +sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = &sa->mcdi; mcdi->proxy_handle = handle; mcdi->proxy_result = result; } -int -sfc_mcdi_init(struct sfc_adapter *sa) +static int +sfc_efx_mcdi_init(struct sfc_adapter *sa) { - struct sfc_mcdi *mcdi; + struct sfc_efx_mcdi *mcdi; size_t max_msg_size; efx_mcdi_transport_t *emtp; int rc; @@ -246,11 +248,11 @@ sfc_mcdi_init(struct sfc_adapter *sa) mcdi = &sa->mcdi; - SFC_ASSERT(mcdi->state == SFC_MCDI_UNINITIALIZED); + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); rte_spinlock_init(&mcdi->lock); - mcdi->state = SFC_MCDI_INITIALIZED; + mcdi->state = SFC_EFX_MCDI_INITIALIZED; max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2; rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id, @@ -265,11 +267,11 @@ sfc_mcdi_init(struct sfc_adapter *sa) emtp = &mcdi->transport; emtp->emt_context = sa; emtp->emt_dma_mem = &mcdi->mem; - emtp->emt_execute = sfc_mcdi_execute; - emtp->emt_ev_cpl = sfc_mcdi_ev_cpl; - emtp->emt_exception = sfc_mcdi_exception; - emtp->emt_logger = sfc_mcdi_logger; - emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response; + emtp->emt_execute = sfc_efx_mcdi_execute; + emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl; + emtp->emt_exception = sfc_efx_mcdi_exception; + emtp->emt_logger = sfc_efx_mcdi_logger; + emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response; sfc_log_init(sa, "init MCDI"); rc = efx_mcdi_init(sa->nic, emtp); @@ -283,14 +285,14 @@ sfc_mcdi_init(struct sfc_adapter *sa) sfc_dma_free(sa, &mcdi->mem); fail_dma_alloc: - mcdi->state = SFC_MCDI_UNINITIALIZED; + mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; return rc; } -void -sfc_mcdi_fini(struct sfc_adapter *sa) +static void +sfc_efx_mcdi_fini(struct sfc_adapter *sa) { - struct sfc_mcdi *mcdi; + struct sfc_efx_mcdi *mcdi; efx_mcdi_transport_t *emtp; sfc_log_init(sa, "entry"); @@ -300,8 +302,8 @@ sfc_mcdi_fini(struct sfc_adapter *sa) rte_spinlock_lock(&mcdi->lock); - SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED); - mcdi->state = SFC_MCDI_UNINITIALIZED; + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); + mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; sfc_log_init(sa, "fini MCDI"); efx_mcdi_fini(sa->nic); @@ -311,3 +313,15 @@ sfc_mcdi_fini(struct sfc_adapter *sa) sfc_dma_free(sa, &mcdi->mem); } + +int +sfc_mcdi_init(struct sfc_adapter *sa) +{ + return sfc_efx_mcdi_init(sa); +} + +void +sfc_mcdi_fini(struct sfc_adapter *sa) +{ + sfc_efx_mcdi_fini(sa); +} diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index 789a16d8bb..10f5bab666 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -22,31 +22,25 @@ extern "C" { #endif -enum sfc_mcdi_state { - SFC_MCDI_UNINITIALIZED = 0, - SFC_MCDI_INITIALIZED, - SFC_MCDI_BUSY, - SFC_MCDI_COMPLETED, +enum sfc_efx_mcdi_state { + SFC_EFX_MCDI_UNINITIALIZED = 0, + SFC_EFX_MCDI_INITIALIZED, + SFC_EFX_MCDI_BUSY, + SFC_EFX_MCDI_COMPLETED, - SFC_MCDI_NSTATES + SFC_EFX_MCDI_NSTATES }; -struct sfc_mcdi { +struct sfc_efx_mcdi { rte_spinlock_t lock; efsys_mem_t mem; - enum sfc_mcdi_state state; + enum sfc_efx_mcdi_state state; efx_mcdi_transport_t transport; uint32_t logtype; uint32_t proxy_handle; efx_rc_t proxy_result; }; - -struct sfc_adapter; - -int sfc_mcdi_init(struct sfc_adapter *sa); -void sfc_mcdi_fini(struct sfc_adapter *sa); - #ifdef __cplusplus } #endif From patchwork Tue Sep 8 09:14:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76887 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 78EE3A04AA; Tue, 8 Sep 2020 11:16:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E84431C10E; Tue, 8 Sep 2020 11:15: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 E1A6B2BAB for ; Tue, 8 Sep 2020 11:15:45 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.143]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 725032009B for ; Tue, 8 Sep 2020 09:15:45 +0000 (UTC) Received: from us4-mdac16-29.at1.mdlocal (unknown [10.110.49.213]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 5EE6E8009B for ; Tue, 8 Sep 2020 09:15:45 +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 1A2E140110 for ; Tue, 8 Sep 2020 09:14:55 +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 D7AD840059 for ; Tue, 8 Sep 2020 09:14:54 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnO5032416 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 671691613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:26 +0100 Message-ID: <1599556475-27820-7-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-8.731200-8.000000-10 X-TMASE-MatchedRID: tcizGzo33Igi+Ly1jF96cbsHVDDM5xAPgcsVZH3dOCQGmHr1eMxt2UAc 6DyoS2rIOelg+pLqPPFsGcpYVjbbPr5FkoP8eT9ncaD+wPaBYtZIevoF6P4wcjbpMgyAfh26jGd KRTlT9kLb2VJ5zpbgoclZ9hhLEWzEex0yPqto0a/knMSTG9lH+KIik2/euMx1VWQnHKxp38iUR6 6C6i5v83xL67a3d6gmRT5xeSl5IKJ5OVTeAyRyiLBZAi3nrnzbYCdLkMLwLkPNOks35FeGOaPFj JEFr+olwXCBO/GKkVqOhzOa6g8KrQDfSq9t4KACXbrUBOI3b4zrqJKHagbR08XkP1A0PpolqOOv oFiXspE= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.731200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556545-hLz-dcBJeo9g Subject: [dpdk-dev] [PATCH 05/14] net/sfc: make MCDI logging helper macros local 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" Prepare to move MCDI helpers to drivers/common. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_log.h | 11 ----------- drivers/net/sfc/sfc_mcdi.c | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h index 5383091c76..4bf44b1f15 100644 --- a/drivers/net/sfc/sfc_log.h +++ b/drivers/net/sfc/sfc_log.h @@ -28,9 +28,6 @@ extern uint32_t sfc_logtype_driver; /** Device MCDI log type name prefix */ #define SFC_LOGTYPE_MCDI_STR SFC_LOGTYPE_PREFIX "mcdi" -/** Level value used by MCDI log statements */ -#define SFC_LOG_LEVEL_MCDI RTE_LOG_INFO - /* Log PMD message, automatically add prefix and \n */ #define SFC_LOG(sas, level, type, ...) \ do { \ @@ -92,13 +89,5 @@ extern uint32_t sfc_logtype_driver; RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) -#define sfc_log_mcdi(sa, ...) \ - do { \ - const struct sfc_adapter *_sa = (sa); \ - \ - SFC_LOG(_sa->priv.shared, SFC_LOG_LEVEL_MCDI, \ - _sa->mcdi.logtype, __VA_ARGS__); \ - } while (0) - #endif /* _SFC_LOG_H_ */ diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index c97a33d558..c716caabdf 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -23,6 +23,17 @@ #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms */ #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s */ +/** Level value used by MCDI log statements */ +#define SFC_EFX_LOG_LEVEL_MCDI RTE_LOG_INFO + +#define sfc_efx_log_mcdi(sa, ...) \ + do { \ + const struct sfc_adapter *_sa = (sa); \ + \ + SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI, \ + _sa->mcdi.logtype, __VA_ARGS__); \ + } while (0) + static void sfc_efx_mcdi_timeout(struct sfc_adapter *sa) { @@ -178,7 +189,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa, * at the end which is required by netlogdecode. */ buffer[position] = '\0'; - sfc_log_mcdi(sa, "%s \\", buffer); + sfc_efx_log_mcdi(sa, "%s \\", buffer); /* Preserve prefix for the next log message */ position = pfxsize; } @@ -207,11 +218,11 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, * * To avoid wasting time, the actual level is examined in advance. */ - if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_LOG_LEVEL_MCDI) + if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI) return; - /* The format including prefix added by sfc_log_mcdi() is the format - * consumed by the Solarflare netlogdecode tool. + /* The format including prefix added by sfc_efx_log_mcdi() is the + * format consumed by the Solarflare netlogdecode tool. */ pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:", type == EFX_LOG_MCDI_REQUEST ? "REQ" : @@ -222,7 +233,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, pfxsize, start); if (start != pfxsize) { buffer[start] = '\0'; - sfc_log_mcdi(sa, "%s", buffer); + sfc_efx_log_mcdi(sa, "%s", buffer); } } From patchwork Tue Sep 8 09:14:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76895 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7286AA04AA; Tue, 8 Sep 2020 11:17:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C92181C19C; Tue, 8 Sep 2020 11:16:06 +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 526311C10C for ; Tue, 8 Sep 2020 11:16:03 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id E817520096 for ; Tue, 8 Sep 2020 09:16:02 +0000 (UTC) Received: from us4-mdac16-23.at1.mdlocal (unknown [10.110.49.205]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 4FAC3800E7 for ; Tue, 8 Sep 2020 09:16:02 +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 39F6F4004D for ; Tue, 8 Sep 2020 09:14:53 +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 03FBF4006D for ; Tue, 8 Sep 2020 09:14:53 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnmB032419 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 72DCF1613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:27 +0100 Message-ID: <1599556475-27820-8-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-6.083700-8.000000-10 X-TMASE-MatchedRID: Op6irFE5Bym+3WtMCwvZqv3HILfxLV/9E3EgF0+MVuBwkdIrVt8X1ciT Wug2C4DNBTL3N8yyT9ePQi9XuOWoOLQHnhaRx4GgMy+jMkhCdFbYuVu0X/rOkEdmDSBYfnJRssk CJ7yz5Pwfhw4XBVnp2E/fJLuJlbjnHxPMjOKY7A8LbigRnpKlKWxlRJiH4397apPiEUUWfU/L32 cs7IQiOmDDNtsHslsUuWcIZI9Qn0KEybG8uWxreg== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.083700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556562-3II151JtYXy1 Subject: [dpdk-dev] [PATCH 06/14] net/sfc: start to make MCDI helpers interface shareable 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" sfc_adapter is network driver specific structure which finally should not be used in shared MCDI helpers interface. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index c716caabdf..35e1f3940d 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -248,17 +248,14 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) } static int -sfc_efx_mcdi_init(struct sfc_adapter *sa) +sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) { - struct sfc_efx_mcdi *mcdi; size_t max_msg_size; efx_mcdi_transport_t *emtp; int rc; sfc_log_init(sa, "entry"); - mcdi = &sa->mcdi; - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); rte_spinlock_init(&mcdi->lock); @@ -301,14 +298,12 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa) } static void -sfc_efx_mcdi_fini(struct sfc_adapter *sa) +sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) { - struct sfc_efx_mcdi *mcdi; efx_mcdi_transport_t *emtp; sfc_log_init(sa, "entry"); - mcdi = &sa->mcdi; emtp = &mcdi->transport; rte_spinlock_lock(&mcdi->lock); @@ -328,11 +323,11 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa) int sfc_mcdi_init(struct sfc_adapter *sa) { - return sfc_efx_mcdi_init(sa); + return sfc_efx_mcdi_init(sa, &sa->mcdi); } void sfc_mcdi_fini(struct sfc_adapter *sa) { - sfc_efx_mcdi_fini(sa); + sfc_efx_mcdi_fini(sa, &sa->mcdi); } From patchwork Tue Sep 8 09:14:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76889 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8843DA04AA; Tue, 8 Sep 2020 11:16:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 254BE1C11D; Tue, 8 Sep 2020 11:15:52 +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 F3FD61C114 for ; Tue, 8 Sep 2020 11:15:49 +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 9DF3320055 for ; Tue, 8 Sep 2020 09:15:49 +0000 (UTC) Received: from us4-mdac16-15.at1.mdlocal (unknown [10.110.49.197]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 793F5800D9 for ; Tue, 8 Sep 2020 09:15:48 +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 7374A100108 for ; Tue, 8 Sep 2020 09:14:54 +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 270AB40075 for ; Tue, 8 Sep 2020 09:14:54 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnNf032422 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 7EE521613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:28 +0100 Message-ID: <1599556475-27820-9-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-15.476000-8.000000-10 X-TMASE-MatchedRID: q1pm6qPPK/2bX4K/DqV0NcXfQl57nu/GlSphlGf1p5FwkdIrVt8X1ciT Wug2C4DNaBlE1XNBqpjE2B1VA3GwSiHhSBQfglfsA9lly13c/gHAmOfzKotToo+Ixb7djOSCfVU ABWHMm0s+FZALrdQw27VYhmmQ16xDEGrGKgXI3I8dt2/pSR7zwIZ6Q5tE4bB0x5B+7qLBJ+z6O4 3MfdK6t+8wp+H295Osy/h3/XXam+iqJxP8CL5wCW6HurDH4PpP8gryAriuOnIRQQ4kFqjjJACJT p5CwDqKGSUXbuI5f3+Jkhd2ZcbBKHnYsjCinlm920204SCJw/qnLZXtX62Wm3S7//lqxurTHXPt gR0gN1zSJsMPesp+yyYRyYlpEhDLENHwxbanitm2+eU4nrUrehdoyFlJ5UUMFBQ5IKls/A7PR1u d0AS9ADhME59DakTsbMYatN9zEWEiRWw1gHaWS6IBnfMCFBiCLPSJu5jov2YUZ5IS2TgivU2p3Z j/R/ne4vM1YF6AJbbCCfuIMF6xLbxAi7jPoeEQftwZ3X11IV0= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--15.476000-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556548-hxEu16sd2n1s Subject: [dpdk-dev] [PATCH 07/14] net/sfc: use own logging helper macros 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" Network driver logging macros depends on sfc_adapter which is specific to the driver and cannot be used in common code. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 2 + drivers/net/sfc/sfc_ethdev.c | 13 ++++++ drivers/net/sfc/sfc_log.h | 12 ++--- drivers/net/sfc/sfc_mcdi.c | 86 +++++++++++++++++++++++------------- drivers/net/sfc/sfc_mcdi.h | 1 + 5 files changed, 75 insertions(+), 39 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index b3ac752334..b20fecb4f8 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -22,6 +22,7 @@ #include "efx.h" #include "sfc_debug.h" +#include "sfc_log.h" #include "sfc_filter.h" #include "sfc_mcdi.h" @@ -170,6 +171,7 @@ struct sfc_adapter_shared { boolean_t isolated; uint32_t tunnel_encaps; + char log_prefix[SFC_LOG_PREFIX_MAX]; struct rte_pci_addr pci_addr; uint16_t port_id; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index acee3e48e4..085f020a4c 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -2136,6 +2136,7 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) int rc; const efx_nic_cfg_t *encp; const struct rte_ether_addr *from; + int ret; sfc_register_dp(); @@ -2147,6 +2148,18 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) return -sfc_eth_dev_secondary_init(dev, logtype_main); /* Required for logging */ + ret = snprintf(sas->log_prefix, sizeof(sas->log_prefix), + "PMD: sfc_efx " PCI_PRI_FMT " #%" PRIu16 ": ", + pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function, + dev->data->port_id); + if (ret < 0 || ret >= (int)sizeof(sas->log_prefix)) { + SFC_GENERIC_LOG(ERR, + "reserved log prefix is too short for " PCI_PRI_FMT, + pci_dev->addr.domain, pci_dev->addr.bus, + pci_dev->addr.devid, pci_dev->addr.function); + return -EINVAL; + } sas->pci_addr = pci_dev->addr; sas->port_id = dev->data->port_id; diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h index 4bf44b1f15..a2d714afb7 100644 --- a/drivers/net/sfc/sfc_log.h +++ b/drivers/net/sfc/sfc_log.h @@ -28,20 +28,16 @@ extern uint32_t sfc_logtype_driver; /** Device MCDI log type name prefix */ #define SFC_LOGTYPE_MCDI_STR SFC_LOGTYPE_PREFIX "mcdi" +#define SFC_LOG_PREFIX_MAX 32 + /* Log PMD message, automatically add prefix and \n */ #define SFC_LOG(sas, level, type, ...) \ do { \ const struct sfc_adapter_shared *_sas = (sas); \ \ rte_log(level, type, \ - RTE_FMT("PMD: sfc_efx " \ - PCI_PRI_FMT " #%" PRIu16 \ - ": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ - _sas->pci_addr.domain, \ - _sas->pci_addr.bus, \ - _sas->pci_addr.devid, \ - _sas->pci_addr.function, \ - _sas->port_id, \ + RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + _sas->log_prefix, \ RTE_FMT_TAIL(__VA_ARGS__,))); \ } while (0) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 35e1f3940d..5f6ad0a4aa 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -23,21 +23,37 @@ #define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms */ #define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s */ -/** Level value used by MCDI log statements */ -#define SFC_EFX_LOG_LEVEL_MCDI RTE_LOG_INFO - -#define sfc_efx_log_mcdi(sa, ...) \ +#define sfc_efx_mcdi_log(mcdi, level, ...) \ do { \ - const struct sfc_adapter *_sa = (sa); \ + const struct sfc_efx_mcdi *_mcdi = (mcdi); \ \ - SFC_LOG(_sa->priv.shared, SFC_EFX_LOG_LEVEL_MCDI, \ - _sa->mcdi.logtype, __VA_ARGS__); \ + rte_log(level, _mcdi->logtype, \ + RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + _mcdi->log_prefix, \ + RTE_FMT_TAIL(__VA_ARGS__,))); \ } while (0) +#define sfc_efx_mcdi_err(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__) + +#define sfc_efx_mcdi_warn(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__) + +#define sfc_efx_mcdi_info(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__) + +/** Level value used by MCDI log statements */ +#define SFC_EFX_LOG_LEVEL_MCDI RTE_LOG_INFO + +#define sfc_efx_log_mcdi(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__) + static void sfc_efx_mcdi_timeout(struct sfc_adapter *sa) { - sfc_warn(sa, "MC TIMEOUT"); + struct sfc_efx_mcdi *mcdi = &sa->mcdi; + + sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT"); sfc_panic(sa, "MCDI timeout handling is not implemented\n"); } @@ -125,7 +141,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) if ((mcdi->proxy_handle != 0) && (mcdi->proxy_handle != proxy_handle)) { - sfc_err(sa, "Unexpected MCDI proxy event"); + sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event"); emrp->emr_rc = EFAULT; } else if (mcdi->proxy_result == 0) { /* @@ -136,9 +152,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) sfc_efx_mcdi_poll(sa, B_FALSE); } else { emrp->emr_rc = mcdi->proxy_result; - sfc_err(sa, "MCDI proxy authorization failed " - "(handle=%08x, result=%d)", - proxy_handle, mcdi->proxy_result); + sfc_efx_mcdi_err(mcdi, + "MCDI proxy authorization failed (handle=%08x, result=%d)", + proxy_handle, mcdi->proxy_result); } } @@ -162,8 +178,9 @@ static void sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; + struct sfc_efx_mcdi *mcdi = &sa->mcdi; - sfc_warn(sa, "MC %s", + sfc_efx_mcdi_warn(mcdi, "MC %s", (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" : (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN"); @@ -173,7 +190,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) #define SFC_MCDI_LOG_BUF_SIZE 128 static size_t -sfc_efx_mcdi_do_log(const struct sfc_adapter *sa, +sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi, char *buffer, void *data, size_t data_size, size_t pfxsize, size_t position) { @@ -189,7 +206,7 @@ sfc_efx_mcdi_do_log(const struct sfc_adapter *sa, * at the end which is required by netlogdecode. */ buffer[position] = '\0'; - sfc_efx_log_mcdi(sa, "%s \\", buffer); + sfc_efx_log_mcdi(mcdi, "%s \\", buffer); /* Preserve prefix for the next log message */ position = pfxsize; } @@ -207,6 +224,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, void *data, size_t data_size) { struct sfc_adapter *sa = (struct sfc_adapter *)arg; + struct sfc_efx_mcdi *mcdi = &sa->mcdi; char buffer[SFC_MCDI_LOG_BUF_SIZE]; size_t pfxsize; size_t start; @@ -218,7 +236,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, * * To avoid wasting time, the actual level is examined in advance. */ - if (rte_log_get_level(sa->mcdi.logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI) + if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI) return; /* The format including prefix added by sfc_efx_log_mcdi() is the @@ -227,13 +245,13 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:", type == EFX_LOG_MCDI_REQUEST ? "REQ" : type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???"); - start = sfc_efx_mcdi_do_log(sa, buffer, header, header_size, + start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size, pfxsize, pfxsize); - start = sfc_efx_mcdi_do_log(sa, buffer, data, data_size, + start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size, pfxsize, start); if (start != pfxsize) { buffer[start] = '\0'; - sfc_efx_log_mcdi(sa, "%s", buffer); + sfc_efx_log_mcdi(mcdi, "%s", buffer); } } @@ -248,30 +266,28 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) } static int -sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) +sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, + uint32_t logtype, const char *log_prefix) { size_t max_msg_size; efx_mcdi_transport_t *emtp; int rc; - sfc_log_init(sa, "entry"); - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); rte_spinlock_init(&mcdi->lock); mcdi->state = SFC_EFX_MCDI_INITIALIZED; + mcdi->logtype = logtype; + mcdi->log_prefix = log_prefix; + max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2; rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id, &mcdi->mem); if (rc != 0) goto fail_dma_alloc; - mcdi->logtype = sfc_register_logtype(&sa->priv.shared->pci_addr, - SFC_LOGTYPE_MCDI_STR, - RTE_LOG_NOTICE); - emtp = &mcdi->transport; emtp->emt_context = sa; emtp->emt_dma_mem = &mcdi->mem; @@ -281,7 +297,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) emtp->emt_logger = sfc_efx_mcdi_logger; emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response; - sfc_log_init(sa, "init MCDI"); + sfc_efx_mcdi_info(mcdi, "init MCDI"); rc = efx_mcdi_init(sa->nic, emtp); if (rc != 0) goto fail_mcdi_init; @@ -302,8 +318,6 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) { efx_mcdi_transport_t *emtp; - sfc_log_init(sa, "entry"); - emtp = &mcdi->transport; rte_spinlock_lock(&mcdi->lock); @@ -311,7 +325,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; - sfc_log_init(sa, "fini MCDI"); + sfc_efx_mcdi_info(mcdi, "fini MCDI"); efx_mcdi_fini(sa->nic); memset(emtp, 0, sizeof(*emtp)); @@ -323,11 +337,21 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) int sfc_mcdi_init(struct sfc_adapter *sa) { - return sfc_efx_mcdi_init(sa, &sa->mcdi); + uint32_t logtype; + + sfc_log_init(sa, "entry"); + + logtype = sfc_register_logtype(&sa->priv.shared->pci_addr, + SFC_LOGTYPE_MCDI_STR, + RTE_LOG_NOTICE); + + return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype, + sa->priv.shared->log_prefix); } void sfc_mcdi_fini(struct sfc_adapter *sa) { + sfc_log_init(sa, "entry"); sfc_efx_mcdi_fini(sa, &sa->mcdi); } diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index 10f5bab666..0194825bfa 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -39,6 +39,7 @@ struct sfc_efx_mcdi { uint32_t logtype; uint32_t proxy_handle; efx_rc_t proxy_result; + const char *log_prefix; }; #ifdef __cplusplus From patchwork Tue Sep 8 09:14:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76890 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF127A04AA; Tue, 8 Sep 2020 11:16:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 42E061C12B; Tue, 8 Sep 2020 11:15:53 +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 28B211C11A for ; Tue, 8 Sep 2020 11:15:51 +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 C0C01200B5 for ; Tue, 8 Sep 2020 09:15:50 +0000 (UTC) Received: from us4-mdac16-47.at1.mdlocal (unknown [10.110.50.130]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 2E2CB800D5 for ; Tue, 8 Sep 2020 09:15:50 +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 E3BEC10010B for ; Tue, 8 Sep 2020 09:14:55 +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 AC01340076 for ; Tue, 8 Sep 2020 09:14:55 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889Ents032425 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 8A5501613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:29 +0100 Message-ID: <1599556475-27820-10-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-11.388300-8.000000-10 X-TMASE-MatchedRID: 8KqAZX9NEj5ITqtSH9SWSS2416nc3bQleouvej40T4gd0WOKRkwsh3Io zGa69omdrdoLblq9S5qas0rFUiAJUTtLCZHM0q2+LTHwnYOikQ3YuVu0X/rOkC4mS5ZcbgykHdp aAe/6URkgIEX6WzwOdHy8wrTvkWOE1u/Sx2voIm8zL6MySEJ0VhpxmKWTfsQI5ucVak1fUMG7im J4LbFoqRfb/g6/AVAtG+8CgnzENLtC4oGQR0QDTH9EwA0OW8QlE3EgF0+MVuCfJbh3pMo2kKPFj JEFr+olwXCBO/GKkVqOhzOa6g8KrZXab56lxlwcDwkFyw4VU4CgCbvlZFwA6dS5yfl5JZAhJjZF ot2mO34= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--11.388300-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556550-XQVrWwetubjr Subject: [dpdk-dev] [PATCH 08/14] net/sfc: avoid usage of NIC pointer from adapter context 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" Prepare to avoid usage of the adapter context in common MCDI helpers. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 19 +++++++++++-------- drivers/net/sfc/sfc_mcdi.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 5f6ad0a4aa..8f446e8bc8 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -75,6 +75,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa) static void sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) { + struct sfc_efx_mcdi *mcdi = &sa->mcdi; efx_nic_t *enp; unsigned int delay_total; unsigned int delay_us; @@ -82,7 +83,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) delay_total = 0; delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US; - enp = sa->nic; + enp = mcdi->nic; do { boolean_t poll_completed; @@ -127,10 +128,10 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); - efx_mcdi_request_start(sa->nic, emrp, B_FALSE); + efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); sfc_efx_mcdi_poll(sa, B_FALSE); - if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) { + if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) { /* * Authorization is required for the MCDI request; * wait for an MCDI proxy response event to bring @@ -148,7 +149,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) * Authorization succeeded; re-issue the original * request and poll for an ordinary MCDI response */ - efx_mcdi_request_start(sa->nic, emrp, B_FALSE); + efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); sfc_efx_mcdi_poll(sa, B_FALSE); } else { emrp->emr_rc = mcdi->proxy_result; @@ -267,7 +268,7 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) static int sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, - uint32_t logtype, const char *log_prefix) + uint32_t logtype, const char *log_prefix, efx_nic_t *nic) { size_t max_msg_size; efx_mcdi_transport_t *emtp; @@ -277,6 +278,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, rte_spinlock_init(&mcdi->lock); + mcdi->nic = nic; + mcdi->state = SFC_EFX_MCDI_INITIALIZED; mcdi->logtype = logtype; @@ -298,7 +301,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response; sfc_efx_mcdi_info(mcdi, "init MCDI"); - rc = efx_mcdi_init(sa->nic, emtp); + rc = efx_mcdi_init(mcdi->nic, emtp); if (rc != 0) goto fail_mcdi_init; @@ -326,7 +329,7 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; sfc_efx_mcdi_info(mcdi, "fini MCDI"); - efx_mcdi_fini(sa->nic); + efx_mcdi_fini(mcdi->nic); memset(emtp, 0, sizeof(*emtp)); rte_spinlock_unlock(&mcdi->lock); @@ -346,7 +349,7 @@ sfc_mcdi_init(struct sfc_adapter *sa) RTE_LOG_NOTICE); return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype, - sa->priv.shared->log_prefix); + sa->priv.shared->log_prefix, sa->nic); } void diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index 0194825bfa..e2105364ad 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -33,6 +33,7 @@ enum sfc_efx_mcdi_state { struct sfc_efx_mcdi { rte_spinlock_t lock; + efx_nic_t *nic; efsys_mem_t mem; enum sfc_efx_mcdi_state state; efx_mcdi_transport_t transport; From patchwork Tue Sep 8 09:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76896 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E23B0A04AA; Tue, 8 Sep 2020 11:17:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F19561C1A1; Tue, 8 Sep 2020 11:16:07 +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 A9C181C10D for ; Tue, 8 Sep 2020 11:16:03 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 5278020075 for ; Tue, 8 Sep 2020 09:16:03 +0000 (UTC) Received: from us4-mdac16-48.at1.mdlocal (unknown [10.110.50.131]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id B9C57800BB for ; Tue, 8 Sep 2020 09:16:02 +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 B29F340133 for ; Tue, 8 Sep 2020 09:14:55 +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 697A540067 for ; Tue, 8 Sep 2020 09:14:55 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnGV032428 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 95D1F1613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:30 +0100 Message-ID: <1599556475-27820-11-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-0.137400-8.000000-10 X-TMASE-MatchedRID: PPPqS2B+Ni0pk5K7iexxzC2416nc3bQleouvej40T4gd0WOKRkwsh3Io zGa69omdrdoLblq9S5o2rW8Pb51lrtLucdA1OHpB0MohG+IQ2sfy++SyyVe4t1VkJxysad/IeOb QA+fBlTa8WuXMAMHMHjpzQoT/n3/mNyl1nd9CIt0URSScn+QSXl1PyA7eE+Ph+gtHj7OwNO3ClX +2r3j3WC+of4vgxtzMb5XhMobMnGETr691g6nSWRp24KintwkLxgiCVINc87CsPGMacX2fm5LSs JKPozupjexyWJd6V8uETBIpmSWuHgAD0FqlZdom0b4rJ92tmtF/d7a9VsfzMGYfzNl+uie3Vcr2 04P67pw= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-0.137400-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556562-y7rUYF3ss5W7 Subject: [dpdk-dev] [PATCH 09/14] net/sfc: avoid panic in the case of MCDI timeout 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" Implement dummy MCDI timeout handling which simply rejects further MCDI requests. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++-- drivers/net/sfc/sfc_mcdi.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 8f446e8bc8..928a08c0a2 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -33,6 +33,9 @@ RTE_FMT_TAIL(__VA_ARGS__,))); \ } while (0) +#define sfc_efx_mcdi_crit(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__) + #define sfc_efx_mcdi_err(mcdi, ...) \ sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__) @@ -55,7 +58,9 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa) sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT"); - sfc_panic(sa, "MCDI timeout handling is not implemented\n"); + mcdi->state = SFC_EFX_MCDI_DEAD; + sfc_efx_mcdi_crit(mcdi, + "MCDI timeout handling is not implemented - NIC is unusable"); } static inline boolean_t @@ -124,6 +129,11 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) struct sfc_efx_mcdi *mcdi = &sa->mcdi; uint32_t proxy_handle; + if (mcdi->state == SFC_EFX_MCDI_DEAD) { + emrp->emr_rc = ENOEXEC; + return; + } + rte_spinlock_lock(&mcdi->lock); SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); @@ -325,7 +335,8 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) rte_spinlock_lock(&mcdi->lock); - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED || + mcdi->state == SFC_EFX_MCDI_DEAD); mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; sfc_efx_mcdi_info(mcdi, "fini MCDI"); diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index e2105364ad..b93b268e32 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -27,6 +27,7 @@ enum sfc_efx_mcdi_state { SFC_EFX_MCDI_INITIALIZED, SFC_EFX_MCDI_BUSY, SFC_EFX_MCDI_COMPLETED, + SFC_EFX_MCDI_DEAD, SFC_EFX_MCDI_NSTATES }; From patchwork Tue Sep 8 09:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76902 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5A49FA04AA; Tue, 8 Sep 2020 11:18:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0F851C0CF; Tue, 8 Sep 2020 11:17:28 +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 47EB81C0CE for ; Tue, 8 Sep 2020 11:17:27 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id E576620074 for ; Tue, 8 Sep 2020 09:17:26 +0000 (UTC) Received: from us4-mdac16-59.at1.mdlocal (unknown [10.110.50.152]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 1BFFE800B1 for ; Tue, 8 Sep 2020 09:17:26 +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 AA3E040135 for ; Tue, 8 Sep 2020 09:14:57 +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 C28EA4005E for ; Tue, 8 Sep 2020 09:14:56 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889EnRN032435 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id A1A951613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:31 +0100 Message-ID: <1599556475-27820-12-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-7.265700-8.000000-10 X-TMASE-MatchedRID: klLfDUJzcbG/kNGHVZrsls50DGuIExk9UXlp1FHYSPVwkdIrVt8X1dN+ VO8UR4MhfGzuoVn0Vs6PQi9XuOWoOLQHnhaRx4GgMy+jMkhCdFZrd+wrP/NNVMd4gWcpDnUclSY jj5D227bG42pGgsfFnI2Ow18fgOyZKjPlgWuJZGwk/b03uBR3ULpKkQnaF6lazdATtc2zn0DlbG AwGirFMOJRsev36MRgiiiUp2zjfThf7y77NDsmYp4CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyMdRT 5TQAJnASWt0iRbOvZk/863Ch77M8LV3TVOy7ItOvVBQZC5rCkGeqD9WtJkSIw== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.265700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556640-9lrWPnnfVxVf Subject: [dpdk-dev] [PATCH 10/14] net/sfc: add MCDI callbacks to allocate/free DMA memory 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" Net driver should use rte_eth_dma_zone_reserve(), but it is ethdev specific API which is not available for vDPA. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 46 +++++++++++++++++++++++++++++++------- drivers/net/sfc/sfc_mcdi.h | 12 ++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 928a08c0a2..5077fcddd6 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -278,16 +278,22 @@ sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) static int sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, - uint32_t logtype, const char *log_prefix, efx_nic_t *nic) + uint32_t logtype, const char *log_prefix, efx_nic_t *nic, + const struct sfc_efx_mcdi_ops *ops, void *ops_cookie) { size_t max_msg_size; efx_mcdi_transport_t *emtp; int rc; + if (ops->dma_alloc == NULL || ops->dma_free == NULL) + return EINVAL; + SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); rte_spinlock_init(&mcdi->lock); + mcdi->ops = ops; + mcdi->ops_cookie = ops_cookie; mcdi->nic = nic; mcdi->state = SFC_EFX_MCDI_INITIALIZED; @@ -296,8 +302,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, mcdi->log_prefix = log_prefix; max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2; - rc = sfc_dma_alloc(sa, "mcdi", 0, max_msg_size, sa->socket_id, - &mcdi->mem); + rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem); if (rc != 0) goto fail_dma_alloc; @@ -319,7 +324,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, fail_mcdi_init: memset(emtp, 0, sizeof(*emtp)); - sfc_dma_free(sa, &mcdi->mem); + ops->dma_free(ops_cookie, &mcdi->mem); fail_dma_alloc: mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; @@ -327,7 +332,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, } static void -sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) +sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi) { efx_mcdi_transport_t *emtp; @@ -345,9 +350,33 @@ sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi) rte_spinlock_unlock(&mcdi->lock); - sfc_dma_free(sa, &mcdi->mem); + mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem); +} + +static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc; +static int +sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len, + efsys_mem_t *esmp) +{ + const struct sfc_adapter *sa = cookie; + + return sfc_dma_alloc(sa, name, 0, len, sa->socket_id, esmp); } +static sfc_efx_mcdi_dma_free_cb sfc_mcdi_dma_free; +static void +sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp) +{ + const struct sfc_adapter *sa = cookie; + + sfc_dma_free(sa, esmp); +} + +static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = { + .dma_alloc = sfc_mcdi_dma_alloc, + .dma_free = sfc_mcdi_dma_free, +}; + int sfc_mcdi_init(struct sfc_adapter *sa) { @@ -360,12 +389,13 @@ sfc_mcdi_init(struct sfc_adapter *sa) RTE_LOG_NOTICE); return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype, - sa->priv.shared->log_prefix, sa->nic); + sa->priv.shared->log_prefix, sa->nic, + &sfc_mcdi_ops, sa); } void sfc_mcdi_fini(struct sfc_adapter *sa) { sfc_log_init(sa, "entry"); - sfc_efx_mcdi_fini(sa, &sa->mcdi); + sfc_efx_mcdi_fini(&sa->mcdi); } diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index b93b268e32..ef24a8bc67 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -32,8 +32,20 @@ enum sfc_efx_mcdi_state { SFC_EFX_MCDI_NSTATES }; +typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name, + size_t len, efsys_mem_t *esmp); + +typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp); + +struct sfc_efx_mcdi_ops { + sfc_efx_mcdi_dma_alloc_cb *dma_alloc; + sfc_efx_mcdi_dma_free_cb *dma_free; +}; + struct sfc_efx_mcdi { rte_spinlock_t lock; + const struct sfc_efx_mcdi_ops *ops; + void *ops_cookie; efx_nic_t *nic; efsys_mem_t mem; enum sfc_efx_mcdi_state state; From patchwork Tue Sep 8 09:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76892 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0313A04AA; Tue, 8 Sep 2020 11:17:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B5DBE1C136; Tue, 8 Sep 2020 11:15:55 +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 577E41C11D for ; Tue, 8 Sep 2020 11:15:51 +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 E5593200C6 for ; Tue, 8 Sep 2020 09:15:50 +0000 (UTC) Received: from us4-mdac16-24.at1.mdlocal (unknown [10.110.49.206]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 2E388800D9 for ; Tue, 8 Sep 2020 09:15:50 +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 B7F0710010E for ; Tue, 8 Sep 2020 09:14:56 +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 7FC774006D for ; Tue, 8 Sep 2020 09:14:56 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889En1S032438 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id AD7A51613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:32 +0100 Message-ID: <1599556475-27820-13-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-6.498100-8.000000-10 X-TMASE-MatchedRID: fo0Y+APoFtkkVMQcdgU2qS2416nc3bQleouvej40T4gd0WOKRkwsh3Io zGa69omdrdoLblq9S5otr+iyiysSKDzCn0Lg6DUs+CjwEqX1p7lfAXPuWnqbj8d4gWcpDnUc3xf zp7pithHjq8Vr7gTGbixPati2bMiYFUPnz5fE4uOeAiCmPx4NwBnUJ0Ek6yhjxEHRux+uk8h+IC quNi0WJNBOAmY2z/6ZMog+FR5SfDBZVmWRTt7mqqoNmuMHFxc9ftwZ3X11IV0= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.498100-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556550-LtBxT8fjKZew Subject: [dpdk-dev] [PATCH 11/14] net/sfc: add MCDI callback to schedule restart 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" MC reboot handling is driver specific. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++-- drivers/net/sfc/sfc_mcdi.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 5077fcddd6..73dbd8194b 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -195,7 +195,7 @@ sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" : (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN"); - sfc_schedule_restart(sa); + mcdi->ops->sched_restart(mcdi->ops_cookie); } #define SFC_MCDI_LOG_BUF_SIZE 128 @@ -285,7 +285,8 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, efx_mcdi_transport_t *emtp; int rc; - if (ops->dma_alloc == NULL || ops->dma_free == NULL) + if (ops->dma_alloc == NULL || ops->dma_free == NULL || + ops->sched_restart == NULL) return EINVAL; SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); @@ -372,9 +373,19 @@ sfc_mcdi_dma_free(void *cookie, efsys_mem_t *esmp) sfc_dma_free(sa, esmp); } +static sfc_efx_mcdi_sched_restart_cb sfc_mcdi_sched_restart; +static void +sfc_mcdi_sched_restart(void *cookie) +{ + struct sfc_adapter *sa = cookie; + + sfc_schedule_restart(sa); +} + static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = { .dma_alloc = sfc_mcdi_dma_alloc, .dma_free = sfc_mcdi_dma_free, + .sched_restart = sfc_mcdi_sched_restart, }; int diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index ef24a8bc67..8f9b1991be 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -37,9 +37,12 @@ typedef int (sfc_efx_mcdi_dma_alloc_cb)(void *cookie, const char *name, typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp); +typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie); + struct sfc_efx_mcdi_ops { sfc_efx_mcdi_dma_alloc_cb *dma_alloc; sfc_efx_mcdi_dma_free_cb *dma_free; + sfc_efx_mcdi_sched_restart_cb *sched_restart; }; struct sfc_efx_mcdi { From patchwork Tue Sep 8 09:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76885 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 620DCA04AA; Tue, 8 Sep 2020 11:15:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CF031C0D4; Tue, 8 Sep 2020 11:15:35 +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 279C21C0C9 for ; Tue, 8 Sep 2020 11:15:34 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.137]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id BBAA7200C3 for ; Tue, 8 Sep 2020 09:15:33 +0000 (UTC) Received: from us4-mdac16-38.at1.mdlocal (unknown [10.110.51.53]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id B53E5600AA for ; Tue, 8 Sep 2020 09:15:33 +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 731DA2200AE for ; Tue, 8 Sep 2020 09:14:56 +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 3D3CD4006C for ; Tue, 8 Sep 2020 09:14:56 +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, 8 Sep 2020 10:14:49 +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, 8 Sep 2020 10:14:49 +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 0889Enl0032441 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id B8FB81613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:33 +0100 Message-ID: <1599556475-27820-14-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-4.214500-8.000000-10 X-TMASE-MatchedRID: eciAImCBKNA5s4xK97Sm/x23b+lJHvPAAp+UH372RZXjIxFSDv7HToWi qUsiuZWpnb6Z+uUpsD0Wsp6eJb7A26H2g9syPs88nFVnNmvv47tLXPA26IG0hNVTZaI6TuNoB+C gGa/H+9wanIBkYv3FTOe40v4bMUWP++XBDev6r0wkOFAoKA9tAti5W7Rf+s6QnyW4d6TKNpCjxY yRBa/qJcFwgTvxipFajoczmuoPCq19MVeTat8blRfgvD9PwrWadJRZ1VPYUgjVyC1amZPFktCaL pDHUriZoBW7lRysbr+9VEqXstCDWlah0ebfizTiH70wGipsuds3I8DUyOoaeU+wJNKvG6HQ1PNk ozhRY3HUNR3AhwxI7LAXtf+fj2qblExlQIQeRG0= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.214500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556530-xRw44okMOgeS Subject: [dpdk-dev] [PATCH 12/14] net/sfc: add MCDI callback to poll management event queue 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" Management event queue polling is required in the case of MCDI proxy authentication (client driver code). Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 14 ++++++++++++-- drivers/net/sfc/sfc_mcdi.h | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 73dbd8194b..fa9160f6d3 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -70,7 +70,7 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa) mcdi->proxy_handle = 0; mcdi->proxy_result = ETIMEDOUT; - sfc_ev_mgmt_qpoll(sa); + mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie); if (mcdi->proxy_result != ETIMEDOUT) return B_TRUE; @@ -286,7 +286,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, int rc; if (ops->dma_alloc == NULL || ops->dma_free == NULL || - ops->sched_restart == NULL) + ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL) return EINVAL; SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); @@ -382,10 +382,20 @@ sfc_mcdi_sched_restart(void *cookie) sfc_schedule_restart(sa); } +static sfc_efx_mcdi_mgmt_evq_poll_cb sfc_mcdi_mgmt_evq_poll; +static void +sfc_mcdi_mgmt_evq_poll(void *cookie) +{ + struct sfc_adapter *sa = cookie; + + sfc_ev_mgmt_qpoll(sa); +} + static const struct sfc_efx_mcdi_ops sfc_mcdi_ops = { .dma_alloc = sfc_mcdi_dma_alloc, .dma_free = sfc_mcdi_dma_free, .sched_restart = sfc_mcdi_sched_restart, + .mgmt_evq_poll = sfc_mcdi_mgmt_evq_poll, }; int diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h index 8f9b1991be..e3a637aeb7 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/net/sfc/sfc_mcdi.h @@ -39,10 +39,13 @@ typedef void (sfc_efx_mcdi_dma_free_cb)(void *cookie, efsys_mem_t *esmp); typedef void (sfc_efx_mcdi_sched_restart_cb)(void *cookie); +typedef void (sfc_efx_mcdi_mgmt_evq_poll_cb)(void *cookie); + struct sfc_efx_mcdi_ops { sfc_efx_mcdi_dma_alloc_cb *dma_alloc; sfc_efx_mcdi_dma_free_cb *dma_free; sfc_efx_mcdi_sched_restart_cb *sched_restart; + sfc_efx_mcdi_mgmt_evq_poll_cb *mgmt_evq_poll; }; struct sfc_efx_mcdi { From patchwork Tue Sep 8 09:14:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76891 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44EC6A04AA; Tue, 8 Sep 2020 11:16:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 786081C132; Tue, 8 Sep 2020 11:15:54 +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 5A05A1C11E for ; Tue, 8 Sep 2020 11:15:51 +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 E5547200C3 for ; Tue, 8 Sep 2020 09:15:50 +0000 (UTC) Received: from us4-mdac16-30.at1.mdlocal (unknown [10.110.49.214]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 2E334800D6 for ; Tue, 8 Sep 2020 09:15:50 +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 3109610010C for ; Tue, 8 Sep 2020 09:14:56 +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 EEB3040059 for ; Tue, 8 Sep 2020 09:14:55 +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, 8 Sep 2020 10:14:50 +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, 8 Sep 2020 10:14:49 +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 0889EnmU032444 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id C487B1613A9 for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:34 +0100 Message-ID: <1599556475-27820-15-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-12.951100-8.000000-10 X-TMASE-MatchedRID: 51SE6p2SBt+bX4K/DqV0NS2416nc3bQleouvej40T4gd0WOKRkwsh0Ac 6DyoS2rICNLuPteRDHcI+r1sul2OdnI/MxNRI7Uk66G2abPj6tjgXnxE81iyseMjEVIO/sdOdr6 6ANUOe/73OF0UjQGruresUpDYXvDYuVKcazUH+Z1C4WIP7GtYLFBijjE0XjY+OF0RIPSotdNT/4 0CMa1mSBkeVHs6jcMzJijtN0Yu2hFeFCVeyol8eRSceev8ZtpPMHi1Ydy2WEhHZg0gWH5yUbuKY ngtsWipqNfMRWfjbpalVflGDTl0k9vJMiGALwMaiuSat/QiCL99LQinZ4QefPcjNeVeWlqY+gtH j7OwNO0f/PIv6AGqLC8xrR8gzvMWsi2j+X+GYPYDrV+OTVs4TxzJZFa6wEQp X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--12.951100-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556550-5PGtEfA5dMrM Subject: [dpdk-dev] [PATCH 13/14] net/sfc: use MCDI control structure as libefx ops context 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" Now MCDI helpers interface is independent from network driver and may be moved into common driver. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_mcdi.c | 47 +++++++++++++++----------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index fa9160f6d3..ff2bc14c5d 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -52,10 +52,8 @@ sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__) static void -sfc_efx_mcdi_timeout(struct sfc_adapter *sa) +sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi) { - struct sfc_efx_mcdi *mcdi = &sa->mcdi; - sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT"); mcdi->state = SFC_EFX_MCDI_DEAD; @@ -64,10 +62,8 @@ sfc_efx_mcdi_timeout(struct sfc_adapter *sa) } static inline boolean_t -sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa) +sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi) { - struct sfc_efx_mcdi *mcdi = &sa->mcdi; - mcdi->proxy_handle = 0; mcdi->proxy_result = ETIMEDOUT; mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie); @@ -78,9 +74,8 @@ sfc_efx_mcdi_proxy_event_available(struct sfc_adapter *sa) } static void -sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) +sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy) { - struct sfc_efx_mcdi *mcdi = &sa->mcdi; efx_nic_t *enp; unsigned int delay_total; unsigned int delay_us; @@ -93,8 +88,9 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) do { boolean_t poll_completed; - poll_completed = (proxy) ? sfc_efx_mcdi_proxy_event_available(sa) : - efx_mcdi_request_poll(enp); + poll_completed = (proxy) ? + sfc_efx_mcdi_proxy_event_available(mcdi) : + efx_mcdi_request_poll(enp); if (poll_completed) return; @@ -102,7 +98,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) if (!proxy) { aborted = efx_mcdi_request_abort(enp); SFC_ASSERT(aborted); - sfc_efx_mcdi_timeout(sa); + sfc_efx_mcdi_timeout(mcdi); } return; @@ -125,8 +121,7 @@ sfc_efx_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy) static void sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) { - struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_efx_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; uint32_t proxy_handle; if (mcdi->state == SFC_EFX_MCDI_DEAD) { @@ -139,7 +134,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); - sfc_efx_mcdi_poll(sa, B_FALSE); + sfc_efx_mcdi_poll(mcdi, B_FALSE); if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) { /* @@ -148,7 +143,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) * a non-zero proxy handle (should be the same as * the value obtained above) and operation status */ - sfc_efx_mcdi_poll(sa, B_TRUE); + sfc_efx_mcdi_poll(mcdi, B_TRUE); if ((mcdi->proxy_handle != 0) && (mcdi->proxy_handle != proxy_handle)) { @@ -160,7 +155,7 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) * request and poll for an ordinary MCDI response */ efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); - sfc_efx_mcdi_poll(sa, B_FALSE); + sfc_efx_mcdi_poll(mcdi, B_FALSE); } else { emrp->emr_rc = mcdi->proxy_result; sfc_efx_mcdi_err(mcdi, @@ -175,10 +170,9 @@ sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) static void sfc_efx_mcdi_ev_cpl(void *arg) { - struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_efx_mcdi *mcdi __rte_unused; + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - mcdi = &sa->mcdi; + RTE_SET_USED(mcdi); SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); /* MCDI is polled, completions are not expected */ @@ -188,8 +182,7 @@ sfc_efx_mcdi_ev_cpl(void *arg) static void sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) { - struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_efx_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; sfc_efx_mcdi_warn(mcdi, "MC %s", (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" : @@ -234,8 +227,7 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, void *header, size_t header_size, void *data, size_t data_size) { - struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_efx_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; char buffer[SFC_MCDI_LOG_BUF_SIZE]; size_t pfxsize; size_t start; @@ -269,15 +261,14 @@ sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, static void sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) { - struct sfc_adapter *sa = (struct sfc_adapter *)arg; - struct sfc_efx_mcdi *mcdi = &sa->mcdi; + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; mcdi->proxy_handle = handle; mcdi->proxy_result = result; } static int -sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, +sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi, uint32_t logtype, const char *log_prefix, efx_nic_t *nic, const struct sfc_efx_mcdi_ops *ops, void *ops_cookie) { @@ -308,7 +299,7 @@ sfc_efx_mcdi_init(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi, goto fail_dma_alloc; emtp = &mcdi->transport; - emtp->emt_context = sa; + emtp->emt_context = mcdi; emtp->emt_dma_mem = &mcdi->mem; emtp->emt_execute = sfc_efx_mcdi_execute; emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl; @@ -409,7 +400,7 @@ sfc_mcdi_init(struct sfc_adapter *sa) SFC_LOGTYPE_MCDI_STR, RTE_LOG_NOTICE); - return sfc_efx_mcdi_init(sa, &sa->mcdi, logtype, + return sfc_efx_mcdi_init(&sa->mcdi, logtype, sa->priv.shared->log_prefix, sa->nic, &sfc_mcdi_ops, sa); } From patchwork Tue Sep 8 09:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 76899 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6154EA04AA; Tue, 8 Sep 2020 11:18:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4F8531C1BB; Tue, 8 Sep 2020 11:16:11 +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 AD5F91C18E for ; Tue, 8 Sep 2020 11:16:06 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.144]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 589E1200C4 for ; Tue, 8 Sep 2020 09:16:06 +0000 (UTC) Received: from us4-mdac16-61.at1.mdlocal (unknown [10.110.50.154]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 36172800EC for ; Tue, 8 Sep 2020 09:16:06 +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 AA3FA40136 for ; Tue, 8 Sep 2020 09:14:57 +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 11BB240071 for ; Tue, 8 Sep 2020 09:14:57 +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, 8 Sep 2020 10:14:50 +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, 8 Sep 2020 10:14:50 +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 0889En0T032447 for ; Tue, 8 Sep 2020 10:14:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id CFEC11613AB for ; Tue, 8 Sep 2020 10:14:49 +0100 (BST) From: Andrew Rybchenko To: Date: Tue, 8 Sep 2020 10:14:35 +0100 Message-ID: <1599556475-27820-16-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> References: <1599556475-27820-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25652.003 X-TM-AS-Result: No-16.077800-8.000000-10 X-TMASE-MatchedRID: UYy6qaIgCawOunQLDaXUBP3HILfxLV/9aeMaKzvXUpnRmpwtWlELp9nf JrUSEbFDMdqMWOXDAJTgLc5WU85ONq0iin8P0KjVT7O/YHJhINDVy4hHC3/gyLZk7gsuflVKY6s q+xRPSkD2Jb4m2Gw+EyPIolTqysMKeDPho5Jw+XCgcOgSnZOzMactle1frZabfkiy7TTogYa7Jw D4pCENFJFbAbroydJRhrjkhjhEe6+v6XrOv9OTH5N65fjGjYMQdkP4mJNdW+x90pZYV0vx9XGEu Q+dMAabbXRjJgWvj8vFW4nueYtaI+mwWKp2/We3caD+wPaBYtZQdXu/xf76ueMO0ez+CNLSuqBE 5JB7VxGo/ZGHCqwNWFnJbES9mdxApIyEjDucfRU+NrfDUTEXxFF5adRR2Ej1dBaEtWosUzWbfnT Dz+a2OV3heIBNVDnDQkXFL6ugRxOfJKoJNVF/JPgAhuaFie7S9/x+2nQH35Ix7ZAwjnj1hqKkU0 t47vZIdT86lTeOQqwnu+ManF2AdX1v/5buqFaOh4xZ8LCgzAxaNaxZBRbNWoNrxWMc29wLhmQTd IAaP8RuEaSUBN9mh7/nK9j4xFuhPIeX4ggjD6QAkh0TeBSwayWo4o4gXl+Q01c7LSleBSEuDhoR +qZH1x1wzDHVf16cyer92EreVsw3fzE3wKa/rKIBnfMCFBiCLPSJu5jov2bJeCU6fGMNn6PFjJE Fr+olwXCBO/GKkVqOhzOa6g8KrZRMZUCEHkRt X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--16.077800-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25652.003 X-MDID: 1599556562-3mwQkE_6yi1d Subject: [dpdk-dev] [PATCH 14/14] net/sfc: move MCDI helpers to common driver 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" These helper will be reused by other libefx consumers, e.g. vDPA driver. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/Makefile | 1 + drivers/common/sfc_efx/meson.build | 1 + .../sfc_efx/rte_common_sfc_efx_version.map | 9 +- drivers/common/sfc_efx/sfc_efx_mcdi.c | 343 ++++++++++++++++++ .../sfc_efx/sfc_efx_mcdi.h} | 12 +- drivers/net/sfc/sfc.h | 3 +- drivers/net/sfc/sfc_mcdi.c | 333 +---------------- 7 files changed, 360 insertions(+), 342 deletions(-) create mode 100644 drivers/common/sfc_efx/sfc_efx_mcdi.c rename drivers/{net/sfc/sfc_mcdi.h => common/sfc_efx/sfc_efx_mcdi.h} (81%) diff --git a/drivers/common/sfc_efx/Makefile b/drivers/common/sfc_efx/Makefile index 0bd6a593e9..bcbb15e789 100644 --- a/drivers/common/sfc_efx/Makefile +++ b/drivers/common/sfc_efx/Makefile @@ -58,6 +58,7 @@ EXPORT_MAP := rte_common_sfc_efx_version.map # SRCS-y += sfc_efx.c +SRCS-y += sfc_efx_mcdi.c VPATH += $(SRCDIR)/base diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build index 8fab4df792..b7a0763a34 100644 --- a/drivers/common/sfc_efx/meson.build +++ b/drivers/common/sfc_efx/meson.build @@ -34,6 +34,7 @@ objs = [base_objs] sources = files( 'sfc_efx.c', + 'sfc_efx_mcdi.c', ) includes += include_directories('base') diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map index 0c719e8250..8c010c90ac 100644 --- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map +++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map @@ -47,13 +47,7 @@ DPDK_21 { efx_mac_stats_update; efx_mac_stats_upload; - efx_mcdi_fini; - efx_mcdi_get_proxy_handle; - efx_mcdi_init; efx_mcdi_new_epoch; - efx_mcdi_request_abort; - efx_mcdi_request_poll; - efx_mcdi_request_start; efx_nic_cfg_get; efx_nic_create; @@ -118,5 +112,8 @@ DPDK_21 { efx_tx_qpush; efx_txq_size; + sfc_efx_mcdi_init; + sfc_efx_mcdi_fini; + local: *; }; diff --git a/drivers/common/sfc_efx/sfc_efx_mcdi.c b/drivers/common/sfc_efx/sfc_efx_mcdi.c new file mode 100644 index 0000000000..7eb565bbd6 --- /dev/null +++ b/drivers/common/sfc_efx/sfc_efx_mcdi.c @@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2016-2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#include + +#include "efx.h" +#include "efx_mcdi.h" +#include "efx_regs_mcdi.h" + +#include "sfc_efx_mcdi.h" +#include "sfc_efx_debug.h" + +#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us */ +#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms */ +#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s */ + +#define sfc_efx_mcdi_log(mcdi, level, ...) \ + do { \ + const struct sfc_efx_mcdi *_mcdi = (mcdi); \ + \ + rte_log(level, _mcdi->logtype, \ + RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + _mcdi->log_prefix, \ + RTE_FMT_TAIL(__VA_ARGS__,))); \ + } while (0) + +#define sfc_efx_mcdi_crit(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__) + +#define sfc_efx_mcdi_err(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__) + +#define sfc_efx_mcdi_warn(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__) + +#define sfc_efx_mcdi_info(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__) + +/** Level value used by MCDI log statements */ +#define SFC_EFX_LOG_LEVEL_MCDI RTE_LOG_INFO + +#define sfc_efx_log_mcdi(mcdi, ...) \ + sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__) + +static void +sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi) +{ + sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT"); + + sfc_efx_mcdi_crit(mcdi, "MCDI timeout handling is not implemented"); + sfc_efx_mcdi_crit(mcdi, "NIC is unusable"); + mcdi->state = SFC_EFX_MCDI_DEAD; +} + +static inline boolean_t +sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi) +{ + mcdi->proxy_handle = 0; + mcdi->proxy_result = ETIMEDOUT; + mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie); + if (mcdi->proxy_result != ETIMEDOUT) + return B_TRUE; + + return B_FALSE; +} + +static void +sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy) +{ + efx_nic_t *enp; + unsigned int delay_total; + unsigned int delay_us; + boolean_t aborted __rte_unused; + + delay_total = 0; + delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US; + enp = mcdi->nic; + + do { + boolean_t poll_completed; + + poll_completed = (proxy) ? + sfc_efx_mcdi_proxy_event_available(mcdi) : + efx_mcdi_request_poll(enp); + if (poll_completed) + return; + + if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) { + if (!proxy) { + aborted = efx_mcdi_request_abort(enp); + SFC_EFX_ASSERT(aborted); + sfc_efx_mcdi_timeout(mcdi); + } + + return; + } + + rte_delay_us(delay_us); + + delay_total += delay_us; + + /* Exponentially back off the poll frequency */ + RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US > + UINT_MAX / 2); + delay_us *= 2; + if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US) + delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US; + + } while (1); +} + +static void +sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) +{ + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; + uint32_t proxy_handle; + + if (mcdi->state == SFC_EFX_MCDI_DEAD) { + emrp->emr_rc = ENOEXEC; + return; + } + + rte_spinlock_lock(&mcdi->lock); + + SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); + + efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); + sfc_efx_mcdi_poll(mcdi, B_FALSE); + + if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) { + /* + * Authorization is required for the MCDI request; + * wait for an MCDI proxy response event to bring + * a non-zero proxy handle (should be the same as + * the value obtained above) and operation status + */ + sfc_efx_mcdi_poll(mcdi, B_TRUE); + + if ((mcdi->proxy_handle != 0) && + (mcdi->proxy_handle != proxy_handle)) { + sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event"); + emrp->emr_rc = EFAULT; + } else if (mcdi->proxy_result == 0) { + /* + * Authorization succeeded; re-issue the original + * request and poll for an ordinary MCDI response + */ + efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); + sfc_efx_mcdi_poll(mcdi, B_FALSE); + } else { + emrp->emr_rc = mcdi->proxy_result; + sfc_efx_mcdi_err(mcdi, + "MCDI proxy authorization failed (handle=%08x, result=%d)", + proxy_handle, mcdi->proxy_result); + } + } + + rte_spinlock_unlock(&mcdi->lock); +} + +static void +sfc_efx_mcdi_ev_cpl(void *arg) +{ + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; + + RTE_SET_USED(mcdi); + SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); + + /* MCDI is polled, completions are not expected */ + SFC_EFX_ASSERT(0); +} + +static void +sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) +{ + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; + + sfc_efx_mcdi_warn(mcdi, "MC %s", + (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" : + (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN"); + + mcdi->ops->sched_restart(mcdi->ops_cookie); +} + +#define SFC_MCDI_LOG_BUF_SIZE 128 + +static size_t +sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi, + char *buffer, void *data, size_t data_size, + size_t pfxsize, size_t position) +{ + uint32_t *words = data; + /* Space separator plus 2 characters per byte */ + const size_t word_str_space = 1 + 2 * sizeof(*words); + size_t i; + + for (i = 0; i < data_size; i += sizeof(*words)) { + if (position + word_str_space >= + SFC_MCDI_LOG_BUF_SIZE) { + /* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash + * at the end which is required by netlogdecode. + */ + buffer[position] = '\0'; + sfc_efx_log_mcdi(mcdi, "%s \\", buffer); + /* Preserve prefix for the next log message */ + position = pfxsize; + } + position += snprintf(buffer + position, + SFC_MCDI_LOG_BUF_SIZE - position, + " %08x", *words); + words++; + } + return position; +} + +static void +sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, + void *header, size_t header_size, + void *data, size_t data_size) +{ + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; + char buffer[SFC_MCDI_LOG_BUF_SIZE]; + size_t pfxsize; + size_t start; + + /* + * Unlike the other cases, MCDI logging implies more onerous work + * needed to produce a message. If the dynamic log level prevents + * the end result from being printed, the CPU time will be wasted. + * + * To avoid wasting time, the actual level is examined in advance. + */ + if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI) + return; + + /* The format including prefix added by sfc_efx_log_mcdi() is the + * format consumed by the Solarflare netlogdecode tool. + */ + pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:", + type == EFX_LOG_MCDI_REQUEST ? "REQ" : + type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???"); + start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size, + pfxsize, pfxsize); + start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size, + pfxsize, start); + if (start != pfxsize) { + buffer[start] = '\0'; + sfc_efx_log_mcdi(mcdi, "%s", buffer); + } +} + +static void +sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) +{ + struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; + + mcdi->proxy_handle = handle; + mcdi->proxy_result = result; +} + +int +sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi, + uint32_t logtype, const char *log_prefix, efx_nic_t *nic, + const struct sfc_efx_mcdi_ops *ops, void *ops_cookie) +{ + size_t max_msg_size; + efx_mcdi_transport_t *emtp; + int rc; + + if (ops->dma_alloc == NULL || ops->dma_free == NULL || + ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL) + return EINVAL; + + SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); + + rte_spinlock_init(&mcdi->lock); + + mcdi->ops = ops; + mcdi->ops_cookie = ops_cookie; + mcdi->nic = nic; + + mcdi->state = SFC_EFX_MCDI_INITIALIZED; + + mcdi->logtype = logtype; + mcdi->log_prefix = log_prefix; + + max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2; + rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem); + if (rc != 0) + goto fail_dma_alloc; + + emtp = &mcdi->transport; + emtp->emt_context = mcdi; + emtp->emt_dma_mem = &mcdi->mem; + emtp->emt_execute = sfc_efx_mcdi_execute; + emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl; + emtp->emt_exception = sfc_efx_mcdi_exception; + emtp->emt_logger = sfc_efx_mcdi_logger; + emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response; + + sfc_efx_mcdi_info(mcdi, "init MCDI"); + rc = efx_mcdi_init(mcdi->nic, emtp); + if (rc != 0) + goto fail_mcdi_init; + + return 0; + +fail_mcdi_init: + memset(emtp, 0, sizeof(*emtp)); + ops->dma_free(ops_cookie, &mcdi->mem); + +fail_dma_alloc: + mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; + return rc; +} + +void +sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi) +{ + efx_mcdi_transport_t *emtp; + + emtp = &mcdi->transport; + + rte_spinlock_lock(&mcdi->lock); + + SFC_EFX_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED || + mcdi->state == SFC_EFX_MCDI_DEAD); + mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; + + sfc_efx_mcdi_info(mcdi, "fini MCDI"); + efx_mcdi_fini(mcdi->nic); + memset(emtp, 0, sizeof(*emtp)); + + rte_spinlock_unlock(&mcdi->lock); + + mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem); +} diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/common/sfc_efx/sfc_efx_mcdi.h similarity index 81% rename from drivers/net/sfc/sfc_mcdi.h rename to drivers/common/sfc_efx/sfc_efx_mcdi.h index e3a637aeb7..836afacddc 100644 --- a/drivers/net/sfc/sfc_mcdi.h +++ b/drivers/common/sfc_efx/sfc_efx_mcdi.h @@ -7,8 +7,8 @@ * for Solarflare) and Solarflare Communications, Inc. */ -#ifndef _SFC_MCDI_H -#define _SFC_MCDI_H +#ifndef _SFC_EFX_MCDI_H +#define _SFC_EFX_MCDI_H #include @@ -62,8 +62,14 @@ struct sfc_efx_mcdi { const char *log_prefix; }; +int sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi, + uint32_t logtype, const char *log_prefix, + efx_nic_t *nic, + const struct sfc_efx_mcdi_ops *ops, void *ops_cookie); +void sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi); + #ifdef __cplusplus } #endif -#endif /* _SFC_MCDI_H */ +#endif /* _SFC_EFX_MCDI_H */ diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index b20fecb4f8..fa7c79b80b 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -21,10 +21,11 @@ #include "efx.h" +#include "sfc_efx_mcdi.h" + #include "sfc_debug.h" #include "sfc_log.h" #include "sfc_filter.h" -#include "sfc_mcdi.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index ff2bc14c5d..644dd9c980 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -7,344 +7,13 @@ * for Solarflare) and Solarflare Communications, Inc. */ -#include +#include "sfc_efx_mcdi.h" -#include "efx.h" -#include "efx_mcdi.h" -#include "efx_regs_mcdi.h" - -#include "sfc_mcdi.h" #include "sfc.h" #include "sfc_debug.h" #include "sfc_log.h" #include "sfc_ev.h" -#define SFC_EFX_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us */ -#define SFC_EFX_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms */ -#define SFC_EFX_MCDI_WATCHDOG_INTERVAL_US (10 * US_PER_S) /* 10s */ - -#define sfc_efx_mcdi_log(mcdi, level, ...) \ - do { \ - const struct sfc_efx_mcdi *_mcdi = (mcdi); \ - \ - rte_log(level, _mcdi->logtype, \ - RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ - _mcdi->log_prefix, \ - RTE_FMT_TAIL(__VA_ARGS__,))); \ - } while (0) - -#define sfc_efx_mcdi_crit(mcdi, ...) \ - sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__) - -#define sfc_efx_mcdi_err(mcdi, ...) \ - sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__) - -#define sfc_efx_mcdi_warn(mcdi, ...) \ - sfc_efx_mcdi_log(mcdi, RTE_LOG_WARNING, __VA_ARGS__) - -#define sfc_efx_mcdi_info(mcdi, ...) \ - sfc_efx_mcdi_log(mcdi, RTE_LOG_INFO, __VA_ARGS__) - -/** Level value used by MCDI log statements */ -#define SFC_EFX_LOG_LEVEL_MCDI RTE_LOG_INFO - -#define sfc_efx_log_mcdi(mcdi, ...) \ - sfc_efx_mcdi_log(mcdi, SFC_EFX_LOG_LEVEL_MCDI, __VA_ARGS__) - -static void -sfc_efx_mcdi_timeout(struct sfc_efx_mcdi *mcdi) -{ - sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT"); - - mcdi->state = SFC_EFX_MCDI_DEAD; - sfc_efx_mcdi_crit(mcdi, - "MCDI timeout handling is not implemented - NIC is unusable"); -} - -static inline boolean_t -sfc_efx_mcdi_proxy_event_available(struct sfc_efx_mcdi *mcdi) -{ - mcdi->proxy_handle = 0; - mcdi->proxy_result = ETIMEDOUT; - mcdi->ops->mgmt_evq_poll(mcdi->ops_cookie); - if (mcdi->proxy_result != ETIMEDOUT) - return B_TRUE; - - return B_FALSE; -} - -static void -sfc_efx_mcdi_poll(struct sfc_efx_mcdi *mcdi, boolean_t proxy) -{ - efx_nic_t *enp; - unsigned int delay_total; - unsigned int delay_us; - boolean_t aborted __rte_unused; - - delay_total = 0; - delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MIN_US; - enp = mcdi->nic; - - do { - boolean_t poll_completed; - - poll_completed = (proxy) ? - sfc_efx_mcdi_proxy_event_available(mcdi) : - efx_mcdi_request_poll(enp); - if (poll_completed) - return; - - if (delay_total > SFC_EFX_MCDI_WATCHDOG_INTERVAL_US) { - if (!proxy) { - aborted = efx_mcdi_request_abort(enp); - SFC_ASSERT(aborted); - sfc_efx_mcdi_timeout(mcdi); - } - - return; - } - - rte_delay_us(delay_us); - - delay_total += delay_us; - - /* Exponentially back off the poll frequency */ - RTE_BUILD_BUG_ON(SFC_EFX_MCDI_POLL_INTERVAL_MAX_US > - UINT_MAX / 2); - delay_us *= 2; - if (delay_us > SFC_EFX_MCDI_POLL_INTERVAL_MAX_US) - delay_us = SFC_EFX_MCDI_POLL_INTERVAL_MAX_US; - - } while (1); -} - -static void -sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp) -{ - struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - uint32_t proxy_handle; - - if (mcdi->state == SFC_EFX_MCDI_DEAD) { - emrp->emr_rc = ENOEXEC; - return; - } - - rte_spinlock_lock(&mcdi->lock); - - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); - - efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); - sfc_efx_mcdi_poll(mcdi, B_FALSE); - - if (efx_mcdi_get_proxy_handle(mcdi->nic, emrp, &proxy_handle) == 0) { - /* - * Authorization is required for the MCDI request; - * wait for an MCDI proxy response event to bring - * a non-zero proxy handle (should be the same as - * the value obtained above) and operation status - */ - sfc_efx_mcdi_poll(mcdi, B_TRUE); - - if ((mcdi->proxy_handle != 0) && - (mcdi->proxy_handle != proxy_handle)) { - sfc_efx_mcdi_err(mcdi, "Unexpected MCDI proxy event"); - emrp->emr_rc = EFAULT; - } else if (mcdi->proxy_result == 0) { - /* - * Authorization succeeded; re-issue the original - * request and poll for an ordinary MCDI response - */ - efx_mcdi_request_start(mcdi->nic, emrp, B_FALSE); - sfc_efx_mcdi_poll(mcdi, B_FALSE); - } else { - emrp->emr_rc = mcdi->proxy_result; - sfc_efx_mcdi_err(mcdi, - "MCDI proxy authorization failed (handle=%08x, result=%d)", - proxy_handle, mcdi->proxy_result); - } - } - - rte_spinlock_unlock(&mcdi->lock); -} - -static void -sfc_efx_mcdi_ev_cpl(void *arg) -{ - struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - - RTE_SET_USED(mcdi); - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED); - - /* MCDI is polled, completions are not expected */ - SFC_ASSERT(0); -} - -static void -sfc_efx_mcdi_exception(void *arg, efx_mcdi_exception_t eme) -{ - struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - - sfc_efx_mcdi_warn(mcdi, "MC %s", - (eme == EFX_MCDI_EXCEPTION_MC_REBOOT) ? "REBOOT" : - (eme == EFX_MCDI_EXCEPTION_MC_BADASSERT) ? "BADASSERT" : "UNKNOWN"); - - mcdi->ops->sched_restart(mcdi->ops_cookie); -} - -#define SFC_MCDI_LOG_BUF_SIZE 128 - -static size_t -sfc_efx_mcdi_do_log(const struct sfc_efx_mcdi *mcdi, - char *buffer, void *data, size_t data_size, - size_t pfxsize, size_t position) -{ - uint32_t *words = data; - /* Space separator plus 2 characters per byte */ - const size_t word_str_space = 1 + 2 * sizeof(*words); - size_t i; - - for (i = 0; i < data_size; i += sizeof(*words)) { - if (position + word_str_space >= - SFC_MCDI_LOG_BUF_SIZE) { - /* Flush at SFC_MCDI_LOG_BUF_SIZE with backslash - * at the end which is required by netlogdecode. - */ - buffer[position] = '\0'; - sfc_efx_log_mcdi(mcdi, "%s \\", buffer); - /* Preserve prefix for the next log message */ - position = pfxsize; - } - position += snprintf(buffer + position, - SFC_MCDI_LOG_BUF_SIZE - position, - " %08x", *words); - words++; - } - return position; -} - -static void -sfc_efx_mcdi_logger(void *arg, efx_log_msg_t type, - void *header, size_t header_size, - void *data, size_t data_size) -{ - struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - char buffer[SFC_MCDI_LOG_BUF_SIZE]; - size_t pfxsize; - size_t start; - - /* - * Unlike the other cases, MCDI logging implies more onerous work - * needed to produce a message. If the dynamic log level prevents - * the end result from being printed, the CPU time will be wasted. - * - * To avoid wasting time, the actual level is examined in advance. - */ - if (rte_log_get_level(mcdi->logtype) < (int)SFC_EFX_LOG_LEVEL_MCDI) - return; - - /* The format including prefix added by sfc_efx_log_mcdi() is the - * format consumed by the Solarflare netlogdecode tool. - */ - pfxsize = snprintf(buffer, sizeof(buffer), "MCDI RPC %s:", - type == EFX_LOG_MCDI_REQUEST ? "REQ" : - type == EFX_LOG_MCDI_RESPONSE ? "RESP" : "???"); - start = sfc_efx_mcdi_do_log(mcdi, buffer, header, header_size, - pfxsize, pfxsize); - start = sfc_efx_mcdi_do_log(mcdi, buffer, data, data_size, - pfxsize, start); - if (start != pfxsize) { - buffer[start] = '\0'; - sfc_efx_log_mcdi(mcdi, "%s", buffer); - } -} - -static void -sfc_efx_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result) -{ - struct sfc_efx_mcdi *mcdi = (struct sfc_efx_mcdi *)arg; - - mcdi->proxy_handle = handle; - mcdi->proxy_result = result; -} - -static int -sfc_efx_mcdi_init(struct sfc_efx_mcdi *mcdi, - uint32_t logtype, const char *log_prefix, efx_nic_t *nic, - const struct sfc_efx_mcdi_ops *ops, void *ops_cookie) -{ - size_t max_msg_size; - efx_mcdi_transport_t *emtp; - int rc; - - if (ops->dma_alloc == NULL || ops->dma_free == NULL || - ops->sched_restart == NULL || ops->mgmt_evq_poll == NULL) - return EINVAL; - - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_UNINITIALIZED); - - rte_spinlock_init(&mcdi->lock); - - mcdi->ops = ops; - mcdi->ops_cookie = ops_cookie; - mcdi->nic = nic; - - mcdi->state = SFC_EFX_MCDI_INITIALIZED; - - mcdi->logtype = logtype; - mcdi->log_prefix = log_prefix; - - max_msg_size = sizeof(uint32_t) + MCDI_CTL_SDU_LEN_MAX_V2; - rc = ops->dma_alloc(ops_cookie, "mcdi", max_msg_size, &mcdi->mem); - if (rc != 0) - goto fail_dma_alloc; - - emtp = &mcdi->transport; - emtp->emt_context = mcdi; - emtp->emt_dma_mem = &mcdi->mem; - emtp->emt_execute = sfc_efx_mcdi_execute; - emtp->emt_ev_cpl = sfc_efx_mcdi_ev_cpl; - emtp->emt_exception = sfc_efx_mcdi_exception; - emtp->emt_logger = sfc_efx_mcdi_logger; - emtp->emt_ev_proxy_response = sfc_efx_mcdi_ev_proxy_response; - - sfc_efx_mcdi_info(mcdi, "init MCDI"); - rc = efx_mcdi_init(mcdi->nic, emtp); - if (rc != 0) - goto fail_mcdi_init; - - return 0; - -fail_mcdi_init: - memset(emtp, 0, sizeof(*emtp)); - ops->dma_free(ops_cookie, &mcdi->mem); - -fail_dma_alloc: - mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; - return rc; -} - -static void -sfc_efx_mcdi_fini(struct sfc_efx_mcdi *mcdi) -{ - efx_mcdi_transport_t *emtp; - - emtp = &mcdi->transport; - - rte_spinlock_lock(&mcdi->lock); - - SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED || - mcdi->state == SFC_EFX_MCDI_DEAD); - mcdi->state = SFC_EFX_MCDI_UNINITIALIZED; - - sfc_efx_mcdi_info(mcdi, "fini MCDI"); - efx_mcdi_fini(mcdi->nic); - memset(emtp, 0, sizeof(*emtp)); - - rte_spinlock_unlock(&mcdi->lock); - - mcdi->ops->dma_free(mcdi->ops_cookie, &mcdi->mem); -} - static sfc_efx_mcdi_dma_alloc_cb sfc_mcdi_dma_alloc; static int sfc_mcdi_dma_alloc(void *cookie, const char *name, size_t len,