DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <stephen@networkplumber.org>,
	<bruce.richardson@intel.com>, <jerin.jacob@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH V3  1/3] ethdev: introduce FEC API
Date: Wed, 9 Sep 2020 20:36:32 +0800	[thread overview]
Message-ID: <1599654994-39640-2-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1599654994-39640-1-git-send-email-humin29@huawei.com>

This patch adds Forward error correction(FEC) support for ethdev.
Introduce APIs which support query and config FEC information in
hardware.

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>

---
v2->v3:
add function return value "-ENOTSUP" for API
---
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 75 +++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 +++
 4 files changed, 207 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5..b7ac791 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3642,6 +3642,56 @@ rte_eth_led_off(uint16_t port_id)
 	return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));
 }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint8_t *fec_cap)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get_capability, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->fec_get_capability)(dev,
+								fec_cap));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, enum rte_fec_mode *mode)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->fec_get)(dev, mode));
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, enum rte_fec_mode mode)
+{
+	struct rte_eth_dev *dev;
+	uint8_t fec_mode_mask;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
+	if (ret)
+		return ret;
+
+	/*
+	 * Check whether the configured mode is within the FEC capability.
+	 * If not, the configured mode will not be supported.
+	 */
+	if (!(fec_mode_mask & (1U << (uint8_t)mode))) {
+		RTE_ETHDEV_LOG(ERR, "unsupported fec mode=%d\n", mode);
+		return -EINVAL;
+	}
+
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_set, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->fec_set)(dev, mode));
+}
+
 /*
  * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
  * an empty spot.
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 70295d7..c353480 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1511,6 +1511,17 @@ struct rte_eth_dcb_info {
 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
 };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {
+	ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	ETH_FEC_BASER,          /**< FEC using common algorithm */
+	ETH_FEC_RS,             /**< FEC using RS algorithm */
+	ETH_FEC_AUTO            /**< FEC autonegotiation modes */
+};
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3328,6 +3339,70 @@ int  rte_eth_led_on(uint16_t port_id);
 int  rte_eth_led_off(uint16_t port_id);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param fec_cap
+ *   returns the FEC capability from the device, as follows:
+ *   bit0: nofec
+ *   bit1: baser
+ *   bit2: rs
+ *   bit3: auto
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint8_t *fec_cap);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param mode
+ *   returns the FEC mode from the device.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ */
+__rte_experimental
+int rte_eth_fec_get(uint16_t port_id, enum rte_fec_mode *mode);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set Forward Error Correction(FEC) mode.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param mode
+ *   the FEC mode.
+ * @return
+ *   - (0) if successful.
+ *   - (-EINVAL) if the FEC mode is not valid.
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ */
+__rte_experimental
+int rte_eth_fec_set(uint16_t port_id, enum rte_fec_mode mode);
+
+/**
  * Get current status of the Ethernet link flow control for Ethernet device
  *
  * @param port_id
diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
index 32407dd..df9e18a 100644
--- a/lib/librte_ethdev/rte_ethdev_core.h
+++ b/lib/librte_ethdev/rte_ethdev_core.h
@@ -604,6 +604,76 @@ typedef int (*eth_tx_hairpin_queue_setup_t)
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
 
 /**
+ * @internal
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param fec_cap
+ *   returns the FEC capability from the device.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.
+ * @retval -EIO
+ *   device is removed.
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
+					uint8_t *fec_cap);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode
+ *   returns the FEC mode from the device.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.
+ * @retval -EIO
+ *   device is removed.
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev, enum rte_fec_mode *mode);
+
+/**
+ * @internal
+ *   Set Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode
+ *   the FEC mode.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.
+ * @retval -EIO
+ *   device is removed.
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, enum rte_fec_mode mode);
+
+/**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
 struct eth_dev_ops {
@@ -752,6 +822,13 @@ struct eth_dev_ops {
 	/**< Set up device RX hairpin queue. */
 	eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
 	/**< Set up device TX hairpin queue. */
+
+	eth_fec_get_capability_t fec_get_capability;
+	/**< Get Forward Error Correction(FEC) capability; */
+	eth_fec_get_t fec_get;
+	/**< Get Forward Error Correction(FEC) mode; */
+	eth_fec_set_t fec_set;
+	/**< Set Forward Error Correction(FEC) mode; */
 };
 
 /**
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 1212a17..33cf5e4 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -241,6 +241,11 @@ EXPERIMENTAL {
 	__rte_ethdev_trace_rx_burst;
 	__rte_ethdev_trace_tx_burst;
 	rte_flow_get_aged_flows;
+
+	# added in 20.11
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
-- 
2.7.4


  reply	other threads:[~2020-09-09 12:38 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  3:41 [dpdk-dev] [RFC 1/2] Description: lib/ethdev: change data type in tc_rxq and tc_txq Min Hu(Connor)
2020-08-31  3:41 ` [dpdk-dev] [RFC 2/2] Description: dpdk: fix compiling errors for more than 256 per-queue statistics Min Hu(Connor)
2020-09-01  1:33 ` [dpdk-dev] [RFC 1/2] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-01  1:33   ` [dpdk-dev] [RFC 2/2] ethdev: fix compiling errors for per-queue statistics Min Hu (Connor)
2020-09-01  2:23     ` Stephen Hemminger
2020-09-01 11:52   ` [dpdk-dev] [PATCH 0/4] ethdev: change the queue ID type Min Hu (Connor)
2020-09-01 11:52     ` [dpdk-dev] [PATCH 1/4] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-04 11:32       ` [dpdk-dev] [PATCH V2 0/4] ethdev: change the queue ID type Min Hu (Connor)
2020-09-04 11:32         ` [dpdk-dev] [PATCH V2 1/4] ethdev: fix compiling errors for per-queue statistics Min Hu (Connor)
2020-09-04 18:04           ` Ferruh Yigit
2020-09-04 18:31           ` Ferruh Yigit
2020-09-05 16:51             ` Thomas Monjalon
2020-09-23  2:31             ` Min Hu (Connor)
2020-09-23  9:18               ` Ferruh Yigit
2020-09-25  8:58                 ` Min Hu (Connor)
2020-09-25  9:36                   ` Ferruh Yigit
2020-09-23 12:59           ` [dpdk-dev] [PATCH V3 0/4] change data type in TC queue Min Hu (Connor)
2020-09-23 12:59             ` [dpdk-dev] [PATCH V3 1/4] dpdk: fix compiling errors for per-queue statistics Min Hu (Connor)
2020-09-23 13:00             ` [dpdk-dev] [PATCH V3 2/4] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-23 13:00             ` [dpdk-dev] [PATCH V3 3/4] doc: announce modified field in DCB TC queue mapping Min Hu (Connor)
2020-09-23 13:00             ` [dpdk-dev] [PATCH V3 4/4] doc: announce modified in queue stats mapping API Min Hu (Connor)
2020-09-25  9:41             ` [dpdk-dev] [PATCH V3 0/4] change data type in TC queue Ferruh Yigit
2020-09-04 11:32         ` [dpdk-dev] [PATCH V2 2/4] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-04 11:32         ` [dpdk-dev] [PATCH V2 3/4] doc: announce modified field in DCB TC queue mapping Min Hu (Connor)
2020-09-04 11:32         ` [dpdk-dev] [PATCH V2 4/4] doc: announce modified field in ethdev API Min Hu (Connor)
2020-09-04 14:33         ` [dpdk-dev] [PATCH V2 0/4] ethdev: change the queue ID type Ferruh Yigit
2020-09-09 12:36       ` [dpdk-dev] [PATCH V3 0/3] add FEC support Min Hu (Connor)
2020-09-09 12:36         ` Min Hu (Connor) [this message]
2020-09-09 12:36         ` [dpdk-dev] [PATCH V3 2/3] net/hns3: support FEC Min Hu (Connor)
2020-09-09 12:36         ` [dpdk-dev] [PATCH V3 3/3] app/testpmd: add FEC command Min Hu (Connor)
2020-09-01 11:52     ` [dpdk-dev] [PATCH 2/4] ethdev: fix compiling errors for per-queue statistics Min Hu (Connor)
2020-09-01 16:17       ` Ferruh Yigit
2020-09-01 11:52     ` [dpdk-dev] [PATCH 3/4] doc: announce modified field in DCB TC queue mapping Min Hu (Connor)
2020-09-01 11:52     ` [dpdk-dev] [PATCH 4/4] doc: announce modified field in ethdev API Min Hu (Connor)
2020-09-01 16:14     ` [dpdk-dev] [PATCH 0/4] ethdev: change the queue ID type Ferruh Yigit
2020-09-25 12:51 ` [dpdk-dev] [PATCH V4 0/2] change data type in TC queue Min Hu (Connor)
2020-09-25 12:51   ` [dpdk-dev] [PATCH V4 1/2] dpdk: resolve compiling errors for per-queue stats Min Hu (Connor)
2020-09-25 12:51   ` [dpdk-dev] [PATCH V4 2/2] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-25 13:14   ` [dpdk-dev] [PATCH V4 0/2] change data type in TC queue Ferruh Yigit
2020-09-27  3:16 ` [dpdk-dev] [PATCH V5 " Min Hu (Connor)
2020-09-27  3:16   ` [dpdk-dev] [PATCH V5 1/2] dpdk: resolve compiling errors for per-queue stats Min Hu (Connor)
2020-09-28  8:59     ` Ferruh Yigit
2020-09-28  9:16       ` [dpdk-dev] [dpdk-techboard] " Thomas Monjalon
2020-09-28 12:00         ` Ananyev, Konstantin
2020-09-28 13:47         ` Min Hu (Connor)
2020-09-28 15:35           ` Thomas Monjalon
2020-09-28 13:53         ` Ferruh Yigit
2020-09-28 15:24           ` Thomas Monjalon
2020-09-28 15:43             ` Stephen Hemminger
2020-10-05 12:23               ` Ferruh Yigit
2020-10-06  8:33                 ` Olivier Matz
2020-10-09 20:32                   ` Ferruh Yigit
2020-10-10  8:09                     ` Thomas Monjalon
2020-10-12 17:02                       ` Ferruh Yigit
2020-09-29  4:49           ` Min Hu (Connor)
2020-09-29  9:33             ` Thomas Monjalon
2020-09-29 13:46               ` Min Hu (Connor)
2020-09-28 11:52       ` Ananyev, Konstantin
2020-09-30  8:34       ` [dpdk-dev] " Kinsella, Ray
2020-09-27  3:16   ` [dpdk-dev] [PATCH V5 2/2] ethdev: change data type in TC rxq and TC txq Min Hu (Connor)
2020-09-28  9:04     ` Ferruh Yigit
2020-09-28  9:21       ` [dpdk-dev] [dpdk-techboard] " Thomas Monjalon
2020-10-05 12:26         ` Ferruh Yigit
2020-10-06 12:04           ` Ferruh Yigit

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=1599654994-39640-2-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=stephen@networkplumber.org \
    /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).