[V15,3/3] app/testpmd: add FEC command
Checks
Commit Message
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.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
---
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(+)
Comments
On 9/29/2020 2:03 AM, Min Hu (Connor) wrote:
> 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>
>
I guess it is:
set port <port_id> fec_mode <auto|off|rs|baser>
> where:
>
> auto|off|rs|baser are four kinds of FEC mode which dev
> support according to MAC link speed.
>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
> ---
> 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(+)
Can you please update the testpmd documenatation for the new commands?
Also can add the new command to the --help output? ('cmd_help_long_parsed()')
<...>
> +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>",
Can you please update the help string as:
"set port <port_id> fec_mode auto|off|rs|baser"
'<>' is to define the variable name, like in '<port_id>' you expect numbers like
0,1,2 .. but 'auto|off|rs|baser' are keywords, not variables.
HI,Ferruh,
how about only considering the first patch:ethdev:add fec API. If this patch looks great to you, I wish it could be merged into 20.11.
To that patch, app/testpmd add fec command, I will fix it later.
thanks.
--------------------------------------------------
胡敏 Hu Min
Mobile: +86-13528728164<tel:+86-13528728164>
Email: humin29@huawei.com<mailto:humin29@huawei.com>
发件人:Ferruh Yigit <ferruh.yigit@intel.com>
收件人:humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
抄 送:konstantin.ananyev <konstantin.ananyev@intel.com>;thomas <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm <linuxarm@huawei.com>
时 间:2020-10-01 00:53:37
主 题:Re: [PATCH V15 3/3] app/testpmd: add FEC command
On 9/29/2020 2:03 AM, Min Hu (Connor) wrote:
> 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>
>
I guess it is:
set port <port_id> fec_mode <auto|off|rs|baser>
> where:
>
> auto|off|rs|baser are four kinds of FEC mode which dev
> support according to MAC link speed.
>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
> ---
> 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(+)
Can you please update the testpmd documenatation for the new commands?
Also can add the new command to the --help output? ('cmd_help_long_parsed()')
<...>
> +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>",
Can you please update the help string as:
"set port <port_id> fec_mode auto|off|rs|baser"
'<>' is to define the variable name, like in '<port_id>' you expect numbers like
0,1,2 .. but 'auto|off|rs|baser' are keywords, not variables.
On 10/7/2020 1:15 AM, humin (Q) wrote:
> HI,Ferruh,
>
> how about only considering the first patch:ethdev:add fec API. If this
> patch looks great to you, I wish it could be merged into 20.11.
>
> To that patch, app/testpmd add fec command, I will fix it later.
Hi Connor,
Better to get them together if possible, -rc1 has been postponed to October 16,
can this additional week help to get a new version?
>
> thanks.
>
> --------------------------------------------------
> 胡敏 Hu Min
> Mobile: +86-13528728164 <tel:+86-13528728164>
> Email: humin29@huawei.com <mailto:humin29@huawei.com>
>
> *发件人:*Ferruh Yigit <ferruh.yigit@intel.com>
> *收件人:*humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
> *抄 送:*konstantin.ananyev <konstantin.ananyev@intel.com>;thomas
> <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm
> <linuxarm@huawei.com>
> *时 间:*2020-10-01 00:53:37
> *主 题:*Re: [PATCH V15 3/3] app/testpmd: add FEC command
>
> On 9/29/2020 2:03 AM, Min Hu (Connor) wrote:
>> 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>
>>
>
> I guess it is:
> set port <port_id> fec_mode <auto|off|rs|baser>
>
>> where:
>>
>> auto|off|rs|baser are four kinds of FEC mode which dev
>> support according to MAC link speed.
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>> Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
>> ---
>> 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(+)
>
> Can you please update the testpmd documenatation for the new commands?
>
> Also can add the new command to the --help output? ('cmd_help_long_parsed()')
>
> <...>
>
>> +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>",
>
> Can you please update the help string as:
> "set port <port_id> fec_mode auto|off|rs|baser"
>
> '<>' is to define the variable name, like in '<port_id>' you expect numbers like
> 0,1,2 .. but 'auto|off|rs|baser' are keywords, not variables.
HI,Ferry,
thank you very much. this is good news to me. I promise the new version will be sent in these two days.
thanks again.
--------------------------------------------------
胡敏 Hu Min
Mobile: +86-13528728164<tel:+86-13528728164>
Email: humin29@huawei.com<mailto:humin29@huawei.com>
发件人:Ferruh Yigit <ferruh.yigit@intel.com>
收件人:humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
抄 送:konstantin.ananyev <konstantin.ananyev@intel.com>;thomas <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm <linuxarm@huawei.com>
时 间:2020-10-07 17:30:09
主 题:Re: [PATCH V15 3/3] app/testpmd: add FEC command
On 10/7/2020 1:15 AM, humin (Q) wrote:
> HI,Ferruh,
>
> how about only considering the first patch:ethdev:add fec API. If this
> patch looks great to you, I wish it could be merged into 20.11.
>
> To that patch, app/testpmd add fec command, I will fix it later.
Hi Connor,
Better to get them together if possible, -rc1 has been postponed to October 16,
can this additional week help to get a new version?
>
> thanks.
>
> --------------------------------------------------
> 胡敏 Hu Min
> Mobile: +86-13528728164 <tel:+86-13528728164>
> Email: humin29@huawei.com <mailto:humin29@huawei.com>
>
> *发件人:*Ferruh Yigit <ferruh.yigit@intel.com>
> *收件人:*humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
> *抄 送:*konstantin.ananyev <konstantin.ananyev@intel.com>;thomas
> <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm
> <linuxarm@huawei.com>
> *时 间:*2020-10-01 00:53:37
> *主 题:*Re: [PATCH V15 3/3] app/testpmd: add FEC command
>
> On 9/29/2020 2:03 AM, Min Hu (Connor) wrote:
>> 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>
>>
>
> I guess it is:
> set port <port_id> fec_mode <auto|off|rs|baser>
>
>> where:
>>
>> auto|off|rs|baser are four kinds of FEC mode which dev
>> support according to MAC link speed.
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>> Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
>> ---
>> 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(+)
>
> Can you please update the testpmd documenatation for the new commands?
>
> Also can add the new command to the --help output? ('cmd_help_long_parsed()')
>
> <...>
>
>> +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>",
>
> Can you please update the help string as:
> "set port <port_id> fec_mode auto|off|rs|baser"
>
> '<>' is to define the variable name, like in '<port_id>' you expect numbers like
> 0,1,2 .. but 'auto|off|rs|baser' are keywords, not variables.
Hi, Ferruh,
I have sent patches of new version named V16. Please check it
out, thanks.
在 2020/10/8 7:38, humin (Q) 写道:
> HI,Ferry,
>
> thank you very much. this is good news to me. I promise the new
> version will be sent in these two days.
>
> thanks again.
>
> --------------------------------------------------
> 胡敏 Hu Min
> Mobile: +86-13528728164 <tel:+86-13528728164>
> Email: humin29@huawei.com <mailto:humin29@huawei.com>
>
> *发件人:*Ferruh Yigit <ferruh.yigit@intel.com>
> *收件人:*humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
> *抄 送:*konstantin.ananyev <konstantin.ananyev@intel.com>;thomas
> <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm
> <linuxarm@huawei.com>
> *时 间:*2020-10-07 17:30:09
> *主 题:*Re: [PATCH V15 3/3] app/testpmd: add FEC command
>
> On 10/7/2020 1:15 AM, humin (Q) wrote:
>> HI,Ferruh,
>>
>> how about only considering the first patch:ethdev:add fec API. If this
>> patch looks great to you, I wish it could be merged into 20.11.
>>
>> To that patch, app/testpmd add fec command, I will fix it later.
>
> Hi Connor,
>
> Better to get them together if possible, -rc1 has been postponed to
> October 16,
> can this additional week help to get a new version?
>
>
>>
>> thanks.
>>
>> --------------------------------------------------
>> 胡敏 Hu Min
>> Mobile: +86-13528728164 <tel:+86-13528728164>
>> Email: humin29@huawei.com <mailto:humin29@huawei.com>
>>
>> *发件人:*Ferruh Yigit <ferruh.yigit@intel.com>
>> *收件人:*humin (Q) <humin29@huawei.com>;dev <dev@dpdk.org>
>> *抄 送:*konstantin.ananyev <konstantin.ananyev@intel.com>;thomas
>> <thomas@monjalon.net>;arybchenko <arybchenko@solarflare.com>;Linuxarm
>> <linuxarm@huawei.com>
>> *时 间:*2020-10-01 00:53:37
>> *主 题:*Re: [PATCH V15 3/3] app/testpmd: add FEC command
>>
>> On 9/29/2020 2:03 AM, Min Hu (Connor) wrote:
>>> 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>
>>>
>>
>> I guess it is:
>> set port <port_id> fec_mode <auto|off|rs|baser>
>>
>>> where:
>>>
>>> auto|off|rs|baser are four kinds of FEC mode which dev
>>> support according to MAC link speed.
>>>
>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>>> Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
>>> Reviewed-by: Chengchang Tang <tangchengchang@huawei.com>
>>> ---
>>> 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(+)
>>
>> Can you please update the testpmd documenatation for the new commands?
>>
>> Also can add the new command to the --help output? ('cmd_help_long_parsed()')
>>
>> <...>
>>
>>> +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>",
>>
>> Can you please update the help string as:
>> "set port <port_id> fec_mode auto|off|rs|baser"
>>
>> '<>' is to define the variable name, like in '<port_id>' you expect numbers like
>> 0,1,2 .. but 'auto|off|rs|baser' are keywords, not variables.
>
>
> _______________________________________________
> Linuxarm mailing list
> Linuxarm@huawei.com
> http://hulk.huawei.com/mailman/listinfo/linuxarm
>
@@ -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,
};
@@ -138,6 +138,58 @@ 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_AUTO,
+ .name = "auto",
+ },
+ {
+ .mode = RTE_ETH_FEC_BASER,
+ .name = "baser",
+ },
+ {
+ .mode = RTE_ETH_FEC_RS,
+ .name = "rs",
+ },
+};
+
+static const struct {
+ uint32_t speed;
+ const char *name;
+} eth_speed_name[] = {
+ {
+ .speed = ETH_SPEED_NUM_10G,
+ .name = "Speed 10G",
+ },
+ {
+ .speed = ETH_SPEED_NUM_25G,
+ .name = "Speed 25G",
+ },
+ {
+ .speed = ETH_SPEED_NUM_40G,
+ .name = "Speed 40G",
+ },
+ {
+ .speed = ETH_SPEED_NUM_50G,
+ .name = "Speed 50G",
+ },
+ {
+ .speed = ETH_SPEED_NUM_100G,
+ .name = "Speed 100G",
+ },
+ {
+ .speed = ETH_SPEED_NUM_200G,
+ .name = "Speed 200G",
+ },
+};
+
static void
print_ethaddr(const char *name, struct rte_ether_addr *eth_addr)
{
@@ -2969,6 +3021,45 @@ set_tx_pkt_split(const char *name)
printf("unknown value: \"%s\"\n", name);
}
+int
+parse_fec_mode(const char *name, uint32_t *mode)
+{
+ uint8_t i;
+
+ for (i = 0; i < RTE_DIM(fec_mode_name); i++) {
+ if (strcmp(fec_mode_name[i].name, name) == 0) {
+ *mode = RTE_ETH_FEC_MODE_TO_CAPA(fec_mode_name[i].mode);
+ return 0;
+ }
+ }
+ return -1;
+}
+
+void
+show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
+{
+ unsigned int i, j, k;
+
+ printf("FEC capabilities:\n");
+
+ for (i = 0; i < num; i++) {
+ for (j = 0; j < RTE_DIM(eth_speed_name); j++) {
+ if (eth_speed_name[j].speed ==
+ speed_fec_capa[i].speed) {
+ printf("%s : ", eth_speed_name[j].name);
+ break;
+ }
+ }
+
+ for (k = RTE_ETH_FEC_AUTO; k < RTE_DIM(fec_mode_name); k++) {
+ if (RTE_ETH_FEC_MODE_TO_CAPA(k) &
+ speed_fec_capa[i].capa)
+ printf("%s ", fec_mode_name[k].name);
+ }
+ printf("\n");
+ }
+}
+
void
show_tx_pkt_segments(void)
{
@@ -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);