[v2] net/i40e: fix link status

Message ID 20200730102527.49884-1-guinanx.sun@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/i40e: fix link status |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/travis-robot warning Travis build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Guinan Sun July 30, 2020, 10:25 a.m. UTC
  If the PF driver supports the new speed reporting capabilities
then use link_event_adv instead of link_event to get the speed.

Fixes: 2a73125b7041 ("i40evf: fix link info update")
Cc: stable@dpdk.org

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
v2:
* Modify commit log.
* Add code comments.
* Delete useless codes.
---
 drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c | 42 +++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 3 deletions(-)
  

Comments

Shougang Wang July 30, 2020, 10:51 a.m. UTC | #1
Tested-by: Shougang Wang <shougangx.wang@intel.com>

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> Sent: Thursday, July 30, 2020 6:25 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia <jia.guo@intel.com>;
> dev@dpdk.org
> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> 
> If the PF driver supports the new speed reporting capabilities then use
> link_event_adv instead of link_event to get the speed.
> 
> Fixes: 2a73125b7041 ("i40evf: fix link info update")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> ---
> v2:
> * Modify commit log.
> * Add code comments.
> * Delete useless codes.
> ---
>  drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
> drivers/net/i40e/i40e_ethdev_vf.c | 42
> +++++++++++++++++++++++++++++--
>  2 files changed, 55 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/i40e/base/virtchnl.h
> b/drivers/net/i40e/base/virtchnl.h
> index 4f498ca45..9c64fd469 100644
> --- a/drivers/net/i40e/base/virtchnl.h
> +++ b/drivers/net/i40e/base/virtchnl.h
> @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
> virtchnl_vsi_resource);
>  #define VIRTCHNL_VF_OFFLOAD_ENCAP		0X00100000
>  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM		0X00200000
>  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM	0X00400000
> -
> +/* Define below the capability flags that are not offloads */
> +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		0x00000080
>  #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
>  			       VIRTCHNL_VF_OFFLOAD_VLAN | \
>  			       VIRTCHNL_VF_OFFLOAD_RSS_PF)
> @@ -536,10 +537,23 @@ enum virtchnl_event_codes {  struct
> virtchnl_pf_event {
>  	enum virtchnl_event_codes event;
>  	union {
> +		/* If the PF driver does not support the new speed reporting
> +		 * capabilities then use link_event else use link_event_adv to
> +		 * get the speed and link information. The ability to
> understand
> +		 * new speeds is indicated by setting the capability flag
> +		 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags
> parameter
> +		 * in virtchnl_vf_resource struct and can be used to
> determine
> +		 * which link event struct to use below.
> +		 */
>  		struct {
>  			enum virtchnl_link_speed link_speed;
>  			bool link_status;
>  		} link_event;
> +		struct {
> +			/* link_speed provided in Mbps */
> +			u32 link_speed;
> +			u8 link_status;
> +		} link_event_adv;
>  	} event_data;
> 
>  	int severity;
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 69cab8e73..f8cf45fbe 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1386,8 +1386,46 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev,
> uint8_t *msg,
>  		break;
>  	case VIRTCHNL_EVENT_LINK_CHANGE:
>  		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE
> event");
> -		vf->link_up = pf_msg->event_data.link_event.link_status;
> -		vf->link_speed = pf_msg-
> >event_data.link_event.link_speed;
> +
> +		if (vf->vf_res->vf_cap_flags &
> VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
> +			vf->link_up =
> +				pf_msg-
> >event_data.link_event_adv.link_status;
> +
> +			switch (pf_msg-
> >event_data.link_event_adv.link_speed) {
> +			case ETH_SPEED_NUM_100M:
> +				vf->link_speed = I40E_LINK_SPEED_100MB;
> +				break;
> +			case ETH_SPEED_NUM_1G:
> +				vf->link_speed = I40E_LINK_SPEED_1GB;
> +				break;
> +			case ETH_SPEED_NUM_2_5G:
> +				vf->link_speed = I40E_LINK_SPEED_2_5GB;
> +				break;
> +			case ETH_SPEED_NUM_5G:
> +				vf->link_speed = I40E_LINK_SPEED_5GB;
> +				break;
> +			case ETH_SPEED_NUM_10G:
> +				vf->link_speed = I40E_LINK_SPEED_10GB;
> +				break;
> +			case ETH_SPEED_NUM_20G:
> +				vf->link_speed = I40E_LINK_SPEED_20GB;
> +				break;
> +			case ETH_SPEED_NUM_25G:
> +				vf->link_speed = I40E_LINK_SPEED_25GB;
> +				break;
> +			case ETH_SPEED_NUM_40G:
> +				vf->link_speed = I40E_LINK_SPEED_40GB;
> +				break;
> +			default:
> +				vf->link_speed =
> I40E_LINK_SPEED_UNKNOWN;
> +				break;
> +			}
> +		} else {
> +			vf->link_up =
> +				pf_msg->event_data.link_event.link_status;
> +			vf->link_speed =
> +				pf_msg->event_data.link_event.link_speed;
> +		}
>  		break;
>  	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
>  		PMD_DRV_LOG(DEBUG,
> "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
> --
> 2.17.1
  
Guo, Jia July 30, 2020, 10:57 a.m. UTC | #2
Acked-by: Jeff Guo <jia.guo@intel.com>

On 7/30/2020 6:51 PM, Wang, ShougangX wrote:
> Tested-by: Shougang Wang <shougangx.wang@intel.com>
>
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
>> Sent: Thursday, July 30, 2020 6:25 PM
>> To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia <jia.guo@intel.com>;
>> dev@dpdk.org
>> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
>> Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
>>
>> If the PF driver supports the new speed reporting capabilities then use
>> link_event_adv instead of link_event to get the speed.
>>
>> Fixes: 2a73125b7041 ("i40evf: fix link info update")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
>> ---
>> v2:
>> * Modify commit log.
>> * Add code comments.
>> * Delete useless codes.
>> ---
>>   drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
>> drivers/net/i40e/i40e_ethdev_vf.c | 42
>> +++++++++++++++++++++++++++++--
>>   2 files changed, 55 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/i40e/base/virtchnl.h
>> b/drivers/net/i40e/base/virtchnl.h
>> index 4f498ca45..9c64fd469 100644
>> --- a/drivers/net/i40e/base/virtchnl.h
>> +++ b/drivers/net/i40e/base/virtchnl.h
>> @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
>> virtchnl_vsi_resource);
>>   #define VIRTCHNL_VF_OFFLOAD_ENCAP0X00100000
>>   #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM0X00200000
>>   #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM0X00400000
>> -
>> +/* Define below the capability flags that are not offloads */
>> +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED0x00000080
>>   #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
>>          VIRTCHNL_VF_OFFLOAD_VLAN | \
>>          VIRTCHNL_VF_OFFLOAD_RSS_PF)
>> @@ -536,10 +537,23 @@ enum virtchnl_event_codes {  struct
>> virtchnl_pf_event {
>>   enum virtchnl_event_codes event;
>>   union {
>> +/* If the PF driver does not support the new speed reporting
>> + * capabilities then use link_event else use link_event_adv to
>> + * get the speed and link information. The ability to
>> understand
>> + * new speeds is indicated by setting the capability flag
>> + * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags
>> parameter
>> + * in virtchnl_vf_resource struct and can be used to
>> determine
>> + * which link event struct to use below.
>> + */
>>   struct {
>>   enum virtchnl_link_speed link_speed;
>>   bool link_status;
>>   } link_event;
>> +struct {
>> +/* link_speed provided in Mbps */
>> +u32 link_speed;
>> +u8 link_status;
>> +} link_event_adv;
>>   } event_data;
>>
>>   int severity;
>> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
>> b/drivers/net/i40e/i40e_ethdev_vf.c
>> index 69cab8e73..f8cf45fbe 100644
>> --- a/drivers/net/i40e/i40e_ethdev_vf.c
>> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
>> @@ -1386,8 +1386,46 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev,
>> uint8_t *msg,
>>   break;
>>   case VIRTCHNL_EVENT_LINK_CHANGE:
>>   PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE
>> event");
>> -vf->link_up = pf_msg->event_data.link_event.link_status;
>> -vf->link_speed = pf_msg-
>>> event_data.link_event.link_speed;
>> +
>> +if (vf->vf_res->vf_cap_flags &
>> VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
>> +vf->link_up =
>> +pf_msg-
>>> event_data.link_event_adv.link_status;
>> +
>> +switch (pf_msg-
>>> event_data.link_event_adv.link_speed) {
>> +case ETH_SPEED_NUM_100M:
>> +vf->link_speed = I40E_LINK_SPEED_100MB;
>> +break;
>> +case ETH_SPEED_NUM_1G:
>> +vf->link_speed = I40E_LINK_SPEED_1GB;
>> +break;
>> +case ETH_SPEED_NUM_2_5G:
>> +vf->link_speed = I40E_LINK_SPEED_2_5GB;
>> +break;
>> +case ETH_SPEED_NUM_5G:
>> +vf->link_speed = I40E_LINK_SPEED_5GB;
>> +break;
>> +case ETH_SPEED_NUM_10G:
>> +vf->link_speed = I40E_LINK_SPEED_10GB;
>> +break;
>> +case ETH_SPEED_NUM_20G:
>> +vf->link_speed = I40E_LINK_SPEED_20GB;
>> +break;
>> +case ETH_SPEED_NUM_25G:
>> +vf->link_speed = I40E_LINK_SPEED_25GB;
>> +break;
>> +case ETH_SPEED_NUM_40G:
>> +vf->link_speed = I40E_LINK_SPEED_40GB;
>> +break;
>> +default:
>> +vf->link_speed =
>> I40E_LINK_SPEED_UNKNOWN;
>> +break;
>> +}
>> +} else {
>> +vf->link_up =
>> +pf_msg->event_data.link_event.link_status;
>> +vf->link_speed =
>> +pf_msg->event_data.link_event.link_speed;
>> +}
>>   break;
>>   case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
>>   PMD_DRV_LOG(DEBUG,
>> "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
>> --
>> 2.17.1
  
Xing, Beilei July 31, 2020, 2:29 a.m. UTC | #3
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> Sent: Thursday, July 30, 2020 6:25 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia <jia.guo@intel.com>;
> dev@dpdk.org
> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> 
> If the PF driver supports the new speed reporting capabilities then use
> link_event_adv instead of link_event to get the speed.
> 
> Fixes: 2a73125b7041 ("i40evf: fix link info update")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> ---
> v2:
> * Modify commit log.
> * Add code comments.
> * Delete useless codes.
> ---
>  drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
> drivers/net/i40e/i40e_ethdev_vf.c | 42 +++++++++++++++++++++++++++++--
>  2 files changed, 55 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/i40e/base/virtchnl.h b/drivers/net/i40e/base/virtchnl.h
> index 4f498ca45..9c64fd469 100644
> --- a/drivers/net/i40e/base/virtchnl.h
> +++ b/drivers/net/i40e/base/virtchnl.h
> @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
> virtchnl_vsi_resource);
>  #define VIRTCHNL_VF_OFFLOAD_ENCAP		0X00100000
>  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM		0X00200000
>  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM	0X00400000
> -
> +/* Define below the capability flags that are not offloads */
> +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		0x00000080

You defined the new capability VIRTCHNL_VF_CAP_ADV_LINK_SPEED in the patch,
but didn't request the capability for i40evf?

>  #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
>  			       VIRTCHNL_VF_OFFLOAD_VLAN | \
>  			       VIRTCHNL_VF_OFFLOAD_RSS_PF)
> @@ -536,10 +537,23 @@ enum virtchnl_event_codes {  struct
> virtchnl_pf_event {
>  	enum virtchnl_event_codes event;
>  	union {
> +		/* If the PF driver does not support the new speed reporting
> +		 * capabilities then use link_event else use link_event_adv to
> +		 * get the speed and link information. The ability to
> understand
> +		 * new speeds is indicated by setting the capability flag
> +		 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags
> parameter
> +		 * in virtchnl_vf_resource struct and can be used to determine
> +		 * which link event struct to use below.
> +		 */
>  		struct {
>  			enum virtchnl_link_speed link_speed;
>  			bool link_status;
>  		} link_event;
> +		struct {
> +			/* link_speed provided in Mbps */
> +			u32 link_speed;
> +			u8 link_status;
> +		} link_event_adv;
>  	} event_data;
> 
>  	int severity;
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 69cab8e73..f8cf45fbe 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1386,8 +1386,46 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev,
> uint8_t *msg,
>  		break;
>  	case VIRTCHNL_EVENT_LINK_CHANGE:
>  		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE
> event");
> -		vf->link_up = pf_msg->event_data.link_event.link_status;
> -		vf->link_speed = pf_msg->event_data.link_event.link_speed;
> +
> +		if (vf->vf_res->vf_cap_flags &
> VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
> +			vf->link_up =
> +				pf_msg-
> >event_data.link_event_adv.link_status;
> +
> +			switch (pf_msg-
> >event_data.link_event_adv.link_speed) {
> +			case ETH_SPEED_NUM_100M:
> +				vf->link_speed = I40E_LINK_SPEED_100MB;
> +				break;
> +			case ETH_SPEED_NUM_1G:
> +				vf->link_speed = I40E_LINK_SPEED_1GB;
> +				break;
> +			case ETH_SPEED_NUM_2_5G:
> +				vf->link_speed = I40E_LINK_SPEED_2_5GB;
> +				break;
> +			case ETH_SPEED_NUM_5G:
> +				vf->link_speed = I40E_LINK_SPEED_5GB;
> +				break;
> +			case ETH_SPEED_NUM_10G:
> +				vf->link_speed = I40E_LINK_SPEED_10GB;
> +				break;
> +			case ETH_SPEED_NUM_20G:
> +				vf->link_speed = I40E_LINK_SPEED_20GB;
> +				break;
> +			case ETH_SPEED_NUM_25G:
> +				vf->link_speed = I40E_LINK_SPEED_25GB;
> +				break;
> +			case ETH_SPEED_NUM_40G:
> +				vf->link_speed = I40E_LINK_SPEED_40GB;
> +				break;
> +			default:
> +				vf->link_speed =
> I40E_LINK_SPEED_UNKNOWN;
> +				break;
> +			}
> +		} else {
> +			vf->link_up =
> +				pf_msg->event_data.link_event.link_status;
> +			vf->link_speed =
> +				pf_msg->event_data.link_event.link_speed;
> +		}
>  		break;
>  	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
>  		PMD_DRV_LOG(DEBUG,
> "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
> --
> 2.17.1
  
Shougang Wang July 31, 2020, 2:37 a.m. UTC | #4
Hi Beilei

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Xing, Beilei
> Sent: Friday, July 31, 2020 10:30 AM
> To: Sun, GuinanX <guinanx.sun@intel.com>; Guo, Jia <jia.guo@intel.com>;
> dev@dpdk.org
> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> 
> 
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> > Sent: Thursday, July 30, 2020 6:25 PM
> > To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia
> > <jia.guo@intel.com>; dev@dpdk.org
> > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> >
> > If the PF driver supports the new speed reporting capabilities then
> > use link_event_adv instead of link_event to get the speed.
> >
> > Fixes: 2a73125b7041 ("i40evf: fix link info update")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> > ---
> > v2:
> > * Modify commit log.
> > * Add code comments.
> > * Delete useless codes.
> > ---
> >  drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
> > drivers/net/i40e/i40e_ethdev_vf.c | 42
> +++++++++++++++++++++++++++++--
> >  2 files changed, 55 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/i40e/base/virtchnl.h
> > b/drivers/net/i40e/base/virtchnl.h
> > index 4f498ca45..9c64fd469 100644
> > --- a/drivers/net/i40e/base/virtchnl.h
> > +++ b/drivers/net/i40e/base/virtchnl.h
> > @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
> > virtchnl_vsi_resource);
> >  #define VIRTCHNL_VF_OFFLOAD_ENCAP		0X00100000
> >  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM		0X00200000
> >  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM	0X00400000
> > -
> > +/* Define below the capability flags that are not offloads */
> > +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		0x00000080
> 
> You defined the new capability VIRTCHNL_VF_CAP_ADV_LINK_SPEED in the
> patch, but didn't request the capability for i40evf?

This capability is given by i40e kernel pf if VIRTCHNL_VF_CAP_ADV_LINK_SPEED is defined. So vf doesn't need to request it.

Thanks.
Shougang
  
Xing, Beilei July 31, 2020, 3:50 a.m. UTC | #5
> -----Original Message-----
> From: Wang, ShougangX <shougangx.wang@intel.com>
> Sent: Friday, July 31, 2020 10:38 AM
> To: Xing, Beilei <beilei.xing@intel.com>; Sun, GuinanX
> <guinanx.sun@intel.com>; Guo, Jia <jia.guo@intel.com>; dev@dpdk.org
> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> 
> Hi Beilei
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Xing, Beilei
> > Sent: Friday, July 31, 2020 10:30 AM
> > To: Sun, GuinanX <guinanx.sun@intel.com>; Guo, Jia
> > <jia.guo@intel.com>; dev@dpdk.org
> > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> >
> >
> >
> > > -----Original Message-----
> > > From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> > > Sent: Thursday, July 30, 2020 6:25 PM
> > > To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia
> > > <jia.guo@intel.com>; dev@dpdk.org
> > > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > > Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> > >
> > > If the PF driver supports the new speed reporting capabilities then
> > > use link_event_adv instead of link_event to get the speed.
> > >
> > > Fixes: 2a73125b7041 ("i40evf: fix link info update")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> > > ---
> > > v2:
> > > * Modify commit log.
> > > * Add code comments.
> > > * Delete useless codes.
> > > ---
> > >  drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
> > > drivers/net/i40e/i40e_ethdev_vf.c | 42
> > +++++++++++++++++++++++++++++--
> > >  2 files changed, 55 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/i40e/base/virtchnl.h
> > > b/drivers/net/i40e/base/virtchnl.h
> > > index 4f498ca45..9c64fd469 100644
> > > --- a/drivers/net/i40e/base/virtchnl.h
> > > +++ b/drivers/net/i40e/base/virtchnl.h
> > > @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
> > > virtchnl_vsi_resource);
> > >  #define VIRTCHNL_VF_OFFLOAD_ENCAP		0X00100000
> > >  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM		0X00200000
> > >  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM	0X00400000
> > > -
> > > +/* Define below the capability flags that are not offloads */
> > > +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		0x00000080
> >
> > You defined the new capability VIRTCHNL_VF_CAP_ADV_LINK_SPEED in the
> > patch, but didn't request the capability for i40evf?
> 
> This capability is given by i40e kernel pf if
> VIRTCHNL_VF_CAP_ADV_LINK_SPEED is defined. So vf doesn't need to request
> it.

All the capabilities for VF is required by VF, please check i40evf_get_vf_resource.

> 
> Thanks.
> Shougang
  
Guinan Sun July 31, 2020, 4:09 a.m. UTC | #6
Hi Beilei

> -----Original Message-----
> From: Xing, Beilei
> Sent: Friday, July 31, 2020 11:50 AM
> To: Wang, ShougangX <shougangx.wang@intel.com>; Sun, GuinanX
> <guinanx.sun@intel.com>; Guo, Jia <jia.guo@intel.com>; dev@dpdk.org
> Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> 
> 
> 
> > -----Original Message-----
> > From: Wang, ShougangX <shougangx.wang@intel.com>
> > Sent: Friday, July 31, 2020 10:38 AM
> > To: Xing, Beilei <beilei.xing@intel.com>; Sun, GuinanX
> > <guinanx.sun@intel.com>; Guo, Jia <jia.guo@intel.com>; dev@dpdk.org
> > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > Subject: RE: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> >
> > Hi Beilei
> >
> > > -----Original Message-----
> > > From: dev <dev-bounces@dpdk.org> On Behalf Of Xing, Beilei
> > > Sent: Friday, July 31, 2020 10:30 AM
> > > To: Sun, GuinanX <guinanx.sun@intel.com>; Guo, Jia
> > > <jia.guo@intel.com>; dev@dpdk.org
> > > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> > > > Sent: Thursday, July 30, 2020 6:25 PM
> > > > To: Xing, Beilei <beilei.xing@intel.com>; Guo, Jia
> > > > <jia.guo@intel.com>; dev@dpdk.org
> > > > Cc: Sun, GuinanX <guinanx.sun@intel.com>; stable@dpdk.org
> > > > Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link status
> > > >
> > > > If the PF driver supports the new speed reporting capabilities
> > > > then use link_event_adv instead of link_event to get the speed.
> > > >
> > > > Fixes: 2a73125b7041 ("i40evf: fix link info update")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> > > > ---
> > > > v2:
> > > > * Modify commit log.
> > > > * Add code comments.
> > > > * Delete useless codes.
> > > > ---
> > > >  drivers/net/i40e/base/virtchnl.h  | 16 +++++++++++-
> > > > drivers/net/i40e/i40e_ethdev_vf.c | 42
> > > +++++++++++++++++++++++++++++--
> > > >  2 files changed, 55 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/net/i40e/base/virtchnl.h
> > > > b/drivers/net/i40e/base/virtchnl.h
> > > > index 4f498ca45..9c64fd469 100644
> > > > --- a/drivers/net/i40e/base/virtchnl.h
> > > > +++ b/drivers/net/i40e/base/virtchnl.h
> > > > @@ -240,7 +240,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(16,
> > > > virtchnl_vsi_resource);  #define
> > > > VIRTCHNL_VF_OFFLOAD_ENCAP0X00100000
> > > >  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM0X00200000
> > > >  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM0X00400000
> > > > -
> > > > +/* Define below the capability flags that are not offloads */
> > > > +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED0x00000080
> > >
> > > You defined the new capability VIRTCHNL_VF_CAP_ADV_LINK_SPEED in the
> > > patch, but didn't request the capability for i40evf?
> >
> > This capability is given by i40e kernel pf if
> > VIRTCHNL_VF_CAP_ADV_LINK_SPEED is defined. So vf doesn't need to
> > request it.
> 
> All the capabilities for VF is required by VF, please check
> i40evf_get_vf_resource.

I will double check for it.
New Patch will fix it.
Thank you.

> 
> >
> > Thanks.
> > Shougang
  

Patch

diff --git a/drivers/net/i40e/base/virtchnl.h b/drivers/net/i40e/base/virtchnl.h
index 4f498ca45..9c64fd469 100644
--- a/drivers/net/i40e/base/virtchnl.h
+++ b/drivers/net/i40e/base/virtchnl.h
@@ -240,7 +240,8 @@  VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_ENCAP		0X00100000
 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM		0X00200000
 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM	0X00400000
-
+/* Define below the capability flags that are not offloads */
+#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		0x00000080
 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
 			       VIRTCHNL_VF_OFFLOAD_VLAN | \
 			       VIRTCHNL_VF_OFFLOAD_RSS_PF)
@@ -536,10 +537,23 @@  enum virtchnl_event_codes {
 struct virtchnl_pf_event {
 	enum virtchnl_event_codes event;
 	union {
+		/* If the PF driver does not support the new speed reporting
+		 * capabilities then use link_event else use link_event_adv to
+		 * get the speed and link information. The ability to understand
+		 * new speeds is indicated by setting the capability flag
+		 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
+		 * in virtchnl_vf_resource struct and can be used to determine
+		 * which link event struct to use below.
+		 */
 		struct {
 			enum virtchnl_link_speed link_speed;
 			bool link_status;
 		} link_event;
+		struct {
+			/* link_speed provided in Mbps */
+			u32 link_speed;
+			u8 link_status;
+		} link_event_adv;
 	} event_data;
 
 	int severity;
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 69cab8e73..f8cf45fbe 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1386,8 +1386,46 @@  i40evf_handle_pf_event(struct rte_eth_dev *dev, uint8_t *msg,
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
-		vf->link_up = pf_msg->event_data.link_event.link_status;
-		vf->link_speed = pf_msg->event_data.link_event.link_speed;
+
+		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
+			vf->link_up =
+				pf_msg->event_data.link_event_adv.link_status;
+
+			switch (pf_msg->event_data.link_event_adv.link_speed) {
+			case ETH_SPEED_NUM_100M:
+				vf->link_speed = I40E_LINK_SPEED_100MB;
+				break;
+			case ETH_SPEED_NUM_1G:
+				vf->link_speed = I40E_LINK_SPEED_1GB;
+				break;
+			case ETH_SPEED_NUM_2_5G:
+				vf->link_speed = I40E_LINK_SPEED_2_5GB;
+				break;
+			case ETH_SPEED_NUM_5G:
+				vf->link_speed = I40E_LINK_SPEED_5GB;
+				break;
+			case ETH_SPEED_NUM_10G:
+				vf->link_speed = I40E_LINK_SPEED_10GB;
+				break;
+			case ETH_SPEED_NUM_20G:
+				vf->link_speed = I40E_LINK_SPEED_20GB;
+				break;
+			case ETH_SPEED_NUM_25G:
+				vf->link_speed = I40E_LINK_SPEED_25GB;
+				break;
+			case ETH_SPEED_NUM_40G:
+				vf->link_speed = I40E_LINK_SPEED_40GB;
+				break;
+			default:
+				vf->link_speed = I40E_LINK_SPEED_UNKNOWN;
+				break;
+			}
+		} else {
+			vf->link_up =
+				pf_msg->event_data.link_event.link_status;
+			vf->link_speed =
+				pf_msg->event_data.link_event.link_speed;
+		}
 		break;
 	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");