From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19F7E42D51; Mon, 26 Jun 2023 04:57:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91E894067B; Mon, 26 Jun 2023 04:57:18 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 2312B40223 for ; Mon, 26 Jun 2023 04:57:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687748237; x=1719284237; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lDxXXL3GU9u1/SA8aLK6aqGm1zeyb3nmnJdqIcHqn2Y=; b=km1MLP2baXaYVS6wqFT+WyeOGiJAtck7BTWLK7psdTYXgHYeEIcaVLtg dhpw+wnChYgcIVvH+3is+5nqG8xLzUhwQu5cLAv4/tndG8VlzxFsulyCT tq6QhkPEBQtZMqO2N9QBrVebbEgSlK5F5Fe+IhFajdhKUa6yyjjgFvNf2 iCFveFiV6JdNPJdFITC4sDmvdCTkuq64rv2qj0W8IGfpZ6qWVGGf44drA 9Bs6UjArYu/VAGCuKd4+yK86KgwirlzVqhznL5zCtJb0Ty5kQQsfl1ss7 nKdgcKD5RbAUlQifpPJXB2Bp/5V2JCL7l3nrsMOjEk3G5HZyebICj/qrq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="358648322" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="358648322" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 19:57:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="781242272" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="781242272" Received: from dpdk-mingxial-ice.sh.intel.com ([10.67.110.210]) by fmsmga008.fm.intel.com with ESMTP; 25 Jun 2023 19:57:14 -0700 From: Mingxia Liu To: dev@dpdk.org Cc: jingjing.wu@intel.com, beilei.xing@intel.com, Mingxia Liu Subject: [PATCH] net/idpf: refine dev_link_update function Date: Mon, 26 Jun 2023 11:14:54 +0000 Message-Id: <20230626111454.489844-1-mingxia.liu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch refines idpf_dev_link_update callback function according to CPFL PMD basic code. Signed-off-by: Mingxia Liu --- drivers/net/idpf/idpf_ethdev.c | 63 ++++++++++++++++------------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index fb59655555..bfdac92b95 100644 --- a/drivers/net/idpf/idpf_ethdev.c +++ b/drivers/net/idpf/idpf_ethdev.c @@ -30,6 +30,23 @@ static const char * const idpf_valid_args[] = { NULL }; +uint32_t idpf_supported_speeds[] = { + RTE_ETH_SPEED_NUM_NONE, + RTE_ETH_SPEED_NUM_10M, + RTE_ETH_SPEED_NUM_100M, + RTE_ETH_SPEED_NUM_1G, + RTE_ETH_SPEED_NUM_2_5G, + RTE_ETH_SPEED_NUM_5G, + RTE_ETH_SPEED_NUM_10G, + RTE_ETH_SPEED_NUM_20G, + RTE_ETH_SPEED_NUM_25G, + RTE_ETH_SPEED_NUM_40G, + RTE_ETH_SPEED_NUM_50G, + RTE_ETH_SPEED_NUM_56G, + RTE_ETH_SPEED_NUM_100G, + RTE_ETH_SPEED_NUM_200G +}; + static const uint64_t idpf_map_hena_rss[] = { [IDPF_HASH_NONF_UNICAST_IPV4_UDP] = RTE_ETH_RSS_NONFRAG_IPV4_UDP, @@ -110,42 +127,22 @@ idpf_dev_link_update(struct rte_eth_dev *dev, { struct idpf_vport *vport = dev->data->dev_private; struct rte_eth_link new_link; + unsigned int i; memset(&new_link, 0, sizeof(new_link)); - switch (vport->link_speed) { - case RTE_ETH_SPEED_NUM_10M: - new_link.link_speed = RTE_ETH_SPEED_NUM_10M; - break; - case RTE_ETH_SPEED_NUM_100M: - new_link.link_speed = RTE_ETH_SPEED_NUM_100M; - break; - case RTE_ETH_SPEED_NUM_1G: - new_link.link_speed = RTE_ETH_SPEED_NUM_1G; - break; - case RTE_ETH_SPEED_NUM_10G: - new_link.link_speed = RTE_ETH_SPEED_NUM_10G; - break; - case RTE_ETH_SPEED_NUM_20G: - new_link.link_speed = RTE_ETH_SPEED_NUM_20G; - break; - case RTE_ETH_SPEED_NUM_25G: - new_link.link_speed = RTE_ETH_SPEED_NUM_25G; - break; - case RTE_ETH_SPEED_NUM_40G: - new_link.link_speed = RTE_ETH_SPEED_NUM_40G; - break; - case RTE_ETH_SPEED_NUM_50G: - new_link.link_speed = RTE_ETH_SPEED_NUM_50G; - break; - case RTE_ETH_SPEED_NUM_100G: - new_link.link_speed = RTE_ETH_SPEED_NUM_100G; - break; - case RTE_ETH_SPEED_NUM_200G: - new_link.link_speed = RTE_ETH_SPEED_NUM_200G; - break; - default: - new_link.link_speed = RTE_ETH_SPEED_NUM_NONE; + for (i = 0; i < RTE_DIM(idpf_supported_speeds); i++) { + if (vport->link_speed == idpf_supported_speeds[i]) { + new_link.link_speed = vport->link_speed; + break; + } + } + + if (i == RTE_DIM(idpf_supported_speeds)) { + if (vport->link_up) + new_link.link_speed = RTE_ETH_SPEED_NUM_UNKNOWN; + else + new_link.link_speed = RTE_ETH_SPEED_NUM_NONE; } new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; -- 2.34.1