From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 391CD9A88 for ; Fri, 1 Apr 2016 00:12:53 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id 139so87721wmn.2 for ; Thu, 31 Mar 2016 15:12:53 -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=Fn4oRsFTSg7/Krs+blDQ2J5JnYtJPBDe5NzBE0gg0EM=; b=KSrJbqBbZfnIREKLkzTEFIPy+yA5MpRrzcUZf4xqnPZ1uYkKNr5Jl+ZsPg2kwSV3nv nd7x5jlBaWW9Gdgv4LUCLXOHHU1XVtE/+DMadtZVhzKF8iZZTckhWydfsDy0lC5J9AHL XK/hz3KLpvtDmQIoeN2oWWkJ2CpoCRFETWSk1hRr0rWrUeJ6ZvOgUO6RexJNozqHN9gy ryNNxA9zFeoPbr6OVvkmVC/h0I5TEtkgQ+L9jHgk0LD7ODUsqgSzWHhVPNN9E3hJ/qkS vYrKnXrWiotirO0Jrr275cyFY2ahIujlTDBtyz1DIBsskZxtjE16d5LihXsBPYIsfubK zQFA== 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=Fn4oRsFTSg7/Krs+blDQ2J5JnYtJPBDe5NzBE0gg0EM=; b=BO9c80kKMMeq+z75Cla/u4KEfZQY9snRRmZgOyTfqJKW5iW9vLIUF/v6f2jTC7Ix8I WEOOpRvqguM4avxhnEAfZgjshNw9sQg+sdLmb2AJUWhvQk1j9TwKYRLvWUH5sbJm18sL VA0d24edPWmtrGmKpq/9xiOxTd6L7xvDa7Us310UQUSn/8dqtBEjT2qdB05dz4hT2hKS OZF5zLu3yA6G9ySwoQ9AZpYZEACTc+yU7ZSYChndavCk3RD20XCIWn3j0rT41lpmtg35 l+d+S7uBR89KhhIghyHtxjeI4Uf2eY+Q7B76qJWOO4D5KDimRW64kp1W0jLfEfBHBU2e 8CZA== X-Gm-Message-State: AD7BkJI98S0rAzsTe+ho5nh8bcwWajdL3FQ7Y/iL8/+TKMadiP2PB1kT7PHeUFcorrumEA== X-Received: by 10.194.134.202 with SMTP id pm10mr867213wjb.111.1459462373063; Thu, 31 Mar 2016 15:12:53 -0700 (PDT) Received: from localhost.localdomain (149.red-83-32-179.dynamicip.rima-tde.net. [83.32.179.149]) by smtp.gmail.com with ESMTPSA id m13sm11495604wma.3.2016.03.31.15.12.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 15:12:52 -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: Fri, 1 Apr 2016 00:12:30 +0200 Message-Id: <1459462351-1120-8-git-send-email-marcdevel@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459462351-1120-1-git-send-email-marcdevel@gmail.com> References: <1458955640-22951-1-git-send-email-marcdevel@gmail.com> <1459462351-1120-1-git-send-email-marcdevel@gmail.com> Subject: [dpdk-dev] [PATCH v14 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: Thu, 31 Mar 2016 22:12:53 -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 b88300d..1342b3a 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1878,6 +1878,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