DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jeff Daly <jeffd@silicom-usa.com>
To: dev@dpdk.org
Cc: Stephen Douthit <stephend@silicom-usa.com>,
	Qiming Yang <qiming.yang@intel.com>,
	Wenjun Wu <wenjun1.wu@intel.com>
Subject: [PATCH v2] net/ixgbe: Treat 1G Cu SFPs as 1G SX on the X550 devices
Date: Thu, 26 May 2022 16:43:55 -0400	[thread overview]
Message-ID: <20220526204355.5014-1-jeffd@silicom-usa.com> (raw)
In-Reply-To: <20220307223442.28012-1-jeffd@silicom-usa.com>

1G Cu SFPs are not officially supported on the X552/X553 family of
devices but create an option cu_sfp_as_sx to treat them as 1G SX
modules since they usually work.  Print a warning though since support
isn't validated, similar to what already happens for other unofficially
supported SFPs enabled via the allow_unsupported_sfps parameter
inherited from the mainline Linux driver.

Signed-off-by: Jeff Daly <jeffd@silicom-usa.com>
Suggested-by: Stephen Douthit <stephend@silicom-usa.com>
---
v2:
* Introduced cu_sfp_as_sx option, default off.
---
 doc/guides/nics/ixgbe.rst           | 16 ++++++++++++++
 drivers/net/ixgbe/base/ixgbe_type.h |  1 +
 drivers/net/ixgbe/base/ixgbe_x550.c | 12 ++++++++++-
 drivers/net/ixgbe/ixgbe_ethdev.c    | 33 +++++++++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.h    |  3 +++
 5 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst
index 82fa453fa28e..5db63083eef8 100644
--- a/doc/guides/nics/ixgbe.rst
+++ b/doc/guides/nics/ixgbe.rst
@@ -101,6 +101,22 @@ To guarantee the constraint, capabilities in dev_conf.rxmode.offloads will be ch
 
 fdir_conf->mode will also be checked.
 
+Runtime Options
+^^^^^^^^^^^^^^^^^^
+
+The following ``devargs`` options can be enabled at runtime. They must
+be passed as part of EAL arguments. For example,
+
+.. code-block:: console
+
+   dpdk-testpmd -a af:10.0,cu_sfp_as_sx=1 -- -i
+
+- ``cu_sfp_as_sx`` (default **0**)
+
+  This option is used to allow the X550 devices to treat 1G Cu SFPs as
+  1G SX SFPs, since this usually works.  By default, 1G Cu SFPs are not
+  supported by Intel for the X550.
+
 VF Runtime Options
 ^^^^^^^^^^^^^^^^^^
 
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h b/drivers/net/ixgbe/base/ixgbe_type.h
index b7eec456358d..36d741dbfaad 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4190,6 +4190,7 @@ struct ixgbe_hw {
 	bool allow_unsupported_sfp;
 	bool wol_enabled;
 	bool need_crosstalk_fix;
+	bool cu_sfp_as_sx;
 };
 
 #define ixgbe_call_func(hw, func, params, error) \
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c b/drivers/net/ixgbe/base/ixgbe_x550.c
index 8810d1658e91..7211b8c707d8 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1538,9 +1538,19 @@ STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
 	case ixgbe_sfp_type_1g_lha_core1:
 		*linear = false;
 		break;
-	case ixgbe_sfp_type_unknown:
 	case ixgbe_sfp_type_1g_cu_core0:
+		if (hw->cu_sfp_as_sx == 1) {
+			EWARN(hw, "WARNING: Treating Cu SFP modules as SX modules is unsupported by Intel and may cause unstable operation or damage to the module or the adapter.  Intel Corporation is not responsible for any harm caused by using Cu modules in this way with this adapter.\n");
+			*linear = false;
+			hw->phy.sfp_type = ixgbe_sfp_type_1g_sx_core0;
+		}
 	case ixgbe_sfp_type_1g_cu_core1:
+		if (hw->cu_sfp_as_sx == 1) {
+			EWARN(hw, "WARNING: Treating Cu SFP modules as SX modules is unsupported by Intel and may cause unstable operation or damage to the module or the adapter.  Intel Corporation is not responsible for any harm caused by using Cu modules in this way with this adapter.\n");
+			*linear = false;
+			hw->phy.sfp_type = ixgbe_sfp_type_1g_sx_core1;
+		}
+	case ixgbe_sfp_type_unknown:
 	default:
 		return IXGBE_ERR_SFP_NOT_SUPPORTED;
 	}
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 2da3f67bbc78..419342f34132 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -129,12 +129,18 @@
 #define IXGBE_DMATXCTL_VT_MASK                 0xFFFF0000
 
 #define IXGBEVF_DEVARG_PFLINK_FULLCHK		"pflink_fullchk"
+#define IXGBE_DEVARG_CU_SFP_AS_SX		"cu_sfp_as_sx"
 
 static const char * const ixgbevf_valid_arguments[] = {
 	IXGBEVF_DEVARG_PFLINK_FULLCHK,
 	NULL
 };
 
+static const char * const ixgbe_valid_arguments[] = {
+	IXGBE_DEVARG_CU_SFP_AS_SX,
+	NULL
+};
+
 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params);
 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
@@ -185,6 +191,8 @@ static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 static int ixgbe_dev_info_get(struct rte_eth_dev *dev,
 			      struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+static int devarg_handle_int(const char *key, const char *value,
+			     void *extra_args);
 static int ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
@@ -1032,6 +1040,29 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
 	ixgbe_release_swfw_semaphore(hw, mask);
 }
 
+static void
+ixgbe_parse_devargs(struct ixgbe_adapter *adapter,
+		    struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	uint16_t cu_sfp_as_sx;
+
+	if (devargs == NULL)
+		return;
+
+	kvlist = rte_kvargs_parse(devargs->args, ixgbe_valid_arguments);
+	if (kvlist == NULL)
+		return;
+
+	if (rte_kvargs_count(kvlist, IXGBE_DEVARG_CU_SFP_AS_SX) == 1 &&
+	    rte_kvargs_process(kvlist, IXGBE_DEVARG_CU_SFP_AS_SX,
+			       devarg_handle_int, &cu_sfp_as_sx) == 0 &&
+	    cu_sfp_as_sx == 1)
+		adapter->cu_sfp_as_sx = 1;
+
+	rte_kvargs_free(kvlist);
+}
+
 /*
  * This function is based on code in ixgbe_attach() in base/ixgbe.c.
  * It returns 0 on success.
@@ -1095,6 +1126,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	}
 
 	rte_atomic32_clear(&ad->link_thread_running);
+	ixgbe_parse_devargs(eth_dev->data->dev_private,
+			    pci_dev->device.devargs);
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 69e0e82a5b1a..c29e14c120b0 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -498,6 +498,9 @@ struct ixgbe_adapter {
 	struct rte_timecounter      tx_tstamp_tc;
  	struct ixgbe_tm_conf        tm_conf;
 
+	/* For treating CU SFPs as SX (Unsupported by Intel) */
+	uint8_t cu_sfp_as_sx;
+
 	/* For RSS reta table update */
 	uint8_t rss_reta_updated;
 
-- 
2.25.1


  parent reply	other threads:[~2022-05-26 20:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 22:34 [PATCH] " jeffd
2022-04-13 14:21 ` Thomas Monjalon
2022-05-20  0:14   ` Zhang, Qi Z
2022-05-20 18:02     ` Jeff Daly
2022-05-23  5:36       ` Zhang, Qi Z
2022-05-23 14:13         ` Jeff Daly
2022-05-23 23:22           ` Zhang, Qi Z
2022-05-25 15:23             ` Jeff Daly
2022-05-26  0:28               ` Zhang, Qi Z
2022-04-14  1:31 ` Wang, Haiyue
2022-04-14  9:42   ` Thomas Monjalon
2022-04-14 12:13     ` Wang, Haiyue
2022-04-14 12:18       ` Thomas Monjalon
2022-04-14 15:11         ` Jeff Daly
2022-04-14 15:43           ` Stephen Hemminger
2022-04-14 17:06             ` Thomas Monjalon
2022-04-19  9:11               ` Morten Brørup
2022-04-19 12:32                 ` Wang, Haiyue
2022-04-15  1:10           ` Wang, Haiyue
2022-05-26 20:43 ` Jeff Daly [this message]
2022-05-29 22:49   ` [PATCH v2] " Zhang, Qi Z
2022-05-30 13:32     ` Jeff Daly
2022-05-30 13:50       ` Zhang, Qi Z
2022-05-31 12:30         ` Jeff Daly
2022-05-31 13:38           ` Zhang, Qi Z

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=20220526204355.5014-1-jeffd@silicom-usa.com \
    --to=jeffd@silicom-usa.com \
    --cc=dev@dpdk.org \
    --cc=qiming.yang@intel.com \
    --cc=stephend@silicom-usa.com \
    --cc=wenjun1.wu@intel.com \
    /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).