net/i40e: fix link status
diff mbox series

Message ID 20200730082539.24104-1-guinanx.sun@intel.com
State Superseded, archived
Delegated to: Qi Zhang
Headers show
Series
  • net/i40e: fix link status
Related show

Checks

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

Commit Message

Guinan Sun July 30, 2020, 8:25 a.m. UTC
The PF driver supports to use link_event_adv or link_event to get
the link speed. However, when using link_event_adv to get link speed,
there is a lack of logic to convert between link speed type
(I40E_LINK_SPEED_XXX) and mbps type (SPEED_XXX).
As a result, the mbps type is not recognized, so the link status down
problem occurs. This patch is used for type replacement between speed
types.

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

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/i40e/base/virtchnl.h  |  8 +++++-
 drivers/net/i40e/i40e_ethdev_vf.c | 42 +++++++++++++++++++++++++++++--
 drivers/net/i40e/i40e_pf.c        |  4 +++
 3 files changed, 51 insertions(+), 3 deletions(-)

Comments

Jeff Guo July 30, 2020, 9:12 a.m. UTC | #1
hi, guinan

On 7/30/2020 4:25 PM, Guinan Sun wrote:
> The PF driver supports to use link_event_adv or link_event to get
> the link speed. However, when using link_event_adv to get link speed,
> there is a lack of logic to convert between link speed type
> (I40E_LINK_SPEED_XXX) and mbps type (SPEED_XXX).
> As a result, the mbps type is not recognized, so the link status down
> problem occurs. This patch is used for type replacement between speed
> types.
>
> Fixes: 2a73125b7041 ("i40evf: fix link info update")
> Cc: stable@dpdk.org
>
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> ---
>   drivers/net/i40e/base/virtchnl.h  |  8 +++++-
>   drivers/net/i40e/i40e_ethdev_vf.c | 42 +++++++++++++++++++++++++++++--
>   drivers/net/i40e/i40e_pf.c        |  4 +++
>   3 files changed, 51 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/i40e/base/virtchnl.h b/drivers/net/i40e/base/virtchnl.h
> index 4f498ca45..90c404fb8 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)
> @@ -540,6 +541,11 @@ struct virtchnl_pf_event {
>   			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;


Is the link_status the same of processing whatever adv speed cap?


> +			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");
> diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
> index 7bf1e7941..33af30bbb 100644
> --- a/drivers/net/i40e/i40e_pf.c
> +++ b/drivers/net/i40e/i40e_pf.c
> @@ -320,6 +320,10 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,
>   	else
>   		vf->request_caps = *(uint32_t *)msg;
>   
> +#ifdef VIRTCHNL_VF_CAP_ADV_LINK_SPEED
> +	vf_res->vf_cap_flags |= VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
> +#endif /* VIRTCHNL_VF_CAP_ADV_LINK_SPEED */
> +


Below code is after your change here,  be careful to use "|=" please.

     vf_res->vf_cap_flags = vf->request_caps &
                    I40E_VIRTCHNL_OFFLOAD_CAPS;


>   	/* enable all RSS by default,
>   	 * doesn't support hena setting by virtchnnl yet.
>   	 */
Guinan Sun July 30, 2020, 9:26 a.m. UTC | #2
Hi Jeff

> -----Original Message-----
> From: Guo, Jia
> Sent: Thursday, July 30, 2020 5:12 PM
> To: Sun, GuinanX <guinanx.sun@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org
> Subject: Re: [PATCH] net/i40e: fix link status
> 
> hi, guinan
> 
> On 7/30/2020 4:25 PM, Guinan Sun wrote:
> > The PF driver supports to use link_event_adv or link_event to get the
> > link speed. However, when using link_event_adv to get link speed,
> > there is a lack of logic to convert between link speed type
> > (I40E_LINK_SPEED_XXX) and mbps type (SPEED_XXX).
> > As a result, the mbps type is not recognized, so the link status down
> > problem occurs. This patch is used for type replacement between speed
> > types.
> >
> > Fixes: 2a73125b7041 ("i40evf: fix link info update")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> > ---
> >   drivers/net/i40e/base/virtchnl.h  |  8 +++++-
> >   drivers/net/i40e/i40e_ethdev_vf.c | 42 +++++++++++++++++++++++++++++-
> -
> >   drivers/net/i40e/i40e_pf.c        |  4 +++
> >   3 files changed, 51 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/i40e/base/virtchnl.h
> > b/drivers/net/i40e/base/virtchnl.h
> > index 4f498ca45..90c404fb8 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) @@ -540,6
> +541,11 @@ struct
> > virtchnl_pf_event {
> >   			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;
> 
> 
> Is the link_status the same of processing whatever adv speed cap?

They are  not the same process, so it's no need to change.

> 
> 
> > +			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"); diff
> > --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index
> > 7bf1e7941..33af30bbb 100644
> > --- a/drivers/net/i40e/i40e_pf.c
> > +++ b/drivers/net/i40e/i40e_pf.c
> > @@ -320,6 +320,10 @@ i40e_pf_host_process_cmd_get_vf_resource(struct
> i40e_pf_vf *vf, uint8_t *msg,
> >   	else
> >   		vf->request_caps = *(uint32_t *)msg;
> >
> > +#ifdef VIRTCHNL_VF_CAP_ADV_LINK_SPEED
> > +	vf_res->vf_cap_flags |= VIRTCHNL_VF_CAP_ADV_LINK_SPEED; #endif
> /*
> > +VIRTCHNL_VF_CAP_ADV_LINK_SPEED */
> > +
> 
> 
> Below code is after your change here,  be careful to use "|=" please.

Yes, you are right, Iwill take care of it.
But there is a problem with the logic of this code, which will be removed later.

> 
>      vf_res->vf_cap_flags = vf->request_caps &
>                     I40E_VIRTCHNL_OFFLOAD_CAPS;
> 
> 
> >   	/* enable all RSS by default,
> >   	 * doesn't support hena setting by virtchnnl yet.
> >   	 */

Patch
diff mbox series

diff --git a/drivers/net/i40e/base/virtchnl.h b/drivers/net/i40e/base/virtchnl.h
index 4f498ca45..90c404fb8 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)
@@ -540,6 +541,11 @@  struct virtchnl_pf_event {
 			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");
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 7bf1e7941..33af30bbb 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -320,6 +320,10 @@  i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,
 	else
 		vf->request_caps = *(uint32_t *)msg;
 
+#ifdef VIRTCHNL_VF_CAP_ADV_LINK_SPEED
+	vf_res->vf_cap_flags |= VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
+#endif /* VIRTCHNL_VF_CAP_ADV_LINK_SPEED */
+
 	/* enable all RSS by default,
 	 * doesn't support hena setting by virtchnnl yet.
 	 */