From patchwork Tue Oct 15 09:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 61252 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68F871EB42; Tue, 15 Oct 2019 11:52:42 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id B5ECB1EB2F for ; Tue, 15 Oct 2019 11:52:39 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9F9isw0001963; Tue, 15 Oct 2019 02:52:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=/A6XPBXYBH4OOOMTN4PtEnLeu0EUvIQW5Vx8hdfz1yE=; b=ANn5xQLsqc7kxRRMX7AtQZDMdbO/fsxauWLnpPS5krh+fWzd0DGh1c2VCneN79tz3ull FidMlNl+1QcJ3inFYO+HrC7cHU6qGOO5Ca5BbjfA5PnUzKsCqIWeiVK3HHbfWi+zTZHV qwXJQM8OGNC6k3LYTx1hvppIfL7Z7qGqOZHdrayT7HN8OczUiwPJuXlQF8vRr7QLe1jJ Bl5u2Rfq8bmRg0b1d+0WX15E87yRt934XZcBJ6OTDtqD9Lsag7GD6079RZcp585ifXiQ BGWXX6wdsfUTW+Kl4ak13A1skRyS8HOaa1f1D8WpnOaIqp62B2AiRjJhGljkEZNyzFpe AQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2vkc6ra17a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2019 02:52:38 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 02:52:37 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 02:52:37 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id 0C6CB3F7041; Tue, 15 Oct 2019 02:52:34 -0700 (PDT) From: To: CC: , , , , Vamsi Attunuru Date: Tue, 15 Oct 2019 15:22:05 +0530 Message-ID: <20191015095207.13249-2-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20191015095207.13249-1-vattunuru@marvell.com> References: <20190914055247.3841-2-vattunuru@marvell.com> <20191015095207.13249-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-15_04:2019-10-15,2019-10-15 signatures=0 Subject: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index 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" From: Vamsi Attunuru Some networking devices may use custom algos for computing hash indices and spread the packets accordingly. Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port. Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash. Such applications may use these API to get the hash index used by the PMD for spreading those traffic. Signed-off-by: Vamsi Attunuru --- lib/librte_ethdev/rte_ethdev.c | 13 +++++++++++++ lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 5 +++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 4 files changed, 41 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index af82360..ed02168 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3140,6 +3140,19 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id, } int +rte_eth_dev_rss_hash_index_get(uint16_t port_id, + uint32_t hash, uint32_t *hash_idx) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_index_get, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->rss_hash_index_get)(dev, hash, + hash_idx)); +} + +int rte_eth_dev_udp_tunnel_port_add(uint16_t port_id, struct rte_eth_udp_tunnel *udp_tunnel) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d937fb4..8198130 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -3306,6 +3306,26 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id, struct rte_eth_rss_conf *rss_conf); /** + * Get hash index of the given hash value that received in mbuf from this port. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param hash + * The hash value used to compute hash_idx. + * @param hash_idx + * Where to store the computed hash_idx + * @return + * - (0) if successful. + * - (-ENODEV) if port identifier is invalid. + * - (-EIO) if device is removed. + * - (-ENOTSUP) if hardware doesn't support RSS. + */ +__rte_experimental +int +rte_eth_dev_rss_hash_index_get(uint16_t port_id, + uint32_t hash, uint32_t *hash_idx); + + /** * Add UDP tunneling port for a specific type of tunnel. * The packets with this UDP port will be identified as this type of tunnel. * Before enabling any offloading function for a tunnel, users can call this API diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h index dcb5ae6..ad6cdc5 100644 --- a/lib/librte_ethdev/rte_ethdev_core.h +++ b/lib/librte_ethdev/rte_ethdev_core.h @@ -364,6 +364,10 @@ typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf); /**< @internal Get current RSS hash configuration of an Ethernet device */ +typedef int (*rss_hash_index_get_t)(struct rte_eth_dev *dev, + uint32_t hash, uint32_t *hash_idx); +/**< @internal Get RSS hash id of given hash value */ + typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); /**< @internal Turn on SW controllable LED on an Ethernet device */ @@ -595,6 +599,7 @@ struct eth_dev_ops { rss_hash_update_t rss_hash_update; /** Configure RSS hash protocols. */ rss_hash_conf_get_t rss_hash_conf_get; /** Get current RSS hash configuration. */ + rss_hash_index_get_t rss_hash_index_get; /** Get RSS hash idx. */ reta_update_t reta_update; /** Update redirection table. */ reta_query_t reta_query; /** Query redirection table. */ diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 6df42a4..ea6d1bf 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -283,4 +283,7 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_dev_rss_hash_index_get; }; From patchwork Tue Oct 15 09:52:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 61253 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B5DB1E928; Tue, 15 Oct 2019 11:52:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id A60DA1EB48 for ; Tue, 15 Oct 2019 11:52:42 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9F9j8Yh013796; Tue, 15 Oct 2019 02:52:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=6ouCd9pSR/4Q1T8RXKqaInR9u6xBc46JFKMo0r8in3k=; b=bsuGCA2/MZgbfDIuHWyYShwsnp6yt6VPNPCO+8tpI4iGx0+VdKGLBtiIJzCnxBhp/axH JXReMvR9BXM2guoH1aS0TEvWfIbO6UT8GHEYIfZmqpmCCCSWg4qlf+WnJCr9Yq1K/W/T nT284UV+yFkNHgatLvuLUYCJJad18Gd1YGANjgE1Jr5QPxDdusLf/egY00vupAgbvfUc neatvQGFLxwc4zqg+W+RD3RV/5yB/0kRu8KB/QW/Htr7wb6IJPxXY2fgVAZnv6hkDy1X b6OW46N9Y7y3NTnOMCTzV4uVT5+MuenifWznLe6FBSop/IxxbfcIWkeZyWqxRIbGqyax sw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2vkebp167a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2019 02:52:41 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 02:52:40 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 02:52:40 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id DFECE3F703F; Tue, 15 Oct 2019 02:52:37 -0700 (PDT) From: To: CC: , , , , Vamsi Attunuru Date: Tue, 15 Oct 2019 15:22:06 +0530 Message-ID: <20191015095207.13249-3-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20191015095207.13249-1-vattunuru@marvell.com> References: <20190914055247.3841-2-vattunuru@marvell.com> <20191015095207.13249-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-15_04:2019-10-15,2019-10-15 signatures=0 Subject: [dpdk-dev] [PATCH v2 2/3] app/test: add hash index verify autotest 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" From: Vamsi Attunuru Patch adds a autotest to validate rte_eth_dev_rss_hash_index_get() ethdev op. Test configures the ethport in loopback mode and enables RSS for IP packets. The hash indices returned by those API gets validated by matching queue number in the reta table with the rxq(queue's idx) on which the packet received. Signed-off-by: Vamsi Attunuru --- app/test/Makefile | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 1 + app/test/test_hash_index.c | 347 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 355 insertions(+) diff --git a/app/test/Makefile b/app/test/Makefile index df7f77f..8674cfe 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -79,6 +79,7 @@ SRCS-y += test_rand_perf.c SRCS-y += test_ring.c SRCS-y += test_ring_perf.c SRCS-y += test_pmd_perf.c +SRCS-y += test_hash_index.c ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y) SRCS-y += test_table.c diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py index 7405149..fef76d0 100644 --- a/app/test/autotest_data.py +++ b/app/test/autotest_data.py @@ -653,6 +653,12 @@ "Report": None, }, { + "Name": "Hash index verify autotest", + "Command": "hash_index_verify_autotest", + "Func": default_autotest, + "Report": None, + }, + { "Name": "Ring pmd perf autotest", "Command": "ring_pmd_perf_autotest", "Func": default_autotest, diff --git a/app/test/meson.build b/app/test/meson.build index 2c23c63..8eefe5e 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -85,6 +85,7 @@ test_sources = files('commands.c', 'test_mp_secondary.c', 'test_pdump.c', 'test_per_lcore.c', + 'test_hash_index.c', 'test_pmd_perf.c', 'test_pmd_ring.c', 'test_pmd_ring_perf.c', diff --git a/app/test/test_hash_index.c b/app/test/test_hash_index.c new file mode 100644 index 0000000..854404f --- /dev/null +++ b/app/test/test_hash_index.c @@ -0,0 +1,347 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include "packet_burst_generator.h" +#include "test.h" + +#define NB_ETHPORTS_USED 1 +#define MAX_PKT_BURST 32 +#define MAX_TRAFFIC_BURST 128 +#define MEMPOOL_CACHE_SIZE 32 +#define MAX_TEST_QUEUES_PER_PORT 4 + +#define DEF_RETA_SIZE RTE_RETA_GROUP_SIZE + +#define NB_MBUF RTE_MAX( \ + (uint32_t)(nb_ports*nb_rx_queue*nb_rxd + \ + nb_ports*MAX_PKT_BURST + \ + nb_ports*nb_tx_queue*nb_txd + \ + 1*MEMPOOL_CACHE_SIZE + \ + nb_ports*MAX_TRAFFIC_BURST), \ + (uint32_t)4096) + +static struct rte_mempool *mbufpool; +static struct rte_eth_rss_reta_entry64 reta_conf; + +static struct rte_eth_conf port_conf = { + .rxmode = { + .mq_mode = ETH_MQ_RX_RSS, + .max_rx_pkt_len = RTE_ETHER_MAX_LEN, + .split_hdr_size = 0, + }, + .txmode = { + .mq_mode = ETH_MQ_TX_NONE, + }, + .lpbk_mode = 1, /* enable loopback */ + .rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP, +}; + +static struct rte_eth_rxconf rx_conf = { + .rx_free_thresh = 32, +}; + +static struct rte_eth_txconf tx_conf = { + .tx_free_thresh = 32, /* Use PMD default values */ + .tx_rs_thresh = 32, /* Use PMD default values */ +}; + +static uint64_t link_mbps; + +static void +check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) +{ +#define CHECK_INTERVAL 100 /* 100ms */ +#define MAX_CHECK_TIME 30 /* 3s (30 * 100ms) in total */ + uint8_t count, all_ports_up, print_flag = 0; + struct rte_eth_link link; + uint16_t portid; + + printf("Checking link statuses...\n"); + fflush(stdout); + for (count = 0; count <= MAX_CHECK_TIME; count++) { + all_ports_up = 1; + for (portid = 0; portid < port_num; portid++) { + if ((port_mask & (1 << portid)) == 0) + continue; + memset(&link, 0, sizeof(link)); + rte_eth_link_get_nowait(portid, &link); + /* print link status if flag set */ + if (print_flag == 1) { + if (link.link_status) { + printf( + "Port%d Link Up. Speed %u Mbps - %s\n", + portid, link.link_speed, + (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? + ("full-duplex") : ("half-duplex\n")); + if (link_mbps == 0) + link_mbps = link.link_speed; + } else + printf("Port %d Link Down\n", portid); + continue; + } + /* clear all_ports_up flag if any link down */ + if (link.link_status == ETH_LINK_DOWN) { + all_ports_up = 0; + break; + } + } + /* after finally printing all link status, get out */ + if (print_flag == 1) + break; + + if (all_ports_up == 0) { + fflush(stdout); + rte_delay_ms(CHECK_INTERVAL); + } + + /* set the print_flag if all ports up or timeout */ + if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) + print_flag = 1; + } +} + +static inline void +copy_buf_to_pkt(void *buf, uint32_t len, struct rte_mbuf *pkt, uint32_t offset) +{ + rte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset), buf, + (size_t) len); +} + +static int +init_traffic(struct rte_mempool *mp, + struct rte_mbuf **pkts_burst, uint32_t burst_size) +{ + static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF }; + static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA }; + struct rte_ether_hdr pkt_eth_hdr; + struct rte_ipv4_hdr pkt_ipv4_hdr; + struct rte_udp_hdr pkt_udp_hdr; + struct rte_mbuf *pkt; + size_t eth_hdr_size; + uint32_t nb_pkt; + + initialize_eth_header(&pkt_eth_hdr, + (struct rte_ether_addr *)src_mac, + (struct rte_ether_addr *)dst_mac, RTE_ETHER_TYPE_IPV4, 0, 0); + + eth_hdr_size = sizeof(struct rte_ether_hdr); + + initialize_udp_header(&pkt_udp_hdr, 0, 0, 18); + + for (nb_pkt = 0; nb_pkt < burst_size; nb_pkt++) { + pkt = rte_pktmbuf_alloc(mp); + if (pkt == NULL) + break; + + pkt->data_len = PACKET_BURST_GEN_PKT_LEN; + + copy_buf_to_pkt(&pkt_eth_hdr, eth_hdr_size, pkt, 0); + + initialize_ipv4_header(&pkt_ipv4_hdr, + IPV4_ADDR(10, 0, 0, 1) + nb_pkt, + IPV4_ADDR(10, 0, 0, 2), 26); + + copy_buf_to_pkt(&pkt_ipv4_hdr, sizeof(struct rte_ipv4_hdr), + pkt, eth_hdr_size); + copy_buf_to_pkt(&pkt_udp_hdr, sizeof(struct rte_udp_hdr), pkt, + eth_hdr_size + sizeof(struct rte_ipv4_hdr)); + + pkt->pkt_len = PACKET_BURST_GEN_PKT_LEN; + pkt->l2_len = eth_hdr_size; + pkt->l3_len = sizeof(struct rte_ipv4_hdr); + + pkts_burst[nb_pkt] = pkt; + } + + return 0; +} + +struct rte_mbuf **tx_burst; + +static int +start_hash_index_verify(int portid) +{ + uint64_t end_cycles = rte_get_timer_hz() * 5; /* 5 Sec */ + struct rte_mbuf *rx_burst[MAX_PKT_BURST]; + uint32_t hash, hash_idx, count = 0, rxq; + uint32_t nb_rx = 0, nb_tx = 0; + int idx = 0, rc, mismatch = 0; + int num = MAX_TRAFFIC_BURST; + uint64_t start_cycles; + + printf("inject %d packet to port %d\n", num, portid); + while (num) { + nb_tx = RTE_MIN(MAX_PKT_BURST, num); + nb_tx = rte_eth_tx_burst(portid, 0, + &tx_burst[idx], nb_tx); + num -= nb_tx; + idx += nb_tx; + } + + printf("Total packets inject to port = %u\n", idx); + + start_cycles = rte_get_timer_cycles(); + + while (count < MAX_TRAFFIC_BURST) { + for (rxq = 0 ; rxq < MAX_TEST_QUEUES_PER_PORT; rxq++) { + nb_rx = rte_eth_rx_burst(portid, rxq, rx_burst, 1); + if (nb_rx) { + hash = rx_burst[0]->hash.rss; + rc = rte_eth_dev_rss_hash_index_get(portid, + hash, + &hash_idx); + if (rc < 0) + hash_idx = hash % DEF_RETA_SIZE; + + if (rxq != reta_conf.reta[hash_idx]) + mismatch++; + + rte_pktmbuf_free(rx_burst[0]); + count += nb_rx; + } + } + if (rte_get_timer_cycles() - start_cycles > end_cycles) + break; + } + + printf("Total packets received = %u\n", count); + + if (mismatch) { + printf("hash index mismatch in %d pkts\n", mismatch); + return -1; + } + + printf("Hash index verified on %u pkts\n", count); + + return 0; +} + +static int +test_hash_index(void) +{ + uint16_t nb_rx_queue = MAX_TEST_QUEUES_PER_PORT; + uint16_t nb_tx_queue = MAX_TEST_QUEUES_PER_PORT; + uint16_t reta_size = RTE_RETA_GROUP_SIZE; + uint16_t nb_rxd = MAX_TRAFFIC_BURST; + uint16_t nb_txd = MAX_TRAFFIC_BURST; + struct rte_eth_dev_info dev_info; + uint16_t portid = 0; + int socketid = -1; + uint16_t nb_ports; + int ret = 0; + uint16_t i; + + printf("Start hash index verify test.\n"); + + nb_ports = rte_eth_dev_count_avail(); + if (nb_ports < NB_ETHPORTS_USED) { + printf("At least %u port(s) used for the test\n", + NB_ETHPORTS_USED); + return -1; + } + + nb_ports = NB_ETHPORTS_USED; + + mbufpool = rte_pktmbuf_pool_create("pkt mempool", NB_MBUF, + MEMPOOL_CACHE_SIZE, 0, + RTE_MBUF_DEFAULT_BUF_SIZE, 0); + if (mbufpool == NULL) + rte_exit(EXIT_FAILURE, "Cannot alloc mbuf pool\n"); + + rte_eth_dev_info_get(portid, &dev_info); + + if (nb_rx_queue > dev_info.max_rx_queues) + nb_rx_queue = dev_info.max_rx_queues; + + if (nb_tx_queue > dev_info.max_tx_queues) + nb_tx_queue = dev_info.max_tx_queues; + + if (reta_size > dev_info.reta_size) + reta_size = dev_info.reta_size; + + /* port configure */ + ret = rte_eth_dev_configure(portid, nb_rx_queue, + nb_tx_queue, &port_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Cannot configure device: err=%d, port=%d\n", + ret, portid); + + for (i = 0; i < nb_tx_queue; i++) { + /* tx queue setup */ + ret = rte_eth_tx_queue_setup(portid, i, nb_txd, + socketid, &tx_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_tx_queue_setup: err=%d, " + "port=%d\n", ret, portid); + } + + for (i = 0; i < nb_rx_queue; i++) { + /* rx queue steup */ + ret = rte_eth_rx_queue_setup(portid, i, nb_rxd, + socketid, &rx_conf, mbufpool); + if (ret < 0) + rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup: err=%d," + "port=%d\n", ret, portid); + } + + for (i = 0; i < reta_size; i++) { + reta_conf.reta[i] = i % nb_rx_queue; + reta_conf.mask |= (1ULL << i); + } + rte_eth_dev_rss_reta_update(portid, &reta_conf, reta_size); + + /* Start device */ + ret = rte_eth_dev_start(portid); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_dev_start: err=%d, port=%d\n", + ret, portid); + + /* always eanble promiscuous */ + rte_eth_promiscuous_enable(portid); + + check_all_ports_link_status(1, 1); + + if (tx_burst == NULL) { + tx_burst = (struct rte_mbuf **) + rte_calloc_socket("tx_buff", + MAX_TRAFFIC_BURST * nb_ports, + sizeof(void *), + RTE_CACHE_LINE_SIZE, socketid); + if (!tx_burst) + return -1; + } + + init_traffic(mbufpool, + tx_burst, MAX_TRAFFIC_BURST * nb_ports); + + printf("Generate %d packets @socket %d\n", + MAX_TRAFFIC_BURST * nb_ports, socketid); + + ret = start_hash_index_verify(portid); + + /* port tear down */ + rte_eth_dev_stop(portid); + rte_eth_dev_close(portid); + + if (tx_burst) + rte_free(tx_burst); + + if (mbufpool) + rte_mempool_free(mbufpool); + + return ret; +} + +REGISTER_TEST_COMMAND(hash_index_verify_autotest, test_hash_index); From patchwork Tue Oct 15 09:52:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 61254 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 118F81EB7D; Tue, 15 Oct 2019 11:52:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 6B8F71E928 for ; Tue, 15 Oct 2019 11:52:45 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9F9isNV001955; Tue, 15 Oct 2019 02:52:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=jBduFEo+C1dqsdjaa+75q/nqQMozPOT68o4Bz5/C/0s=; b=l36zoA9VqABXgZ7vgbyj7swO0eySuWsn41jTKOuUF5k16eIc4XKhh905CsskJVy/wnzv 9mfg4WO3Akn9T+kc0ZqkZgmBOeFvoOWTcIfuzTB+37IYiSgGpTYZZxPWT43zcPn2IM7A fgytWFonfiBIHx80COgwB74PW31n+Thu0wMk1cERXgcFB5QHqWtFYya24MdLsraPsW74 5ILLvQRtj44MuQTdFerMavrf3TS5/HAIib+vv+M49X2GecRmVKH+9QAWJWZ40LOh/QQV oUKz6WZLbue04swKAk8oeH9Tz3h7YAWwJo+tv3+hYfGDiD/BAKeuwkRN3BeuEfnNunAz 7A== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2vkc6ra17p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2019 02:52:44 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 02:52:43 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 02:52:43 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id BE7CE3F7040; Tue, 15 Oct 2019 02:52:40 -0700 (PDT) From: To: CC: , , , , Vamsi Attunuru Date: Tue, 15 Oct 2019 15:22:07 +0530 Message-ID: <20191015095207.13249-4-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20191015095207.13249-1-vattunuru@marvell.com> References: <20190914055247.3841-2-vattunuru@marvell.com> <20191015095207.13249-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-15_04:2019-10-15,2019-10-15 signatures=0 Subject: [dpdk-dev] [PATCH v2 3/3] net/octeontx2: add eth dev op callback to get hash index 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" From: Vamsi Attunuru patch adds pmd support for hash_index_get() ethdev_op callback. Signed-off-by: Vamsi Attunuru --- drivers/net/octeontx2/otx2_ethdev.c | 1 + drivers/net/octeontx2/otx2_ethdev.h | 3 +++ drivers/net/octeontx2/otx2_rss.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 4a60f9f..eb41ba4 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -1961,6 +1961,7 @@ static const struct eth_dev_ops otx2_eth_dev_ops = { .reta_query = otx2_nix_dev_reta_query, .rss_hash_update = otx2_nix_rss_hash_update, .rss_hash_conf_get = otx2_nix_rss_hash_conf_get, + .rss_hash_index_get = otx2_nix_rss_hash_index_get, .xstats_get = otx2_nix_xstats_get, .xstats_get_names = otx2_nix_xstats_get_names, .xstats_reset = otx2_nix_xstats_reset, diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index 33fa0c6..b410988 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -471,6 +471,9 @@ int otx2_nix_rss_hash_update(struct rte_eth_dev *eth_dev, int otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev, struct rte_eth_rss_conf *rss_conf); +int otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev, + uint32_t hash, uint32_t *hash_idx); + /* CGX */ int otx2_cgx_rxtx_start(struct otx2_eth_dev *dev); int otx2_cgx_rxtx_stop(struct otx2_eth_dev *dev); diff --git a/drivers/net/octeontx2/otx2_rss.c b/drivers/net/octeontx2/otx2_rss.c index 5afa214..4b40dfd 100644 --- a/drivers/net/octeontx2/otx2_rss.c +++ b/drivers/net/octeontx2/otx2_rss.c @@ -328,6 +328,24 @@ otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev, } int +otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev, + uint32_t hash, uint32_t *hash_idx) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + union flow_tag { + uint32_t hash; + uint8_t byte[4]; + } tag; + + tag.hash = hash; + + *hash_idx = (tag.byte[0] ^ tag.byte[1] ^ tag.byte[2] ^ tag.byte[3]) % + dev->rss_info.rss_size; + + return 0; +} + +int otx2_nix_rss_config(struct rte_eth_dev *eth_dev) { struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);