Skip to contentSkip to conversation

ethdev: add Forward Error Correction support

RFC In review Min Hu(Connor) 7 participants 118 messages Aug 28, 2020 – Jan 16, 2021 Network drivers Page 1 of 2

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: add Forward Error Correction support

Hi All,

I would like to add FEC support of ethdev for DPDK. I am planning to add this support in v20.11 release.

This RFC attempts to get feedback from the community.

In current DPDK version, Forward Error Correction(FEC) is not supported.

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. You can enable or disable this function as required.

To enable FEC support in DPDK, following items need to work out:
a) Add three API:
rte_eth_fec_get_capability
rte_eth_fec_get
rte_eth_fec_set

b) Add new data structure:

	enum rte_fec_mode {
		ETH_FEC_NOFEC,
		ETH_FEC_BASER,
		ETH_FEC_RS,
		ETH_FEC_AUTO
	};

c) Add items in "struct eth_dev_ops":

	struct eth_dev_ops {
	+	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; */

};

The details are as follows:

---
 lib/librte_ethdev/rte_ethdev.c      | 33 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h      | 52 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h | 65 +++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)
lib/librte_ethdev/rte_ethdev.c +33 -0
index 7858ad5..0a96718 100644
@@ -3642,6 +3642,39 @@ rte_eth_led_off(uint16_t port_id)
 	return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));
 }
 
+void
+rte_eth_fec_get_capability(uint16_t port_id, int *mode_mask)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->fec_get_capability);
+	(*dev->dev_ops->fec_get_capability)(dev, mode_mask);
+}
+
+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;
+
+	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_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.
lib/librte_ethdev/rte_ethdev.h +52 -0

64 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +65 -0

77 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 39 lines · Min Hu(Connor)

Hi All,

I would like to add FEC support of ethdev for DPDK. I am planning to add this support in v20.11 release.

This RFC attempts to get feedback from the community.

In current DPDK version, Forward Error Correction(FEC) is not supported.

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. You can enable or disable this function as required.

To enable FEC support in DPDK, following items need to work out:
a) Add three API:
rte_eth_fec_get_capability
rte_eth_fec_get
rte_eth_fec_set

b) Add new data structure:

	enum rte_fec_mode {
		ETH_FEC_NOFEC,
		ETH_FEC_BASER,
		ETH_FEC_RS,
		ETH_FEC_AUTO
	};

c) Add items in "struct eth_dev_ops":

	struct eth_dev_ops {
	+	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; */
Quoted 3 lines

};

The details are as follows:

1. New API should be experimental with corresponding markup.

2. FEC capabilities may depend on link speed if I'm not mistaken and it should be properly reported in capabilities.

3. Hopefully Ferruh's patches will make the dev_ops structure ethdev internal and these additions could be done in 20.11.

4. Format in mode_mask is not defined below.

#2 lore raw

cover add FEC support

In reply to Min Hu(Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 206 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 154 +++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  50 ++++++++
 lib/librte_ethdev/rte_ethdev.h           |  74 +++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  77 ++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 10 files changed, 641 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 1/3 ethdev: introduce FEC API

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

---
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 74 ++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 +++
 4 files changed, 206 insertions(+)
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..b7ac791 100644
@@ -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.
lib/librte_ethdev/rte_ethdev.h +74 -0

86 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +77 -0

89 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 1212a17..33cf5e4 100644
@@ -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 {
Signature · 1 line
2.7.4
#4 lore raw

v2 cover add FEC support

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 154 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  50 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  74 +++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  77 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 10 files changed, 654 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 1/3 ethdev: introduce FEC API

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

---
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 74 ++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 +++
 4 files changed, 206 insertions(+)
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..b7ac791 100644
@@ -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.
lib/librte_ethdev/rte_ethdev.h +74 -0

86 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +77 -0

89 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 1212a17..33cf5e4 100644
@@ -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 {
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 154 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 173 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +154 -0

184 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..daf723e 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..072f390 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint8_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..7ab91ad 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);
+void show_fec_capability(uint8_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#8 lore raw

PATCH 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 154 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 173 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +154 -0

184 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..daf723e 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#9 lore raw

PATCH 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
 app/test-pmd/cmdline.c | 206 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 +++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 262 insertions(+)
app/test-pmd/cmdline.c +206 -0
index 0a6ed85..71b2711 100644
@@ -19054,6 +19054,209 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint8_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret < 0)
+		return;
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret < 0)
+		return;
+
+	switch (mode) {
+	case ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret < 0) {
+		printf("Set fec mode for Port %d failed\n", port_id);
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19888,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..7ab91ad 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);
+void show_fec_capability(uint8_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#10 lore raw

v4 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 156 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 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 +
 10 files changed, 657 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#11 lore raw

PATCH v4 1/3 ethdev: introduce FEC API

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

---
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(+)
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..b7ac791 100644
@@ -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.
lib/librte_ethdev/rte_ethdev.h +75 -0

87 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +77 -0

89 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 1212a17..33cf5e4 100644
@@ -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 {
Signature · 1 line
2.7.4
Reviewed-by on v4 1/3
#12 lore raw

Re: [dpdk-dev] [PATCH V4 1/3] ethdev: introduce FEC API

Quoted 9 lines · Min Hu (Connor)

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

Quoted 295 lines

---
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(+)
lib/librte_ethdev/rte_ethdev.c +50 -1
index 7858ad5..b7ac791 100644
@@ -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.

lib/librte_ethdev/rte_ethdev.h +13 -0
index 70295d7..c353480 100644
@@ -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.
+ */

lib/librte_ethdev/rte_ethdev.h +6 -0
+__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.
+ */

lib/librte_ethdev/rte_ethdev.h +6 -0
+__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.

+ */

lib/librte_ethdev/rte_ethdev.h +4 -0
+__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

lib/librte_ethdev/rte_ethdev_core.h +70 -0
index 32407dd..df9e18a 100644
@@ -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 {

lib/librte_ethdev/rte_ethdev_core.h +7 -0
@@ -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; */
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +5 -1
index 1212a17..33cf5e4 100644
@@ -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

#13 lore raw

Re: [dpdk-dev] [PATCH V4 1/3] ethdev: introduce FEC API

In reply to Min Hu (Connor)

Seems ok in general, few nits below.

Quoted 9 lines

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

Quoted 8 lines

---
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 +++

This is a wew feature, probably worth to update release notes.

Quoted 68 lines
 4 files changed, 207 insertions(+)
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..b7ac791 100644
@@ -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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..c353480 100644

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1519

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +6 -0
@@ -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 */

As it is a public enum, RTE_ prefix is needed for each value.

Quoted 15 lines
lib/librte_ethdev/rte_ethdev.h +8 -0
+	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
+ *

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3354

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ * 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

Instead of putting bit description into the comment, I think it is better to define them explicitly. Something like:

#define RTE_ETH_FEC_CAPA_XXX (1 << RTE_ETH_FEC_XXX)

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3363

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
+ * @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);

Probably make sense to have uint32_t bit value for fec_cap (for possible future expansion)?

Quoted 158 lines
lib/librte_ethdev/rte_ethdev.h +42 -0
+
+/**
+ * @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
lib/librte_ethdev/rte_ethdev_core.h +77 -0
index 32407dd..df9e18a 100644
@@ -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; */
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +5 -1
index 1212a17..33cf5e4 100644
@@ -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

#14 lore raw

PATCH v4 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 156 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 175 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +156 -0

186 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..daf723e 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#15 lore raw

PATCH v4 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..072f390 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint8_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..7ab91ad 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);
+void show_fec_capability(uint8_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#16 lore raw

Re: [dpdk-dev] [PATCH V4 0/3] add FEC support

In reply to Min Hu (Connor)
Quoted 2 lines · Min Hu (Connor)

This series add FEC support for ethdev.

Can you tell why DPDK applications need this info?

Quoted 23 lines

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219
+++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 156 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 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 +
 10 files changed, 657 insertions(+), 1 deletion(-)

--
2.7.4

#17 lore raw

Re: [dpdk-dev] [PATCH V4 0/3] add FEC support

Hi, Ajit Khaparde:

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality.

FEC ensures signal transmission quality in high-speed networks. DPDK application needs FEC information from device if user want to set FEC mode to ensures signal transmission quality.

For example, if user wants to set FEC mode for device by "rte_eth_fec_set",FEC capability of device getting from "rte_eth_fec_get_capability" is needed by user. AS FEC mode should be within the limits of FEC capability of device.

Quoted 29 lines · Ajit Khaparde

On Thu, Sep 10, 2020 at 12:26 AM Min Hu (Connor) <[email protected] <mailto:[email protected]>> wrote:

This series add FEC support for ethdev.

Can you tell why DPDK applications need this info?

Min Hu (Connor) (3):
  ethdev: introduce FEC API
  net/hns3: support FEC
  app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219
+++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++ app/test-pmd/testpmd.h                   |   2 + drivers/net/hns3/hns3_cmd.h              |  19 ++- drivers/net/hns3/hns3_ethdev.c           | 156 ++++++++++++++++++++++ drivers/net/hns3/hns3_ethdev.h           |   1 + 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 +
 10 files changed, 657 insertions(+), 1 deletion(-)

--
2.7.4

#18 lore raw

Re: [dpdk-dev] [PATCH V4 0/3] add FEC support

In reply to Min Hu (Connor)

Hi, all
Are there any comment?

Thanks
Connor

Quoted 19 lines · Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

  app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
  app/test-pmd/config.c                    |  54 ++++++++
  app/test-pmd/testpmd.h                   |   2 +
  drivers/net/hns3/hns3_cmd.h              |  19 ++-
  drivers/net/hns3/hns3_ethdev.c           | 156 ++++++++++++++++++++++
  drivers/net/hns3/hns3_ethdev.h           |   1 +
  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 +
  10 files changed, 657 insertions(+), 1 deletion(-)
#19 lore raw

v5 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  13 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 157 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  50 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  83 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  77 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 679 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#20 lore raw

PATCH v5 1/3 ethdev: introduce FEC API

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 13 +++++
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +13 -0
index cc72609..e4f0587 100644
@@ -55,6 +55,19 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+  Added hns3 FEC PMD, for suppporting query and config FEC mode.
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +50 -0

56 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +83 -0

95 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +77 -0

89 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#21 lore raw

PATCH v5 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 157 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 176 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +157 -0

187 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..daf723e 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#22 lore raw

PATCH v5 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..c8fb616 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..8cc4728 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#23 lore raw

v5 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  13 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 157 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  50 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  83 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  77 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 679 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#24 lore raw

PATCH v5 1/3 ethdev: introduce FEC API

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 13 +++++
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +13 -0
index cc72609..e4f0587 100644
@@ -55,6 +55,19 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+  Added hns3 FEC PMD, for supporting query and config FEC mode.
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +50 -0

56 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +83 -0

95 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +77 -0

89 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#25 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 31 lines · Min Hu (Connor)

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 13 +++++
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +0 -0
index cc72609..e4f0587 100644

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -55,6 +55,19 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.

The patch does not add a library. It adds an API get FEC capabilities, get current configuration and allows to set a new configuration.

doc/guides/rel_notes/release_20_11.rst New Features · line 63

Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +2 -0
+
+  Added hns3 FEC PMD, for supporting query and config FEC mode.

If required, it should be later in release notes in accordance with defined order.

doc/guides/rel_notes/release_20_11.rst New Features · line 70

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +7 -0
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.

IMHO, it is not much details for release notes. As I understand it is assumed that testpmd must be updated for any new ethdev feature, so, the information about testpmd is not really required.

Quoted 32 lines
doc/guides/rel_notes/release_20_11.rst +0 -0
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +21 -0
index 7858ad5..fde77c1 100644
@@ -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, uint32_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));

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3675

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, enum rte_fec_mode mode)
+{
+	struct rte_eth_dev *dev;
+	uint32_t fec_mode_mask;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

Basically the check is duplicated since get_capabilities does it. However, there is no much harm to keep. If so, I'd move it below just before port_id usage as an index in rte_eth_devices array.

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3678

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
+
+	ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
+	if (ret)

Please, compare with 0 explicitly as specified in DPDK coding style.

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3686

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+		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 << (uint32_t)mode))) {
+		RTE_ETHDEV_LOG(ERR, "unsupported fec mode=%d\n", mode);

I'd use "FEC" (in capitals) in log message as well. Also I think it would be useful to log port_id. .

Quoted 16 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+		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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..aa79326 100644

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1518

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
@@ -1511,6 +1511,25 @@ 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 {

enum rte_eth_fec_mode
to be consistent with other enums and to have library prefix.

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1522

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+	RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */

May I suggest to put AUTO just after NOFEC. It would look move logical in the future when more FEC modes are added. It would look strange with AUTO in the middle of the list.

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1523

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+	RTE_ETH_FEC_NUM

I'm not about about current policy for such items. Is it really required? Addition of more FEC modes will be ABI breakage.

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +12 -0
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3328,6 +3347,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
+ *

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3362

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ * 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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_AUTO

I'd like to see thoughts about different FEC modes for different link speed. How to report it? (sorry if I missed it before)

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
+ * @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, uint32_t *fec_cap);

[snip]

#26 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 35 lines · Andrew Rybchenko
Quoted 34 lines · Min Hu (Connor)

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
  doc/guides/rel_notes/release_20_11.rst   | 13 +++++
  lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
  lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_version.map |  5 ++
  5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +0 -0
index cc72609..e4f0587 100644
@@ -55,6 +55,19 @@ New Features
       Also, make sure to start the actual text at the margin.
       =======================================================
 
Quoted 8 lines

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +4 -0
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.

The patch does not add a library. It adds an API get FEC capabilities, get current configuration and allows to set a new configuration.

I fixed it in V6,thanks.

Quoted 7 lines

doc/guides/rel_notes/release_20_11.rst New Features · line 63

Quoted 3 lines
doc/guides/rel_notes/release_20_11.rst +2 -0
+
+  Added hns3 FEC PMD, for supporting query and config FEC mode.

If required, it should be later in release notes in accordance with defined order.

I fixed it in V6,thanks.

Quoted 4 lines
Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +4 -0
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
Quoted 9 lines

doc/guides/rel_notes/release_20_11.rst New Features · line 70

Quoted 3 lines
doc/guides/rel_notes/release_20_11.rst +3 -0
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.

IMHO, it is not much details for release notes. As I understand it is assumed that testpmd must be updated for any new ethdev feature, so, the information about testpmd is not really required.

I fixed it in V6,thanks.

Quoted 39 lines
Quoted 39 lines
doc/guides/rel_notes/release_20_11.rst +0 -0
  Removed Items
  -------------
lib/librte_ethdev/rte_ethdev.c +28 -0
index 7858ad5..fde77c1 100644
@@ -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, uint32_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;
+	uint32_t fec_mode_mask;
Quoted 9 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3675

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

Basically the check is duplicated since get_capabilities does it. However, there is no much harm to keep. If so, I'd move it below just before port_id usage as an index in rte_eth_devices array.

I fixed it in V6,just delete the duplicated check, thanks.

Quoted 7 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3678

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
+
+	ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
+	if (ret)

Please, compare with 0 explicitly as specified in DPDK coding style.

I fixed it in V6,thanks.

Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3686

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+		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 << (uint32_t)mode))) {
+		RTE_ETHDEV_LOG(ERR, "unsupported fec mode=%d\n", mode);

I'd use "FEC" (in capitals) in log message as well. Also I think it would be useful to log port_id.

I fixed it in V6,thanks.

Quoted 20 lines

.

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+		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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..aa79326 100644
@@ -1511,6 +1511,25 @@ struct rte_eth_dcb_info {
  	struct rte_eth_dcb_tc_queue_mapping tc_queue;
  };
 
Quoted 9 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1518

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {

enum rte_eth_fec_mode
to be consistent with other enums and to have library prefix.

I fixed it in V6,thanks.

Quoted 9 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1522

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+	RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */

May I suggest to put AUTO just after NOFEC. It would look move logical in the future when more FEC modes are added. It would look strange with AUTO in the middle of the list.

hns3 PMD is the first to implement FEC function. The FEC mode order is in accordance with the bit definition in hardware FEC module. in other ways, AUTO is flexible mode, which should not be differently
treated,the location in last item of enum is ok.

Quoted 4 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1523

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+	RTE_ETH_FEC_NUM

I'm not about about current policy for such items. Is it really required? Addition of more FEC modes will be ABI breakage.

it does not matter even though RTE_ETH_FEC_NUM value is changed when
adding new element to that enum.
RTE_ETH_FEC_NUM is used as the MAX vlaue of FEC modes, not one FEC
mode itself.
One of the application scenarios is as follows,set "testpmd" as an
example:
show_fec_capability(uint32_t fec_cap)

{
    uint32_t i;

    if (fec_cap == 0) {
        printf("FEC is not supported\n");
        return;
    }

    printf("FEC capabilities: ");
    for (i = RTE_ETH_FEC_BASER; i < RTE_ETH_FEC_NUM; i++) {
        if (fec_cap & 1U << i)
            printf("%s ", fec_mode_name[i].name);
    }
    printf("\n");
}
Quoted 25 lines
Quoted 25 lines
lib/librte_ethdev/rte_ethdev.h +18 -0
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3328,6 +3347,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:
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3362

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_AUTO

I'd like to see thoughts about different FEC modes for different link speed. How to report it? (sorry if I missed it before)

the relation between FEC mode and link speed, we can refer to hns3 PMD code, as follows:

	switch (mac->link_speed) {
	case ETH_SPEED_NUM_10G:
	case ETH_SPEED_NUM_40G:
		mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER |
			RTE_ETH_FEC_CAPA_AUTO;
		break;
	case ETH_SPEED_NUM_25G:
	case ETH_SPEED_NUM_50G:
		mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER |
			RTE_ETH_FEC_CAPA_RS | RTE_ETH_FEC_CAPA_AUTO;
		break;
	case ETH_SPEED_NUM_100G:
	case ETH_SPEED_NUM_200G:
		mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_RS |
			RTE_ETH_FEC_CAPA_AUTO;
		break;
	default:
		mode = 0;
		break;
	}
Quoted 14 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3371

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
+ * @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, uint32_t *fec_cap);

[snip]
.

#27 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 21 lines · Min Hu (Connor)
Quoted 18 lines · Andrew Rybchenko
Quoted 17 lines · Min Hu (Connor)

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

[snip]

Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..aa79326 100644
@@ -1511,6 +1511,25 @@ struct rte_eth_dcb_info {
       struct rte_eth_dcb_tc_queue_mapping tc_queue;
   };
Quoted 9 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1518

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {

enum rte_eth_fec_mode
to be consistent with other enums and to have library prefix.

I fixed it in V6,thanks.

Quoted 5 lines
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+    RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+    RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+    RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+    RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */
Quoted 6 lines
Quoted 4 lines

May I suggest to put AUTO just after NOFEC. It would look move logical in the future when more FEC modes are added. It would look strange with AUTO in the middle of the list.

 hns3 PMD is the first to implement FEC function. The FEC mode order is in accordance with the bit definition in hardware FEC module.

Sorry, it is not a good justification.
It does not matter who is the first and who will be the last.

Quoted 2 lines

 in other ways, AUTO is flexible mode, which should not be differently treated,the location in last item of enum is ok.

I still disagree. If it is OK for other ethdev maintainer - no problem, but I'd like to see explicit confirmation.

[snip]

Quoted 36 lines
Quoted 13 lines
Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -3328,6 +3347,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:

Quoted 8 lines
Quoted 4 lines

+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_AUTO

I'd like to see thoughts about different FEC modes for different link speed. How to report it? (sorry if I missed it before)

the relation between FEC mode and link speed, we can refer to hns3 PMD code, as follows:

    switch (mac->link_speed) {
    case ETH_SPEED_NUM_10G:
    case ETH_SPEED_NUM_40G:
        mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER | RTE_ETH_FEC_CAPA_AUTO;
        break;
    case ETH_SPEED_NUM_25G:
    case ETH_SPEED_NUM_50G:
        mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER | RTE_ETH_FEC_CAPA_RS | RTE_ETH_FEC_CAPA_AUTO; break;
    case ETH_SPEED_NUM_100G:

Quoted 8 lines

    case ETH_SPEED_NUM_200G:
        mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_RS | RTE_ETH_FEC_CAPA_AUTO;
        break;
    default:
        mode = 0;
        break;
    }

I'm sorry, but it does not answer my question.
I think we should change the API to report supported FEC modes per supported link speed.

Quoted 13 lines
Quoted 13 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3371

Quoted 9 lines

+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

[snip]
.

#28 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 55 lines · Andrew Rybchenko
Quoted 21 lines · Min Hu (Connor)
Quoted 18 lines · Andrew Rybchenko
Quoted 17 lines · Min Hu (Connor)

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

[snip]

Quoted 23 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +1 -0
index 70295d7..aa79326 100644
@@ -1511,6 +1511,25 @@ struct rte_eth_dcb_info {
       struct rte_eth_dcb_tc_queue_mapping tc_queue;
   };
+/**
Quoted 9 lines
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +1 -0
+ * This enum indicates the possible (forward error correction)FEC 

modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {

enum rte_eth_fec_mode
to be consistent with other enums and to have library prefix.

I fixed it in V6,thanks.

Quoted 5 lines
Quoted 4 lines

+    RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+    RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */ +    RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */ +    RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */

Quoted 6 lines
Quoted 4 lines

May I suggest to put AUTO just after NOFEC. It would look move logical in the future when more FEC modes are added. It would look strange with AUTO in the middle of the list.

  hns3 PMD is the first to implement FEC function. The FEC mode order is in accordance with the bit definition in hardware FEC module.

Quoted 7 lines

Sorry, it is not a good justification.
It does not matter who is the first and who will be the last.

Quoted 1 line

  in other ways, AUTO is flexible mode, which should not be differently     treated,the location in last item of enum is ok.

I still disagree. If it is OK for other ethdev maintainer - no problem, but I'd like to see explicit confirmation.

OK,thanks, I will try to fix it as you suggested.

Quoted 48 lines

[snip]

Quoted 36 lines
Quoted 13 lines
Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -3328,6 +3347,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:

Quoted 8 lines
Quoted 4 lines

+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_AUTO

I'd like to see thoughts about different FEC modes for different link speed. How to report it? (sorry if I missed it before)

the relation between FEC mode and link speed, we can refer to hns3 PMD code, as follows:

     switch (mac->link_speed) {
     case ETH_SPEED_NUM_10G:
     case ETH_SPEED_NUM_40G:
         mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER | RTE_ETH_FEC_CAPA_AUTO;
         break;
     case ETH_SPEED_NUM_25G:
     case ETH_SPEED_NUM_50G:
         mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER | RTE_ETH_FEC_CAPA_RS | RTE_ETH_FEC_CAPA_AUTO; break;
     case ETH_SPEED_NUM_100G:

Quoted 8 lines

     case ETH_SPEED_NUM_200G:
         mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_RS | RTE_ETH_FEC_CAPA_AUTO;
         break;
     default:
         mode = 0;
         break;
     }

Quoted 3 lines

I'm sorry, but it does not answer my question.
I think we should change the API to report supported FEC modes per supported link speed.

Sorry, maybe I do not get your meaning. By this API
(rte_eth_fec_get_capability),we can get FEC capabilityes from device. we (as user )do not care about the link speed, because this is done in PMD.
So, how to change the API. Could your make it more clearer? Hope for your reply.

Quoted 16 lines
Quoted 14 lines
Quoted 14 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3371

Quoted 10 lines

+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

[snip]
.

.

Acked-by on v5 1/3
#29 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

In reply to Min Hu (Connor)
Quoted 121 lines

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 13 +++++
 lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +13 -0
index cc72609..e4f0587 100644
@@ -55,6 +55,19 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+  Added hns3 FEC PMD, for supporting query and config FEC mode.
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..fde77c1 100644
@@ -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, uint32_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;
+	uint32_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 << (uint32_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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..aa79326 100644
@@ -1511,6 +1511,25 @@ struct rte_eth_dcb_info {
 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
 };
 

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1523

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+	RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_NUM

It is better not to have RTE_ETH_FEC_NUM here:
Any future additions to that enum would overwrite _NUM values and would considered as ABI breakage.
Aprart from that:

Quoted 196 lines
lib/librte_ethdev/rte_ethdev.h +73 -0
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3328,6 +3347,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_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, uint32_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
lib/librte_ethdev/rte_ethdev_core.h +77 -0
index 32407dd..cd1acf1 100644
@@ -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,
+					uint32_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; */
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +5 -1
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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

#30 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 136 lines · Konstantin
Quoted 121 lines

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

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
  doc/guides/rel_notes/release_20_11.rst   | 13 +++++
  lib/librte_ethdev/rte_ethdev.c           | 50 +++++++++++++++++++
  lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_core.h      | 77 +++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_version.map |  5 ++
  5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +13 -0
index cc72609..e4f0587 100644
@@ -55,6 +55,19 @@ New Features
       Also, make sure to start the actual text at the margin.
       =======================================================
 
+* **Added the FEC Library, a generic FEC query and config library.**
+
+  Added the FEC library which provides an API for query FEC capabilities and
+  FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+  Added hns3 FEC PMD, for supporting query and config FEC mode.
+
+* **Updated testpmd with a command for FEC.**
+
+  Added a FEC command to testpmd app,
+  ``show port <port_id> fec capabilities`` which queries FEC capabilities device supports.
+  ``show port <port_id> fec_mode`` which queries FEC mode from device.
+  ``set port <port_id> fec_mode <auto|off|rs|baser>`` which configures FEC mode to device.
 
  Removed Items
  -------------
lib/librte_ethdev/rte_ethdev.c +50 -0
index 7858ad5..fde77c1 100644
@@ -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, uint32_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;
+	uint32_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 << (uint32_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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..aa79326 100644
@@ -1511,6 +1511,25 @@ struct rte_eth_dcb_info {
  	struct rte_eth_dcb_tc_queue_mapping tc_queue;
  };
 

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1523

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+	RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_NUM

It is better not to have RTE_ETH_FEC_NUM here:
Any future additions to that enum would overwrite _NUM values and would considered as ABI breakage.
Aprart from that:

Quoted 2 lines

HI,
it does not matter even though RTE_ETH_FEC_NUM value is changed
when adding new element to that enum. RTE_ETH_FEC_NUM is used as the MAX vlaue of FEC modes, not one FEC mode itself.
One of the application scenarios is as follows,set "testpmd" as
an example:
show_fec_capability(uint32_t fec_cap)

{
	uint32_t i;

	if (fec_cap == 0) {
		printf("FEC is not supported\n");
		return;
	}

	printf("FEC capabilities: ");
	for (i = RTE_ETH_FEC_BASER; i < RTE_ETH_FEC_NUM; i++) {
		if (fec_cap & 1U << i)
			printf("%s ", fec_mode_name[i].name);
	}
	printf("\n");
}

Hope for your reply.

Quoted 199 lines
Quoted 195 lines
lib/librte_ethdev/rte_ethdev.h +73 -0
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3328,6 +3347,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ *   RTE_ETH_FEC_CAPA_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, uint32_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
lib/librte_ethdev/rte_ethdev_core.h +77 -0
index 32407dd..cd1acf1 100644
@@ -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,
+					uint32_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; */
  };
 
  /**
lib/librte_ethdev/rte_ethdev_version.map +5 -1
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
--
Quoted 1 line

2.7.4

.

#31 lore raw

Re: [dpdk-dev] [V5 1/3] ethdev: introduce FEC API

Quoted 18 lines
Quoted 16 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1523

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+	RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_NUM

It is better not to have RTE_ETH_FEC_NUM here:
Any future additions to that enum would overwrite _NUM values and would considered as ABI breakage.
Aprart from that:

Quoted 2 lines
Quoted 4 lines

HI,
it does not matter even though RTE_ETH_FEC_NUM value is changed
when adding new element to that enum. RTE_ETH_FEC_NUM is used as the MAX vlaue of FEC modes, not one FEC mode itself.

I understand that, but when in future you'll try to add some new mode, it will cause a change of RTE_ETH_FEC_NUM value.
As I remember, abicheck will report it as ABI breakage.
So adding new values to that enum will be really problematic.

Quoted 13 lines

One of the application scenarios is as follows,set "testpmd" as
an example:
show_fec_capability(uint32_t fec_cap)

{
	uint32_t i;

	if (fec_cap == 0) {
		printf("FEC is not supported\n");
		return;
	}

	printf("FEC capabilities: ");
	for (i = RTE_ETH_FEC_BASER; i < RTE_ETH_FEC_NUM; i++) {

I think you can use RTE_DIM(fec_mode_name) here instead of RTE_ETH_FEC_NUM.

Quoted 1 line
		if (fec_cap & 1U << i)

BTW, one more thing - as you translate from mode to capa all over the place, I think it deserves a separate macro for it.
Something like:
#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (x))

Quoted 16 lines
			printf("%s ", fec_mode_name[i].name);
	}
	printf("\n");
}

Hope for your reply.

Quoted 9 lines
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+
+
#32 lore raw

PATCH v5 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 157 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 176 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +157 -0

187 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..daf723e 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#33 lore raw

PATCH v5 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..c8fb616 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..8cc4728 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#34 lore raw

v6 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 157 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  49 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  83 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  78 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 676 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#35 lore raw

PATCH v6 1/3 ethdev: introduce FEC API

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

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 ++++
 lib/librte_ethdev/rte_ethdev.c           | 49 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 83 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 78 ++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 225 insertions(+)
doc/guides/rel_notes/release_20_11.rst +10 -0
index cc72609..e19b037 100644
@@ -55,6 +55,16 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +83 -0

95 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +79 -0

91 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#36 lore raw

PATCH v6 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 157 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 176 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +157 -0

187 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..2435668 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_eth_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#37 lore raw

PATCH v6 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..96da9aa 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_eth_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_eth_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#38 lore raw

v7 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 157 ++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  49 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  85 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  79 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 679 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#39 lore raw

PATCH v7 1/3 ethdev: introduce FEC API

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

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 ++++
 lib/librte_ethdev/rte_ethdev.c           | 49 ++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 85 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 79 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +10 -0
index cc72609..e19b037 100644
@@ -55,6 +55,16 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +85 -0

103 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +79 -0

91 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
Acked-by on v7 1/3
#40 lore raw

Re: [dpdk-dev] [PATCH V7 1/3] ethdev: introduce FEC API

Quoted 28 lines

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

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

Quoted 5 lines

---
v2->v3:
add function return value "-ENOTSUP" for API

---

Quoted 1 line

2.7.4

Reviewed-by
#41 lore raw

Re: [dpdk-dev] [PATCH V7 1/3] ethdev: introduce FEC API

Quoted 29 lines · Konstantin
Quoted 29 lines

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

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

Quoted 7 lines
Quoted 5 lines

---
v2->v3:
add function return value "-ENOTSUP" for API

---

Quoted 3 lines
Quoted 2 lines

2.7.4

#42 lore raw

Re: [dpdk-dev] [PATCH V7 1/3] ethdev: introduce FEC API

Quoted 30 lines · Ajit Khaparde
Quoted 28 lines · Konstantin
Quoted 28 lines

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

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

---
v2->v3:
add function return value "-ENOTSUP" for API

---

I'm sorry, but I'm still unhappy with enum members order and get capabilities API. See v5 notes.

#43 lore raw

PATCH v7 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 157 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 176 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +157 -0

187 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..2435668 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_eth_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#44 lore raw

PATCH v7 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..96da9aa 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_eth_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_eth_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
Acked-by on v7 3/3
#45 lore raw

Re: [dpdk-dev] [PATCH V7 3/3] app/testpmd: add FEC command

Quoted 12 lines · Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

Quoted 7 lines

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

Quoted 352 lines

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..96da9aa 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
        },
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+       cmdline_fixed_string_t cmd_show;
+       cmdline_fixed_string_t cmd_port;
+       cmdline_fixed_string_t cmd_fec;
+       cmdline_fixed_string_t cmd_keyword;
+       portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+               __rte_unused struct cmdline *cl,
+               __rte_unused void *data)
+{
+       struct cmd_show_fec_capability_result *res = parsed_result;
+       uint32_t fec_cap;
+       int ret;
+
+       if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+               printf("Invalid port id %u\n", res->cmd_pid);
+               return;
+       }
+
+       ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+       if (ret == -ENOTSUP) {
+               printf("Function not implemented\n");
+               return;
+       } else if (ret < 0) {
+               printf("Get FEC capability failed\n");
+               return;
+       }
+
+       show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+                       cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+                       cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+       TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+                       cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+                       cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+                       cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+       .f = cmd_show_fec_capability_parsed,
+       .data = NULL,
+       .help_str = "show port <port_id> fec capabilities",
+       .tokens = {
+               (void *)&cmd_show_fec_capability_show,
+               (void *)&cmd_show_fec_capability_port,
+               (void *)&cmd_show_fec_capability_pid,
+               (void *)&cmd_show_fec_capability_fec,
+               (void *)&cmd_show_fec_capability_keyword,
+               NULL,
+       },
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+       cmdline_fixed_string_t cmd_show;
+       cmdline_fixed_string_t cmd_port;
+       cmdline_fixed_string_t cmd_keyword;
+       portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+               __rte_unused struct cmdline *cl,
+               __rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+       struct cmd_show_fec_metadata_result *res = parsed_result;
+       enum rte_eth_fec_mode mode;
+       char buf[FEC_NAME_SIZE];
+       int ret;
+
+       if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+               printf("Invalid port id %u\n", res->cmd_pid);
+               return;
+       }
+       ret = rte_eth_fec_get(res->cmd_pid, &mode);
+       if (ret == -ENOTSUP) {
+               printf("Function not implemented\n");
+               return;
+       } else if (ret < 0) {
+               printf("Get FEC mode failed\n");
+               return;
+       }
+
+       switch (mode) {
+       case RTE_ETH_FEC_NOFEC:
+               strlcpy(buf, "off", sizeof(buf));
+               break;
+       case RTE_ETH_FEC_BASER:
+               strlcpy(buf, "baser", sizeof(buf));
+               break;
+       case RTE_ETH_FEC_RS:
+               strlcpy(buf, "rs", sizeof(buf));
+               break;
+       case RTE_ETH_FEC_AUTO:
+               strlcpy(buf, "auto", sizeof(buf));
+               break;
+       default:
+               return;
+       }
+
+       printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+                       cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+                       cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+       TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+                       cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+       TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+                       cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+       .f = cmd_show_fec_mode_parsed,
+       .data = NULL,
+       .help_str = "show port <port_id> fec_mode",
+       .tokens = {
+               (void *)&cmd_show_fec_mode_show,
+               (void *)&cmd_show_fec_mode_port,
+               (void *)&cmd_show_fec_mode_pid,
+               (void *)&cmd_show_fec_mode_keyword,
+               NULL,
+       },
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+       cmdline_fixed_string_t set;
+       cmdline_fixed_string_t port;
+       portid_t port_id;
+       cmdline_fixed_string_t fec_mode;
+       cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_port_fec_mode,
+                set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_port_fec_mode,
+                port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_set_port_fec_mode,
+                port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_port_fec_mode,
+                fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_set_port_fec_mode,
+                fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+       void *parsed_result,
+       __rte_unused struct cmdline *cl,
+       __rte_unused void *data)
+{
+       struct cmd_set_port_fec_mode *res = parsed_result;
+       uint16_t port_id = res->port_id;
+       enum rte_eth_fec_mode mode;
+       int ret;
+
+       ret = parse_fec_mode(res->fec_value, &mode);
+       if (ret < 0) {
+               printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+                       port_id);
+               return;
+       }
+
+       ret = rte_eth_fec_set(port_id, mode);
+       if (ret == -ENOTSUP) {
+               printf("Function not implemented\n");
+               return;
+       } else if (ret < 0) {
+               printf("Set FEC mode failed\n");
+               return;
+       }
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+       .f = cmd_set_port_fec_mode_parsed,
+       .data = NULL,
+       .help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+       .tokens = {
+               (void *)&cmd_set_port_fec_mode_set,
+               (void *)&cmd_set_port_fec_mode_port,
+               (void *)&cmd_set_port_fec_mode_port_id,
+               (void *)&cmd_set_port_fec_mode_str,
+               (void *)&cmd_set_port_fec_mode_value,
+               NULL,
+       },
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_show_set_raw,
        (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
        (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+       (cmdline_parse_inst_t *)&cmd_show_fec_mode,
+       (cmdline_parse_inst_t *)&cmd_set_fec_mode,
+       (cmdline_parse_inst_t *)&cmd_show_capability,
        NULL,
 };
 
app/test-pmd/config.c +54 -0
index 30bee33..e35d61a 100644
@@ -138,6 +138,28 @@ const struct rss_type_info rss_type_table[] = {
        { NULL, 0 },
 };
 
+static const struct {
+       enum rte_eth_fec_mode mode;
+       const char *name;
+} fec_mode_name[] = {
+       {
+               .mode = RTE_ETH_FEC_NOFEC,
+               .name = "off",
+       },
+       {
+               .mode = RTE_ETH_FEC_BASER,
+               .name = "baser",
+       },
+       {
+               .mode = RTE_ETH_FEC_RS,
+               .name = "rs",
+       },
+       {
+               .mode = RTE_ETH_FEC_AUTO,
+               .name = "auto",
+       },
+};
+
 static void
 print_ethaddr(const char *name, struct rte_ether_addr *eth_addr)
 {
@@ -2967,6 +2989,38 @@ set_tx_pkt_split(const char *name)
        printf("unknown value: \"%s\"\n", name);
 }
 
+int
+parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode)
+{
+       uint8_t i;
+
+       for (i = 0; i < RTE_DIM(fec_mode_name); i++) {
+               if (strcmp(fec_mode_name[i].name, name) == 0) {
+                       *mode = fec_mode_name[i].mode;
+                       return 0;
+               }
+       }
+       return -1;
+}
+
+void
+show_fec_capability(uint32_t fec_cap)
+{
+       uint32_t i;
+
+       if (fec_cap == 0) {
+               printf("FEC is not supported\n");
+               return;
+       }
+
+       printf("FEC capabilities: ");
+       for (i = RTE_ETH_FEC_BASER; i < RTE_DIM(fec_mode_name); i++) {
+               if (fec_cap & RTE_ETH_FEC_MODE_TO_CAPA(i))
+                       printf("%s ", fec_mode_name[i].name);
+       }
+       printf("\n");
+}
+
 void
 show_tx_pkt_segments(void)
 {
app/test-pmd/testpmd.h +2 -1
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
--

2.7.4

#46 lore raw

v8 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 183 ++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  49 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  85 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  79 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 705 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#47 lore raw

PATCH v8 1/3 ethdev: introduce FEC API

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

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 ++++
 lib/librte_ethdev/rte_ethdev.c           | 49 ++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 85 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 79 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +10 -0
index cc72609..e19b037 100644
@@ -55,6 +55,16 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +85 -0

103 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +79 -0

91 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#48 lore raw

PATCH v8 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 183 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 202 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +183 -0

219 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..2435668 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_eth_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#49 lore raw

PATCH v8 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..3394bea 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_eth_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_eth_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#50 lore raw

v9 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 183 ++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  49 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  85 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  79 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 705 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#51 lore raw

PATCH v9 1/3 ethdev: introduce FEC API

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

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 ++++
 lib/librte_ethdev/rte_ethdev.c           | 49 ++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 85 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 79 +++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)
doc/guides/rel_notes/release_20_11.rst +10 -0
index cc72609..e19b037 100644
@@ -55,6 +55,16 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +85 -0

103 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +79 -0

91 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#52 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Quoted 10 lines · Min Hu (Connor)

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

[snip]

lib/librte_ethdev/rte_ethdev.h struct rte_eth_conf { · line 1315

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
index 70295d7..7d5e81b 100644
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
 
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+

It should not be so far from rte_eth_fec_mode. Please, add just after it.

May be it should be:
#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (RTE_ETH_FEC_ ## x))

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +6 -0
 /**
  * Preferred Rx/Tx port parameters.
  * There are separate instances of this structure for transmission
@@ -1511,6 +1514,24 @@ 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_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1532

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* This indicates FEC capabilities */
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Shouldn't RTE_ETH_FEC_MODE_TO_CAPA be used as definition values?

Quoted 21 lines
lib/librte_ethdev/rte_ethdev.h +14 -0
+
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa; /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
};

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

where:
- num is in/out with a number of elements in an array
- speed_capa is out only with per-speed capabilities

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+
+/**
+ * @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

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3393

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   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_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Does AUTO make sense here?

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+
+/**
+ * @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

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3413

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   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_eth_fec_mode mode);

It does not allow to tweak autoneg facilities.
E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+/**
  * Get current status of the Ethernet link flow control for Ethernet device
  *
  * @param port_id

[snip]

#53 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Quoted 22 lines · Andrew Rybchenko
Quoted 10 lines · Min Hu (Connor)

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

[snip]

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..7d5e81b 100644
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
  #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
  #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
 
Quoted 6 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_conf { · line 1315

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+

It should not be so far from rte_eth_fec_mode. Please, add just after it.

I will fix it in V10, thanks.

Quoted 4 lines

May be it should be:
#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (RTE_ETH_FEC_ ## x))

This will be weird, as "x" should be one fec mode。examples as follows:

rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode)

{
	struct rte_eth_dev *dev;
	uint32_t fec_mode_mask;
	int ret;

	ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
	if (ret != 0)
		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 & RTE_ETH_FEC_MODE_TO_CAPA(mode))) {
		RTE_ETHDEV_LOG(ERR, "unsupported FEC mode = %d, port_id = %u\n",
			       mode, port_id);
		return -EINVAL;
	}

[snip]

Quoted 19 lines
Quoted 19 lines

/**
* Preferred Rx/Tx port parameters.
* There are separate instances of this structure for transmission

lib/librte_ethdev/rte_ethdev.h +12 -0
@@ -1511,6 +1514,24 @@ 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_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* This indicates FEC capabilities */
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1532

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Shouldn't RTE_ETH_FEC_MODE_TO_CAPA be used as definition values?
I will define a new macro as you suggest in V10, like this:

/* This macro indicates FEC capa mask*/
#define RTE_ETH_FEC_MODE_CAPA_MASK(x) (1U << (RTE_ETH_FEC_ ## x))

that macro will replace the follow macros:

#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

i.e.:
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC)
RTE_ETH_FEC_MODE_CAPA_MASK(AUTO)
RTE_ETH_FEC_MODE_CAPA_MASK(BASER)
RTE_ETH_FEC_MODE_CAPA_MASK(RS)

thanks for your suggestions.

Quoted 42 lines
Quoted 21 lines
lib/librte_ethdev/rte_ethdev.h +14 -0
+
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa; /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
};

Quoted 8 lines

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

where:
- num is in/out with a number of elements in an array
- speed_capa is out only with per-speed capabilities

There is no need to report capabilities per link speed, because relastionship between the link speed and fec mode is fixed. The infomations can be referred to in official documents or internet.

A ethernet port may have various link speed in diffrent situations(for example, optical module with different speed is used). But we do not care about capabilities per link speed. We only care about FEC capa of the ethernet device at a specific moment, because set FEC mode also depend on the current FEC capa.

By the way, we can also get link speed of the device by API "rte_eth_link_get" in the same time.

thanks.

Quoted 24 lines
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+
+/**
+ * @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

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3393

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   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_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Quoted 2 lines

Does AUTO make sense here?

OK, I will add the information in the function header comment:
when link down,None AUTO mode(RS, BASER. NOFEC) keep as it is when link up, AUTO mode will change from rs,baser to nofec when quering the mode.

Quoted 19 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +19 -0
+
+/**
+ * @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
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3413

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+int rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode);

It does not allow to tweak autoneg facilities. E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is

The two FEC modes cannot be configured for hardware at the same time, including AUTO and other FEC modes. This is determined by Hardware itself. Thanks.

Quoted 19 lines

not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3418

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+/**
   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id

[snip]

.

#54 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Quoted 49 lines · Min Hu (Connor)
Quoted 14 lines · Andrew Rybchenko
Quoted 10 lines · Min Hu (Connor)

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

[snip]

Quoted 14 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_conf { · line 1315

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
index 70295d7..7d5e81b 100644
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
   #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
   #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1

  +/* Translate from FEC mode to FEC capa */

lib/librte_ethdev/rte_ethdev.h +2 -0
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)    (1U << (x))
+

It should not be so far from rte_eth_fec_mode. Please, add just after it.

I will fix it in V10, thanks.

Quoted 4 lines

May be it should be:
#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (RTE_ETH_FEC_ ## x))

This will be weird, as "x" should be one fec mode。examples as follows:

rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode) {
    struct rte_eth_dev *dev;
    uint32_t fec_mode_mask;
    int ret;

    ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask); if (ret != 0)
        return ret;

Quoted 9 lines

    /*
     * Check whether the configured mode is within the FEC capability.
     * If not, the configured mode will not be supported.
     */
    if (!(fec_mode_mask & RTE_ETH_FEC_MODE_TO_CAPA(mode))) { RTE_ETHDEV_LOG(ERR, "unsupported FEC mode = %d, port_id = %u\n", mode, port_id);
        return -EINVAL;
    }

Got it, makes sense.

Quoted 36 lines

[snip]

Quoted 18 lines
Quoted 18 lines

  /**
   * Preferred Rx/Tx port parameters.
   * There are separate instances of this structure for transmission

lib/librte_ethdev/rte_ethdev.h +0 -0
@@ -1511,6 +1514,24 @@ 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.
+ */

lib/librte_ethdev/rte_ethdev.h +8 -0
+enum rte_eth_fec_mode {
+    RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+    RTE_ETH_FEC_AUTO,        /**< FEC autonegotiation modes */
+    RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+    RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* This indicates FEC capabilities */
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1532

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Shouldn't RTE_ETH_FEC_MODE_TO_CAPA be used as definition values?
I will define a new macro as you suggest in V10, like this:

/* This macro indicates FEC capa mask*/
#define RTE_ETH_FEC_MODE_CAPA_MASK(x)    (1U << (RTE_ETH_FEC_ ## x))

that macro will replace the follow macros:
#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC) #define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO) #define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER) #define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Quoted 7 lines

i.e.:
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC)
RTE_ETH_FEC_MODE_CAPA_MASK(AUTO)
RTE_ETH_FEC_MODE_CAPA_MASK(BASER)
RTE_ETH_FEC_MODE_CAPA_MASK(RS)

thanks for your suggestions.

Thanks for your work on the patchset.

Quoted 46 lines
Quoted 46 lines
Quoted 29 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+

  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
    /* Macros to check for valid port */

lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
   uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */ };

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

Quoted 7 lines
Quoted 4 lines

where:
  - num is in/out with a number of elements in an array
  - speed_capa is out only with per-speed capabilities

There is no need to report capabilities per link speed, because relastionship between the link speed and fec mode is fixed. The infomations can be referred to in official documents or internet.

Should an application download documents and search for it? :)

Quoted 6 lines

A ethernet port may have various link speed in diffrent situations(for example, optical module with different speed is used). But we do not care about capabilities per link speed. We only care about FEC capa of the ethernet device at a specific moment, because set FEC mode also depend on the current FEC capa.

Capabilities should not be for a specific moment. Capabilities should be fixed and stable (if transceiver is not replaced). Capabilities should not depend on a link speed or link status. Otherwise an application can't use it in a reliable way.

Quoted 31 lines

By the way, we can also get link speed of the device by API "rte_eth_link_get" in the same time.

thanks.

Quoted 25 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Quoted 5 lines
Quoted 2 lines

Does AUTO make sense here?

OK, I will add the information in the function header comment:
when link down,None AUTO mode(RS, BASER. NOFEC) keep as it is when link up, AUTO mode will change from rs,baser to nofec when quering the mode.

I'll take a look at the patch, above text is hardly readable.

Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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

Quoted 8 lines
Quoted 1 line

+int rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode);

It does not allow to tweak autoneg facilities. E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is

Quoted 2 lines

The two FEC modes cannot be configured for hardware at the same time, including AUTO and other FEC modes. This is determined by Hardware itself.

Which HW? Yours? If so, it does not matter. The patch adds generic API. My comments are not abstract thoughts. There are requirements and capabilities behind.

Quoted 22 lines

Thanks.

Quoted 20 lines

not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+/**

   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id

[snip]

.

#55 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Quoted 158 lines · Andrew Rybchenko
Quoted 49 lines · Min Hu (Connor)
Quoted 14 lines · Andrew Rybchenko
Quoted 10 lines · Min Hu (Connor)

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

[snip]

Quoted 14 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_conf { · line 1314

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
index 70295d7..7d5e81b 100644
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
   #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
   #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
   +/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)    (1U << (x))
+

It should not be so far from rte_eth_fec_mode. Please, add just after it.

I will fix it in V10, thanks.

Quoted 4 lines

May be it should be:
#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (RTE_ETH_FEC_ ## x))

This will be weird, as "x" should be one fec mode。examples as follows:

rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode) {
    struct rte_eth_dev *dev;
    uint32_t fec_mode_mask;
    int ret;

    ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask); if (ret != 0)
        return ret;

Quoted 9 lines

    /*
     * Check whether the configured mode is within the FEC capability.
     * If not, the configured mode will not be supported.
     */
    if (!(fec_mode_mask & RTE_ETH_FEC_MODE_TO_CAPA(mode))) { RTE_ETHDEV_LOG(ERR, "unsupported FEC mode = %d, port_id = %u\n", mode, port_id);
        return -EINVAL;
    }

Got it, makes sense.

Quoted 36 lines

[snip]

Quoted 18 lines
Quoted 18 lines

  /**
   * Preferred Rx/Tx port parameters.
   * There are separate instances of this structure for transmission

lib/librte_ethdev/rte_ethdev.h +11 -0
@@ -1511,6 +1514,24 @@ 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_eth_fec_mode {
+    RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+    RTE_ETH_FEC_AUTO,        /**< FEC autonegotiation modes */
+    RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+    RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* This indicates FEC capabilities */
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1532

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC)
+#define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO)
+#define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER)
+#define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Shouldn't RTE_ETH_FEC_MODE_TO_CAPA be used as definition values?
I will define a new macro as you suggest in V10, like this:

/* This macro indicates FEC capa mask*/
#define RTE_ETH_FEC_MODE_CAPA_MASK(x)    (1U << (RTE_ETH_FEC_ ## x))

that macro will replace the follow macros:
#define RTE_ETH_FEC_CAPA_NOFEC  (1U << RTE_ETH_FEC_NOFEC) #define RTE_ETH_FEC_CAPA_AUTO   (1U << RTE_ETH_FEC_AUTO) #define RTE_ETH_FEC_CAPA_BASER  (1U << RTE_ETH_FEC_BASER) #define RTE_ETH_FEC_CAPA_RS     (1U << RTE_ETH_FEC_RS)

Quoted 7 lines

i.e.:
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC)
RTE_ETH_FEC_MODE_CAPA_MASK(AUTO)
RTE_ETH_FEC_MODE_CAPA_MASK(BASER)
RTE_ETH_FEC_MODE_CAPA_MASK(RS)

thanks for your suggestions.

Thanks for your work on the patchset.

Quoted 50 lines
Quoted 50 lines
Quoted 29 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+
   #define RTE_ETH_ALL RTE_MAX_ETHPORTS
     /* Macros to check for valid port */
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
   uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
};

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

where:
  - num is in/out with a number of elements in an array
  - speed_capa is out only with per-speed capabilities

Quoted 5 lines
Quoted 3 lines

There is no need to report capabilities per link speed, because relastionship between the link speed and fec mode is fixed. The infomations can be referred to in official documents or internet.

Should an application download documents and search for it? :)

OK, I will report capabilities per link speed in V11. By the way,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

where:
- num is in/out with a number of elements in an array

could you describe "num" more detailedly, how to use this value?

Quoted 44 lines
Quoted 7 lines

A ethernet port may have various link speed in diffrent situations(for example, optical module with different speed is used). But we do not care about capabilities per link speed. We only care about FEC capa of the ethernet device at a specific moment, because set FEC mode also depend on the current FEC capa.

Capabilities should not be for a specific moment. Capabilities should be fixed and stable (if transceiver is not replaced). Capabilities should not depend on a link speed or link status. Otherwise an application can't use it in a reliable way.

Quoted 31 lines

By the way, we can also get link speed of the device by API "rte_eth_link_get" in the same time.

thanks.

Quoted 25 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Does AUTO make sense here?

OK, I will add the information in the function header comment:
when link down,None AUTO mode(RS, BASER. NOFEC) keep as it is when link up, AUTO mode will change from rs,baser to nofec when quering the mode.

I'll take a look at the patch, above text is hardly readable.(1). If the current mode of device is one of these modes:

RS, BASER. NOFEC.
when link up, for example, the mode is RS. when the device is linked down, the mode is always RS.

(2). If the current mode of device is AUTO:
when the device is linked down, the mode varies in this order:
rs->baser->nofec, until Auto-negotiation success (link shoud be up first).

But this is defined in our hardware. I think the first feature(1) are common and can be adopted.

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 21 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode);

It does not allow to tweak autoneg facilities. E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is

Quoted 6 lines
Quoted 2 lines

The two FEC modes cannot be configured for hardware at the same time, including AUTO and other FEC modes. This is determined by Hardware itself.

Which HW? Yours? If so, it does not matter. The patch adds generic API. My comments are not abstract thoughts. There are requirements and capabilities behind.

yes, it is in my HW. But I think the feature of FEC will exist in other HW: the two FEC modes cannot be configured for hardware at the same time. By the way, if set two FEC mode in our HW, the result will be unknown.
I also test X710 nic device, it does not support that feature.
I do not support that solutions. thanks.

Quoted 8 lines
Quoted 8 lines

Thanks.

Quoted 6 lines

not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be

Why? if the mode is unsupported (not in capa),why we can configure the the mode to the device? Because this is unreaonable. Also, the configure will not be ineffective, and the hardware will return error back to the driver.

Quoted 17 lines
Quoted 12 lines
Quoted 12 lines

a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+/**
    * Get current status of the Ethernet link flow control for

Ethernet device
   *
   * @param port_id

[snip]

Quoted 2 lines
Quoted 2 lines

.

.

#56 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Quoted 18 lines · Min Hu (Connor)
Quoted 15 lines · Andrew Rybchenko
Quoted 14 lines · Min Hu (Connor)
Quoted 11 lines · Andrew Rybchenko
Quoted 10 lines · Min Hu (Connor)

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

[snip]

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 38 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
    uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
};

Quoted 8 lines

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

where:
   - num is in/out with a number of elements in an array
   - speed_capa is out only with per-speed capabilities

There is no need to report capabilities per link speed, because relastionship between the link speed and fec mode is fixed. The infomations can be referred to in official documents or internet.

Quoted 8 lines
Quoted 1 line

Should an application download documents and search for it? :)

OK, I will report capabilities per link speed in V11. By the way,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

where:
    - num is in/out with a number of elements in an array

could you describe "num" more detailedly, how to use this value?

On input, num should specify a number of elements in speed_capa array provided by the caller to get FEC capabilities. If the number is insufficient to, error should be returned and the number should contain required number of elements. If sufficient, on output driver should return a number of filled in array elements.

Quoted 57 lines
Quoted 44 lines
Quoted 7 lines

A ethernet port may have various link speed in diffrent situations(for example, optical module with different speed is used). But we do not care about capabilities per link speed. We only care about FEC capa of the ethernet device at a specific moment, because set FEC mode also depend on the current FEC capa.

Capabilities should not be for a specific moment. Capabilities should be fixed and stable (if transceiver is not replaced). Capabilities should not depend on a link speed or link status. Otherwise an application can't use it in a reliable way.

Quoted 31 lines

By the way, we can also get link speed of the device by API "rte_eth_link_get" in the same time.

thanks.

Quoted 25 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

Review

Quoted 2 lines
(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Does AUTO make sense here?

OK, I will add the information in the function header comment:
when link down,None AUTO mode(RS, BASER. NOFEC) keep as it is when link up, AUTO mode will change from rs,baser to nofec when quering the mode.

I'll take a look at the patch, above text is hardly readable.

(1). If the current mode of device is one of these modes:
RS, BASER. NOFEC.
when link up, for example, the mode is RS. when the device is linked down, the mode is always RS.

Quoted 7 lines

(2). If the current mode of device is AUTO:
when the device is linked down, the mode varies in this order:
rs->baser->nofec, until Auto-negotiation success (link shoud be up first).

But this is defined in our hardware. I think the first feature(1) are common and can be adopted.

Sorry, I don't understand.
What abgot if link is down and AUTO is enabled, AUTO is returned, otherwise, configured FEC mode is returned. If link is up, current FEC mode is returned (i.e. not AUTO, either NOFEC, or RS, or BASER).

Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

Review

Quoted 2 lines
(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode);

It does not allow to tweak autoneg facilities. E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is

Quoted 7 lines
Quoted 3 lines

The two FEC modes cannot be configured for hardware at the same time, including AUTO and other FEC modes. This is determined by Hardware itself.

Which HW? Yours? If so, it does not matter. The patch adds generic API. My comments are not abstract thoughts. There are requirements and capabilities behind.

Quoted 5 lines

yes, it is in my HW. But I think the feature of FEC will exist in other
HW: the two FEC modes cannot be configured for hardware at the same time. By the way, if set two FEC mode in our HW, the result will be unknown. I also test X710 nic device, it does not support that feature. I do not support that solutions. thanks.

I'm not trying to say that two FEC modes could be running simultaneously. I'm trying to say that in the future a PHY could support more than one FEC mode and autonegotiation could make a choice which FEC mode to use.
E.g.
NOFEC, FOO and BAR modes supported
set (AUTO|FOO|BAR) will require either FOO or BAR to be negotiated and does not allow NOFEC.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Thanks.

Quoted 6 lines

not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be

Quoted 4 lines

Why? if the mode is unsupported (not in capa),why we can configure the the mode to the device? Because this is unreaonable. Also, the configure will not be ineffective, and the hardware will return error back to the driver.

I agree that requested mode should be in capabilities for at least some speed, but not required to be applicable to currently negotiated and running speed. May be it is obvious. I.e. if I set AUTO|NOFEC|RS when capabilities are 25G(NOFEC,AUTO,BASER) and 100G(NOFEC,AUTO,RS), it will enforce NOFEC for 25G (since BASER is disabled) and allow either NOFEC or RS for 100G.

Quoted 17 lines
Quoted 17 lines
Quoted 12 lines
Quoted 12 lines

a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

Quoted 6 lines
(quoted diff) +2 -0
+
+/**

    * Get current status of the Ethernet link flow control for Ethernet device
    *
    * @param port_id

[snip]

Quoted 2 lines
Quoted 2 lines

.

.

#57 lore raw

Re: [dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

Hi, Andrew,
I have fixed it about FEC in V11 according to your suggestion. could your please check it out.

thanks.

Quoted 251 lines · Andrew Rybchenko
Quoted 18 lines · Min Hu (Connor)
Quoted 15 lines · Andrew Rybchenko
Quoted 14 lines · Min Hu (Connor)
Quoted 11 lines · Andrew Rybchenko
Quoted 10 lines · Min Hu (Connor)

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

[snip]

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 38 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -3328,6 +3349,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:
+ *   RTE_ETH_FEC_CAPA_NOFEC
+ *   RTE_ETH_FEC_CAPA_AUTO
+ *   RTE_ETH_FEC_CAPA_BASER
+ *   RTE_ETH_FEC_CAPA_RS
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3373

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap);

The API does not allow to report capabilities per link speed:
which FEC mode is supported at which link speed?

What about something like:

struct rte_eth_fec_capa {
    uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */ uint32_t capa;  /**< FEC capabilities bitmask (see
RTE_FEC_CAPA_*) */
};

Quoted 8 lines

__rte_experimental
int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num, struct rte_eth_fec_capa *speed_capa);

where:
   - num is in/out with a number of elements in an array
   - speed_capa is out only with per-speed capabilities

There is no need to report capabilities per link speed, because relastionship between the link speed and fec mode is fixed. The infomations can be referred to in official documents or internet.

Quoted 8 lines
Quoted 1 line

Should an application download documents and search for it? :)

OK, I will report capabilities per link speed in V11. By the way,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

where:
    - num is in/out with a number of elements in an array

could you describe "num" more detailedly, how to use this value?

On input, num should specify a number of elements in speed_capa array provided by the caller to get FEC capabilities. If the number is insufficient to, error should be returned and the number should contain required number of elements. If sufficient, on output driver should return a number of filled in array elements.

Quoted 57 lines
Quoted 44 lines
Quoted 7 lines

A ethernet port may have various link speed in diffrent situations(for example, optical module with different speed is used). But we do not care about capabilities per link speed. We only care about FEC capa of the ethernet device at a specific moment, because set FEC mode also depend on the current FEC capa.

Capabilities should not be for a specific moment. Capabilities should be fixed and stable (if transceiver is not replaced). Capabilities should not depend on a link speed or link status. Otherwise an application can't use it in a reliable way.

Quoted 31 lines

By the way, we can also get link speed of the device by API "rte_eth_link_get" in the same time.

thanks.

Quoted 25 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

Review

Quoted 2 lines
(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode);

Please, specify what should be reported if link is down. E.g. if set to RS, but link is down.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Does AUTO make sense here?

OK, I will add the information in the function header comment:
when link down,None AUTO mode(RS, BASER. NOFEC) keep as it is when link up, AUTO mode will change from rs,baser to nofec when quering the mode.

I'll take a look at the patch, above text is hardly readable.

(1). If the current mode of device is one of these modes:
RS, BASER. NOFEC.
when link up, for example, the mode is RS. when the device is linked down, the mode is always RS.

Quoted 7 lines

(2). If the current mode of device is AUTO:
when the device is linked down, the mode varies in this order:
rs->baser->nofec, until Auto-negotiation success (link shoud be up first).

But this is defined in our hardware. I think the first feature(1) are common and can be adopted.

Sorry, I don't understand.
What abgot if link is down and AUTO is enabled, AUTO is returned, otherwise, configured FEC mode is returned. If link is up, current FEC mode is returned (i.e. not AUTO, either NOFEC, or RS, or BASER).

Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @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.
+ */

Review

Quoted 2 lines
(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode);

It does not allow to tweak autoneg facilities. E.g. "I know that RS is buggy, so I want to exclude it from auto-negotiation".
So, I suggest to change mode to capa bitmask.
If AUTO is set, other bits may be set and specify allowed options. E.g. AUTO|RS|BASER will require FEC, i.e. NOFEC is

Quoted 7 lines
Quoted 3 lines

The two FEC modes cannot be configured for hardware at the same time, including AUTO and other FEC modes. This is determined by Hardware itself.

Which HW? Yours? If so, it does not matter. The patch adds generic API. My comments are not abstract thoughts. There are requirements and capabilities behind.

Quoted 5 lines

yes, it is in my HW. But I think the feature of FEC will exist in other
HW: the two FEC modes cannot be configured for hardware at the same time. By the way, if set two FEC mode in our HW, the result will be unknown. I also test X710 nic device, it does not support that feature. I do not support that solutions. thanks.

I'm not trying to say that two FEC modes could be running simultaneously. I'm trying to say that in the future a PHY could support more than one FEC mode and autonegotiation could make a choice which FEC mode to use.
E.g.
NOFEC, FOO and BAR modes supported
set (AUTO|FOO|BAR) will require either FOO or BAR to be negotiated and does not allow NOFEC.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Thanks.

Quoted 6 lines

not allowed. If just RS, it means that auto-negotiation is disabled and RS must be used.
If AUTO is unset, only one bit may be set in capabilities. Since we don't do it per speed, I think it is safe to ignore unsupported mode bits. I.e. do not return error if unsupported capa is requested to together with AUTO, however it could be

Quoted 4 lines

Why? if the mode is unsupported (not in capa),why we can configure the the mode to the device? Because this is unreaonable. Also, the configure will not be ineffective, and the hardware will return error back to the driver.

I agree that requested mode should be in capabilities for at least some speed, but not required to be applicable to currently negotiated and running speed. May be it is obvious. I.e. if I set AUTO|NOFEC|RS when capabilities are 25G(NOFEC,AUTO,BASER) and 100G(NOFEC,AUTO,RS), it will enforce NOFEC for 25G (since BASER is disabled) and allow either NOFEC or RS for 100G.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

a problem if no modes are allowed for negotiated link speed. Thoughts are welcome.

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+
+/**
     * Get current status of the Ethernet link flow control for

Ethernet device
    *
    * @param port_id

[snip]

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

.

.

.

#58 lore raw

PATCH v9 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 183 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 202 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +183 -0

219 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..2435668 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_eth_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#59 lore raw

PATCH v9 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..3394bea 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_eth_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_eth_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#60 lore raw

v10 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 219 +++++++++++++++++++++++++++++++
 app/test-pmd/config.c                    |  54 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h              |  19 ++-
 drivers/net/hns3/hns3_ethdev.c           | 187 ++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  49 +++++++
 lib/librte_ethdev/rte_ethdev.h           |  81 ++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  79 +++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 705 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#61 lore raw

PATCH v10 1/3 ethdev: introduce FEC API

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

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 ++++
 lib/librte_ethdev/rte_ethdev.c           | 49 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 81 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      | 79 +++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 224 insertions(+)
doc/guides/rel_notes/release_20_11.rst +10 -0
index cc72609..e19b037 100644
@@ -55,6 +55,16 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +81 -0

93 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_core.h +79 -0

91 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +5 -0
index 02081d9..9f3fb8f 100644
@@ -239,6 +239,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 {
Signature · 1 line
2.7.4
#62 lore raw

PATCH v10 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v9->v10:
use RTE_ETH_FEC_MODE_CAPA_MASK(x) which is just defined.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++++-
 drivers/net/hns3/hns3_ethdev.c | 187 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 206 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index d70f42e..8b80353 100644
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
 	HNS3_MAC_COMMON_INT_EN          = 0x030E,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +187 -0

223 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index 0e665e5..2435668 100644
@@ -510,6 +510,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	enum rte_eth_fec_mode fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#63 lore raw

PATCH v10 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  54 ++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)
app/test-pmd/cmdline.c +219 -0
index 0a6ed85..3394bea 100644
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	uint32_t fec_cap;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	enum rte_eth_fec_mode mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_NOFEC:
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_AUTO:
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_BASER:
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_RS:
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	enum rte_eth_fec_mode mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19685,6 +19901,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +54 -0

66 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 25a12b1..3be56e8 100644
@@ -778,6 +778,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t fec_cap);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#64 lore raw

v11 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (4):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command
doc: add FEC API and PMD information

 app/test-pmd/cmdline.c                   | 221 +++++++++++++++++++
 app/test-pmd/config.c                    |  91 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |   9 +
 drivers/net/hns3/hns3_cmd.h              |  19 +-
 drivers/net/hns3/hns3_ethdev.c           | 357 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  37 ++++
 lib/librte_ethdev/rte_ethdev.h           |  91 ++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  82 +++++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 11 files changed, 912 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#65 lore raw

PATCH v11 1/4 ethdev: introduce FEC API

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

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 lib/librte_ethdev/rte_ethdev.c           | 37 +++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 91 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    | 82 ++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 ++
 4 files changed, 213 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index dfe5c1b..b614bfc 100644
@@ -3679,6 +3679,43 @@ 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, uint32_t *num,
+			   struct rte_eth_fec_capa *speed_fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (num == NULL || speed_fec_capa == NULL)
+		return -EINVAL;
+
+	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, num,
+							speed_fec_capa));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+
+	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.
lib/librte_ethdev/rte_ethdev.h +91 -0

103 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +82 -0

94 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
Signature · 1 line
2.7.4
#66 lore raw

PATCH v11 2/4 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v10->v11:
allow to report capabilities per link speed.
specify what should be reported if link is down
when get FEC.
change mode to capa bitmask.

---
v9->v10:
use RTE_ETH_FEC_MODE_CAPA_MASK(x) which is just defined.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++-
 drivers/net/hns3/hns3_ethdev.c | 357 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 376 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index 87d6053..a1e9604 100644
@@ -100,6 +100,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_QUERY_LINK_STATUS      = 0x0307,
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -684,9 +685,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +357 -0

399 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index fd6a9f9..393b91f 100644
@@ -620,6 +620,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	uint32_t fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#67 lore raw

PATCH v11 3/4 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v10->v11:
change mode to capa bitmask.

---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  91 ++++++++++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 314 insertions(+)
app/test-pmd/cmdline.c +221 -0
index 5f93409..445726f 100644
@@ -19161,6 +19161,224 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_CAP_NUM 2
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
+	uint32_t num = FEC_CAP_NUM;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &num, speed_fec_capa);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(num, speed_fec_capa);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	uint32_t mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	uint32_t mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19795,6 +20013,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +91 -0

103 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index f139fe7..85ea030 100644
@@ -804,6 +804,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#68 lore raw

PATCH v11 4/4 doc: add FEC API and PMD information

In reply to Min Hu (Connor)

Added the FEC API, and hns3 FEC PMD information in release 20.11.rst file.

---
 doc/guides/rel_notes/release_20_11.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
doc/guides/rel_notes/release_20_11.rst +9 -0
index c6642f5..de2c8e4 100644
@@ -78,6 +78,15 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
 
 Removed Items
 -------------
Signature · 1 line
2.7.4
#69 lore raw

v12 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (4):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command
doc: add FEC API and PMD information

 app/test-pmd/cmdline.c                   | 221 +++++++++++++++++++
 app/test-pmd/config.c                    |  91 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |   9 +
 drivers/net/hns3/hns3_cmd.h              |  19 +-
 drivers/net/hns3/hns3_ethdev.c           | 357 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  37 ++++
 lib/librte_ethdev/rte_ethdev.h           |  91 ++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  82 +++++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 11 files changed, 912 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#70 lore raw

PATCH v12 1/4 ethdev: introduce FEC API

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

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 lib/librte_ethdev/rte_ethdev.c           | 37 +++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 91 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    | 82 ++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 ++
 4 files changed, 213 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index dfe5c1b..b614bfc 100644
@@ -3679,6 +3679,43 @@ 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, uint32_t *num,
+			   struct rte_eth_fec_capa *speed_fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (num == NULL || speed_fec_capa == NULL)
+		return -EINVAL;
+
+	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, num,
+							speed_fec_capa));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+
+	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.
lib/librte_ethdev/rte_ethdev.h +91 -0

103 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +82 -0

94 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
Signature · 1 line
2.7.4
#71 lore raw

Re: [dpdk-dev] [PATCH V12 1/4] ethdev: introduce FEC API

Quoted 3 lines · Min Hu (Connor)

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

Almost good now. See my notes below.
Many thanks for hard work and patience.

Quoted 7 lines

I think that tags for Ajit and Konstantin should be dropped, since API changes significantly after their review.

Quoted 56 lines

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 lib/librte_ethdev/rte_ethdev.c           | 37 +++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 91 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    | 82 ++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 ++
 4 files changed, 213 insertions(+)
lib/librte_ethdev/rte_ethdev.c +0 -0
index dfe5c1b..b614bfc 100644
@@ -3679,6 +3679,43 @@ rte_eth_led_off(uint16_t port_id)
 	return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3689

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
 }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+			   struct rte_eth_fec_capa *speed_fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (num == NULL || speed_fec_capa == NULL)
+		return -EINVAL;

I think it is OK to have speed_fec_cap==NULL if *num is 0. I.e. a request to get number of required array entries.

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3701

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+
+	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, num,
+							speed_fec_capa));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *mode)
+{
+	struct rte_eth_dev *dev;

I think it would be good to check that mode is not NULL here.

Quoted 25 lines
lib/librte_ethdev/rte_ethdev.c +17 -0
+
+	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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+
+	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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 645a186..104181d 100644

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1548

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -1544,6 +1544,29 @@ struct rte_eth_dcb_info {
 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
 };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes

(forward error correction)FEC -> Forward Error Correction (FEC)

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1561

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +13 -0
+ * of an ethdev port.
+ */
+enum rte_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+
+/* This macro indicates FEC capa mask*/

Add missing space before */

Quoted 14 lines
lib/librte_ethdev/rte_ethdev.h +8 -0
+#define RTE_ETH_FEC_MODE_CAPA_MASK(x)	(1U << (RTE_ETH_FEC_ ## x))
+
+/* A structure used to get capabilities per link speed */
+struct rte_eth_fec_capa {
+	uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
+	uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
+};
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3397,6 +3420,74 @@ int  rte_eth_led_on(uint16_t port_id);
 int  rte_eth_led_off(uint16_t port_id);
 

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3431

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
 /**
+ * @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 num
+ *   the num is in/out with a number of elements in an array.

Please, see below my notes on callback description.

Quoted 38 lines
lib/librte_ethdev/rte_ethdev.h +38 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @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.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+			struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @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, uint32_t *mode);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3479

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

See below.

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
  * Get current status of the Ethernet link flow control for Ethernet device
  *
  * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
index 23cc1e0..625b8c5 100644

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 584

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +7 -0
@@ -575,6 +575,81 @@ 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 num
+ *   the num is in/out with a number of elements in an array.

I'm sorry, I should do it before my previous suggestion, but:
Looking at rte_eth_xstats_get_names() and trying to be consistent I'd like to suggest to put the argument after speed_fec_capa and make it input only with a number of array elements.
Positive return values should be used to provide number of filled in array elements. If the returned value is greater than 'num', just provided elements are filled in, but it is indication as well, that num is too small.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.

See above.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 594

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 596

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 598

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 12 lines
lib/librte_ethdev/rte_ethdev_driver.h +12 -0
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, uint32_t *num,
+				struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 620

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+ * @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.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 622

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 631

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +9 -0
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *mode);
+
+/**
+ * @internal
+ *   Set Forward Error Correction(FEC) mode.

Remove extra spaces before "Set"

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 636

Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +5 -0
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode
+ *   the FEC mode.

The description is insufficient and misleading. It should be fec_capa and described as:
Bitmask of allowed FEC modes. If must be only one if AUTO is disabled. If AUTO is enabled, other bits specify FEC modes which may be negotiated.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 644

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

What about -EINVAL in the case of unsupported FEC mode requested? It is listed above in API function but missing here.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 646

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 648

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +4 -0
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
 struct eth_dev_ops {

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 793

Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +3 -0
@@ -713,6 +788,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; */

It should be a dot (.) at the end, not semicolon (;).

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 795

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+	eth_fec_get_t fec_get;
+	/**< Get Forward Error Correction(FEC) mode; */

same

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 797

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+	eth_fec_set_t fec_set;
+	/**< Set Forward Error Correction(FEC) mode; */

same

Quoted 18 lines
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
#72 lore raw

Re: [dpdk-dev] [PATCH V12 1/4] ethdev: introduce FEC API

HI,Andrew,
I fix it in V13 according to your advice.
Thanks for your patient review. Please check it out again.

By the way, there is always a coding check warning, like this:

WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #264: FILE: drivers/net/hns3/hns3_ethdev.c:5601:
+ /* fallthrough */

total: 0 errors, 1 warnings, 0 checks, 439 lines checked.

I have tried some ways, but it does not help.
Could you giver some advice?
thanks.

Quoted 426 lines · Andrew Rybchenko
Quoted 3 lines · Min Hu (Connor)

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

Almost good now. See my notes below.
Many thanks for hard work and patience.

Quoted 7 lines

I think that tags for Ajit and Konstantin should be dropped, since API changes significantly after their review.

Quoted 56 lines

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
  lib/librte_ethdev/rte_ethdev.c           | 37 +++++++++++++
  lib/librte_ethdev/rte_ethdev.h           | 91 ++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    | 82 ++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_version.map |  3 ++
  4 files changed, 213 insertions(+)
lib/librte_ethdev/rte_ethdev.c +0 -0
index dfe5c1b..b614bfc 100644
@@ -3679,6 +3679,43 @@ rte_eth_led_off(uint16_t port_id)
  	return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3689

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
  }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+			   struct rte_eth_fec_capa *speed_fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (num == NULL || speed_fec_capa == NULL)
+		return -EINVAL;

I think it is OK to have speed_fec_cap==NULL if *num is 0. I.e. a request to get number of required array entries.

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3701

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+
+	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, num,
+							speed_fec_capa));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *mode)
+{
+	struct rte_eth_dev *dev;

I think it would be good to check that mode is not NULL here.

Quoted 25 lines
lib/librte_ethdev/rte_ethdev.c +17 -0
+
+	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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+
+	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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 645a186..104181d 100644

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1548

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -1544,6 +1544,29 @@ struct rte_eth_dcb_info {
  	struct rte_eth_dcb_tc_queue_mapping tc_queue;
  };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes

(forward error correction)FEC -> Forward Error Correction (FEC)

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1561

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +13 -0
+ * of an ethdev port.
+ */
+enum rte_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+
+/* This macro indicates FEC capa mask*/

Add missing space before */

Quoted 14 lines
lib/librte_ethdev/rte_ethdev.h +8 -0
+#define RTE_ETH_FEC_MODE_CAPA_MASK(x)	(1U << (RTE_ETH_FEC_ ## x))
+
+/* A structure used to get capabilities per link speed */
+struct rte_eth_fec_capa {
+	uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
+	uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
+};
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3397,6 +3420,74 @@ int  rte_eth_led_on(uint16_t port_id);
  int  rte_eth_led_off(uint16_t port_id);
 

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3431

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
  /**
+ * @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 num
+ *   the num is in/out with a number of elements in an array.

Please, see below my notes on callback description.

Quoted 38 lines
lib/librte_ethdev/rte_ethdev.h +38 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @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.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+			struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @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, uint32_t *mode);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3479

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

See below.

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
index 23cc1e0..625b8c5 100644

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 584

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +7 -0
@@ -575,6 +575,81 @@ 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 num
+ *   the num is in/out with a number of elements in an array.

I'm sorry, I should do it before my previous suggestion, but:
Looking at rte_eth_xstats_get_names() and trying to be consistent I'd like to suggest to put the argument after speed_fec_capa and make it input only with a number of array elements.
Positive return values should be used to provide number of filled in array elements. If the returned value is greater than 'num', just provided elements are filled in, but it is indication as well, that num is too small.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.

See above.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 594

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 596

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 598

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 12 lines
lib/librte_ethdev/rte_ethdev_driver.h +12 -0
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, uint32_t *num,
+				struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 620

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+ * @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.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 622

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 631

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +9 -0
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *mode);
+
+/**
+ * @internal
+ *   Set Forward Error Correction(FEC) mode.

Remove extra spaces before "Set"

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 636

Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +5 -0
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode
+ *   the FEC mode.

The description is insufficient and misleading. It should be fec_capa and described as:
Bitmask of allowed FEC modes. If must be only one if AUTO is disabled. If AUTO is enabled, other bits specify FEC modes which may be negotiated.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 644

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

What about -EINVAL in the case of unsupported FEC mode requested? It is listed above in API function but missing here.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 646

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 648

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +4 -0
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
  struct eth_dev_ops {

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 793

Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +3 -0
@@ -713,6 +788,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; */

It should be a dot (.) at the end, not semicolon (;).

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 795

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+	eth_fec_get_t fec_get;
+	/**< Get Forward Error Correction(FEC) mode; */

same

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 797

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+	eth_fec_set_t fec_set;
+	/**< Set Forward Error Correction(FEC) mode; */

same

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
  };
 
  /**
lib/librte_ethdev/rte_ethdev_version.map +0 -0
index c95ef51..b9ace3a 100644

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 237

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -229,6 +229,9 @@ EXPERIMENTAL {
  	# added in 20.11
  	rte_eth_link_speed_to_str;
  	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
  };
 
  INTERNAL {

.

#73 lore raw

Re: [dpdk-dev] [PATCH V12 1/4] ethdev: introduce FEC API

Quoted 10 lines · Min Hu (Connor)

HI,Andrew,
I fix it in V13 according to your advice.
Thanks for your patient review. Please check it out again.

By the way, there is always a coding check warning, like this:

WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #264: FILE: drivers/net/hns3/hns3_ethdev.c:5601:
+ /* fallthrough */

Try /* FALLTHROUGH */

Quoted 435 lines

total: 0 errors, 1 warnings, 0 checks, 439 lines checked.

I have tried some ways, but it does not help.
Could you giver some advice?
thanks.

Quoted 426 lines · Andrew Rybchenko
Quoted 3 lines · Min Hu (Connor)

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

Almost good now. See my notes below.
Many thanks for hard work and patience.

Quoted 7 lines

I think that tags for Ajit and Konstantin should be dropped, since API changes significantly after their review.

Quoted 56 lines

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
  lib/librte_ethdev/rte_ethdev.c           | 37 +++++++++++++
  lib/librte_ethdev/rte_ethdev.h           | 91 ++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    | 82 ++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_version.map |  3 ++
  4 files changed, 213 insertions(+)
lib/librte_ethdev/rte_ethdev.c +0 -0
index dfe5c1b..b614bfc 100644
@@ -3679,6 +3679,43 @@ rte_eth_led_off(uint16_t port_id)
     return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3689

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
  }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+                       struct rte_eth_fec_capa *speed_fec_capa)
+{
+    struct rte_eth_dev *dev;
+
+    if (num == NULL || speed_fec_capa == NULL)
+            return -EINVAL;

I think it is OK to have speed_fec_cap==NULL if *num is 0. I.e. a request to get number of required array entries.

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3701

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+
+    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, num,
+                                                    speed_fec_capa));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *mode)
+{
+    struct rte_eth_dev *dev;

I think it would be good to check that mode is not NULL here.

Quoted 25 lines
lib/librte_ethdev/rte_ethdev.c +17 -0
+
+    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, uint32_t mode)
+{
+    struct rte_eth_dev *dev;
+
+    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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 645a186..104181d 100644

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1548

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -1544,6 +1544,29 @@ struct rte_eth_dcb_info {
     struct rte_eth_dcb_tc_queue_mapping tc_queue;
  };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes

(forward error correction)FEC -> Forward Error Correction (FEC)

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1561

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.h +13 -0
+ * of an ethdev port.
+ */
+enum rte_eth_fec_mode {
+    RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+    RTE_ETH_FEC_AUTO,           /**< FEC autonegotiation modes */
+    RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+    RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x) (1U << (x))
+
+/* This macro indicates FEC capa mask*/

Add missing space before */

Quoted 14 lines
lib/librte_ethdev/rte_ethdev.h +8 -0
+#define RTE_ETH_FEC_MODE_CAPA_MASK(x)       (1U << (RTE_ETH_FEC_ ## x))
+
+/* A structure used to get capabilities per link speed */
+struct rte_eth_fec_capa {
+    uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
+    uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */
+};
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3397,6 +3420,74 @@ int  rte_eth_led_on(uint16_t port_id);
  int  rte_eth_led_off(uint16_t port_id);
 

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3431

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +9 -0
  /**
+ * @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 num
+ *   the num is in/out with a number of elements in an array.

Please, see below my notes on callback description.

Quoted 38 lines
lib/librte_ethdev/rte_ethdev.h +38 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @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.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id, uint32_t *num,
+                    struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @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, uint32_t *mode);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3479

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

See below.

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
index 23cc1e0..625b8c5 100644

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 584

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +7 -0
@@ -575,6 +575,81 @@ 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 num
+ *   the num is in/out with a number of elements in an array.

I'm sorry, I should do it before my previous suggestion, but:
Looking at rte_eth_xstats_get_names() and trying to be consistent I'd like to suggest to put the argument after speed_fec_capa and make it input only with a number of array elements.
Positive return values should be used to provide number of filled in array elements. If the returned value is greater than 'num', just provided elements are filled in, but it is indication as well, that num is too small.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.

See above.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 594

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 596

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 598

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 12 lines
lib/librte_ethdev/rte_ethdev_driver.h +12 -0
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, uint32_t *num,
+                            struct rte_eth_fec_capa *speed_fec_capa);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 620

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+ * @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.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 622

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 631

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +9 -0
+ * @retval -ENODEV
+ *   Device is gone.
+ */
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+                         uint32_t *mode);
+
+/**
+ * @internal
+ *   Set Forward Error Correction(FEC) mode.

Remove extra spaces before "Set"

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 636

Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +5 -0
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode
+ *   the FEC mode.

The description is insufficient and misleading. It should be fec_capa and described as:
Bitmask of allowed FEC modes. If must be only one if AUTO is disabled. If AUTO is enabled, other bits specify FEC modes which may be negotiated.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 644

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8 -0
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   operation is not supported.

Should start from upper case letter

What about -EINVAL in the case of unsupported FEC mode requested? It is listed above in API function but missing here.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 646

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -EIO
+ *   device is removed.

Should start from upper case letter

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 648

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ * @retval -ENODEV
+ *   Device is gone.

What's the difference between "device is remove" and "Device is gone"

Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +4 -0
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
  struct eth_dev_ops {

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 793

Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +3 -0
@@ -713,6 +788,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; */

It should be a dot (.) at the end, not semicolon (;).

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 795

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+    eth_fec_get_t fec_get;
+    /**< Get Forward Error Correction(FEC) mode; */

same

lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 797

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+    eth_fec_set_t fec_set;
+    /**< Set Forward Error Correction(FEC) mode; */

same

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
  };
 
  /**
lib/librte_ethdev/rte_ethdev_version.map +0 -0
index c95ef51..b9ace3a 100644

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 237

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -229,6 +229,9 @@ EXPERIMENTAL {
     # added in 20.11
     rte_eth_link_speed_to_str;
     rte_eth_link_to_str;
+    rte_eth_fec_get_capability;
+    rte_eth_fec_get;
+    rte_eth_fec_set;
  };
 
  INTERNAL {

.

#74 lore raw

Re: [dpdk-dev] [PATCH V12 1/4] ethdev: introduce FEC API

Quoted 5 lines · On Fri, 25 Sep 2020 08:36:06 -0700 Ajit Khaparde <[email protected]>…
Quoted 4 lines

WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #264: FILE: drivers/net/hns3/hns3_ethdev.c:5601:
+ /* fallthrough */

Try /* FALLTHROUGH */

That won't work either.

This is a new warning from upstream Linux kernel checkpatch. The Linux kernel has converted code to use a new macro.

The warning should be silenced by the DPDK checkpatch script.

devtools/checkpatches.sh +1 -1
index 78a408ef9823..923ff6f7d9ee 100755
@@ -33,7 +33,7 @@ VOLATILE,PREFER_PACKED,PREFER_ALIGNED,PREFER_PRINTF,\
 PREFER_KERNEL_TYPES,PREFER_FALLTHROUGH,BIT_MACRO,CONST_STRUCT,\
 SPLIT_STRING,LONG_LINE_STRING,C99_COMMENT_TOLERANCE,\
 LINE_SPACING,PARENTHESIS_ALIGNMENT,NETWORKING_BLOCK_COMMENT_STYLE,\
-NEW_TYPEDEFS,COMPARISON_TO_NULL"
+NEW_TYPEDEFS,COMPARISON_TO_NULL,PREFER_FALLTHROUGH"
 options="$options $DPDK_CHECKPATCH_OPTIONS"
#75 lore raw

Re: [dpdk-dev] [PATCH V12 1/4] ethdev: introduce FEC API

Quoted 21 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 25 Sep 2020 08:36:06 -0700 Ajit Khaparde <[email protected]>…
Quoted 4 lines

WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #264: FILE: drivers/net/hns3/hns3_ethdev.c:5601:
+ /* fallthrough */

Try /* FALLTHROUGH */

That won't work either.

This is a new warning from upstream Linux kernel checkpatch. The Linux kernel has converted code to use a new macro.

The warning should be silenced by the DPDK checkpatch script.

devtools/checkpatches.sh +0 -0
index 78a408ef9823..923ff6f7d9ee 100755

devtools/checkpatches.sh VOLATILE,PREFER_PACKED,PREFER_ALIGNED,PREFER_PRINTF,\ · line 38

Quoted 7 lines
devtools/checkpatches.sh +1 -1
@@ -33,7 +33,7 @@ VOLATILE,PREFER_PACKED,PREFER_ALIGNED,PREFER_PRINTF,\
  PREFER_KERNEL_TYPES,PREFER_FALLTHROUGH,BIT_MACRO,CONST_STRUCT,\
  SPLIT_STRING,LONG_LINE_STRING,C99_COMMENT_TOLERANCE,\
  LINE_SPACING,PARENTHESIS_ALIGNMENT,NETWORKING_BLOCK_COMMENT_STYLE,\
-NEW_TYPEDEFS,COMPARISON_TO_NULL"
+NEW_TYPEDEFS,COMPARISON_TO_NULL,PREFER_FALLTHROUGH"
  options="$options $DPDK_CHECKPATCH_OPTIONS"
 

It should be already applied: https://patches.dpdk.org/patch/75173/
https://git.dpdk.org/dpdk/commit/?id=fcea4c8e29b6

#76 lore raw

PATCH v12 2/4 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v11->v12:
fix coding warning.

v10->v11:
allow to report capabilities per link speed.
specify what should be reported if link is down
when get FEC.
change mode to capa bitmask.

---
v9->v10:
use RTE_ETH_FEC_MODE_CAPA_MASK(x) which is just defined.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h    |  19 ++-
 drivers/net/hns3/hns3_ethdev.c | 357 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 376 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_cmd.h +18 -1
index 87d6053..a1e9604 100644
@@ -100,6 +100,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_QUERY_LINK_STATUS      = 0x0307,
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -684,9 +685,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +357 -0

399 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index fd6a9f9..393b91f 100644
@@ -620,6 +620,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	uint32_t fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#77 lore raw

PATCH v12 3/4 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v10->v11:
change mode to capa bitmask.

---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  91 ++++++++++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 314 insertions(+)
app/test-pmd/cmdline.c +221 -0
index 5f93409..445726f 100644
@@ -19161,6 +19161,224 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_CAP_NUM 2
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
+	uint32_t num = FEC_CAP_NUM;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, &num, speed_fec_capa);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	show_fec_capability(num, speed_fec_capa);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	uint32_t mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	uint32_t mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19795,6 +20013,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +91 -0

103 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index f139fe7..85ea030 100644
@@ -804,6 +804,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#78 lore raw

PATCH v12 4/4 doc: add FEC API and PMD information

In reply to Min Hu (Connor)

Added the FEC API, and hns3 FEC PMD information in release 20.11.rst file.

---
 doc/guides/rel_notes/release_20_11.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
doc/guides/rel_notes/release_20_11.rst +9 -0
index c6642f5..de2c8e4 100644
@@ -78,6 +78,15 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
 
 Removed Items
 -------------
Signature · 1 line
2.7.4
#79 lore raw

Re: [dpdk-dev] [PATCH V12 4/4] doc: add FEC API and PMD information

Quoted 16 lines · Min Hu (Connor)

Added the FEC API, and hns3 FEC PMD information in release 20.11.rst file.

---
 doc/guides/rel_notes/release_20_11.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
doc/guides/rel_notes/release_20_11.rst +0 -0
index c6642f5..de2c8e4 100644

doc/guides/rel_notes/release_20_11.rst New Features · line 85

Quoted 8 lines
doc/guides/rel_notes/release_20_11.rst +5 -0
@@ -78,6 +78,15 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+

Release notes should be updated when corresponding functionality is added. So above lines belong to 1/4.

doc/guides/rel_notes/release_20_11.rst New Features · line 89

Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +4 -0
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.

These lines belong to 2/4 and don't forget to add extra empty line since it must be two empty lines the next section.

Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +0 -0
 Removed Items
 -------------
 
#80 lore raw

v13 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 223 +++++++++++++++++++
 app/test-pmd/config.c                    |  91 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 +
 drivers/net/hns3/hns3_cmd.h              |  19 +-
 drivers/net/hns3/hns3_ethdev.c           | 356 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  43 ++++
 lib/librte_ethdev/rte_ethdev.h           |  94 ++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  80 +++++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 11 files changed, 921 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#81 lore raw

PATCH v13 1/3 ethdev: introduce FEC API

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

---
v12->v13:
change fec get capa API.
fix comment styles.

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros. Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 doc/guides/rel_notes/release_20_11.rst   |  5 ++
 lib/librte_ethdev/rte_ethdev.c           | 43 +++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 94 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    | 80 +++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 +
 5 files changed, 225 insertions(+)
doc/guides/rel_notes/release_20_11.rst +5 -0
index c6642f5..1f04bd5 100644
@@ -78,6 +78,11 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +43 -0

49 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +94 -0

106 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +80 -0

92 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
Signature · 1 line
2.7.4
Acked-by on v13 1/3
#82 lore raw

Re: [dpdk-dev] [PATCH V13 1/3] ethdev: introduce FEC API

Quoted 8 lines · Min Hu (Connor)

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

With few nits below:

Quoted 77 lines

---
v12->v13:
change fec get capa API.
fix comment styles.

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros. Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 doc/guides/rel_notes/release_20_11.rst   |  5 ++
 lib/librte_ethdev/rte_ethdev.c           | 43 +++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 94 ++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    | 80 +++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 +
 5 files changed, 225 insertions(+)
doc/guides/rel_notes/release_20_11.rst +5 -0
index c6642f5..1f04bd5 100644
@@ -78,6 +78,11 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +0 -0
index dfe5c1b..86ead87 100644

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3688

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
@@ -3679,6 +3679,49 @@ 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,
+			   struct rte_eth_fec_capa *speed_fec_capa,
+			   unsigned int num)
+{
+	struct rte_eth_dev *dev;
+	int ret;

if (speed_fec_capa == NULL && num > 0)

        return -EINVAL;

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3696

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+
+	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);
+	ret = (*dev->dev_ops->fec_get_capability)(dev, speed_fec_capa, num);
+	if (ret > (int)num)
+		RTE_ETHDEV_LOG(ERR, "Insufficient num, num should be no less than %d\n",
+			       ret);

It is incorrect to log error, since

    num = rte_eth_fec_get_capability(port_id, NULL, 0);

may be used to obtain required number of array elements (nothing bad is happening).

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +13 -0
+
+	return ret;
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *mode)
+{
+	struct rte_eth_dev *dev;
+
+	if (mode == NULL)
+		return -EINVAL;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3719

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

Quoted 27 lines
lib/librte_ethdev/rte_ethdev.c +5 -0
+	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.
lib/librte_ethdev/rte_ethdev.h +11 -0
index 645a186..04525a8 100644
@@ -1544,6 +1544,29 @@ 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_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1567

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+
+/* This macro indicates FEC capa mask */
+#define RTE_ETH_FEC_MODE_CAPA_MASK(x)	(1U << (RTE_ETH_FEC_ ## x))
+
+/* A structure used to get capabilities per link speed */
+struct rte_eth_fec_capa {
+	uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
+	uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */

Thre is no RTE_FEC_CAPA_* enum/defnes any more. I'd just remove everything in parenthesis.

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
+};
+
 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
 /* Macros to check for valid port */
@@ -3397,6 +3420,77 @@ 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
+ *

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3435

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *   If set to NULL, the function returns the required number
+ *   of required array entries.
+ * @param num
+ *   the num is in/out with a number of elements in an array.

Just (it it not in/out now):
a number of elements in an speed_fec_capa array

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3438

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+ *
+ * @return
+ *   - (0) if successful.

Wrong description. Any non-negative return value is success (number of speed_fec_capa array elements filled in)

Quoted 34 lines
lib/librte_ethdev/rte_ethdev.h +34 -0
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id,
+			       struct rte_eth_fec_capa *speed_fec_capa,
+			       unsigned int num);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @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, uint32_t *mode);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3482

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

mode -> fec_capa
A bitmask of enabled FEC modes. If AUTO bit is set, other bits specify FEC modes which may be negotiated. If AUTO bit is clear, specify FEC modes to be used (only one valid mode per speed may be set).

Quoted 21 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
  * Get current status of the Ethernet link flow control for Ethernet device
  *
  * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
index 23cc1e0..306f3a6 100644
@@ -575,6 +575,79 @@ typedef int (*eth_tx_hairpin_queue_setup_t)
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
 

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 586

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +9 -0
 /**
+ * @internal
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ * @param num
+ *   the num is in/out with a number of elements in an array.

same as above

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +6 -0
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.

same as above

Quoted 29 lines
lib/librte_ethdev/rte_ethdev_driver.h +29 -0
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EIO
+ *   Device is removed.
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
+		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
+
+/**
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 631

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *mode);
+
+/**
+ * @internal
+ * Set Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode

similar as aboe I suggest to name it fec_capa,
since it is not a single mode

Quoted 51 lines
lib/librte_ethdev/rte_ethdev_driver.h +26 -0
+ *   bitmask of allowed FEC modes. It must be only one
+ *   if AUTO is disabled. If AUTO is enabled, other
+ *   bits specify FEC modes which may be negotiated.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EINVAL
+ *   Unsupported FEC mode requested.
+ * @retval -EIO
+ *   Device is removed.
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
 struct eth_dev_ops {
@@ -713,6 +786,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. */
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
#83 lore raw

Re: [dpdk-dev] [PATCH V13 1/3] ethdev: introduce FEC API

Hi, Andrew,
I have sent V14, in which I fixed it as you suggested, please check it out,thank you.

Quoted 409 lines · Andrew Rybchenko
Quoted 8 lines · Min Hu (Connor)

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

With few nits below:

Quoted 77 lines

---
v12->v13:
change fec get capa API.
fix comment styles.

---
v10->v11:
allow to report capabilities per link speed. specify what should be reported if link is down when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros. Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
  doc/guides/rel_notes/release_20_11.rst   |  5 ++
  lib/librte_ethdev/rte_ethdev.c           | 43 +++++++++++++++
  lib/librte_ethdev/rte_ethdev.h           | 94 ++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    | 80 +++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev_version.map |  3 +
  5 files changed, 225 insertions(+)
doc/guides/rel_notes/release_20_11.rst +5 -0
index c6642f5..1f04bd5 100644
@@ -78,6 +78,11 @@ New Features
      ``--portmask=N``
      where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
 
  Removed Items
  -------------
lib/librte_ethdev/rte_ethdev.c +0 -0
index dfe5c1b..86ead87 100644

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3688

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
@@ -3679,6 +3679,49 @@ 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,
+			   struct rte_eth_fec_capa *speed_fec_capa,
+			   unsigned int num)
+{
+	struct rte_eth_dev *dev;
+	int ret;

if (speed_fec_capa == NULL && num > 0)

         return -EINVAL;

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3696

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+
+	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);
+	ret = (*dev->dev_ops->fec_get_capability)(dev, speed_fec_capa, num);
+	if (ret > (int)num)
+		RTE_ETHDEV_LOG(ERR, "Insufficient num, num should be no less than %d\n",
+			       ret);

It is incorrect to log error, since

     num = rte_eth_fec_get_capability(port_id, NULL, 0);

may be used to obtain required number of array elements (nothing bad is happening).

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +13 -0
+
+	return ret;
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *mode)
+{
+	struct rte_eth_dev *dev;
+
+	if (mode == NULL)
+		return -EINVAL;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3719

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	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, uint32_t mode)
+{
+	struct rte_eth_dev *dev;
+

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

Quoted 27 lines
lib/librte_ethdev/rte_ethdev.c +5 -0
+	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.
lib/librte_ethdev/rte_ethdev.h +11 -0
index 645a186..04525a8 100644
@@ -1544,6 +1544,29 @@ 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_eth_fec_mode {
+	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
+	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
+	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
+	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
+};
+

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dcb_info { · line 1567

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
+
+/* This macro indicates FEC capa mask */
+#define RTE_ETH_FEC_MODE_CAPA_MASK(x)	(1U << (RTE_ETH_FEC_ ## x))
+
+/* A structure used to get capabilities per link speed */
+struct rte_eth_fec_capa {
+	uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
+	uint32_t capa;  /**< FEC capabilities bitmask (see RTE_FEC_CAPA_*) */

Thre is no RTE_FEC_CAPA_* enum/defnes any more. I'd just remove everything in parenthesis.

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
+};
+
  #define RTE_ETH_ALL RTE_MAX_ETHPORTS
 
  /* Macros to check for valid port */
@@ -3397,6 +3420,77 @@ 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
+ *

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3435

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *   If set to NULL, the function returns the required number
+ *   of required array entries.
+ * @param num
+ *   the num is in/out with a number of elements in an array.

Just (it it not in/out now):
a number of elements in an speed_fec_capa array

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3438

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+ *
+ * @return
+ *   - (0) if successful.

Wrong description. Any non-negative return value is success (number of speed_fec_capa array elements filled in)

Quoted 34 lines
lib/librte_ethdev/rte_ethdev.h +34 -0
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id,
+			       struct rte_eth_fec_capa *speed_fec_capa,
+			       unsigned int num);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @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, uint32_t *mode);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3482

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

mode -> fec_capa
A bitmask of enabled FEC modes. If AUTO bit is set, other bits specify FEC modes which may be negotiated. If AUTO bit is clear, specify FEC modes to be used (only one valid mode per speed may be set).

Quoted 21 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +0 -0
index 23cc1e0..306f3a6 100644
@@ -575,6 +575,79 @@ typedef int (*eth_tx_hairpin_queue_setup_t)
  	 const struct rte_eth_hairpin_conf *hairpin_conf);
 

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 586

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +9 -0
  /**
+ * @internal
+ * Get Forward Error Correction(FEC) capability.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ * @param num
+ *   the num is in/out with a number of elements in an array.

same as above

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +6 -0
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, get FEC success.

same as above

Quoted 29 lines
lib/librte_ethdev/rte_ethdev_driver.h +29 -0
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EIO
+ *   Device is removed.
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
+		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
+
+/**
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 631

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *mode);
+
+/**
+ * @internal
+ * Set Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode

similar as aboe I suggest to name it fec_capa,
since it is not a single mode

Quoted 42 lines
lib/librte_ethdev/rte_ethdev_driver.h +26 -0
+ *   bitmask of allowed FEC modes. It must be only one
+ *   if AUTO is disabled. If AUTO is enabled, other
+ *   bits specify FEC modes which may be negotiated.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EINVAL
+ *   Unsupported FEC mode requested.
+ * @retval -EIO
+ *   Device is removed.
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
  struct eth_dev_ops {
@@ -713,6 +786,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. */
  };
 
  /**
lib/librte_ethdev/rte_ethdev_version.map +0 -0
index c95ef51..b9ace3a 100644

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 237

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -229,6 +229,9 @@ EXPERIMENTAL {
  	# added in 20.11
  	rte_eth_link_speed_to_str;
  	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
  };
 
  INTERNAL {

.

#84 lore raw

PATCH v13 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v12->v13:
change fec get capa interface.

---
v11->v12:
fix coding warning.

v10->v11:
allow to report capabilities per link speed.
specify what should be reported if link is down
when get FEC.
change mode to capa bitmask.

---
v9->v10:
use RTE_ETH_FEC_MODE_CAPA_MASK(x) which is just defined.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 doc/guides/rel_notes/release_20_11.rst |   5 +
 drivers/net/hns3/hns3_cmd.h            |  19 +-
 drivers/net/hns3/hns3_ethdev.c         | 356 +++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h         |   1 +
 4 files changed, 380 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_20_11.rst +5 -0
index 1f04bd5..eec6930 100644
@@ -83,6 +83,11 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
drivers/net/hns3/hns3_cmd.h +18 -1
index 87d6053..a1e9604 100644
@@ -100,6 +100,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_QUERY_LINK_STATUS      = 0x0307,
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -684,9 +685,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +356 -0

398 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index fd6a9f9..393b91f 100644
@@ -620,6 +620,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	uint32_t fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4
#85 lore raw

PATCH v13 3/3 app/testpmd: add FEC command

In reply to Min Hu (Connor)

This commit adds testpmd capability to query and config FEC function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port <port_id> 0 <auto|off|rs|baser>

where:

auto|off|rs|baser are four kinds of FEC mode which dev support according to MAC link speed.

---
v12->v13:
change fec get capa interface.

---
v10->v11:
change mode to capa bitmask.

---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style. added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |  91 ++++++++++++++++++++
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 316 insertions(+)
app/test-pmd/cmdline.c +223 -0
index 5f93409..407513c 100644
@@ -19161,6 +19161,226 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_fec;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_CAP_NUM 2
+	struct cmd_show_fec_capability_result *res = parsed_result;
+	struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
+	unsigned int num = FEC_CAP_NUM;
+	unsigned int ret_num;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+
+	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC capability failed\n");
+		return;
+	}
+
+	ret_num = (unsigned int)ret;
+	show_fec_capability(ret_num, speed_fec_capa);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+			cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+	.f = cmd_show_fec_capability_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec capabilities",
+	.tokens = {
+		(void *)&cmd_show_fec_capability_show,
+		(void *)&cmd_show_fec_capability_port,
+		(void *)&cmd_show_fec_capability_pid,
+		(void *)&cmd_show_fec_capability_fec,
+		(void *)&cmd_show_fec_capability_keyword,
+		NULL,
+	},
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_keyword;
+	portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+	struct cmd_show_fec_metadata_result *res = parsed_result;
+	uint32_t mode;
+	char buf[FEC_NAME_SIZE];
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+		printf("Invalid port id %u\n", res->cmd_pid);
+		return;
+	}
+	ret = rte_eth_fec_get(res->cmd_pid, &mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Get FEC mode failed\n");
+		return;
+	}
+
+	switch (mode) {
+	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
+		strlcpy(buf, "off", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
+		strlcpy(buf, "auto", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
+		strlcpy(buf, "baser", sizeof(buf));
+		break;
+	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
+		strlcpy(buf, "rs", sizeof(buf));
+		break;
+	default:
+		return;
+	}
+
+	printf("%s\n", buf);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_mode_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_mode_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_mode_pid =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
+			cmd_keyword, "fec_mode");
+
+cmdline_parse_inst_t cmd_show_fec_mode = {
+	.f = cmd_show_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> fec_mode",
+	.tokens = {
+		(void *)&cmd_show_fec_mode_show,
+		(void *)&cmd_show_fec_mode_port,
+		(void *)&cmd_show_fec_mode_pid,
+		(void *)&cmd_show_fec_mode_keyword,
+		NULL,
+	},
+};
+
+/* *** set fec mode per port configuration *** */
+struct cmd_set_port_fec_mode {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t fec_mode;
+	cmdline_fixed_string_t fec_value;
+};
+
+/* Common CLI fields for set fec mode */
+cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port, "port");
+cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_mode, "fec_mode");
+cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_port_fec_mode,
+		 fec_value, NULL);
+
+static void
+cmd_set_port_fec_mode_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_set_port_fec_mode *res = parsed_result;
+	uint16_t port_id = res->port_id;
+	uint32_t mode;
+	int ret;
+
+	ret = parse_fec_mode(res->fec_value, &mode);
+	if (ret < 0) {
+		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
+			port_id);
+		return;
+	}
+
+	ret = rte_eth_fec_set(port_id, mode);
+	if (ret == -ENOTSUP) {
+		printf("Function not implemented\n");
+		return;
+	} else if (ret < 0) {
+		printf("Set FEC mode failed\n");
+		return;
+	}
+}
+
+cmdline_parse_inst_t cmd_set_fec_mode = {
+	.f = cmd_set_port_fec_mode_parsed,
+	.data = NULL,
+	.help_str = "set port <port_id> fec_mode <auto|off|rs|baser>",
+	.tokens = {
+		(void *)&cmd_set_port_fec_mode_set,
+		(void *)&cmd_set_port_fec_mode_port,
+		(void *)&cmd_set_port_fec_mode_port_id,
+		(void *)&cmd_set_port_fec_mode_str,
+		(void *)&cmd_set_port_fec_mode_value,
+		NULL,
+	},
+};
+
 /* show port supported ptypes */
 
 /* Common result structure for show port ptypes */
@@ -19795,6 +20015,9 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
+	(cmdline_parse_inst_t *)&cmd_show_capability,
 	NULL,
 };
 
app/test-pmd/config.c +91 -0

103 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index f139fe7..85ea030 100644
@@ -804,6 +804,8 @@ void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
 void set_tx_pkt_split(const char *name);
+int parse_fec_mode(const char *name, enum rte_eth_fec_mode *mode);
+void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
 void set_nb_pkt_per_burst(uint16_t pkt_burst);
 char *list_pkt_forwarding_modes(void);
 char *list_pkt_forwarding_retry_modes(void);
Signature · 1 line
2.7.4
#86 lore raw

Re: [dpdk-dev] [PATCH V13 0/3] add FEC support

In reply to Min Hu (Connor)

Hello,
Are there any suggustions for this set patches ?

Quoted 20 lines · Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

  app/test-pmd/cmdline.c                   | 223 +++++++++++++++++++
  app/test-pmd/config.c                    |  91 ++++++++
  app/test-pmd/testpmd.h                   |   2 +
  doc/guides/rel_notes/release_20_11.rst   |  10 +
  drivers/net/hns3/hns3_cmd.h              |  19 +-
  drivers/net/hns3/hns3_ethdev.c           | 356 +++++++++++++++++++++++++++++++
  drivers/net/hns3/hns3_ethdev.h           |   1 +
  lib/librte_ethdev/rte_ethdev.c           |  43 ++++
  lib/librte_ethdev/rte_ethdev.h           |  94 ++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    |  80 +++++++
  lib/librte_ethdev/rte_ethdev_version.map |   3 +
  11 files changed, 921 insertions(+), 1 deletion(-)
#87 lore raw

Re: [dpdk-dev] [PATCH V13 0/3] add FEC support

Quoted 4 lines · Min Hu (Connor)

Hello,
    Are there any suggustions for this set patches ?

Quoted 21 lines
Quoted 20 lines · Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
   ethdev: introduce FEC API
   net/hns3: support FEC
   app/testpmd: add FEC command

  app/test-pmd/cmdline.c                   | 223 +++++++++++++++++++ app/test-pmd/config.c                    |  91 ++++++++ app/test-pmd/testpmd.h                   |   2 + doc/guides/rel_notes/release_20_11.rst   |  10 + drivers/net/hns3/hns3_cmd.h              |  19 +-

  drivers/net/hns3/hns3_ethdev.c           | 356 +++++++++++++++++++++++++++++++
  drivers/net/hns3/hns3_ethdev.h           |   1 +
  lib/librte_ethdev/rte_ethdev.c           |  43 ++++
  lib/librte_ethdev/rte_ethdev.h           |  94 ++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    |  80 +++++++
  lib/librte_ethdev/rte_ethdev_version.map |   3 +
  11 files changed, 921 insertions(+), 1 deletion(-)

Hi Connor,

Can you please make a new version addressing the minor issues Andrew highlighted and including his ack?

Thanks,
ferruh

#88 lore raw

Re: [dpdk-dev] [PATCH V13 0/3] add FEC support

Hi, Ferruh,
I've send a set of patches named V14, please check it ,thanks.

Quoted 35 lines · Ferruh Yigit
Quoted 4 lines · Min Hu (Connor)

Hello,
     Are there any suggustions for this set patches ?

Quoted 22 lines
Quoted 21 lines · Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
   ethdev: introduce FEC API
   net/hns3: support FEC
   app/testpmd: add FEC command

  app/test-pmd/cmdline.c                   | 223 +++++++++++++++++++ app/test-pmd/config.c                    |  91 ++++++++ app/test-pmd/testpmd.h                   |   2 + doc/guides/rel_notes/release_20_11.rst   |  10 + drivers/net/hns3/hns3_cmd.h              |  19 +- drivers/net/hns3/hns3_ethdev.c           | 356
+++++++++++++++++++++++++++++++

  drivers/net/hns3/hns3_ethdev.h           |   1 +
  lib/librte_ethdev/rte_ethdev.c           |  43 ++++
  lib/librte_ethdev/rte_ethdev.h           |  94 ++++++++
  lib/librte_ethdev/rte_ethdev_driver.h    |  80 +++++++
  lib/librte_ethdev/rte_ethdev_version.map |   3 +
  11 files changed, 921 insertions(+), 1 deletion(-)

Hi Connor,

Can you please make a new version addressing the minor issues Andrew highlighted and including his ack?

Thanks,
ferruh
.

#89 lore raw

v14 cover add FEC support

In reply to Min Hu (Connor)

This series add FEC support for ethdev.

Min Hu (Connor) (3):
ethdev: introduce FEC API
net/hns3: support FEC
app/testpmd: add FEC command

 app/test-pmd/cmdline.c                   | 223 +++++++++++++++++++
 app/test-pmd/config.c                    |  91 ++++++++
 app/test-pmd/testpmd.h                   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 +
 drivers/net/hns3/hns3_cmd.h              |  19 +-
 drivers/net/hns3/hns3_ethdev.c           | 356 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h           |   1 +
 lib/librte_ethdev/rte_ethdev.c           |  44 ++++
 lib/librte_ethdev/rte_ethdev.h           | 102 +++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  88 ++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 11 files changed, 938 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#90 lore raw

PATCH v14 1/3 ethdev: introduce FEC API

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

---
v13->v14:
change mode to fec_capa.
fix comment about API.

---
v12->v13:
change fec get capa API.
fix comment styles.

---
v10->v11:
allow to report capabilities per link speed.
specify what should be reported if link is down
when get FEC.
change mode to capa bitmask.

---
v9->v10:
add macro RTE_ETH_FEC_MODE_CAPA_MASK(x) to indicate different FEC mode capa.

---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage. add new macro to indicate translation from fec mode to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API.

---
 doc/guides/rel_notes/release_20_11.rst   |   5 ++
 lib/librte_ethdev/rte_ethdev.c           |  44 +++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 102 +++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  88 ++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 5 files changed, 242 insertions(+)
doc/guides/rel_notes/release_20_11.rst +5 -0
index c6642f5..1f04bd5 100644
@@ -78,6 +78,11 @@ New Features
     ``--portmask=N``
     where N represents the hexadecimal bitmask of ports used.
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
lib/librte_ethdev/rte_ethdev.c +44 -0

50 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +102 -0

114 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +88 -0

100 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
Signature · 1 line
2.7.4
#91 lore raw

Re: [dpdk-dev] [PATCH V14 1/3] ethdev: introduce FEC API

Quoted 9 lines · Min Hu (Connor)

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

[snip]

Quoted 33 lines
lib/librte_ethdev/rte_ethdev.c +25 -0
index dfe5c1b..996d230 100644
@@ -3679,6 +3679,50 @@ 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,
+			   struct rte_eth_fec_capa *speed_fec_capa,
+			   unsigned int num)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	if (speed_fec_capa == NULL && num > 0)
+		return -EINVAL;
+
+	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);
+	ret = (*dev->dev_ops->fec_get_capability)(dev, speed_fec_capa, num);
+
+	return ret;
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (fec_capa == NULL)

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3716

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		return -EINVAL;
+
+	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, fec_capa));
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, uint32_t mode)

mode -> fec_capa, since it is not a single mode

Quoted 16 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+{
+	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_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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 645a186..50c5280 100644

[snip]

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +6 -0
@@ -3397,6 +3420,85 @@ 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

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3438

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   The port identifier of the Ethernet device.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *   If set to NULL, the function returns the required number
+ *   of required array entries.
+ * @param num
+ *   a number of elements in an speed_fec_capa array.
+ *
+ * @return
+ *   - A positive value lower or equal to num: success. The return value

positive -> non-negative
since 0 is OK if FEC is not applicable/supported

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3440

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+ *     is the number of entries filled in the fec capa array.
+ *   - A positive value higher than num: error, the given fec capa array

same, positive -> non-negative

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3443

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+ *     is too small. The return value corresponds to the num that should
+ *     be given to succeed. The entries in fec capa array are not valid and
+ *     shall not be used by the caller.

OK for me, possible option is to fill in just provided entries (up to num)

Quoted 37 lines
lib/librte_ethdev/rte_ethdev.h +37 -0
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id,
+			       struct rte_eth_fec_capa *speed_fec_capa,
+			       unsigned int num);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param fec_capa
+ *   A bitmask of enabled FEC modes. If AUTO bit is set, other
+ *   bits specify FEC modes which may be negotiated. If AUTO
+ *   bit is clear, specify FEC modes to be used (only one valid
+ *   mode per speed may be set).
+ * @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, uint32_t *fec_capa);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3490

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

mode -> fec_capa
with description from callback below

Quoted 27 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
  * Get current status of the Ethernet link flow control for Ethernet device
  *
  * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +5 -0
index 23cc1e0..a1f10d6 100644
@@ -575,6 +575,87 @@ 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.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ * @param num
+ *   a number of elements in an speed_fec_capa array.
+ *
+ * @return
+ *   Negative errno value on error, positive value on success.
+ *
+ * @retval positive value
+ *   A positive value lower or equal to num: success. The return value

same as above

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 594

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ *   is the number of entries filled in the fec capa array.
+ *   A positive value higher than num: error, the given fec capa array

same as above

Quoted 35 lines
lib/librte_ethdev/rte_ethdev_driver.h +35 -0
+ *   is too small. The return value corresponds to the num that should
+ *   be given to succeed. The entries in the fec capa array are not valid
+ *   and shall not be used by the caller.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EIO
+ *   Device is removed.
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
+		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param fec_capa
+ *   a bitmask of enabled FEC modes. If AUTO bit is set, other
+ *   bits specify FEC modes which may be negotiated. If AUTO
+ *   bit is clear, specify FEC modes to be used (only one valid
+ *   mode per speed may be set).
+ *
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 639

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *fec_capa);
+
+/**
+ * @internal
+ * Set Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode

mode -> fec_capa

Quoted 51 lines
lib/librte_ethdev/rte_ethdev_driver.h +26 -0
+ *   bitmask of allowed FEC modes. It must be only one
+ *   if AUTO is disabled. If AUTO is enabled, other
+ *   bits specify FEC modes which may be negotiated.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EINVAL
+ *   Unsupported FEC mode requested.
+ * @retval -EIO
+ *   Device is removed.
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
 struct eth_dev_ops {
@@ -713,6 +794,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. */
 };
 
 /**
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index c95ef51..b9ace3a 100644
@@ -229,6 +229,9 @@ EXPERIMENTAL {
 	# added in 20.11
 	rte_eth_link_speed_to_str;
 	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
 };
 
 INTERNAL {
#92 lore raw

Re: [dpdk-dev] [PATCH V14 1/3] ethdev: introduce FEC API

Hi, Andrew, ALL,
I have fixed it in V15. please check it out. By the way, I wish this patch will be merged into 20.11. Because if missed ,one more year will be waited. Please check it,thanks.

Quoted 312 lines · Andrew Rybchenko
Quoted 9 lines · Min Hu (Connor)

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

[snip]

Quoted 33 lines
lib/librte_ethdev/rte_ethdev.c +25 -0
index dfe5c1b..996d230 100644
@@ -3679,6 +3679,50 @@ 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,
+			   struct rte_eth_fec_capa *speed_fec_capa,
+			   unsigned int num)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	if (speed_fec_capa == NULL && num > 0)
+		return -EINVAL;
+
+	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);
+	ret = (*dev->dev_ops->fec_get_capability)(dev, speed_fec_capa, num);
+
+	return ret;
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa)
+{
+	struct rte_eth_dev *dev;
+
+	if (fec_capa == NULL)

lib/librte_ethdev/rte_ethdev.c rte_eth_led_off(uint16_t port_id) · line 3716

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		return -EINVAL;
+
+	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, fec_capa));
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, uint32_t mode)

mode -> fec_capa, since it is not a single mode

Quoted 16 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+{
+	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_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.
lib/librte_ethdev/rte_ethdev.h +0 -0
index 645a186..50c5280 100644

[snip]

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +6 -0
@@ -3397,6 +3420,85 @@ 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

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3438

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *   The port identifier of the Ethernet device.
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ *   If set to NULL, the function returns the required number
+ *   of required array entries.
+ * @param num
+ *   a number of elements in an speed_fec_capa array.
+ *
+ * @return
+ *   - A positive value lower or equal to num: success. The return value

positive -> non-negative
since 0 is OK if FEC is not applicable/supported

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3440

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
+ *     is the number of entries filled in the fec capa array.
+ *   - A positive value higher than num: error, the given fec capa array

same, positive -> non-negative

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3443

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+ *     is too small. The return value corresponds to the num that should
+ *     be given to succeed. The entries in fec capa array are not valid and
+ *     shall not be used by the caller.

OK for me, possible option is to fill in just provided entries (up to num)

Quoted 37 lines
lib/librte_ethdev/rte_ethdev.h +37 -0
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
+ */
+__rte_experimental
+int rte_eth_fec_get_capability(uint16_t port_id,
+			       struct rte_eth_fec_capa *speed_fec_capa,
+			       unsigned int num);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get current Forward Error Correction(FEC) mode.
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param fec_capa
+ *   A bitmask of enabled FEC modes. If AUTO bit is set, other
+ *   bits specify FEC modes which may be negotiated. If AUTO
+ *   bit is clear, specify FEC modes to be used (only one valid
+ *   mode per speed may be set).
+ * @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, uint32_t *fec_capa);
+

lib/librte_ethdev/rte_ethdev.h int rte_eth_led_on(uint16_t port_id); · line 3490

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+/**
+ * @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.

mode -> fec_capa
with description from callback below

Quoted 27 lines
lib/librte_ethdev/rte_ethdev.h +11 -0
+ * @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, uint32_t mode);
+
+/**
   * Get current status of the Ethernet link flow control for Ethernet device
   *
   * @param port_id
lib/librte_ethdev/rte_ethdev_driver.h +5 -0
index 23cc1e0..a1f10d6 100644
@@ -575,6 +575,87 @@ 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.

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 592

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+ * @param speed_fec_capa
+ *   speed_fec_capa is out only with per-speed capabilities.
+ * @param num
+ *   a number of elements in an speed_fec_capa array.
+ *
+ * @return
+ *   Negative errno value on error, positive value on success.
+ *
+ * @retval positive value
+ *   A positive value lower or equal to num: success. The return value

same as above

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 594

Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2 -0
+ *   is the number of entries filled in the fec capa array.
+ *   A positive value higher than num: error, the given fec capa array

same as above

Quoted 35 lines
lib/librte_ethdev/rte_ethdev_driver.h +35 -0
+ *   is too small. The return value corresponds to the num that should
+ *   be given to succeed. The entries in the fec capa array are not valid
+ *   and shall not be used by the caller.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EIO
+ *   Device is removed.
+ * @retval -EINVAL
+ *   *num* or *speed_fec_capa* invalid.
+ */
+typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
+		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
+
+/**
+ * @internal
+ * Get Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param fec_capa
+ *   a bitmask of enabled FEC modes. If AUTO bit is set, other
+ *   bits specify FEC modes which may be negotiated. If AUTO
+ *   bit is clear, specify FEC modes to be used (only one valid
+ *   mode per speed may be set).
+ *
+ * @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.
+ */

lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 639

Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
+typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
+			     uint32_t *fec_capa);
+
+/**
+ * @internal
+ * Set Forward Error Correction(FEC) mode.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param mode

mode -> fec_capa

Quoted 42 lines
lib/librte_ethdev/rte_ethdev_driver.h +26 -0
+ *   bitmask of allowed FEC modes. It must be only one
+ *   if AUTO is disabled. If AUTO is enabled, other
+ *   bits specify FEC modes which may be negotiated.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, set FEC success.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EINVAL
+ *   Unsupported FEC mode requested.
+ * @retval -EIO
+ *   Device is removed.
+ */
+typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t mode);
+
+/**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
  struct eth_dev_ops {
@@ -713,6 +794,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. */
  };
 
  /**
lib/librte_ethdev/rte_ethdev_version.map +0 -0
index c95ef51..b9ace3a 100644

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 237

Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -229,6 +229,9 @@ EXPERIMENTAL {
  	# added in 20.11
  	rte_eth_link_speed_to_str;
  	rte_eth_link_to_str;
+	rte_eth_fec_get_capability;
+	rte_eth_fec_get;
+	rte_eth_fec_set;
  };
 
  INTERNAL {

.

#93 lore raw

PATCH v14 2/3 net/hns3: support FEC

In reply to Min Hu (Connor)

Forward error correction (FEC) is a bit error correction mode. It adds error correction information to data packets at the transmit end, and uses the error correction information to correct the bit errors generated during data packet transmission at the receive end. This improves signal quality but also brings a delay to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev operations which support query and config FEC information in hardware.

---
v13->v14:
change mode to fec_capa.

---
v12->v13:
change fec get capa interface.

---
v11->v12:
fix coding warning.

v10->v11:
allow to report capabilities per link speed.
specify what should be reported if link is down
when get FEC.
change mode to capa bitmask.

---
v9->v10:
use RTE_ETH_FEC_MODE_CAPA_MASK(x) which is just defined.

---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with that defined in the ethdev library. So the sequence needs to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 doc/guides/rel_notes/release_20_11.rst |   5 +
 drivers/net/hns3/hns3_cmd.h            |  19 +-
 drivers/net/hns3/hns3_ethdev.c         | 356 +++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev.h         |   1 +
 4 files changed, 380 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_20_11.rst +5 -0
index 1f04bd5..eec6930 100644
@@ -83,6 +83,11 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also provided.
+
 
 Removed Items
 -------------
drivers/net/hns3/hns3_cmd.h +18 -1
index 87d6053..a1e9604 100644
@@ -100,6 +100,7 @@ enum hns3_opcode_type {
 	HNS3_OPC_QUERY_LINK_STATUS      = 0x0307,
 	HNS3_OPC_CONFIG_MAX_FRM_SIZE    = 0x0308,
 	HNS3_OPC_CONFIG_SPEED_DUP       = 0x0309,
+	HNS3_OPC_CONFIG_FEC_MODE        = 0x031A,
 
 	/* PFC/Pause commands */
 	HNS3_OPC_CFG_MAC_PAUSE_EN       = 0x0701,
@@ -684,9 +685,25 @@ struct hns3_config_auto_neg_cmd {
 	uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B	0
+#define HNS3_MAC_CFG_FEC_MODE_S		1
+#define HNS3_MAC_CFG_FEC_MODE_M	GENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF		0
+#define HNS3_MAC_FEC_BASER		1
+#define HNS3_MAC_FEC_RS			2
+
 struct hns3_sfp_speed_cmd {
 	uint32_t  sfp_speed;
-	uint32_t  rsv[5];
+	uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+	uint8_t   active_fec; /* current FEC mode */
+	uint16_t  rsv1;
+	uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+	uint8_t fec_mode;
+	uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B		BIT(0)
drivers/net/hns3/hns3_ethdev.c +356 -0

398 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev.h +1 -0
index fd6a9f9..393b91f 100644
@@ -620,6 +620,7 @@ struct hns3_pf {
 	struct hns3_err_msix_intr_stats abn_int_stats;
 
 	bool support_sfp_query;
+	uint32_t fec_mode; /* current FEC mode for ethdev */
 
 	struct hns3_vtag_cfg vtag_config;
 	LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list;
Signature · 1 line
2.7.4