From patchwork Thu Jun 22 03:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Pryazhennikov X-Patchwork-Id: 128901 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7CE142D1D; Thu, 22 Jun 2023 05:48:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D14042D12; Thu, 22 Jun 2023 05:47:52 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 851A7410FC for ; Thu, 22 Jun 2023 05:47:42 +0200 (CEST) Received: from localhost.localdomain (unknown [37.252.90.118]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA512) (No client certificate requested) by agw.arknetworks.am (Postfix) with ESMTPSA id F3D05E0924; Thu, 22 Jun 2023 07:47:41 +0400 (+04) From: Denis Pryazhennikov To: dev@dpdk.org Cc: Ferruh Yigit , Andrew Rybchenko , Roman Zhukov , Andy Moreton Subject: [PATCH v2 3/4] common/sfc_efx/base: add support for configure MAC to keep FCS Date: Thu, 22 Jun 2023 07:47:37 +0400 Message-Id: <20230622034738.51288-4-denis.pryazhennikov@arknetworks.am> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230622034738.51288-1-denis.pryazhennikov@arknetworks.am> References: <20230601114220.17796-1-denis.pryazhennikov@arknetworks.am> <20230622034738.51288-1-denis.pryazhennikov@arknetworks.am> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Roman Zhukov Drivers cannot determine if received packet includes the FCS or not. Only packets with an external port have the FCS included and functions without link control privilege cannot determine the MAC configuration. This patch is trying to make assumptions that: if PF is the only function (there are no VFs or additional PFs); it can set the MAC configuration and it never expects packets it sends to be looped back then it can assume that changed the MAC configuration to include the FCS is safe and that all received packets will include their FCS. Signed-off-by: Roman Zhukov Signed-off-by: Denis Pryazhennikov Reviewed-by: Andy Moreton Acked-by: Andrew Rybchenko --- drivers/common/sfc_efx/base/ef10_mac.c | 5 +-- drivers/common/sfc_efx/base/efx.h | 5 +++ drivers/common/sfc_efx/base/efx_impl.h | 1 + drivers/common/sfc_efx/base/efx_mac.c | 48 ++++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 5 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/common/sfc_efx/base/ef10_mac.c b/drivers/common/sfc_efx/base/ef10_mac.c index 28228a9fb784..bfc82b80c7e5 100644 --- a/drivers/common/sfc_efx/base/ef10_mac.c +++ b/drivers/common/sfc_efx/base/ef10_mac.c @@ -307,9 +307,10 @@ ef10_mac_reconfigure( */ MCDI_IN_SET_DWORD(req, SET_MAC_IN_FCNTL, MC_CMD_FCNTL_AUTO); - /* Do not include the Ethernet frame checksum in RX packets */ + /* Include the Ethernet frame checksum in RX packets if it's required */ MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_IN_FLAGS, - SET_MAC_IN_FLAG_INCLUDE_FCS, 0); + SET_MAC_IN_FLAG_INCLUDE_FCS, + epp->ep_include_fcs ? 1 : 0); efx_mcdi_execute_quiet(enp, &req); diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index b5bd390169ae..ef626cc55a7e 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -747,6 +747,11 @@ efx_mac_fcntl_get( __out unsigned int *fcntl_wantedp, __out unsigned int *fcntl_linkp); +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mac_include_fcs_set( + __in efx_nic_t *enp, + __in boolean_t enabled); #if EFSYS_OPT_MAC_STATS diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 09b1e95c594c..92a30c34ae28 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -363,6 +363,7 @@ typedef struct efx_port_s { uint32_t ep_default_adv_cap_mask; uint32_t ep_phy_cap_mask; boolean_t ep_mac_drain; + boolean_t ep_include_fcs; #if EFSYS_OPT_BIST efx_bist_type_t ep_current_bist; #endif diff --git a/drivers/common/sfc_efx/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c index c51e86b52c29..13cac5a75130 100644 --- a/drivers/common/sfc_efx/base/efx_mac.c +++ b/drivers/common/sfc_efx/base/efx_mac.c @@ -527,6 +527,54 @@ efx_mac_filter_default_rxq_clear( emop->emo_filter_default_rxq_clear(enp); } + __checkReturn efx_rc_t +efx_mac_include_fcs_set( + __in efx_nic_t *enp, + __in boolean_t enabled) +{ + efx_port_t *epp = &(enp->en_port); + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); + const efx_mac_ops_t *emop = epp->ep_emop; + efx_rc_t rc; + + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); + EFSYS_ASSERT(emop != NULL); + + if (enabled && !encp->enc_rx_include_fcs_supported) { + rc = ENOTSUP; + goto fail1; + } + + /* + * Enabling 'include FCS' changes link control state and affects + * behaviour for all PCI functions on the port, so to avoid this it + * can be enabled only if the PCI function is exclusive port user + */ + if (enabled && encp->enc_port_usage != EFX_PORT_USAGE_EXCLUSIVE) { + rc = EACCES; + goto fail2; + } + + if (epp->ep_include_fcs != enabled) { + epp->ep_include_fcs = enabled; + + rc = emop->emo_reconfigure(enp); + if (rc != 0) + goto fail3; + } + + return 0; + +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return rc; +} #if EFSYS_OPT_MAC_STATS diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index e91bcbcad863..01113bffa7cb 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -71,6 +71,7 @@ INTERNAL { efx_mac_drain; efx_mac_fcntl_get; efx_mac_fcntl_set; + efx_mac_include_fcs_set; efx_mac_filter_default_rxq_clear; efx_mac_filter_default_rxq_set; efx_mac_filter_get_all_ucast_mcast;