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 3F4CCA04DC; Mon, 19 Oct 2020 10:55:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB050C8A8; Mon, 19 Oct 2020 10:53:01 +0200 (CEST) Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by dpdk.org (Postfix) with ESMTP id 913B9C82A for ; Mon, 19 Oct 2020 10:52:47 +0200 (CEST) X-QQ-mid: bizesmtp6t1603097562tyqb0s1ny Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Mon, 19 Oct 2020 16:52:42 +0800 (CST) X-QQ-SSF: 01400000002000C0C000B00A0000000 X-QQ-FEAT: uJKlVohL8Wq5V/1+0TiIUtui25ranIBCncCqjISY2qII+29oGeiopJ+I1m8/5 BIA//Ffg4Ck6u5eAe/y8BvwWkIJuez/nEzjP95Eb2NnjqY12Zdt161U32qHCdSaB00DXr6L A3Ag9z5lpKlimTtyBUvbDUYQNwGydfyPdBzCZFzBXVlF+S1YA+5GljTOFj9r157oM5IKvN6 1Wae77Znk+twwg+Le8l4RRd84CXNtDnODMaaQtKM64LEvlJgj+5BZfZJueW15K1jtwjrcLT WjaHu6G9v/xix9WRpEEesCpIAXA2WZHjFbRudaaJcCkdags4qZmSWfGXeUNnsQHsCGxHcb0 9b5lXBPc6mXY3SG4TVJQFbCtphakwTu2TDHuRsm X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Mon, 19 Oct 2020 16:53:29 +0800 Message-Id: <20201019085415.82207-13-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201019085415.82207-1-jiawenwu@trustnetic.com> References: <20201019085415.82207-1-jiawenwu@trustnetic.com> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v4 12/58] net/txgbe: add info get operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add device information get operation. Signed-off-by: Jiawen Wu --- doc/guides/nics/features/txgbe.ini | 1 + drivers/net/txgbe/base/txgbe_hw.c | 7 +- drivers/net/txgbe/base/txgbe_type.h | 2 + drivers/net/txgbe/meson.build | 1 + drivers/net/txgbe/txgbe_ethdev.c | 79 ++++++++++++++++++++ drivers/net/txgbe/txgbe_ethdev.h | 31 ++++++++ drivers/net/txgbe/txgbe_rxtx.c | 112 ++++++++++++++++++++++++++++ drivers/net/txgbe/txgbe_rxtx.h | 15 ++++ 8 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 drivers/net/txgbe/txgbe_rxtx.c create mode 100644 drivers/net/txgbe/txgbe_rxtx.h diff --git a/doc/guides/nics/features/txgbe.ini b/doc/guides/nics/features/txgbe.ini index 76c43c7f1..2fc202c3a 100644 --- a/doc/guides/nics/features/txgbe.ini +++ b/doc/guides/nics/features/txgbe.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Speed capabilities = Y Linux UIO = Y Linux VFIO = Y ARMv8 = Y diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 598ef3e99..31f8688d4 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -8,6 +8,8 @@ #include "txgbe_mng.h" #include "txgbe_hw.h" +#define TXGBE_RAPTOR_MAX_TX_QUEUES 128 +#define TXGBE_RAPTOR_MAX_RX_QUEUES 128 #define TXGBE_RAPTOR_RAR_ENTRIES 128 /** @@ -304,7 +306,6 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw) /* MAC */ mac->init_hw = txgbe_init_hw; mac->reset_hw = txgbe_reset_hw; - mac->num_rar_entries = TXGBE_RAPTOR_RAR_ENTRIES; /* EEPROM */ rom->init_params = txgbe_init_eeprom_params; @@ -320,6 +321,10 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw) rom->update_checksum = txgbe_update_eeprom_checksum; rom->calc_checksum = txgbe_calc_eeprom_checksum; + mac->num_rar_entries = TXGBE_RAPTOR_RAR_ENTRIES; + mac->max_rx_queues = TXGBE_RAPTOR_MAX_RX_QUEUES; + mac->max_tx_queues = TXGBE_RAPTOR_MAX_TX_QUEUES; + return 0; } diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 438734f8c..09089fce8 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -303,6 +303,8 @@ struct txgbe_mac_info { u16 wwpn_prefix; u32 num_rar_entries; + u32 max_tx_queues; + u32 max_rx_queues; u8 san_mac_rar_index; u64 orig_autoc; /* cached value of AUTOC */ diff --git a/drivers/net/txgbe/meson.build b/drivers/net/txgbe/meson.build index 295f39296..3c11d5e33 100644 --- a/drivers/net/txgbe/meson.build +++ b/drivers/net/txgbe/meson.build @@ -6,6 +6,7 @@ objs = [base_objs] sources = files( 'txgbe_ethdev.c', + 'txgbe_rxtx.c', ) includes += include_directories('base') diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 2967c450f..3ddbfd934 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -14,6 +14,7 @@ #include "txgbe_logs.h" #include "base/txgbe.h" #include "txgbe_ethdev.h" +#include "txgbe_rxtx.h" static int txgbe_dev_close(struct rte_eth_dev *dev); @@ -26,6 +27,20 @@ static const struct rte_pci_id pci_id_txgbe_map[] = { { .vendor_id = 0, /* sentinel */ }, }; +static const struct rte_eth_desc_lim rx_desc_lim = { + .nb_max = TXGBE_RING_DESC_MAX, + .nb_min = TXGBE_RING_DESC_MIN, + .nb_align = TXGBE_RXD_ALIGN, +}; + +static const struct rte_eth_desc_lim tx_desc_lim = { + .nb_max = TXGBE_RING_DESC_MAX, + .nb_min = TXGBE_RING_DESC_MIN, + .nb_align = TXGBE_TXD_ALIGN, + .nb_seg_max = TXGBE_TX_MAX_SEG, + .nb_mtu_seg_max = TXGBE_TX_MAX_SEG, +}; + static const struct eth_dev_ops txgbe_eth_dev_ops; static inline int @@ -262,7 +277,71 @@ txgbe_dev_close(struct rte_eth_dev *dev) return 0; } +static int +txgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct txgbe_hw *hw = TXGBE_DEV_HW(dev); + + dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues; + dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues; + dev_info->min_rx_bufsize = 1024; + dev_info->max_rx_pktlen = 15872; + dev_info->max_mac_addrs = hw->mac.num_rar_entries; + dev_info->max_hash_mac_addrs = TXGBE_VMDQ_NUM_UC_MAC; + dev_info->max_vfs = pci_dev->max_vfs; + dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->vmdq_queue_num = dev_info->max_rx_queues; + dev_info->rx_queue_offload_capa = txgbe_get_rx_queue_offloads(dev); + dev_info->rx_offload_capa = (txgbe_get_rx_port_offloads(dev) | + dev_info->rx_queue_offload_capa); + dev_info->tx_queue_offload_capa = txgbe_get_tx_queue_offloads(dev); + dev_info->tx_offload_capa = txgbe_get_tx_port_offloads(dev); + + dev_info->default_rxconf = (struct rte_eth_rxconf) { + .rx_thresh = { + .pthresh = TXGBE_DEFAULT_RX_PTHRESH, + .hthresh = TXGBE_DEFAULT_RX_HTHRESH, + .wthresh = TXGBE_DEFAULT_RX_WTHRESH, + }, + .rx_free_thresh = TXGBE_DEFAULT_RX_FREE_THRESH, + .rx_drop_en = 0, + .offloads = 0, + }; + + dev_info->default_txconf = (struct rte_eth_txconf) { + .tx_thresh = { + .pthresh = TXGBE_DEFAULT_TX_PTHRESH, + .hthresh = TXGBE_DEFAULT_TX_HTHRESH, + .wthresh = TXGBE_DEFAULT_TX_WTHRESH, + }, + .tx_free_thresh = TXGBE_DEFAULT_TX_FREE_THRESH, + .offloads = 0, + }; + + dev_info->rx_desc_lim = rx_desc_lim; + dev_info->tx_desc_lim = tx_desc_lim; + + dev_info->hash_key_size = TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t); + dev_info->reta_size = ETH_RSS_RETA_SIZE_128; + dev_info->flow_type_rss_offloads = TXGBE_RSS_OFFLOAD_ALL; + + dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G; + dev_info->speed_capa |= ETH_LINK_SPEED_100M; + + /* Driver-preferred Rx/Tx parameters */ + dev_info->default_rxportconf.burst_size = 32; + dev_info->default_txportconf.burst_size = 32; + dev_info->default_rxportconf.nb_queues = 1; + dev_info->default_txportconf.nb_queues = 1; + dev_info->default_rxportconf.ring_size = 256; + dev_info->default_txportconf.ring_size = 256; + + return 0; +} + static const struct eth_dev_ops txgbe_eth_dev_ops = { + .dev_infos_get = txgbe_dev_info_get, }; RTE_PMD_REGISTER_PCI(net_txgbe, rte_txgbe_pmd); diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 5db03ba20..c81528295 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -7,6 +7,23 @@ #include "base/txgbe.h" +/* + * Defines that were not part of txgbe_type.h as they are not used by the + * FreeBSD driver. + */ +#define TXGBE_HKEY_MAX_INDEX 10 + +#define TXGBE_RSS_OFFLOAD_ALL ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV6_UDP | \ + ETH_RSS_IPV6_EX | \ + ETH_RSS_IPV6_TCP_EX | \ + ETH_RSS_IPV6_UDP_EX) + /* * Structure to store private data for each driver instance (for each port). */ @@ -18,4 +35,18 @@ struct txgbe_adapter { (&((struct txgbe_adapter *)(dev)->data->dev_private)->hw) #define TXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */ + +/* + * Default values for RX/TX configuration + */ +#define TXGBE_DEFAULT_RX_FREE_THRESH 32 +#define TXGBE_DEFAULT_RX_PTHRESH 8 +#define TXGBE_DEFAULT_RX_HTHRESH 8 +#define TXGBE_DEFAULT_RX_WTHRESH 0 + +#define TXGBE_DEFAULT_TX_FREE_THRESH 32 +#define TXGBE_DEFAULT_TX_PTHRESH 32 +#define TXGBE_DEFAULT_TX_HTHRESH 0 +#define TXGBE_DEFAULT_TX_WTHRESH 0 + #endif /* _TXGBE_ETHDEV_H_ */ diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c new file mode 100644 index 000000000..8a7282328 --- /dev/null +++ b/drivers/net/txgbe/txgbe_rxtx.c @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2020 + */ + +#include + +#include +#include +#include + +#include +#include + +#include "txgbe_logs.h" +#include "base/txgbe.h" +#include "txgbe_ethdev.h" +#include "txgbe_rxtx.h" + +static int +txgbe_is_vf(struct rte_eth_dev *dev) +{ + struct txgbe_hw *hw = TXGBE_DEV_HW(dev); + + switch (hw->mac.type) { + case txgbe_mac_raptor_vf: + return 1; + default: + return 0; + } +} + +uint64_t +txgbe_get_rx_queue_offloads(struct rte_eth_dev *dev __rte_unused) +{ + return DEV_RX_OFFLOAD_VLAN_STRIP; +} + +uint64_t +txgbe_get_rx_port_offloads(struct rte_eth_dev *dev) +{ + uint64_t offloads; + struct txgbe_hw *hw = TXGBE_DEV_HW(dev); + struct rte_eth_dev_sriov *sriov = &RTE_ETH_DEV_SRIOV(dev); + + offloads = DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_KEEP_CRC | + DEV_RX_OFFLOAD_JUMBO_FRAME | + DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_RSS_HASH | + DEV_RX_OFFLOAD_SCATTER; + + if (!txgbe_is_vf(dev)) + offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_QINQ_STRIP | + DEV_RX_OFFLOAD_VLAN_EXTEND); + + /* + * RSC is only supported by PF devices in a non-SR-IOV + * mode. + */ + if (hw->mac.type == txgbe_mac_raptor && !sriov->active) + offloads |= DEV_RX_OFFLOAD_TCP_LRO; + + if (hw->mac.type == txgbe_mac_raptor) + offloads |= DEV_RX_OFFLOAD_MACSEC_STRIP; + + offloads |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM; + + return offloads; +} + +uint64_t +txgbe_get_tx_queue_offloads(struct rte_eth_dev *dev) +{ + RTE_SET_USED(dev); + + return 0; +} + +uint64_t +txgbe_get_tx_port_offloads(struct rte_eth_dev *dev) +{ + uint64_t tx_offload_capa; + + tx_offload_capa = + DEV_TX_OFFLOAD_VLAN_INSERT | + DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_TCP_TSO | + DEV_TX_OFFLOAD_UDP_TSO | + DEV_TX_OFFLOAD_UDP_TNL_TSO | + DEV_TX_OFFLOAD_IP_TNL_TSO | + DEV_TX_OFFLOAD_VXLAN_TNL_TSO | + DEV_TX_OFFLOAD_GRE_TNL_TSO | + DEV_TX_OFFLOAD_IPIP_TNL_TSO | + DEV_TX_OFFLOAD_GENEVE_TNL_TSO | + DEV_TX_OFFLOAD_MULTI_SEGS; + + if (!txgbe_is_vf(dev)) + tx_offload_capa |= DEV_TX_OFFLOAD_QINQ_INSERT; + + tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT; + + tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; + + return tx_offload_capa; +} + diff --git a/drivers/net/txgbe/txgbe_rxtx.h b/drivers/net/txgbe/txgbe_rxtx.h new file mode 100644 index 000000000..9488c2b75 --- /dev/null +++ b/drivers/net/txgbe/txgbe_rxtx.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2020 + */ + +#ifndef _TXGBE_RXTX_H_ +#define _TXGBE_RXTX_H_ + +#define TXGBE_TX_MAX_SEG 40 + +uint64_t txgbe_get_tx_port_offloads(struct rte_eth_dev *dev); +uint64_t txgbe_get_rx_queue_offloads(struct rte_eth_dev *dev); +uint64_t txgbe_get_rx_port_offloads(struct rte_eth_dev *dev); +uint64_t txgbe_get_tx_queue_offloads(struct rte_eth_dev *dev); + +#endif /* _TXGBE_RXTX_H_ */ -- 2.18.4