DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@arknetworks.am>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Andy Moreton <andy.moreton@amd.com>,
	Pieter Jansen Van Vuuren <pieter.jansen-van-vuuren@amd.com>,
	Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Subject: [PATCH v2 36/45] common/sfc_efx/base: correct MAC PDU calculation on Medford4
Date: Wed, 23 Apr 2025 19:59:53 +0400	[thread overview]
Message-ID: <20250423160002.35706-37-ivan.malov@arknetworks.am> (raw)
In-Reply-To: <20250423160002.35706-1-ivan.malov@arknetworks.am>

For managing MAC PDU (max. frame size), client drivers apply
EFX macros to switch between PDU and SDU forms. These macros
include a workaround for a bug that dates back to Siena NICs.

Starting with Medford4, the bug is no longer there and it is
wrong to use the macros, so provide users with a replacement.
The new APIs will either include the said workaround or omit
it, depending on whether support for netport MCDI is present.

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <andy.moreton@amd.com>
Reviewed-by: Pieter Jansen Van Vuuren <pieter.jansen-van-vuuren@amd.com>
---
 drivers/common/sfc_efx/base/efx.h         | 25 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_mac.c     | 19 +++++++++++++++--
 drivers/common/sfc_efx/base/efx_nic.c     |  3 +++
 drivers/common/sfc_efx/sfc_base_symbols.c |  1 +
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 6ca108cffe..73dc38f84e 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -668,24 +668,45 @@ typedef enum efx_link_mode_e {
 
 #define	EFX_MAC_SDU_MAX	9202
 
+/*
+ * NOTE: the PDU macros implement an obsolete workaround that is needed for
+ * MC_CMD_SET_MAC; do not use the PDU macros for the netport MCDI commands,
+ * which do not use the workaround.
+ */
+
 #define	EFX_MAC_PDU_ADJUSTMENT					\
 	(/* EtherII */ 14					\
 	    + /* VLAN */ 4					\
 	    + /* CRC */ 4					\
 	    + /* bug16011 */ 16)				\
 
+/* NOTE: this macro is deprecated; use efx_mac_pdu_from_sdu(). */
 #define	EFX_MAC_PDU(_sdu)					\
 	EFX_P2ROUNDUP(size_t, (_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8)
 
 /*
  * Due to the EFX_P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give
  * the SDU rounded up slightly.
+ *
+ * NOTE: do not use this macro in new code as it is
+ * incorrect for the netport MCDI commands.
  */
 #define	EFX_MAC_SDU_FROM_PDU(_pdu)	((_pdu) - EFX_MAC_PDU_ADJUSTMENT)
 
 #define	EFX_MAC_PDU_MIN	60
+
+/* NOTE: this macro is deprecated; use encp->enc_mac_pdu_max. */
 #define	EFX_MAC_PDU_MAX	EFX_MAC_PDU(EFX_MAC_SDU_MAX)
 
+/*
+ * For use with efx_mac_pdu_set(), convert the given SDU value to its PDU form.
+ */
+LIBEFX_API
+extern			size_t
+efx_mac_pdu_from_sdu(
+	__in		efx_nic_t *enp,
+	__in		size_t sdu);
+
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
 efx_mac_pdu_get(
@@ -1729,6 +1750,10 @@ typedef struct efx_nic_cfg_s {
 	efx_nic_dma_mapping_t	enc_dma_mapping;
 	/* Physical ports shared by PFs */
 	efx_port_usage_t	enc_port_usage;
+	/* Minimum MAC PDU value to use with efx_mac_pdu_set() */
+	uint32_t		enc_mac_pdu_min;
+	/* Maximum MAC PDU value to use with efx_mac_pdu_set() */
+	uint32_t		enc_mac_pdu_max;
 } efx_nic_cfg_t;
 
 #define	EFX_PCI_VF_INVALID 0xffff
diff --git a/drivers/common/sfc_efx/base/efx_mac.c b/drivers/common/sfc_efx/base/efx_mac.c
index 9a0cf64fd9..69f053ce44 100644
--- a/drivers/common/sfc_efx/base/efx_mac.c
+++ b/drivers/common/sfc_efx/base/efx_mac.c
@@ -114,6 +114,20 @@ static const efx_mac_ops_t	__efx_mac_medford4_ops = {
 };
 #endif /* EFSYS_OPT_MEDFORD4 */
 
+			size_t
+efx_mac_pdu_from_sdu(
+	__in		efx_nic_t *enp,
+	__in		size_t sdu)
+{
+	if (efx_np_supported(enp) != B_FALSE) {
+		/* PDU size for netport MCDI capable adaptors. */
+		return sdu + 14 /* ETH */ + 4 /* VLAN */ + 4 /* FCS */;
+	} else {
+		/* PDU size for legacy MC_CMD_SET_MAC command. */
+		return EFX_MAC_PDU(sdu);
+	}
+}
+
 	__checkReturn			efx_rc_t
 efx_mac_pdu_set(
 	__in				efx_nic_t *enp,
@@ -121,6 +135,7 @@ efx_mac_pdu_set(
 {
 	efx_port_t *epp = &(enp->en_port);
 	const efx_mac_ops_t *emop = epp->ep_emop;
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
 	uint32_t old_pdu;
 	efx_rc_t rc;
 
@@ -128,12 +143,12 @@ efx_mac_pdu_set(
 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
 	EFSYS_ASSERT(emop != NULL);
 
-	if (pdu < EFX_MAC_PDU_MIN) {
+	if (pdu < encp->enc_mac_pdu_min) {
 		rc = EINVAL;
 		goto fail1;
 	}
 
-	if (pdu > EFX_MAC_PDU_MAX) {
+	if (pdu > encp->enc_mac_pdu_max) {
 		rc = EINVAL;
 		goto fail2;
 	}
diff --git a/drivers/common/sfc_efx/base/efx_nic.c b/drivers/common/sfc_efx/base/efx_nic.c
index 1ec684da40..1c25270792 100644
--- a/drivers/common/sfc_efx/base/efx_nic.c
+++ b/drivers/common/sfc_efx/base/efx_nic.c
@@ -491,6 +491,9 @@ efx_nic_probe(
 
 	encp->enc_features = enp->en_features;
 
+	encp->enc_mac_pdu_max = efx_mac_pdu_from_sdu(enp, EFX_MAC_SDU_MAX);
+	encp->enc_mac_pdu_min = EFX_MAC_PDU_MIN;
+
 	if ((rc = efx_phy_probe(enp)) != 0)
 		goto fail2;
 
diff --git a/drivers/common/sfc_efx/sfc_base_symbols.c b/drivers/common/sfc_efx/sfc_base_symbols.c
index ae6605632d..0e74034031 100644
--- a/drivers/common/sfc_efx/sfc_base_symbols.c
+++ b/drivers/common/sfc_efx/sfc_base_symbols.c
@@ -59,6 +59,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(efx_intr_trigger)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_intr_status_line)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_intr_status_message)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_intr_fatal)
+RTE_EXPORT_INTERNAL_SYMBOL(efx_mac_pdu_from_sdu)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_mac_pdu_set)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_mac_pdu_get)
 RTE_EXPORT_INTERNAL_SYMBOL(efx_mac_addr_set)
-- 
2.39.5


  parent reply	other threads:[~2025-04-23 16:05 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 13:59 [PATCH 00/46] Support AMD Solarflare X45xx adaptors Ivan Malov
2025-04-16 13:59 ` [PATCH 01/46] common/sfc_efx/base: add Medford4 PCI IDs to common code Ivan Malov
2025-04-16 13:59 ` [PATCH 02/46] common/sfc_efx/base: add efsys option for Medford4 Ivan Malov
2025-04-17  7:08   ` Andrew Rybchenko
2025-04-17 15:07     ` Stephen Hemminger
2025-04-18  7:25       ` Andrew Rybchenko
2025-04-16 13:59 ` [PATCH 03/46] common/sfc_efx/base: add Medford4 support to NIC module Ivan Malov
2025-04-17  7:14   ` Andrew Rybchenko
2025-04-16 13:59 ` [PATCH 04/46] common/sfc_efx/base: add Medford4 support to EV module Ivan Malov
2025-04-16 13:59 ` [PATCH 05/46] common/sfc_efx/base: add Medford4 support to FILTER module Ivan Malov
2025-04-16 13:59 ` [PATCH 06/46] common/sfc_efx/base: add Medford4 support to INTR module Ivan Malov
2025-04-16 13:59 ` [PATCH 07/46] common/sfc_efx/base: add Medford4 support to MAC module Ivan Malov
2025-04-16 13:59 ` [PATCH 08/46] common/sfc_efx/base: add Medford4 support to PHY module Ivan Malov
2025-04-16 13:59 ` [PATCH 09/46] common/sfc_efx/base: add Medford4 support to TUNNEL module Ivan Malov
2025-04-16 13:59 ` [PATCH 10/46] common/sfc_efx/base: add Medford4 support to MCDI module Ivan Malov
2025-04-16 13:59 ` [PATCH 11/46] common/sfc_efx/base: add Medford4 support to Rx module Ivan Malov
2025-04-16 13:59 ` [PATCH 12/46] common/sfc_efx/base: add Medford4 support to Tx module Ivan Malov
2025-04-16 13:59 ` [PATCH 13/46] drivers: enable support for AMD Solarflare X4 adapter family Ivan Malov
2025-04-16 13:59 ` [PATCH 14/46] common/sfc_efx/base: update X4 BAR layout and PCI IDs Ivan Malov
2025-04-16 13:59 ` [PATCH 15/46] net/sfc: add Medford4 with only full feature datapath engine Ivan Malov
2025-04-16 13:59 ` [PATCH 16/46] common/sfc_efx/base: add port mode for 8 port hardware Ivan Malov
2025-04-16 13:59 ` [PATCH 17/46] common/sfc_efx/base: add new X4 port mode Ivan Malov
2025-04-16 13:59 ` [PATCH 18/46] common/sfc_efx/base: extend list of supported X4 port modes Ivan Malov
2025-04-16 13:59 ` [PATCH 19/46] common/sfc_efx/base: update MCDI headers Ivan Malov
2025-04-16 13:59 ` [PATCH 20/46] common/sfc_efx/base: provide a stub for basic netport attach Ivan Malov
2025-04-16 13:59 ` [PATCH 21/46] common/sfc_efx/base: provide defaults on netport attach path Ivan Malov
2025-04-16 13:59 ` [PATCH 22/46] common/sfc_efx/base: obtain assigned netport handle from NIC Ivan Malov
2025-04-16 13:59 ` [PATCH 23/46] common/sfc_efx/base: allow for const in MCDI struct accessor Ivan Malov
2025-04-16 13:59 ` [PATCH 24/46] common/sfc_efx/base: get netport fixed capabilities on probe Ivan Malov
2025-04-16 13:59 ` [PATCH 25/46] common/sfc_efx/base: decode netport link state on probe path Ivan Malov
2025-04-16 13:59 ` [PATCH 26/46] common/sfc_efx/base: fill in loopback modes on netport probe Ivan Malov
2025-04-16 13:59 ` [PATCH 27/46] common/sfc_efx/base: introduce Medford4 stub for PHY methods Ivan Malov
2025-04-16 13:59 ` [PATCH 28/46] common/sfc_efx/base: refactor EF10 link mode decoding helper Ivan Malov
2025-04-16 13:59 ` [PATCH 29/46] common/sfc_efx/base: provide PHY link get method on Medford4 Ivan Malov
2025-04-16 14:00 ` [PATCH 30/46] common/sfc_efx/base: implement PHY link control for Medford4 Ivan Malov
2025-04-17  7:31   ` Andrew Rybchenko
2025-04-16 14:00 ` [PATCH 31/46] common/sfc_efx/base: introduce Medford4 stub for MAC methods Ivan Malov
2025-04-16 14:00 ` [PATCH 32/46] common/sfc_efx/base: add MAC reconfigure method for Medford4 Ivan Malov
2025-04-17  7:34   ` Andrew Rybchenko
2025-04-16 14:00 ` [PATCH 33/46] common/sfc_efx/base: fill in software LUT for MAC statistics Ivan Malov
2025-04-16 14:00 ` [PATCH 34/46] common/sfc_efx/base: fill in MAC statistics mask on Medford4 Ivan Malov
2025-04-16 14:00 ` [PATCH 35/46] common/sfc_efx/base: support MAC statistics on Medford4 NICs Ivan Malov
2025-04-17  7:43   ` Andrew Rybchenko
2025-04-16 14:00 ` [PATCH 36/46] common/sfc_efx/base: implement MAC PDU controls for Medford4 Ivan Malov
2025-04-16 14:00 ` [PATCH 37/46] common/sfc_efx/base: correct MAC PDU calculation on Medford4 Ivan Malov
2025-04-16 14:00 ` [PATCH 38/46] net/sfc: make use of generic EFX MAC PDU calculation helpers Ivan Malov
2025-04-16 14:00 ` [PATCH 39/46] common/sfc_efx/base: ignore legacy link events on new boards Ivan Malov
2025-04-16 14:00 ` [PATCH 40/46] common/sfc_efx/base: add link event processing " Ivan Malov
2025-04-16 14:00 ` [PATCH 41/46] net/sfc: query link status on link change events on new NICs Ivan Malov
2025-04-16 14:00 ` [PATCH 42/46] common/sfc_efx/base: subscribe to netport link change events Ivan Malov
2025-04-16 14:00 ` [PATCH 43/46] net/sfc: offer support for 200G link ability on new adaptors Ivan Malov
2025-04-16 14:00 ` [PATCH 44/46] common/sfc_efx/base: support controls for netport lane count Ivan Malov
2025-04-17  7:57   ` Andrew Rybchenko
2025-04-16 14:00 ` [PATCH 45/46] net/sfc: add support for control of physical port " Ivan Malov
2025-04-16 14:00 ` [PATCH 46/46] doc: advertise support for AMD Solarflare X45xx adapters Ivan Malov
2025-04-16 15:14 ` [PATCH 00/46] Support AMD Solarflare X45xx adaptors Stephen Hemminger
2025-04-16 15:38   ` Ivan Malov
2025-04-16 16:31     ` Stephen Hemminger
2025-04-16 17:37       ` Ivan Malov
2025-04-16 21:44         ` Stephen Hemminger
2025-04-17  8:09 ` Andrew Rybchenko
2025-04-23 15:59 ` [PATCH v2 00/45] " Ivan Malov
2025-04-23 15:59   ` [PATCH v2 01/45] common/sfc_efx/base: add Medford4 PCI IDs to common code Ivan Malov
2025-04-23 15:59   ` [PATCH v2 02/45] common/sfc_efx/base: add efsys option for Medford4 Ivan Malov
2025-04-23 15:59   ` [PATCH v2 03/45] common/sfc_efx/base: add Medford4 support to NIC module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 04/45] common/sfc_efx/base: add Medford4 support to EV module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 05/45] common/sfc_efx/base: add Medford4 support to FILTER module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 06/45] common/sfc_efx/base: add Medford4 support to INTR module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 07/45] common/sfc_efx/base: add Medford4 support to MAC module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 08/45] common/sfc_efx/base: add Medford4 support to PHY module Ivan Malov
2025-04-23 19:15     ` Andrew Rybchenko
2025-04-23 15:59   ` [PATCH v2 09/45] common/sfc_efx/base: add Medford4 support to TUNNEL module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 10/45] common/sfc_efx/base: add Medford4 support to MCDI module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 11/45] common/sfc_efx/base: add Medford4 support to Rx module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 12/45] common/sfc_efx/base: add Medford4 support to Tx module Ivan Malov
2025-04-23 15:59   ` [PATCH v2 13/45] drivers: enable support for AMD Solarflare X4 adapter family Ivan Malov
2025-04-23 15:59   ` [PATCH v2 14/45] net/sfc: add Medford4 with only full feature datapath engine Ivan Malov
2025-04-23 15:59   ` [PATCH v2 15/45] common/sfc_efx/base: add port mode for 8 port hardware Ivan Malov
2025-04-23 15:59   ` [PATCH v2 16/45] common/sfc_efx/base: add new X4 port mode Ivan Malov
2025-04-23 15:59   ` [PATCH v2 17/45] common/sfc_efx/base: extend list of supported X4 port modes Ivan Malov
2025-04-23 15:59   ` [PATCH v2 18/45] common/sfc_efx/base: update MCDI headers Ivan Malov
2025-04-23 15:59   ` [PATCH v2 19/45] common/sfc_efx/base: provide a stub for basic netport attach Ivan Malov
2025-04-23 15:59   ` [PATCH v2 20/45] common/sfc_efx/base: provide defaults on netport attach path Ivan Malov
2025-04-23 15:59   ` [PATCH v2 21/45] common/sfc_efx/base: obtain assigned netport handle from NIC Ivan Malov
2025-04-23 15:59   ` [PATCH v2 22/45] common/sfc_efx/base: allow for const in MCDI struct accessor Ivan Malov
2025-04-23 15:59   ` [PATCH v2 23/45] common/sfc_efx/base: get netport fixed capabilities on probe Ivan Malov
2025-04-23 15:59   ` [PATCH v2 24/45] common/sfc_efx/base: decode netport link state on probe path Ivan Malov
2025-04-23 15:59   ` [PATCH v2 25/45] common/sfc_efx/base: fill in loopback modes on netport probe Ivan Malov
2025-04-23 15:59   ` [PATCH v2 26/45] common/sfc_efx/base: introduce Medford4 stub for PHY methods Ivan Malov
2025-04-23 15:59   ` [PATCH v2 27/45] common/sfc_efx/base: refactor EF10 link mode decoding helper Ivan Malov
2025-04-23 15:59   ` [PATCH v2 28/45] common/sfc_efx/base: provide PHY link get method on Medford4 Ivan Malov
2025-04-23 15:59   ` [PATCH v2 29/45] common/sfc_efx/base: implement PHY link control for Medford4 Ivan Malov
2025-04-23 15:59   ` [PATCH v2 30/45] common/sfc_efx/base: introduce Medford4 stub for MAC methods Ivan Malov
2025-04-23 15:59   ` [PATCH v2 31/45] common/sfc_efx/base: add MAC reconfigure method for Medford4 Ivan Malov
2025-04-23 15:59   ` [PATCH v2 32/45] common/sfc_efx/base: fill in software LUT for MAC statistics Ivan Malov
2025-04-23 15:59   ` [PATCH v2 33/45] common/sfc_efx/base: fill in MAC statistics mask on Medford4 Ivan Malov
2025-04-23 15:59   ` [PATCH v2 34/45] common/sfc_efx/base: support MAC statistics on Medford4 NICs Ivan Malov
2025-04-23 15:59   ` [PATCH v2 35/45] common/sfc_efx/base: implement MAC PDU controls for Medford4 Ivan Malov
2025-04-23 15:59   ` Ivan Malov [this message]
2025-04-23 15:59   ` [PATCH v2 37/45] net/sfc: make use of generic EFX MAC PDU calculation helpers Ivan Malov
2025-04-23 15:59   ` [PATCH v2 38/45] common/sfc_efx/base: ignore legacy link events on new boards Ivan Malov
2025-04-23 15:59   ` [PATCH v2 39/45] common/sfc_efx/base: add link event processing " Ivan Malov
2025-04-23 15:59   ` [PATCH v2 40/45] net/sfc: query link status on link change events on new NICs Ivan Malov
2025-04-23 15:59   ` [PATCH v2 41/45] common/sfc_efx/base: subscribe to netport link change events Ivan Malov
2025-04-23 15:59   ` [PATCH v2 42/45] net/sfc: offer support for 200G link ability on new adaptors Ivan Malov
2025-04-23 16:00   ` [PATCH v2 43/45] common/sfc_efx/base: support controls for netport lane count Ivan Malov
2025-04-23 16:00   ` [PATCH v2 44/45] net/sfc: add support for control of physical port " Ivan Malov
2025-04-23 16:00   ` [PATCH v2 45/45] doc: advertise support for AMD Solarflare X45xx adapters Ivan Malov
2025-04-23 19:15     ` Andrew Rybchenko
2025-04-23 19:19   ` [PATCH v2 00/45] Support AMD Solarflare X45xx adaptors Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250423160002.35706-37-ivan.malov@arknetworks.am \
    --to=ivan.malov@arknetworks.am \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=andy.moreton@amd.com \
    --cc=dev@dpdk.org \
    --cc=pieter.jansen-van-vuuren@amd.com \
    --cc=stephen@networkplumber.org \
    --cc=viacheslav.galaktionov@arknetworks.am \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).