From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by dpdk.org (Postfix) with ESMTP id 8D8EECE7 for ; Fri, 25 Mar 2016 20:44:47 +0100 (CET) Received: by mail-wm0-f48.google.com with SMTP id l68so32764078wml.1 for ; Fri, 25 Mar 2016 12:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9aGQXr3qjGSGruZtHgJuik5q27pP8OxLKoP1QFXMILM=; b=X8iXC5h9uPUBV/Fi0Bl93mYckxR7Ll4FnYPriIL4rZhmjt59Ek67tVkkzzLPtbAeBh r/to6TFxvZBYIuBNDG4RmmLEXCmYaEXO3uibySmmMFPsCItNQ5Xc94WU/ujVHqRn+Wnx I/Fc/eDFoXAWOAIeIgTVpjw7nXb3KxPTw7dkhK6xhu+g7ThpKOsxzBo+xsNR5j7bOETl K+VFiIYcbJFfaq6KR9HEUOIR/q/TH+gLg6zQFo51nnjOY6CwQW+YjcpeaYcuIrcgb4Xi XglYu+mtmbyV78XhWlZcIhPTAmfOusvbnH8X4BziFUHGeAMhJuTp1yjpMX8Nty4rbnVx bO7w== 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=9aGQXr3qjGSGruZtHgJuik5q27pP8OxLKoP1QFXMILM=; b=b+dUPYyHljyo/uvkXhaeBQVc4nSoxLmXMWAnctSQTJJMboBo5jpxb+51B+Oy0OZ3Ci 9TotlL7bo8rRDmXoCBhffWachpYVni1NHY7ozvTLi48cyVEYWM346y5HB83ogLa7W64F lCFV14sOqrLYDwVbQHu9wpK4u5gLcV+H9tFIZjqUB5kOAdXjQ8snSacFWPMZFJhaTOoY eYK3RFPhnFZf7eDXBDRlSzV6RjfaYGhp2v67LVXxGURnS9qjUL37CuWP2IEE73m1llHC 3I1Z2H2JmwovcPqx2dRp3dGZB7hty9KxPzN7o+3NcE3wqHmEwHdU6rxL3e8Oae+J7ytP Ba9A== X-Gm-Message-State: AD7BkJL0+GUoXRH/+TIbKn2N0q7laMI6wvfn3Jmdk/bkrImJqBi04/Bf6UOxrfNuuG3+Or4T X-Received: by 10.28.0.148 with SMTP id 142mr184225wma.72.1458935087454; Fri, 25 Mar 2016 12:44:47 -0700 (PDT) Received: from XPS13.localdomain (91.111.75.86.rev.sfr.net. [86.75.111.91]) by smtp.gmail.com with ESMTPSA id u4sm13240660wjz.4.2016.03.25.12.44.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 12:44:46 -0700 (PDT) From: Thomas Monjalon To: marcdevel@gmail.com, bruce.richardson@intel.com, declan.doherty@intel.com, konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, helin.zhang@intel.com, jing.d.chen@intel.com, harish.patil@qlogic.com, rahul.lakkireddy@chelsio.com, johndale@cisco.com, vido@cesnet.cz, adrien.mazarguil@6wind.com, alejandro.lucero@netronome.com Cc: dev@dpdk.org Date: Fri, 25 Mar 2016 20:42:29 +0100 Message-Id: <1458934950-23333-8-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458934950-23333-1-git-send-email-thomas.monjalon@6wind.com> References: <1458238145-7496-1-git-send-email-thomas.monjalon@6wind.com> <1458934950-23333-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v12 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: Fri, 25 Mar 2016 19:44:47 -0000 From: Marc Sune 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 03d3278..bb08ead 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.7.0