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 35047A00BE; Tue, 28 Apr 2020 10:53:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0B3D61D5B6; Tue, 28 Apr 2020 10:53:28 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 8561B1D5B3; Tue, 28 Apr 2020 10:53:25 +0200 (CEST) IronPort-SDR: OEn3vQ3Tts56mv2aVOEE2mYiWDMziY1p2tjzcQ9EnjDqdor/hfOadaeahwDCA71tgHhhbDYsGt rfhcumgWa8DA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 01:53:24 -0700 IronPort-SDR: 5+gJ7wQwyP82NXJ8IjcBOsrcdC7byKVrSnz+hB0Ei7MqNNPTtqZq/NNQRxRSajHXUI+Jw4MYg5 5bXWK0a1OKxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,327,1583222400"; d="scan'208";a="367440039" Received: from shwdenpg235.ccr.corp.intel.com ([10.240.182.60]) by fmsmga001.fm.intel.com with ESMTP; 28 Apr 2020 01:53:22 -0700 From: alvinx.zhang@intel.com To: dev@dpdk.org Cc: qi.z.zhang@intel.com, beilei.xing@intel.com, Alvin Zhang , jingjing.wu@intel.com, stable@dpdk.org Date: Tue, 28 Apr 2020 16:52:33 +0800 Message-Id: <20200428085233.19748-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] net/iavf: fix link speed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: 20200428064858.21392-1-alvinx.zhang@intel.com List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Alvin Zhang 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@dpdk.org Signed-off-by: Alvin Zhang --- 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..5b8d32e 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(enum virtchnl_link_speed 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