From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id E53EF5AA6 for ; Sat, 26 Mar 2016 02:28:09 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id u125so7234644wmg.0 for ; Fri, 25 Mar 2016 18:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yQZdr8egPJShPhkRsKgRPzuJnVPl2nLx/+Q/mxDAr6Y=; b=DcBcKF2LZmBuAO8B3CKLLQ1CW7ZCCzDYqMYaYhBey1R01/iZOmg2N3byPIQFiIJD/P yR4ijwVzu6Jz+roMKYxeTugxWKotJgSP47iVlnG0rNa+STBBrWFv9XMtCu/C5DMRvAkh VnowO+6DW7MYhgeBamDJgENP66B+8SiYIj810R0bq83vJVnla7johvdzXQ6cujaJFdVc G0dCrNzVWelNowfBzgYOcPnEg1jGeybfZndIjZoH3WLnLVczDe8nU8HZKCGUPXams8YQ bQln7sCsemUJovzIW/nUPcPoBlSv935qJKN0V0piZdb+vOro3bbcq8yG6gM2cgI2fdry OSEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yQZdr8egPJShPhkRsKgRPzuJnVPl2nLx/+Q/mxDAr6Y=; b=eN4EhZnnbfZyvV00/mNdkPc+WJ0vPbji2nOMK2Uq4WyMJfkXXx6uBBH7cRrrIhVn9F Asi10AyUOAiipG2tkO+PyGsw1Bz+48ov4IOFa1ZBZxYFMYl18XPo7hqiRdFcfrx6O6e9 sG29et6CqLHKwvKRYsTUR37h54AukxlSLSlOdbYUX1AHjXd4S1CCY6CYw8AQ2w8v7n9P K1KjBNHrOa3V/dL4Kg0mhwQoRo13I8sJXG1qFgXWY6wxoz/EBnMTQ9unJikRet9a1uHd jkdNB9EF8GzIxDdkGWFtJY9IDMVygW4AQ//MZ8kpXlALud/8XaehqbkwBSnFKnlx+El4 WAcw== X-Gm-Message-State: AD7BkJLuP4dWoNT7Zkx9zz7/+HWxoTkgIlL02F+7Y63zcDp2rWM4Rhk1VJZeGEdz93at3Q== X-Received: by 10.194.143.82 with SMTP id sc18mr17205430wjb.14.1458955689799; Fri, 25 Mar 2016 18:28:09 -0700 (PDT) Received: from localhost.localdomain (28.red-88-23-79.staticip.rima-tde.net. [88.23.79.28]) by smtp.gmail.com with ESMTPSA id hh8sm14070113wjc.42.2016.03.25.18.28.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Mar 2016 18:28:09 -0700 (PDT) From: Marc Sune To: Thomas Monjalon , "Xu, Qian Q" , "Xing, Beilei" , "dev@dpdk.org" , "Ananyev, Konstantin" , "Lu, Wenzhuo" , "Richardson, Bruce" , "Glynn, Michael J" Cc: Marc Sune Date: Sat, 26 Mar 2016 02:27:19 +0100 Message-Id: <1458955640-22951-8-git-send-email-marcdevel@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458955640-22951-1-git-send-email-marcdevel@gmail.com> References: <1458934950-23333-1-git-send-email-thomas.monjalon@6wind.com> <1458955640-22951-1-git-send-email-marcdevel@gmail.com> Subject: [dpdk-dev] [PATCH v13 7/8] ethdev: convert speed number to bitmap flag X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Mar 2016 01:28:10 -0000 It is a helper for the bitmap configuration. Signed-off-by: Marc Sune Signed-off-by: Thomas Monjalon --- lib/librte_ether/rte_ethdev.c | 31 +++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 13 +++++++++++++ lib/librte_ether/rte_ether_version.map | 1 + 3 files changed, 45 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 76a30fd..695b475 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -866,6 +866,37 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) return 0; } +uint32_t +rte_eth_speed_bitflag(uint32_t speed, int duplex) +{ + switch (speed) { + case ETH_SPEED_NUM_10M: + return duplex ? ETH_LINK_SPEED_10M : ETH_LINK_SPEED_10M_HD; + case ETH_SPEED_NUM_100M: + return duplex ? ETH_LINK_SPEED_100M : ETH_LINK_SPEED_100M_HD; + case ETH_SPEED_NUM_1G: + return ETH_LINK_SPEED_1G; + case ETH_SPEED_NUM_2_5G: + return ETH_LINK_SPEED_2_5G; + case ETH_SPEED_NUM_5G: + return ETH_LINK_SPEED_5G; + case ETH_SPEED_NUM_10G: + return ETH_LINK_SPEED_10G; + case ETH_SPEED_NUM_20G: + return ETH_LINK_SPEED_20G; + case ETH_SPEED_NUM_25G: + return ETH_LINK_SPEED_25G; + case ETH_SPEED_NUM_40G: + return ETH_LINK_SPEED_40G; + case ETH_SPEED_NUM_50G: + return ETH_LINK_SPEED_50G; + case ETH_SPEED_NUM_56G: + return ETH_LINK_SPEED_56G; + default: + return 0; + } +} + int rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, const struct rte_eth_conf *dev_conf) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 9a1466b..0b436d9 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1876,6 +1876,19 @@ struct eth_driver { void rte_eth_driver_register(struct eth_driver *eth_drv); /** + * Convert a numerical speed in Mbps to a bitmap flag that can be used in + * the bitmap link_speeds of the struct rte_eth_conf + * + * @param speed + * Numerical speed value in Mbps + * @param duplex + * ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds) + * @return + * 0 if the speed cannot be mapped + */ +uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex); + +/** * Configure an Ethernet device. * This function must be invoked first before any other function in the * Ethernet API. This function can also be re-invoked when a device is in the diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index b1f4475..214ecc7 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -125,6 +125,7 @@ DPDK_16.04 { rte_eth_dev_set_vlan_ether_type; rte_eth_dev_udp_tunnel_port_add; rte_eth_dev_udp_tunnel_port_delete; + rte_eth_speed_bitflag; rte_eth_tx_buffer_count_callback; rte_eth_tx_buffer_drop_callback; rte_eth_tx_buffer_init; -- 2.1.4