DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/iavf: fix link speed
@ 2020-04-28  6:48 alvinx.zhang
  2020-04-28  7:49 ` Xing, Beilei
  2020-04-30  7:28 ` Xie, WeiX
  0 siblings, 2 replies; 4+ messages in thread
From: alvinx.zhang @ 2020-04-28  6:48 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, beilei.xing, Alvin Zhang, jingjing.wu

From: Alvin Zhang <alvinx.zhang@intel.com>

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.

Fixes: 48de41ca11f0 (net/iavf: enable link status update)
Cc: jingjing.wu@intel.com

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
 drivers/net/iavf/iavf_vchnl.c | 47 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 2a0cdd9..104a769 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -130,6 +130,44 @@
 	return err;
 }
 
+static uint32_t
+iavf_convert_link_speed(uint32_t virt_link_speed)
+{
+	uint32_t speed;
+
+	switch (virt_link_speed) {
+	case VIRTCHNL_LINK_SPEED_100MB:
+		speed = 100;
+		break;
+	case VIRTCHNL_LINK_SPEED_1GB:
+		speed = 1000;
+		break;
+	case VIRTCHNL_LINK_SPEED_10GB:
+		speed = 10000;
+		break;
+	case VIRTCHNL_LINK_SPEED_40GB:
+		speed = 40000;
+		break;
+	case VIRTCHNL_LINK_SPEED_20GB:
+		speed = 20000;
+		break;
+	case VIRTCHNL_LINK_SPEED_25GB:
+		speed = 25000;
+		break;
+	case VIRTCHNL_LINK_SPEED_2_5GB:
+		speed = 2500;
+		break;
+	case VIRTCHNL_LINK_SPEED_5GB:
+		speed = 5000;
+		break;
+	default:
+		speed = 0;
+		break;
+	}
+
+	return speed;
+}
+
 static void
 iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
 			uint16_t msglen)
@@ -151,7 +189,14 @@
 	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_adv.link_speed;
+		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
+			vf->link_speed =
+				pf_msg->event_data.link_event_adv.link_speed;
+		} else {
+			enum virtchnl_link_speed speed;
+			speed = pf_msg->event_data.link_event.link_speed;
+			vf->link_speed = iavf_convert_link_speed(speed);
+		}
 		iavf_dev_link_update(dev, 0);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 					      NULL);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/iavf: fix link speed
  2020-04-28  6:48 [dpdk-dev] [PATCH] net/iavf: fix link speed alvinx.zhang
@ 2020-04-28  7:49 ` Xing, Beilei
  2020-04-28  8:43   ` Zhang, AlvinX
  2020-04-30  7:28 ` Xie, WeiX
  1 sibling, 1 reply; 4+ messages in thread
From: Xing, Beilei @ 2020-04-28  7:49 UTC (permalink / raw)
  To: Zhang, AlvinX, dev; +Cc: Zhang, Qi Z, Wu, Jingjing



> -----Original Message-----
> From: Zhang, AlvinX <alvinx.zhang@intel.com>
> Sent: Tuesday, April 28, 2020 2:49 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> Zhang, AlvinX <alvinx.zhang@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: [PATCH] net/iavf: fix link speed
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> 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.
> 
> Fixes: 48de41ca11f0 (net/iavf: enable link status update)
> Cc: jingjing.wu@intel.com

Cc stable.

> 
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
>  drivers/net/iavf/iavf_vchnl.c | 47
> ++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index
> 2a0cdd9..104a769 100644
> --- a/drivers/net/iavf/iavf_vchnl.c
> +++ b/drivers/net/iavf/iavf_vchnl.c
> @@ -130,6 +130,44 @@
>  	return err;
>  }
> 
> +static uint32_t
> +iavf_convert_link_speed(uint32_t virt_link_speed) {

Why use uint32_t but not enum virtchnl_link_speed for the parameter?

> +	uint32_t speed;
> +
> +	switch (virt_link_speed) {
> +	case VIRTCHNL_LINK_SPEED_100MB:
> +		speed = 100;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_1GB:
> +		speed = 1000;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_10GB:
> +		speed = 10000;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_40GB:
> +		speed = 40000;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_20GB:
> +		speed = 20000;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_25GB:
> +		speed = 25000;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_2_5GB:
> +		speed = 2500;
> +		break;
> +	case VIRTCHNL_LINK_SPEED_5GB:
> +		speed = 5000;
> +		break;
> +	default:
> +		speed = 0;
> +		break;
> +	}
> +
> +	return speed;
> +}
> +
>  static void
>  iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
>  			uint16_t msglen)
> @@ -151,7 +189,14 @@
>  	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_adv.link_speed;
> +		if (vf->vf_res->vf_cap_flags &
> VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
> +			vf->link_speed =
> +				pf_msg-
> >event_data.link_event_adv.link_speed;
> +		} else {
> +			enum virtchnl_link_speed speed;
> +			speed = pf_msg->event_data.link_event.link_speed;
> +			vf->link_speed = iavf_convert_link_speed(speed);
> +		}
>  		iavf_dev_link_update(dev, 0);
>  		_rte_eth_dev_callback_process(dev,
> RTE_ETH_EVENT_INTR_LSC,
>  					      NULL);
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/iavf: fix link speed
  2020-04-28  7:49 ` Xing, Beilei
@ 2020-04-28  8:43   ` Zhang, AlvinX
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, AlvinX @ 2020-04-28  8:43 UTC (permalink / raw)
  To: Xing, Beilei, dev; +Cc: Zhang, Qi Z, Wu, Jingjing

Thanks Beilei.

> -----Original Message-----
> From: Xing, Beilei
> Sent: Tuesday, April 28, 2020 3:50 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Subject: RE: [PATCH] net/iavf: fix link speed
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, AlvinX <alvinx.zhang@intel.com>
> > Sent: Tuesday, April 28, 2020 2:49 PM
> > To: dev@dpdk.org
> > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Zhang, AlvinX <alvinx.zhang@intel.com>; Wu,
> > Jingjing <jingjing.wu@intel.com>
> > Subject: [PATCH] net/iavf: fix link speed
> >
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > 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.
> >
> > Fixes: 48de41ca11f0 (net/iavf: enable link status update)
> > Cc: jingjing.wu@intel.com
> 
> Cc stable.
> 
> >
> > Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> > ---
> >  drivers/net/iavf/iavf_vchnl.c | 47
> > ++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 46 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/iavf/iavf_vchnl.c
> > b/drivers/net/iavf/iavf_vchnl.c index
> > 2a0cdd9..104a769 100644
> > --- a/drivers/net/iavf/iavf_vchnl.c
> > +++ b/drivers/net/iavf/iavf_vchnl.c
> > @@ -130,6 +130,44 @@
> >  return err;
> >  }
> >
> > +static uint32_t
> > +iavf_convert_link_speed(uint32_t virt_link_speed) {
> 
> Why use uint32_t but not enum virtchnl_link_speed for the parameter?
> 
> > +uint32_t speed;
> > +
> > +switch (virt_link_speed) {
> > +case VIRTCHNL_LINK_SPEED_100MB:
> > +speed = 100;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_1GB:
> > +speed = 1000;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_10GB:
> > +speed = 10000;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_40GB:
> > +speed = 40000;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_20GB:
> > +speed = 20000;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_25GB:
> > +speed = 25000;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_2_5GB:
> > +speed = 2500;
> > +break;
> > +case VIRTCHNL_LINK_SPEED_5GB:
> > +speed = 5000;
> > +break;
> > +default:
> > +speed = 0;
> > +break;
> > +}
> > +
> > +return speed;
> > +}
> > +
> >  static void
> >  iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
> > uint16_t msglen) @@ -151,7 +189,14 @@  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_adv.link_speed;
> > +if (vf->vf_res->vf_cap_flags &
> > VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
> > +vf->link_speed =
> > +pf_msg-
> > >event_data.link_event_adv.link_speed;
> > +} else {
> > +enum virtchnl_link_speed speed;
> > +speed = pf_msg->event_data.link_event.link_speed;
> > +vf->link_speed = iavf_convert_link_speed(speed);
> > +}
> >  iavf_dev_link_update(dev, 0);
> >  _rte_eth_dev_callback_process(dev,
> > RTE_ETH_EVENT_INTR_LSC,
> >        NULL);
> > --
> > 1.8.3.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/iavf: fix link speed
  2020-04-28  6:48 [dpdk-dev] [PATCH] net/iavf: fix link speed alvinx.zhang
  2020-04-28  7:49 ` Xing, Beilei
@ 2020-04-30  7:28 ` Xie, WeiX
  1 sibling, 0 replies; 4+ messages in thread
From: Xie, WeiX @ 2020-04-30  7:28 UTC (permalink / raw)
  To: Zhang, AlvinX, dev; +Cc: Zhang, Qi Z, Xing, Beilei, Zhang, AlvinX, Wu, Jingjing

Tested-by:  Xie,WeiX < weix.xie@intel.com>

Regards,
Xie Wei

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of alvinx.zhang@intel.com
Sent: Tuesday, April 28, 2020 2:49 PM
To: dev@dpdk.org
Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Zhang, AlvinX <alvinx.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
Subject: [dpdk-dev] [PATCH] net/iavf: fix link speed

From: Alvin Zhang <alvinx.zhang@intel.com>

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.

Fixes: 48de41ca11f0 (net/iavf: enable link status update)
Cc: jingjing.wu@intel.com

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
 drivers/net/iavf/iavf_vchnl.c | 47 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 2a0cdd9..104a769 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -130,6 +130,44 @@
 	return err;
 }
 
+static uint32_t
+iavf_convert_link_speed(uint32_t virt_link_speed) {
+	uint32_t speed;
+
+	switch (virt_link_speed) {
+	case VIRTCHNL_LINK_SPEED_100MB:
+		speed = 100;
+		break;
+	case VIRTCHNL_LINK_SPEED_1GB:
+		speed = 1000;
+		break;
+	case VIRTCHNL_LINK_SPEED_10GB:
+		speed = 10000;
+		break;
+	case VIRTCHNL_LINK_SPEED_40GB:
+		speed = 40000;
+		break;
+	case VIRTCHNL_LINK_SPEED_20GB:
+		speed = 20000;
+		break;
+	case VIRTCHNL_LINK_SPEED_25GB:
+		speed = 25000;
+		break;
+	case VIRTCHNL_LINK_SPEED_2_5GB:
+		speed = 2500;
+		break;
+	case VIRTCHNL_LINK_SPEED_5GB:
+		speed = 5000;
+		break;
+	default:
+		speed = 0;
+		break;
+	}
+
+	return speed;
+}
+
 static void
 iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
 			uint16_t msglen)
@@ -151,7 +189,14 @@
 	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_adv.link_speed;
+		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
+			vf->link_speed =
+				pf_msg->event_data.link_event_adv.link_speed;
+		} else {
+			enum virtchnl_link_speed speed;
+			speed = pf_msg->event_data.link_event.link_speed;
+			vf->link_speed = iavf_convert_link_speed(speed);
+		}
 		iavf_dev_link_update(dev, 0);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 					      NULL);
--
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-30  7:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28  6:48 [dpdk-dev] [PATCH] net/iavf: fix link speed alvinx.zhang
2020-04-28  7:49 ` Xing, Beilei
2020-04-28  8:43   ` Zhang, AlvinX
2020-04-30  7:28 ` Xie, WeiX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).