From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 146B8A04D9; Thu, 3 Sep 2020 10:39:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 092011C0AE; Thu, 3 Sep 2020 10:38:59 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 07B05DE0; Thu, 3 Sep 2020 10:38:56 +0200 (CEST) IronPort-SDR: AQKcxefjKJvAwLHx/DviG3GdfKFJi5RI3JlhzJgQUKnZYZveVo2d7hlL2+9uMPm+kEnPtXqpAf N1qhObEhRjMg== X-IronPort-AV: E=McAfee;i="6000,8403,9732"; a="155045361" X-IronPort-AV: E=Sophos;i="5.76,386,1592895600"; d="scan'208";a="155045361" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2020 01:38:55 -0700 IronPort-SDR: E+HbwcvwMxRQwAVY2Gv2dEReXqry7jjlqWPI/x9YLnqjtF2983G+zfGgLh3fs7o20mIaMJN7R1 4RrD+mbUWw0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,386,1592895600"; d="scan'208";a="302130749" Received: from jguo15x-mobl.ccr.corp.intel.com (HELO [10.67.68.194]) ([10.67.68.194]) by orsmga006.jf.intel.com with ESMTP; 03 Sep 2020 01:38:54 -0700 To: Guinan Sun , dev@dpdk.org Cc: Beilei Xing , stable@dpdk.org References: <20200730082539.24104-1-guinanx.sun@intel.com> <20200902080626.34518-1-guinanx.sun@intel.com> From: Jeff Guo Message-ID: Date: Thu, 3 Sep 2020 16:38:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200902080626.34518-1-guinanx.sun@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v4] net/i40e: fix link status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Acked-by: Jeff Guo On 9/2/2020 4:06 PM, Guinan Sun wrote: > 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 > Tested-by: Shougang Wang > --- > v4: > * fix compilation issue in meson build > v3: > * request the capability for i40evf > v2: > * modify commit log > * add code comments > * delete useless code > --- > drivers/net/i40e/base/virtchnl.h | 16 ++++++++++- > drivers/net/i40e/i40e_ethdev_vf.c | 45 ++++++++++++++++++++++++++++--- > 2 files changed, 57 insertions(+), 4 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..664de5e5e 100644 > --- a/drivers/net/i40e/i40e_ethdev_vf.c > +++ b/drivers/net/i40e/i40e_ethdev_vf.c > @@ -469,7 +469,8 @@ i40evf_get_vf_resource(struct rte_eth_dev *dev) > VIRTCHNL_VF_OFFLOAD_RSS_AQ | > VIRTCHNL_VF_OFFLOAD_RSS_REG | > VIRTCHNL_VF_OFFLOAD_VLAN | > - VIRTCHNL_VF_OFFLOAD_RX_POLLING; > + VIRTCHNL_VF_OFFLOAD_RX_POLLING | > + VIRTCHNL_VF_CAP_ADV_LINK_SPEED; > args.in_args = (uint8_t *)∩︀ > args.in_args_size = sizeof(caps); > } else { > @@ -1386,8 +1387,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 = VIRTCHNL_LINK_SPEED_100MB; > + break; > + case ETH_SPEED_NUM_1G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_1GB; > + break; > + case ETH_SPEED_NUM_2_5G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_2_5GB; > + break; > + case ETH_SPEED_NUM_5G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_5GB; > + break; > + case ETH_SPEED_NUM_10G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_10GB; > + break; > + case ETH_SPEED_NUM_20G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_20GB; > + break; > + case ETH_SPEED_NUM_25G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_25GB; > + break; > + case ETH_SPEED_NUM_40G: > + vf->link_speed = VIRTCHNL_LINK_SPEED_40GB; > + break; > + default: > + vf->link_speed = VIRTCHNL_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");