net/i40e: i40e rework for ipn3ke
PATCH 1/1 net/i40e: i40e rework for ipn3ke
Add switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
--- drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +122 -6
@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" -#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -2784,6 +2786,80 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)
@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));
@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED ; + link.link_speed = +ETH_SPEED_NUM_25G ; + link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
Signature · 1 line
1.8.3.1
Hi,
Quoted 14 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.
Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")
My understanding cc people should add in git send-email not in patch.
Quoted 188 lines
Signed-off-by Andy Pei <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)drivers/net/i40e/i40e_ethdev.c +7
-5@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" -#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL};static const struct
rte_pci_idpci_id_i40e_map[] = { @@ -2784,6 +2786,80
@@ voidi40e_flex_payload_reg_set_default(struct i40e_hw *hw)drivers/net/i40e/i40e_ethdev.c +61
-0} } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + + snprintf(switch_ethdev_name, sizeof(switch_ethdev_name), + "net_%s_representor_%s", switch_name,
port_name);drivers/net/i40e/i40e_ethdev.c +42
-0+PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED;drivers/net/i40e/i40e_ethdev.c +2
-0+ link.link_speed = +ETH_SPEED_NUM_25G;drivers/net/i40e/i40e_ethdev.c +8
-0+ link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16"
drivers/net/i40e/i40e_ethdev.c +2
-2ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE"); --1.8.3.1
Quoted 24 lines · Rosen
Hi,
Quoted 14 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")
Quoted 1 line
My understanding cc people should add in git send-email not in patch.
"git send-email" is picking the names from commit log, so putting the names in the commit log is another way, but as you said at the end of the day we don't want names be in the git history.
But what can be done is, putting the names after "---" works for both, those names still will be picked by "git send-email" and cc'ed automatically, and this information is part of the patch meanwhile they will be stripped automatically when merged, so they won't be in the git history without causing manual cleanup task to maintainers.
Quoted 3 lines
Quoted 3 lines
Signed-off-by Andy Pei <[email protected]>---
<----- HERE
Quoted 4 lines
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)
<...>
Hi, Ferruh
Thanks a lot. Your tips is really helpful, and I will follow this in the future.
-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, May 24, 2019 9:12 PM
To: Xu, Rosen <[email protected]>; Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Subject: Re: [PATCH] net/i40e: i40e rework for ipn3ke
Quoted 25 lines · Rosen
Hi,
Quoted 15 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")
Quoted 1 line
My understanding cc people should add in git send-email not in patch.
"git send-email" is picking the names from commit log, so putting the names in the commit log is another way, but as you said at the end of the day we don't want names be in the git history.
But what can be done is, putting the names after "---" works for both, those names still will be picked by "git send-email" and cc'ed automatically, and this information is part of the patch meanwhile they will be stripped automatically when merged, so they won't be in the git history without causing manual cleanup task to maintainers.
Quoted 3 lines
Quoted 3 lines
Signed-off-by Andy Pei <[email protected]>---
<----- HERE
Quoted 4 lines
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)
<...>
Hi, Rosen
Your ACK is needed if there is no other issue except the CC list
-----Original Message-----
From: Xu, Rosen
Sent: Friday, May 24, 2019 9:05 AM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3ke
Hi,
Quoted 15 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.
Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")
My understanding cc people should add in git send-email not in patch.
Quoted 186 lines
Signed-off-by Andy Pei <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex cab440f..9873ea0 100644drivers/net/i40e/i40e_ethdev.c +7
-5@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" -#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(structi40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL};static const struct
rte_pci_idpci_id_i40e_map[] = { @@ -2784,6
+2786,80 @@ voidi40e_flex_payload_reg_set_default(struct i40e_hw *hw)drivers/net/i40e/i40e_ethdev.c +60
-0} } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + + snprintf(switch_ethdev_name, sizeof(switch_ethdev_name), + "net_%s_representor_%s", switch_name,
port_name);drivers/net/i40e/i40e_ethdev.c +42
-0+PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED;drivers/net/i40e/i40e_ethdev.c +2
-0+ link.link_speed = +ETH_SPEED_NUM_25G;drivers/net/i40e/i40e_ethdev.c +10
-2+ link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE"); --1.8.3.1
Xu, Rosen
Acked-byHi Andy,
Quoted 232 lines
-----Original Message-----
From: Pei, Andy
Sent: Monday, June 10, 2019 14:15
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3keHi, Rosen
Your ACK is needed if there is no other issue except the CC list
-----Original Message-----
From: Xu, Rosen
Sent: Friday, May 24, 2019 9:05 AM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3keHi,
Quoted 15 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")My understanding cc people should add in git send-email not in patch.
Quoted 178 lines
Signed-off-by Andy Pei <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex cab440f..9873ea0 100644drivers/net/i40e/i40e_ethdev.c +7
-5@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" -#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(structi40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL};static const struct
rte_pci_idpci_id_i40e_map[] = { @@ -2784,6
+2786,80 @@ voidi40e_flex_payload_reg_set_default(struct i40e_hw *hw)drivers/net/i40e/i40e_ethdev.c +60
-0} } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + + snprintf(switch_ethdev_name, sizeof(switch_ethdev_name), + "net_%s_representor_%s", switch_name,
port_name);drivers/net/i40e/i40e_ethdev.c +42
-0+PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED;drivers/net/i40e/i40e_ethdev.c +2
-0+ link.link_speed = +ETH_SPEED_NUM_25G;drivers/net/i40e/i40e_ethdev.c +8
-0+ link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);drivers/net/i40e/i40e_ethdev.c struct i40e_customized_pctype* · line 12906
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16"
Quoted 6 lines
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +2
-2ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE"); --1.8.3.1
Pei, Andy
Acked-by Rosen Xu+ Ye Xiaolong
-----Original Message-----
From: Xu, Rosen
Sent: Tuesday, June 11, 2019 10:35 AM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3ke
Hi Andy,
Quoted 232 lines
-----Original Message-----
From: Pei, Andy
Sent: Monday, June 10, 2019 14:15
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3keHi, Rosen
Your ACK is needed if there is no other issue except the CC list
-----Original Message-----
From: Xu, Rosen
Sent: Friday, May 24, 2019 9:05 AM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [PATCH] net/i40e: i40e rework for ipn3keHi,
Quoted 15 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, May 23, 2019 17:15
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH] net/i40e: i40e rework for ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.Quoted 7 lines
Fixes c60869e2b742 ("net/i40e: fix link status update")My understanding cc people should add in git send-email not in patch.
Quoted 178 lines
Signed-off-by Andy Pei <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex cab440f..9873ea0 100644drivers/net/i40e/i40e_ethdev.c +7
-5@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h" -#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(structi40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL};static const struct
rte_pci_idpci_id_i40e_map[] = { @@ -2784,6
+2786,80 @@ void i40e_flex_payload_reg_set_default(structi40e_hwdrivers/net/i40e/i40e_ethdev.c +60
-0+*hw) } } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) { +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + + snprintf(switch_ethdev_name, sizeof(switch_ethdev_name), + "net_%s_representor_%s", switch_name,
port_name);drivers/net/i40e/i40e_ethdev.c +42
-0+PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED;drivers/net/i40e/i40e_ethdev.c +2
-0+ link.link_speed = +ETH_SPEED_NUM_25G;drivers/net/i40e/i40e_ethdev.c +8
-0+ link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);drivers/net/i40e/i40e_ethdev.c struct i40e_customized_pctype* · line 12906
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16"
Quoted 6 lines
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +2
-2ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE"); --1.8.3.1
Hi, Andy
Better to use a more specific subject for this patch:
net/i40e: get link status update for ipn3ke
or something similar.
Quoted 6 lines · Andy Pei
Add
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.Fixes c60869e2b742 ("net/i40e: fix link status update")
For me, this patch is rather a new feature add than a fix.
Quoted 6 lines
As Ferruh suggested, currently we don't need this cc info in git log history, you can move the cc block after --- mark, while all those names will still be picked-up and cc'ed by git send-email.
Quoted 14 lines
Signed-off-by Andy Pei <[email protected]>---
drivers/net/i40e/i40e_ethdev.c| 128 +++++++++++++++++++++++++++++++++++++++--1 file changed, 122 insertions(+), 6 deletions(-)drivers/net/i40e/i40e_ethdev.c +0
-0@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h"
drivers/net/i40e/i40e_ethdev.c line 46
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-5-#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec"
Above changes are not relevant.
Quoted 15 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {@@ -2784,6 +2786,80 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } }
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2797
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +9
-0+static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); +
When will you free the memory alloced by strdup.
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2810
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +13
-0+if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 };
Above initializations are not needed.
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2814
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +4
-0+uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ;
This initialization is not needed.
Quoted 36 lines
drivers/net/i40e/i40e_ethdev.c +36
-0+ +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); + PMD_DRV_LOG(DEBUG, "switch_ethdev_name is %s",
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2860
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ;
After read the body of this function, it's about getting a switch_ethdev by a name other than updating the link status, so the func name is confusing, better to use a more precise name, and return value can be struct *rte_eth_dev, then you wouldn't have to pass struct rte_eth_dev **.
Quoted 45 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+} +int
i40e_dev_link_update(structrte_eth_dev*dev,
intwait_to_complete)drivers/net/i40e/i40e_ethdev.c +29
-0@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED ;
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2922
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ link.link_speed = +ETH_SPEED_NUM_25G ; + link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } +
Better to wrap above code to a function to avoid too many levels of block nesting.
Thanks,
Xiaolong
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +2
-1ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");Signature · 1 line
1.8.3.1
Hi, Xiaolong
OK, I will do this in V2.
Thanks.
-----Original Message-----
From: Ye, Xiaolong
Sent: Wednesday, June 26, 2019 11:33 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: i40e rework for ipn3ke
Hi, Andy
Better to use a more specific subject for this patch:
net/i40e: get link status update for ipn3ke
or something similar.
Quoted 5 lines · Andy Pei
Add
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to.
i40e PF get link status update via the connected FPGA.Fixes c60869e2b742 ("net/i40e: fix link status update")
For me, this patch is rather a new feature add than a fix.
Quoted 6 lines
As Ferruh suggested, currently we don't need this cc info in git log history, you can move the cc block after --- mark, while all those names will still be picked-up and cc'ed by git send-email.
Quoted 15 lines
Signed-off-by Andy Pei <[email protected]>---
drivers/net/i40e/i40e_ethdev.c| 128
+++++++++++++++++++++++++++++++++++++++--1 file changed, 122 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex cab440f..9873ea0 100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -39,11 +39,12 @@#include "i40e_regs.h" #include "rte_pmd_i40e.h"
drivers/net/i40e/i40e_ethdev.c line 46
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +5
-5-#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" -#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" -#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" -#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" -#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb" +#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list" +#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver" +#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf" +#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec"
Above changes are not relevant.
Quoted 16 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200@@ -410,6 +411,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL};static const struct
rte_pci_idpci_id_i40e_map[] = { @@ -2784,6 +2786,80 @@ voidi40e_flex_payload_reg_set_default(struct i40e_hw *hw)} }
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2797
Quoted 9 lines
drivers/net/i40e/i40e_ethdev.c +9
-0+static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); +
When will you free the memory alloced by strdup.
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2810
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +13
-0+if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static void +i40e_pf_switch_mode_link_update (const char *cfg_str, +struct rte_eth_dev **switch_ethdev) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char port_name[RTE_ETH_NAME_MAX_LEN ] = {0 }; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ] = {0 };
Above initializations are not needed.
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2814
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +4
-0+uint16_t port_id; +const char *p_src; +char *p_dst; +int ret =-1 ;
This initialization is not needed.
Quoted 36 lines
drivers/net/i40e/i40e_ethdev.c +36
-0+ +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); + PMD_DRV_LOG(DEBUG, "switch_ethdev_name is %s",
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2860
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) + *switch_ethdev =NULL ; +else + *switch_ethdev = &rte_eth_devices[port_id]; + }else + *switch_ethdev =NULL ;
After read the body of this function, it's about getting a switch_ethdev by a name other than updating the link status, so the func name is confusing, better to use a more precise name, and return value can be struct *rte_eth_dev, then you wouldn't have to pass struct rte_eth_dev **.
Quoted 45 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+} +int
i40e_dev_link_update(structrte_eth_dev*dev,
intwait_to_complete)drivers/net/i40e/i40e_ethdev.c +29
-0@@ -2792,6 +2868,11 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;int ret; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ;memset (&link,0 ,sizeof (link));@@ -2805,6 +2886,40 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) { + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist !=NULL ) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) + ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, + &switch_cfg_str)) { + +i40e_pf_switch_mode_link_update ( + switch_cfg_str, + &switch_ethdev); + +if (switch_ethdev) { +rte_eth_linkstatus_get ( + switch_ethdev, + &link); + }else { + link.link_duplex = +ETH_LINK_FULL_DUPLEX ; + link.link_autoneg = +ETH_LINK_SPEED_FIXED ;
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2922
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ link.link_speed = +ETH_SPEED_NUM_25G ; + link.link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } + } +
Better to wrap above code to a function to avoid too many levels of block nesting.
Thanks,
Xiaolong
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +2
-2ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12790,4 +12905,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE"); --1.8.3.1
PATCH v2 1/1 net/i40e: i40e get link status update from ipn3ke
In reply to Andy PeiAdd switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block nesting.
drivers/net/i40e/i40e_ethdev.c | 121 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_ethdev.c +120 -1
@@ -44,6 +44,7 @@#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver"#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf"#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -406,6 +407,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -2778,6 +2780,116 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else +return NULL ; +} + +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_devargs *devargs,struct rte_eth_link *link) +{ +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev; +char *switch_cfg_str =NULL ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, &switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name ( + switch_cfg_str); + +rte_free (switch_cfg_str); + +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, + link); + }else { + link->link_autoneg = +ETH_LINK_SPEED_FIXED ; + link->link_duplex = +ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } + } + } +rte_kvargs_free (kvlist); + } +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)
@@ -2785,6 +2897,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_devargs *devargs;int ret;memset (&link,0 ,sizeof (link));
@@ -2799,6 +2913,10 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) +i40e_pf_linkstatus_get_from_switch_ethdev (devargs, &link); + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12772,4 +12890,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2] net/i40e: i40e get link status update from ipn3ke
Quoted 18 lines
-----Original Message-----
From: Pei, Andy
Sent: Friday, June 28, 2019 4:33 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v2] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.Signed-off-by Andy Pei <[email protected]>---
....
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2919
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -2799,6 +2913,10 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) +i40e_pf_linkstatus_get_from_switch_ethdev (devargs, &link);
It's not necessary to check devargs every time we do i40e_dev_link_update,
its better initialize the ipn3ke mode during initialization (add some field in i40e_adapter maybe), so we can reuse the result at runtime
Quoted 1 line
(quoted diff) +1
-0+
......
Re: [dpdk-dev] [PATCH v2] net/i40e: i40e get link status update from ipn3ke
Hi Qi,
I will do it in v3.
Thanks
-----Original Message-----
From: Zhang, Qi Z
Sent: Sunday, June 30, 2019 8:36 AM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: RE: [PATCH v2] net/i40e: i40e get link status update from ipn3ke
Quoted 17 lines
-----Original Message-----
From: Pei, Andy
Sent: Friday, June 28, 2019 4:33 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v2] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.Signed-off-by Andy Pei <[email protected]>---
....
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2919
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -2799,6 +2913,10 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + devargs = pci_dev->device.devargs; +if (devargs) +i40e_pf_linkstatus_get_from_switch_ethdev (devargs, &link);
It's not necessary to check devargs every time we do i40e_dev_link_update, its better initialize the ipn3ke mode during initialization (add some field in i40e_adapter maybe), so we can reuse the result at runtime
Quoted 1 line
(quoted diff) +1
-0+
......
PATCH v3 1/1 net/i40e: i40e get link status update from ipn3ke
In reply to Andy PeiAdd switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
Add switch_ethdev to rte_eth_dev_data to track the bind switch device. Try to bind i40e pf to switch device when i40e device is probed. If it fail to find correct switch device, bind will occur again when update i40e device link status.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v3:
* Add switch_ethdev to rte_eth_dev_data to track the bind switch device
* Try to bind i40e pf when it is probed.
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block nesting.
drivers/net/i40e/i40e_ethdev.c | 136 +++++++++++++++++++++++++++++++++++- lib/librte_ethdev/rte_ethdev_core.h | 4 ++ 2 files changed, 138 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +134 -2
@@ -44,6 +44,7 @@#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver"#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf"#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -406,6 +407,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -625,14 +627,115 @@ struct rte_i40e_xstats_name_off { sizeof(rte_i40e_txq_prio_strings[0]))static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} + +static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else + *p_dst++ = *p_src++; + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else +return NULL ; +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char *switch_cfg_str =NULL ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, &switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name ( + switch_cfg_str); + +rte_free (switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} + +static int eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) {char name[RTE_ETH_NAME_MAX_LEN ];struct rte_eth_devargs eth_da = { .nb_representor_ports =0 }; +struct rte_eth_dev *switch_ethdev =NULL ;int i, retval;if (pci_dev->device.devargs) { + switch_ethdev =i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); retval =rte_eth_devargs_parse (pci_dev->device.devargs->args, ð_da);if (retval)
@@ -654,6 +757,8 @@ struct rte_i40e_xstats_name_off {if (pf_ethdev ==NULL )return -ENODEV ; + pf_ethdev->data->switch_ethdev = switch_ethdev; +for (i =0 ; i < eth_da.nb_representor_ports; i++) {struct i40e_vf_representor representor = { .vf_id = eth_da.representor_ports[i],
@@ -687,7 +792,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)if (!ethdev)return -ENODEV ; - + ethdev->data->switch_ethdev =NULL ;if (ethdev->data->dev_flags &RTE_ETH_DEV_REPRESENTOR )return rte_eth_dev_destroy (ethdev, i40e_vf_representor_uninit);else
@@ -2779,6 +2884,20 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) +{ +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)
@@ -2786,6 +2905,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_devargs *devargs;int ret;memset (&link,0 ,sizeof (link));
@@ -2800,6 +2921,16 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (!dev->data->switch_ethdev) { + devargs = pci_dev->device.devargs; +if (devargs) + dev->data->switch_ethdev = +i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (dev->data->switch_ethdev, + &link); + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12773,4 +12904,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
lib/librte_ethdev/rte_ethdev_core.h +4 -0
@@ -635,6 +635,10 @@ struct rte_eth_dev_data {/**< Switch-specific identifier. * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. */ +struct rte_eth_dev *switch_ethdev; +/* point to switch_ethdev specific by "switch_mode" in +* devargs +*/ } __rte_cache_aligned;/**
Signature · 1 line
1.8.3.1
PATCH v4 1/1 net/i40e: i40e get link status update from ipn3ke
Add switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
Add switch_ethdev to rte_eth_dev_data to track the bind switch device. Try to bind i40e pf to switch device when i40e device is probed. If it fail to find correct switch device, bind will occur again when update i40e device link status.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v4:
* use an array instead of a pointer to store switch device string to
* avoid memory free error.
v3:
* Add switch_ethdev to rte_eth_dev_data to track the bind switch device
* Try to bind i40e pf when it is probed.
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block
* nesting.
drivers/net/i40e/i40e_ethdev.c | 139 +++++++++++++++++++++++++++++++++++- lib/librte_ethdev/rte_ethdev_core.h | 4 ++ 2 files changed, 141 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +137 -2
@@ -44,6 +44,7 @@#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver"#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf"#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -406,6 +407,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -625,14 +627,118 @@ struct rte_i40e_xstats_name_off { sizeof(rte_i40e_txq_prio_strings[0]))static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + +if (RTE_ETH_NAME_MAX_LEN >strlen (value)) { +rte_memcpy (extra_args, value,strlen (value) +1 ); +return 0 ; + }else { +PMD_DRV_LOG (ERR , +"switch_mode args should be less than %d characters" , +RTE_ETH_NAME_MAX_LEN ); +return -EINVAL ; + } +} + +static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name ( + switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} + +static int eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) {char name[RTE_ETH_NAME_MAX_LEN ];struct rte_eth_devargs eth_da = { .nb_representor_ports =0 }; +struct rte_eth_dev *switch_ethdev =NULL ;int i, retval;if (pci_dev->device.devargs) { + switch_ethdev =i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); retval =rte_eth_devargs_parse (pci_dev->device.devargs->args, ð_da);if (retval)
@@ -654,6 +760,8 @@ struct rte_i40e_xstats_name_off {if (pf_ethdev ==NULL )return -ENODEV ; + pf_ethdev->data->switch_ethdev = switch_ethdev; +for (i =0 ; i < eth_da.nb_representor_ports; i++) {struct i40e_vf_representor representor = { .vf_id = eth_da.representor_ports[i],
@@ -687,7 +795,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)if (!ethdev)return -ENODEV ; - + ethdev->data->switch_ethdev =NULL ;if (ethdev->data->dev_flags &RTE_ETH_DEV_REPRESENTOR )return rte_eth_dev_destroy (ethdev, i40e_vf_representor_uninit);else
@@ -2779,6 +2887,20 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) +{ +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete)
@@ -2786,6 +2908,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_devargs *devargs;int ret;memset (&link,0 ,sizeof (link));
@@ -2800,6 +2924,16 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (!dev->data->switch_ethdev) { + devargs = pci_dev->device.devargs; +if (devargs) + dev->data->switch_ethdev = +i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (dev->data->switch_ethdev, + &link); + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12773,4 +12907,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
lib/librte_ethdev/rte_ethdev_core.h +4 -0
@@ -635,6 +635,10 @@ struct rte_eth_dev_data {/**< Switch-specific identifier. * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. */ +struct rte_eth_dev *switch_ethdev; +/* point to switch_ethdev specific by "switch_mode" in +* devargs +*/ } __rte_cache_aligned;/**
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4] net/i40e: i40e get link status update from ipn3ke
Quoted 21 lines
-----Original Message-----
From: Pei, Andy
Sent: Monday, July 8, 2019 11:03 AM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v4] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA. Addswitch_ethdevtorte_eth_dev_datato track the bind switch device. Try to bind i40e pf to switch device when i40e device is probed. If it fail to find correct switch device, bind will occur again when update i40e device link status.Signed-off-by Andy Pei <[email protected]>
.....
Quoted 6 lines
lib/librte_ethdev/rte_ethdev_core.h +0
-0
lib/librte_ethdev/rte_ethdev_core.h struct rte_eth_dev_data { · line 642
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_core.h +4
-0@@ -635,6 +635,10 @@ struct rte_eth_dev_data {/**< Switch-specific identifier. * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. */ +struct rte_eth_dev *switch_ethdev; +/* point to switch_ethdev specific by "switch_mode" in +* devargs +*/ } __rte_cache_aligned;
Missing below comment in previous review.
No need to add new field in rte_eth_dev_data to break ABI, you can just add to i40e specific structure: i40e_pf.
Quoted 4 lines
lib/librte_ethdev/rte_ethdev_core.h +0
-1/** -- 1.8.3.1
PATCH v5 1/1 net/i40e: i40e get link status update from ipn3ke
In reply to Andy PeiAdd switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
Add bool switch_ethdev_support_flag to struct i40e_pf to specify if there are switch_mode argues in cmd.
Add switch_ethdev to struct i40e_pf to track the bind switch device. Try to bind i40e pf to switch device when i40e device is initialized. If it fail to find correct switch device, bind will occur again when update i40e device link status.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v5:
* use a bool switch_ethdev_support_flag in struct i40e_pf to specify
* if i40e device needs to get link status update from ipn3ke device.
v4:
* use an array instead of a pointer to store switch device string to
* avoid memory free error.
v3:
* Add switch_ethdev to rte_eth_dev_data to track the bind switch
* device
* Try to bind i40e pf when it is probed.
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block
* nesting.
drivers/net/i40e/i40e_ethdev.c | 181 ++++++++++++++++++++++++++++++++++++++++- drivers/net/i40e/i40e_ethdev.h | 4 + 2 files changed, 184 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_ethdev.c +180 -1
@@ -44,6 +44,7 @@#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver"#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf"#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -406,6 +407,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -1260,6 +1262,125 @@ static inline void i40e_config_automask(struct i40e_pf *pf)#define I40E_ALARM_INTERVAL 50000/* us */ static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + +if (RTE_ETH_NAME_MAX_LEN >strlen (value)) { +rte_memcpy (extra_args, value,strlen (value) +1 ); + }else { +PMD_DRV_LOG (ERR , +"switch_mode args should be less than %d characters" , +RTE_ETH_NAME_MAX_LEN ); +return -EINVAL ; + } +return 0 ; +} + +static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + } +} + +static void +eth_i40e_pf_switch_dev_init (struct rte_eth_dev *dev, +struct i40e_pf *pf) +{ +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; +struct rte_kvargs *kvlist =NULL ; +struct rte_devargs *devargs; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); + + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; + + devargs = pci_dev->device.devargs; +if (!devargs) +return ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { + pf->switch_ethdev_support_flag =1 ; + +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + pf->switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +return ; +} +static void +eth_i40e_pf_switch_dev_uninit (struct i40e_pf *pf) +{ + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; +return ; +} + +static int eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) {struct rte_pci_device *pci_dev;
@@ -1582,6 +1703,11 @@ static inline void i40e_config_automask(struct i40e_pf *pf)memset (&pf->rss_info,0 ,sizeof (struct i40e_rte_flow_rss_conf )); +/* parse the switch device from devargs, try to bind to the switch +* device, if binding not succeed, bind again when i40e_dev_link_update +*/ +eth_i40e_pf_switch_dev_init (dev, pf); +/* reset all stats of the device, including pf and main vsi */ i40e_dev_stats_reset (dev);
@@ -1762,6 +1888,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)rte_free (p_flow); } +eth_i40e_pf_switch_dev_uninit (pf); +/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);
@@ -2779,13 +2907,52 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) +{ +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete) {struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);int ret;memset (&link,0 ,sizeof (link));
@@ -2800,6 +2967,17 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (pf->switch_ethdev_support_flag) { +if (!pf->switch_ethdev) { +if (pci_dev->device.devargs) + pf->switch_ethdev = +i40e_get_switch_ethdev_from_devargs + (pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (pf->switch_ethdev, + &link); + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12773,4 +12951,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
drivers/net/i40e/i40e_ethdev.h +4 -0
@@ -975,6 +975,10 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; +bool switch_ethdev_support_flag; +/* flag indicating if switch mode is required like other devargs */ +struct rte_eth_dev *switch_ethdev; +/* point to switch_ethdev specific by "switch_mode" in devargs */ };enum pending_msg {
Signature · 1 line
1.8.3.1
PATCH v6 1/2 net/i40e: i40e get link status update from ipn3ke
Add switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
Add bool switch_ethdev_support_flag to struct i40e_pf to specify if there are switch_mode argues in cmd.
Add switch_ethdev to struct i40e_pf to track the bind switch device. Try to bind i40e pf to switch device when i40e device is initialized. If it fail to find correct switch device, bind will occur again when update i40e device link status.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v6:
* fix some coding style.
v5:
* use a bool switch_ethdev_support_flag in struct i40e_pf to specify
* if i40e device needs to get link status update from ipn3ke device.
v4:
* use an array instead of a pointer to store switch device string to
* avoid memory free error.
v3:
* Add switch_ethdev to rte_eth_dev_data to track the bind switch
* device
* Try to bind i40e pf when it is probed.
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block
* nesting.
drivers/net/i40e/i40e_ethdev.c | 179 ++++++++++++++++++++++++++++++++++++++++-
drivers/net/i40e/i40e_ethdev.h | 6 ++ 2 files changed, 184 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_ethdev.c +178 -1
@@ -44,6 +44,7 @@#define ETH_I40E_SUPPORT_MULTI_DRIVER "support-multi-driver"#define ETH_I40E_QUEUE_NUM_PER_VF_ARG "queue-num-per-vf"#define ETH_I40E_USE_LATEST_VEC "use-latest-supported-vec" +#define ETH_I40E_SWITCH_MODE_ARG "switch_mode"#define I40E_CLEAR_PXE_WAIT_MS 200
@@ -406,6 +407,7 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,ETH_I40E_SUPPORT_MULTI_DRIVER ,ETH_I40E_QUEUE_NUM_PER_VF_ARG ,ETH_I40E_USE_LATEST_VEC , +ETH_I40E_SWITCH_MODE_ARG , NULL}; static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -1260,6 +1262,123 @@ static inline void i40e_config_automask(struct i40e_pf *pf)#define I40E_ALARM_INTERVAL 50000/* us */ static int +i40e_pf_parse_switch_mode(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + +if (strlen (value) <RTE_ETH_NAME_MAX_LEN ) { +rte_memcpy (extra_args, value,strlen (value) +1 ); + }else { +PMD_DRV_LOG (ERR , +"switch_mode args should be less than %d characters" , +RTE_ETH_NAME_MAX_LEN ); +return -EINVAL ; + } +return 0 ; +} + +static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) +{ +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name); + + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + } +} + +static void +eth_i40e_pf_switch_dev_init (struct rte_eth_dev *dev, +struct i40e_pf *pf) +{ +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; +struct rte_kvargs *kvlist =NULL ; +struct rte_devargs *devargs; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); + + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; + + devargs = pci_dev->device.devargs; +if (!devargs) +return ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { + pf->switch_ethdev_support_flag =1 ; + +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + pf->switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +} +static void +eth_i40e_pf_switch_dev_uninit (struct i40e_pf *pf) +{ + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; +} + +static int eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) {struct rte_pci_device *pci_dev;
@@ -1582,6 +1701,11 @@ static inline void i40e_config_automask(struct i40e_pf *pf)memset (&pf->rss_info,0 ,sizeof (struct i40e_rte_flow_rss_conf )); +/* parse the switch device from devargs, try to bind to the switch +* device, if binding not succeed, bind again when i40e_dev_link_update +*/ +eth_i40e_pf_switch_dev_init (dev, pf); +/* reset all stats of the device, including pf and main vsi */ i40e_dev_stats_reset (dev);
@@ -1762,6 +1886,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)rte_free (p_flow); } +eth_i40e_pf_switch_dev_uninit (pf); +/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);
@@ -2779,13 +2905,52 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) +{ +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str); + } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete) {struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);int ret;memset (&link,0 ,sizeof (link));
@@ -2800,6 +2965,17 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (pf->switch_ethdev_support_flag) { +if (!pf->switch_ethdev) { +if (pci_dev->device.devargs) + pf->switch_ethdev = +i40e_get_switch_ethdev_from_devargs + (pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (pf->switch_ethdev, + &link); + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);
@@ -12773,4 +12949,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
drivers/net/i40e/i40e_ethdev.h +6 -0
@@ -975,6 +975,12 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; + +/* flag indicating if switch mode is required like other devargs */ +bool switch_ethdev_support_flag; + +/* point to switch_ethdev specific by "switch_mode" in devargs */ +struct rte_eth_dev *switch_ethdev; };enum pending_msg {
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
Quoted 12 lines
-----Original Message-----
From: Pei, Andy
Sent: Wednesday, July 10, 2019 5:41 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
You can merge patch 2/2 with this patch.
...
Quoted 48 lines
drivers/net/i40e/i40e_ethdev.c +47
-0+static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) { +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1339
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + }
This code can simplified to
If (... ) {
...
If (!ret)
return &ret_eth_devices[port_id];
}return NULL;
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf)
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+} + +static void +eth_i40e_pf_switch_dev_init (struct rte_eth_dev *dev,struct i40e_pf +*pf) {
Argument "pf" is redundant, please remove it and use
pf =I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +13
-0+char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; +struct rte_kvargs *kvlist =NULL ; +struct rte_devargs *devargs; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); + + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; + + devargs = pci_dev->device.devargs; +if (!devargs) +return ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1368
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { + pf->switch_ethdev_support_flag =1 ; + +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + pf->switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line.
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1371
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+ } + } +rte_kvargs_free (kvlist);
Wrong intend
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1369
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+ } +} +static void +eth_i40e_pf_switch_dev_uninit (struct i40e_pf *pf) { + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; +}
This function is not necessary, after dev_init must be called after dev_unit, and above reset is performed in eth_i40e_pf_switch_dev_init already.
Quoted 51 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+ +static int eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused){
drivers/net/i40e/i40e_ethdev.c +25
-0struct rte_pci_device *pci_dev;@@ -1582,6 +1701,11 @@ static inline void i40e_config_automask(struct i40e_pf *pf) memset(&pf->rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); +/* parse the switch device from devargs, try to bind to the switch +* device, if binding not succeed, bind again when i40e_dev_link_update +*/ +eth_i40e_pf_switch_dev_init (dev, pf); +/* reset all stats of the device, including pf and main vsi */ i40e_dev_stats_reset (dev);@@ -1762,6 +1886,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)rte_free (p_flow ); } +eth_i40e_pf_switch_dev_uninit (pf); +/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);@@ -2779,13 +2905,52 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) { +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) { +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ];
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2936
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line
Quoted 21 lines
drivers/net/i40e/i40e_ethdev.c +9
-0+ } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete) {struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);int ret;memset (&link,0 ,sizeof (link));
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2971
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -2800,6 +2965,17 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + if (pf->switch_ethdev_support_flag) { +if (!pf->switch_ethdev) { +if (pci_dev->device.devargs)
No need to check here,
If swtch_ethdev_support_flag is 1, pci_dev->device.devargs should not be null, right?
Quoted 38 lines
drivers/net/i40e/i40e_ethdev.c +10
-1+ pf->switch_ethdev = +i40e_get_switch_ethdev_from_devargs + (pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (pf->switch_ethdev, + &link); + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12773,4 +12949,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");drivers/net/i40e/i40e_ethdev.h +6
-0@@ -975,6 +975,12 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; + +/* flag indicating if switch mode is required like other devargs */ +bool switch_ethdev_support_flag; + +/* point to switch_ethdev specific by "switch_mode" in devargs */ +struct rte_eth_dev *switch_ethdev; };enum
pending_msg{
--
1.8.3.1
Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
Hi, Qi
Reply inline.
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 11, 2019 12:37 PM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: RE: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
Quoted 4 lines
-----Original Message-----
From: Pei, Andy
Sent: Wednesday, July 10, 2019 5:41 PM
To: [email protected]
Quoted 8 lines
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
You can merge patch 2/2 with this patch.
OK
...
Quoted 48 lines
drivers/net/i40e/i40e_ethdev.c +47
-0+static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) { +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1339
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + }
This code can simplified to
If (... ) {
...
If (!ret)
return &ret_eth_devices[port_id];
}return NULL;
OK
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf)
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+} + +static void +eth_i40e_pf_switch_dev_init (struct rte_eth_dev *dev,struct i40e_pf +*pf) {
Argument "pf" is redundant, please remove it and use pf =I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
OK
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +13
-0+char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; +struct rte_kvargs *kvlist =NULL ; +struct rte_devargs *devargs; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); + + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; + + devargs = pci_dev->device.devargs; +if (!devargs) +return ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1368
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { + pf->switch_ethdev_support_flag =1 ; + +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + pf->switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line.
This will cause a coding style issue. CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #174: FILE: drivers/net/i40e/i40e_ethdev.c:721:
+ i40e_eth_dev_get_by_switch_mode_name(
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1371
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+ } + } +rte_kvargs_free (kvlist);
Wrong intend
OK
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1369
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+ } +} +static void +eth_i40e_pf_switch_dev_uninit (struct i40e_pf *pf) { + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; +}
This function is not necessary, after dev_init must be called after dev_unit, and above reset is performed in eth_i40e_pf_switch_dev_init already. OK
Quoted 51 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+ +static int eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params
__rte_unused) {drivers/net/i40e/i40e_ethdev.c +25
-0struct rte_pci_device *pci_dev;@@ -1582,6 +1701,11 @@ static inline void i40e_config_automask(struct i40e_pf *pf) memset(&pf->rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); +/* parse the switch device from devargs, try to bind to the switch +* device, if binding not succeed, bind again when i40e_dev_link_update +*/ +eth_i40e_pf_switch_dev_init (dev, pf); +/* reset all stats of the device, including pf and main vsi */ i40e_dev_stats_reset (dev);@@ -1762,6 +1886,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)rte_free (p_flow ); } +eth_i40e_pf_switch_dev_uninit (pf); +/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);@@ -2779,13 +2905,52 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) { +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) { +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ];
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2936
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line
Quoted 21 lines
drivers/net/i40e/i40e_ethdev.c +9
-0+ } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete) {struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);int ret;memset (&link,0 ,sizeof (link));
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2971
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -2800,6 +2965,17 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + if (pf->switch_ethdev_support_flag) { +if (!pf->switch_ethdev) { +if (pci_dev->device.devargs)
No need to check here,
If swtch_ethdev_support_flag is 1, pci_dev->device.devargs should not be null, right?
Switch device may not be probed when i40e device is being probed. In this case, swtch_ethdev_support_flag is 1, , pci_dev->device.devargs is null. This is explained here.
/* parse the switch device from devargs, try to bind to the switch
* device, if binding not succeed, bind again when i40e_dev_link_update
*/eth_i40e_pf_switch_dev_init(dev);
Quoted 38 lines
drivers/net/i40e/i40e_ethdev.c +10
-1+ pf->switch_ethdev = +i40e_get_switch_ethdev_from_devargs + (pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (pf->switch_ethdev, + &link); + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12773,4 +12949,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.hindex 38ac3ea..cfdcecb 100644drivers/net/i40e/i40e_ethdev.h +6
-0@@ -975,6 +975,12 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; + +/* flag indicating if switch mode is required like other devargs */ +bool switch_ethdev_support_flag; + +/* point to switch_ethdev specific by "switch_mode" in devargs */ +struct rte_eth_dev *switch_ethdev; };enum
pending_msg{
--
1.8.3.1
Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
In reply to Zhang, Qi ZHI QI
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 11, 2019 12:37 PM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: RE: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
Quoted 4 lines
-----Original Message-----
From: Pei, Andy
Sent: Wednesday, July 10, 2019 5:41 PM
To: [email protected]
Quoted 8 lines
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
You can merge patch 2/2 with this patch.
...
Quoted 48 lines
drivers/net/i40e/i40e_ethdev.c +47
-0+static struct rte_eth_dev * +i40e_eth_dev_get_by_switch_mode_name (const char *cfg_str) { +char switch_name[RTE_ETH_NAME_MAX_LEN ]; +char port_name[RTE_ETH_NAME_MAX_LEN ]; +char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +uint16_t port_id; +const char *p_src; +char *p_dst; +int ret; + +/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */ +if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++; + +/* move over the first underline */ + p_src++; + + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ; + p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++; + + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"port_name is %s" , port_name); + +snprintf (switch_ethdev_name,sizeof (switch_ethdev_name), +"net_%s_representor_%s" , switch_name, port_name); +PMD_DRV_LOG (DEBUG ,"switch_ethdev_name is %s" , + switch_ethdev_name);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1339
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + ret =rte_eth_dev_get_port_by_name (switch_ethdev_name, + &port_id); +if (ret) +return NULL ; +else +return &rte_eth_devices[port_id]; + }else { +return NULL ; + }
This code can simplified to
If (... ) {
...
If (!ret)
return &ret_eth_devices[port_id];
}return NULL;
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf)
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+} + +static void +eth_i40e_pf_switch_dev_init (struct rte_eth_dev *dev,struct i40e_pf +*pf) {
Argument "pf" is redundant, please remove it and use pf =I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +13
-0+char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ]; +struct rte_kvargs *kvlist =NULL ; +struct rte_devargs *devargs; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); + + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; + + devargs = pci_dev->device.devargs; +if (!devargs) +return ; + + kvlist =rte_kvargs_parse (devargs->args, valid_keys);
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1368
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { + pf->switch_ethdev_support_flag =1 ; + +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + pf->switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line.
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1371
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+ } + } +rte_kvargs_free (kvlist);
Wrong intend
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1369
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+ } +} +static void +eth_i40e_pf_switch_dev_uninit (struct i40e_pf *pf) { + pf->switch_ethdev_support_flag =0 ; + pf->switch_ethdev =NULL ; +}
This function is not necessary, after dev_init must be called after dev_unit, and above reset is performed in eth_i40e_pf_switch_dev_init already.
Quoted 51 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+ +static int eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params
__rte_unused) {drivers/net/i40e/i40e_ethdev.c +25
-0struct rte_pci_device *pci_dev;@@ -1582,6 +1701,11 @@ static inline void i40e_config_automask(struct i40e_pf *pf) memset(&pf->rss_info, 0, sizeof(struct i40e_rte_flow_rss_conf)); +/* parse the switch device from devargs, try to bind to the switch +* device, if binding not succeed, bind again when i40e_dev_link_update +*/ +eth_i40e_pf_switch_dev_init (dev, pf); +/* reset all stats of the device, including pf and main vsi */ i40e_dev_stats_reset (dev);@@ -1762,6 +1886,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)rte_free (p_flow ); } +eth_i40e_pf_switch_dev_uninit (pf); +/* Remove all Traffic Manager configuration */ i40e_tm_conf_uninit (dev);@@ -2779,13 +2905,52 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) } } +static void +i40e_pf_linkstatus_get_from_switch_ethdev +(struct rte_eth_dev *switch_ethdev,struct rte_eth_link *link) { +if (switch_ethdev) { +rte_eth_linkstatus_get (switch_ethdev, link); + }else { + link->link_autoneg =ETH_LINK_SPEED_FIXED ; + link->link_duplex =ETH_LINK_FULL_DUPLEX ; + link->link_speed =ETH_SPEED_NUM_25G ; + link->link_status =0 ; + } +} + +static struct rte_eth_dev * +i40e_get_switch_ethdev_from_devargs (struct rte_devargs *devargs) { +struct rte_kvargs *kvlist =NULL ; +struct rte_eth_dev *switch_ethdev =NULL ; +char switch_cfg_str[RTE_ETH_NAME_MAX_LEN ];
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2936
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_keys); +if (kvlist) { +if (rte_kvargs_count (kvlist,ETH_I40E_SWITCH_MODE_ARG ) ==1 ) { +if (!rte_kvargs_process (kvlist, +ETH_I40E_SWITCH_MODE_ARG , + &i40e_pf_parse_switch_mode, switch_cfg_str)) { + switch_ethdev = +i40e_eth_dev_get_by_switch_mode_name + (switch_cfg_str);
"(" should follow above line
Quoted 21 lines
drivers/net/i40e/i40e_ethdev.c +9
-0+ } + } +rte_kvargs_free (kvlist); + } +return switch_ethdev; +} +int i40e_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete) {struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev);int ret;memset (&link,0 ,sizeof (link));
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2971
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -2800,6 +2965,17 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) else update_link_aq(hw, &link, enable_lse, wait_to_complete); + if (pf->switch_ethdev_support_flag) { +if (!pf->switch_ethdev) { +if (pci_dev->device.devargs)
No need to check here,
If swtch_ethdev_support_flag is 1, pci_dev->device.devargs should not be null, right? Got your point
Quoted 38 lines
drivers/net/i40e/i40e_ethdev.c +10
-1+ pf->switch_ethdev = +i40e_get_switch_ethdev_from_devargs + (pci_dev->device.devargs); + } +i40e_pf_linkstatus_get_from_switch_ethdev (pf->switch_ethdev, + &link); + } + ret =rte_eth_linkstatus_set (dev, &link);i40e_notify_all_vfs_link_status (dev);@@ -12773,4 +12949,5 @@ struct i40e_customized_pctype*ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>" ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16" ETH_I40E_SUPPORT_MULTI_DRIVER "=1" - ETH_I40E_USE_LATEST_VEC "=0|1"); +ETH_I40E_USE_LATEST_VEC "=0|1" + ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.hindex 38ac3ea..cfdcecb 100644drivers/net/i40e/i40e_ethdev.h +6
-0@@ -975,6 +975,12 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; + +/* flag indicating if switch mode is required like other devargs */ +bool switch_ethdev_support_flag; + +/* point to switch_ethdev specific by "switch_mode" in devargs */ +struct rte_eth_dev *switch_ethdev; };enum
pending_msg{
--
1.8.3.1
PATCH v7 1/1 net/i40e: i40e get link status update from ipn3ke
In reply to Andy PeiAdd switch_mode argument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA.
Add bool switch_ethdev_support_flag to struct i40e_pf to specify if there are switch_mode argues in cmd.
Add switch_ethdev to struct i40e_pf to track the bind switch device. Try to bind i40e pf to switch device when i40e device is initialized. If it fail to find correct switch device, bind will occur again when update i40e device link status.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
v7:
* simplify code and delete redundance.
v6:
* fix some coding style.
v5:
* use a bool switch_ethdev_support_flag in struct i40e_pf to specify
* if i40e device needs to get link status update from ipn3ke device.
v4:
* use an array instead of a pointer to store switch device string to
* avoid memory free error.
v3:
* Add switch_ethdev to rte_eth_dev_data to track the bind switch
* device
* Try to bind i40e pf when it is probed.
v2:
* use a more specific subject for this patch.
* delete modifications that are not relevant.
* free memory allocted by strdup.
* delete unnecessary initializations.
* name function more precisely.
* wrap relevant code to a function to avoid too many levels of block
* nesting.
doc/guides/nics/i40e.rst | 11 +++ drivers/net/i40e/i40e_ethdev.c | 166 ++++++++++++++++++++++++++++++++++++++++- drivers/net/i40e/i40e_ethdev.h | 6 ++ 3 files changed, 182 insertions(+), 1 deletion(-)
doc/guides/nics/i40e.rst +11 -0
@@ -513,6 +513,17 @@ details please refer to :doc:`../testpmd_app_ug/index`. testpmd> set port (port_id) queue-region flush (on|off) testpmd> show port (port_id) queue-region +Switch Mode +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The Intel® Ethernet 700 Series can be component of IPN3KE device, in which the +Intel® Ethernet 700 Series is connected to other pci device. This pci device +works as switch device via which the Intel® Ethernet 700 Series get link status +from. For example: the Intel® Ethernet 700 Series 0000:b1:00.0 is connected to +an IPN3KE device whose BDF is b3:00.0. In this case 0000:b1:00.0 use representor +0 on b3:00.0. + + ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 -w 0000:b1:00.0,switch_mode=IPN3KE_0@b3:00.0_0 + Limitations or Known issues ---------------------------
drivers/net/i40e/i40e_ethdev.c +165 -1
212 lines not on this page · raw message
drivers/net/i40e/i40e_ethdev.h +6 -0
@@ -975,6 +975,12 @@ struct i40e_pf {struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX ];/* Switch Domain Id */ uint16_t switch_domain_id; + +/* flag indicating if switch mode is required like other devargs */ +bool switch_ethdev_support_flag; + +/* point to switch_ethdev specific by "switch_mode" in devargs */ +struct rte_eth_dev *switch_ethdev; };enum pending_msg {
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v7] net/i40e: i40e get link status update from ipn3ke
Quoted 23 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, July 11, 2019 2:39 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v7] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA. Add boolswitch_ethdev_support_flagto structi40e_pfto specify if there areswitch_modeargues in cmd.
Addswitch_ethdevto structi40e_pfto track the bind switch device. Try to bind i40e pf to switch device when i40e device is initialized. If it fail to find correct switch device, bind will occur again when update i40e device link status.Signed-off-by Andy Pei <[email protected]>
....
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1293
Quoted 1 line
drivers/net/i40e/i40e_ethdev.c +1
-0+/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */
My understanding, in above example you want to have
Swtich_name = "0|b3:00.0" and port_name = "0", right?
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1300
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +7
-0+if (!strncmp (cfg_str,"IPN3KE" ,strlen ("IPN3KE" ))) { + p_src = cfg_str; +PMD_DRV_LOG (DEBUG ,"cfg_str is %s" , cfg_str); + +/* move over "IPN3KE" */ +while ((*p_src !='_' ) && (*p_src)) + p_src++;
p_src = strchr(p_src, '_') should do the same thing?
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1303
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+ +/* move over the first underline */ + p_src++;
What if *p_src == null ?, error handle needed.
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1308
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+ + p_dst = switch_name; +while ((*p_src !='_' ) && (*p_src)) { +if (*p_src =='@' ) { + *p_dst++ ='|' ;
Are you replace '@' to '|"? why not define the expected argument as "IPN3KE_0|b3:00.0_0", so can simply do strncpy here.
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1318
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +10
-0+ p_src++; + }else { + *p_dst++ = *p_src++; + } + } + *p_dst =0 ; +PMD_DRV_LOG (DEBUG ,"switch_name is %s" , switch_name); + +/* move over the second underline */ + p_src++;
Same as above, error handle.
drivers/net/i40e/i40e_ethdev.c static inline void i40e_config_automask(struct i40e_pf *pf) · line 1323
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +5
-0+ + p_dst = port_name; +while (*p_src) + *p_dst++ = *p_src++; + *p_dst =0 ;
Use strncpy.
...
PATCH v6 2/2 doc: add switch mode devargs
In reply to Andy Peiadd document for switch_mode devargs.
--- doc/guides/nics/i40e.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)
doc/guides/nics/i40e.rst +11 -0
@@ -513,6 +513,17 @@ details please refer to :doc:`../testpmd_app_ug/index`. testpmd> set port (port_id) queue-region flush (on|off) testpmd> show port (port_id) queue-region +Switch Mode +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The Intel® Ethernet 700 Series can be component of IPN3KE device, in which the +Intel® Ethernet 700 Series is connected to other pci device. This pci device +works as switch device via which the Intel® Ethernet 700 Series get link status +from. For example: the Intel® Ethernet 700 Series 0000:b1:00.0 is connected to +an IPN3KE device whose BDF is b3:00.0. In this case 0000:b1:00.0 use representor +0 on b3:00.0. + + ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 -w 0000:b1:00.0,switch_mode=IPN3KE_0@b3:00.0_0 + Limitations or Known issues ---------------------------
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3] net/i40e: i40e get link status update from ipn3ke
In reply to Andy PeiHi Andy:
Quoted 18 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, July 4, 2019 2:56 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v3] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA. Addswitch_ethdevtorte_eth_dev_datato track the bind switch device. Try to bind i40e pf to switch device when i40e device is probed. If it fail to find correct switch device, bind will occur again when update i40e device link status.
......
Quoted 16 lines
int
i40e_dev_link_update(structrte_eth_dev*dev,drivers/net/i40e/i40e_ethdev.c +2
-0int wait_to_complete)@@ -2786,6 +2905,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_devargs *devargs;int ret;drivers/net/i40e/i40e_ethdev.c +0
-0memset (&link,0 ,sizeof (link));@@ -2800,6 +2921,16 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2931
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +7
-0else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (!dev->data->switch_ethdev) { + devargs = pci_dev->device.devargs; +if (devargs) + dev->data->switch_ethdev = +i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); + }
For regular mode, switch_ethdev is always null, seems above code did unnecessary devargs parsing for every link_update call
Can we add an intermediate flag (add a field in i40e_pf indicate if switch mode is required like other devargs ) so during probe this flag can be initialized, and it can be reused later.
So all switch mode related code can be braces with that flag. If (xxx_flag)
{
.....
}
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2932
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+i40e_pf_linkstatus_get_from_switch_ethdev (dev->data->switch_ethdev, + &link);
Why i40e_pf_linkstatus_get_from_switch_ethdev is always be called?, should we do
If (dev->data->switch_ethdev)
i40e_pf_linkstatus_get_from_switch_ethdev(dev->data->switch_ethdev, &link);
Re: [dpdk-dev] [PATCH v3] net/i40e: i40e get link status update from ipn3ke
Yes. I think you are right. I will try your suggestion.
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, July 8, 2019 1:56 PM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: RE: [PATCH v3] net/i40e: i40e get link status update from ipn3ke
Hi Andy:
Quoted 19 lines
-----Original Message-----
From: Pei, Andy
Sent: Thursday, July 4, 2019 2:56 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]
Subject: [PATCH v3] net/i40e: i40e get link status update from ipn3keAdd
switch_modeargument for i40e PF to specify the specific FPGA that i40e PF is connected to. i40e PF get link status update via the connected FPGA. Addswitch_ethdevtorte_eth_dev_datato track the bind switch device. Try to bind i40e pf to switch device when i40e device is probed. If it fail to find correct switch device, bind will occur again when update i40e device link status.
......
Quoted 16 lines
int
i40e_dev_link_update(structrte_eth_dev*dev,drivers/net/i40e/i40e_ethdev.c +2
-0int wait_to_complete)@@ -2786,6 +2905,8 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);struct rte_eth_link link;bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_devargs *devargs;int ret;drivers/net/i40e/i40e_ethdev.c +0
-0memset (&link,0 ,sizeof (link));@@ -2800,6 +2921,16 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct · line 2931
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +7
-0else update_link_aq (hw, &link, enable_lse, wait_to_complete); +if (!dev->data->switch_ethdev) { + devargs = pci_dev->device.devargs; +if (devargs) + dev->data->switch_ethdev = +i40e_get_switch_ethdev_from_devargs ( + pci_dev->device.devargs); + }
For regular mode, switch_ethdev is always null, seems above code did unnecessary devargs parsing for every link_update call Can we add an intermediate flag (add a field in i40e_pf indicate if switch mode is required like other devargs ) so during probe this flag can be initialized, and it can be reused later.
So all switch mode related code can be braces with that flag. If (xxx_flag)
{
.....
}
drivers/net/i40e/i40e_ethdev.c void i40e_flex_payload_reg_set_default(struct i40e_hw *hw) · line 2932
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +2
-0+i40e_pf_linkstatus_get_from_switch_ethdev (dev->data->switch_ethdev, + &link);
Why i40e_pf_linkstatus_get_from_switch_ethdev is always be called?, should we do
If (dev->data->switch_ethdev)
i40e_pf_linkstatus_get_from_switch_ethdev(dev->data->switch_ethdev, &link);