From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0073.outbound.protection.outlook.com [157.56.110.73]) by dpdk.org (Postfix) with ESMTP id 1B1BCCF5D for ; Fri, 17 Jun 2016 15:31:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7S7taEQ0IR84Llg35maODjrVRH6nbCD8h7KxxkzNvR0=; b=h9uygNEXNX+aNTOo+RujJ9QNoI5MOm5WYyZo2pejNvV54G7WjEeeVfv46LpHWiDRkO7JPiRb8f7X/sz0ENUemrBW4OH59GJECbg1+OY5W9ZjIo5mS4Ow58x+k8xoA4UVjJRskdvI8iqieaX+z7GU/RihNftwVm9hbd9i7zibJRY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.17.70) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 13:31:52 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Fri, 17 Jun 2016 18:59:42 +0530 Message-ID: <1466170194-28393-16-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.17.70] X-ClientProxiedBy: BM1PR01CA0028.INDPRD01.PROD.OUTLOOK.COM (10.163.198.163) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 9ff31ba8-f2c7-432a-fde0-08d396b3c0ac X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:UoNVm217xrAng7AguvWsVrfC2mi46gKq5CG23CllhCwFNZtdpFE6m1PbA/U+Pa8ML3NGESpZXWbewxaIzoJrqL77LQl8J2viBIrSs38j1W0Hno8jC9RvAeMpS+SRzwEKxVknAvLAzPNCqqlghAr6ncvRbOql6UK3Omr6qPastyB4t/YVKACkf34YKQk2ttPA; 3:dTseMfLCL9xIqvjJDKrFU5lPORiJUlX2eCxg6h+gmU0uQAO8Mv+C0XXO9IWk1kFGU0ipv5Iw92UXxveGAo4LkUtbvBaAH0cV3oUKpLjvM9hC5SirYxNsrBa5q5k44cf2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:X9UNi1ayoYkYg0QFS4mE9HFbbJGBE4bCH3dHLMLH+Eqc/AIOGADJOr9rg6FJIz6/PqMwbL+eoEwa3JDqxnHQQT5xjIaXY3aLQWKwukPzo7D2DM2L0WlbX+vn657uNOFMemUuSDGN1MSjXonAoSVYX5xljvGb5A8fZLDfvPGruKWFsknTJK2c/cdxXnemfV6K/ntgQU8LdVRdJLxY6/SF2YdqSSa1cPjYBJd3Z5p3wiLV087/nyF6dbs7Nq9XS7kvu/FDt39E/R71k1EUk+noylYjPZ1IMUe0sgmAf8SJ+oSNagGvuX5sv2z1JS1vnw6JvXFHsvjVNcxrwklIIc4Wmm8ZzCvqW8X+UrzpOXNVPeH2c1Nge3BOCU/biFAntiQWX+jW/XQAPU8G+yh4/45K5lZgjd0VETHFXUevaSUJQ2gCPEQpsVQNsFCaHJdJfnoLsOmhm9KwDzgftvQQYTkbuJ2T2EGdnPX4pzP98V4F9lyEXpmNeigmcp2MJAOIvkbLCilNlloTtxcNyWvETmSlQ6Y8Sg2Xf/Zr4opV7qRWC6IF+e7TfXi8pbfmrNJgf/AQlhzQTkScjVyclAYYPkz74TEQ58Dov6/a8K034bYxbZQKtY3ro81lbFLEqRZ1RkatmilxBU1Dp5a6JsHXUa4+2kQEgRumGyOb8W7PjUAYg/NRlHWqhdYpwwk+9eNGD8v+6ndFxY92RtD8ZzR0S5SaLP/iso4lsx8f61B+i1thOV5B1MXCaps9WK1gYu2UlFQsvmUkWSVgWX15n77NOoyzJg== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:6hrcb7cQm/6L5StWCcwe0yoyq4jsByD1O0RU5jalbgSCQdEq2Ds+PUkrUbD/tsg8fEoSL78K/S8YLqd3NiQcX2qYSF4w4n2iwxJDx8EKdfaVI042reR9uXD3p6y0jm6PmkqO11/kaYzxKtjmZUv1aqBfIv9BUB+rQCdnTLtS8I8WDuSbPo3FhDBZ6U2Tk8SCI/G1opBvJ6DhQH3c1kifJdtuZKUu2FCYcrqdUXYqGGec6jPwu2O2V/QzH9sPNpHjPfEh3BNIP+ztwwcD6rgzafAdNhzZ9VZDN9je7Hg7OdHcw4/Gwg7b/XRZ0DdY576tI7XM0A2URPGRLIVXLc2TvTuac3KHycBQlnWYOLire5AwxwS9+oC0fQHrtre9sMJ4mnUlvr8qSbvtVbf7suRf/JlychT0B0XqPBJHovdS6Q9UyELx2hnxdfVTuPoJ9t3RbN88nRudXxdVAW+9ef3PxfL7EEQW5wuuJWYsZoK/vppfp9CHYc6np/IexMYas5QYsAJvXm8VLe3B5wVyID3oqk6r4KGzGtL/Ch9TP89uEghsv4hC4FbDxstsYI2rA8CxWNHII0zzxEB8tNdJA9YtOFX4ZLbdlZPgpSSLWRhC7FQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:gyVKvkrwjuxN+r1xljwK7eMLhz/Egotlv69O/6gLH0bzYyFrXTfBMjYiTklHHn7xFPc7XUCmm4LA+QKCFO/4hWp3LB77lFwG6Vnk29J6Nz3qssFBsJH4HXJGvv0heqedFe8vTNQzXAwBlCJ1PsUa/qtl3VfK2OuVkwJEy8afV+OdXER7Ryy4HTmRlcRMkY5wYxdtPNnXo3O1Axa4nksK4rcYZjyFPQz74/M7BXmq6Cy4vaoQm8y5lZtluen++fyN03nbU7gC+iG6RrmpBCVtLLyx7yeo19bKmf77e2+KPp3XqzWjnDATCCxVzLnc5PZlptH5iCB033tZarkTUHFeE/PzKAuz9K47lhU/sk1m87x3k3ti9sV9uSJNCLW/A3nBhshx1bvT7N20gTJ7wqMHOYBm65wK0BvxquYFQhDZJxo= X-Forefront-PRVS: 09760A0505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(48376002)(19580395003)(68736007)(2351001)(47776003)(229853001)(97736004)(19580405001)(586003)(50986999)(110136002)(36756003)(3846002)(66066001)(92566002)(105586002)(189998001)(76176999)(33646002)(42186005)(81156014)(5004730100002)(101416001)(50466002)(2950100001)(5003940100001)(4326007)(5008740100001)(50226002)(2906002)(6116002)(77096005)(81166006)(8676002)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1718; 23:+OYDFxh5FEb4DNcyIP/dqGYX5SAwgsPe87N8dIO?= =?us-ascii?Q?dtR2wxsyBoOTv4Px9bYwDEbzDCoOefzvXbTXqbrURgh/9xoTWFhuLFUcsYUI?= =?us-asc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8WFNOS+3lbLrlH+?= =?us-ascii?Q?+c2mSeyKT8EJqu1z0VG5VyfJ6wqKiIvE72Z5O9QuVzLgro56mCMMu0UQ9MX+?= =?us-ascii?Q?QLhPB4q5WTEvpljkbxiBSr6eY2pV0?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 6:p+v/jQMBH9mdf5iFYXVCDCUlmQURgmT4yim4KiuIr0B9iKCpcvdSH1BWkpa9u6P+8VOhD0qe/SEqpwBeHPxR+nJkdR7fBwFEQLrNGG0mZgdP+0FXsIyfoap5JF56aM2PUrnGnoEPGAkrSKI+fCKt3KurVAFOlYnW6Z+EIe1M/0oR8f9OoLFUF6x4wVZ3oDY+jSiVg2M+CMChDday4QQqK6A/Hn/n3uRVMNgu1qaCUmrhOfWfealeabnzWOmqfmXa5m2m9BU0F8uMnmy/4C0c92l9PLRHEEQciP2QyqAJCUg=; 5:gcyKrCpHPJtb4GFTxvTMi/m9BVwUtpFwfNwEkrHCtNg+YNvrGWMJInIl/SH0HLhZ4T+ndpTR5thvzzyJhoUXMwAB7k/Bfi4n2OPeCxnpPM2wlKTeKV0W0YaH2WaEXLCnc1aMuEHcDSlxe5aWu43XUw==; 24:l5kFOP25dcXPJ9k8b1xTMooCGsyp5y+aClDe2U+qtq96e++fR53c2lRLQMZQ4NKSXMjzUDEx0lx71hv/6JhzSi8GIsJktvtaowhUU72NUNY=; 7:0EKfDzoWxbF4C0MS0qWipKTfyfdlR9tlVIk0ylt6IfCaemD55lp/k4/C+7wsH23VZXC0R81ETFDlzHqpmIh6T2YMstpW3djjEYB17uCbcbZBJvmRj+bTDFzooaNnBiH3K7TgZBSlXVArIMYNbEr23n8WHHM1HyTBRjGrAo/RzN011gnYExnLpiBQMqaP7aNnfQAiMiO+gW6g7xAWBYtABQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:31:52.6495 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 15/27] net/thunderx: add RSS and reta query and update support 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, 17 Jun 2016 13:31:59 -0000 Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki Reviewed-by: Ferruh Yigit --- drivers/net/thunderx/nicvf_ethdev.c | 172 ++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index e786481..08f65b3 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -168,6 +168,174 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs) return -ENOTSUP; } +static inline uint64_t +nicvf_rss_ethdev_to_nic(struct nicvf *nic, uint64_t ethdev_rss) +{ + uint64_t nic_rss = 0; + + if (ethdev_rss & ETH_RSS_IPV4) + nic_rss |= RSS_IP_ENA; + + if (ethdev_rss & ETH_RSS_IPV6) + nic_rss |= RSS_IP_ENA; + + if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_UDP) + nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA); + + if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_TCP) + nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA); + + if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_UDP) + nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA); + + if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_TCP) + nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA); + + if (ethdev_rss & ETH_RSS_PORT) + nic_rss |= RSS_L2_EXTENDED_HASH_ENA; + + if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) { + if (ethdev_rss & ETH_RSS_VXLAN) + nic_rss |= RSS_TUN_VXLAN_ENA; + + if (ethdev_rss & ETH_RSS_GENEVE) + nic_rss |= RSS_TUN_GENEVE_ENA; + + if (ethdev_rss & ETH_RSS_NVGRE) + nic_rss |= RSS_TUN_NVGRE_ENA; + } + + return nic_rss; +} + +static inline uint64_t +nicvf_rss_nic_to_ethdev(struct nicvf *nic, uint64_t nic_rss) +{ + uint64_t ethdev_rss = 0; + + if (nic_rss & RSS_IP_ENA) + ethdev_rss |= (ETH_RSS_IPV4 | ETH_RSS_IPV6); + + if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_TCP_ENA)) + ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_TCP | + ETH_RSS_NONFRAG_IPV6_TCP); + + if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_UDP_ENA)) + ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_UDP | + ETH_RSS_NONFRAG_IPV6_UDP); + + if (nic_rss & RSS_L2_EXTENDED_HASH_ENA) + ethdev_rss |= ETH_RSS_PORT; + + if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) { + if (nic_rss & RSS_TUN_VXLAN_ENA) + ethdev_rss |= ETH_RSS_VXLAN; + + if (nic_rss & RSS_TUN_GENEVE_ENA) + ethdev_rss |= ETH_RSS_GENEVE; + + if (nic_rss & RSS_TUN_NVGRE_ENA) + ethdev_rss |= ETH_RSS_NVGRE; + } + return ethdev_rss; +} + +static int +nicvf_dev_reta_query(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE]; + int ret, i, j; + + if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) { + RTE_LOG(ERR, PMD, "The size of hash lookup table configured " + "(%d) doesn't match the number hardware can supported " + "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE); + return -EINVAL; + } + + ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE); + if (ret) + return ret; + + /* Copy RETA table */ + for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) { + for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) + if ((reta_conf[i].mask >> j) & 0x01) + reta_conf[i].reta[j] = tbl[j]; + } + + return 0; +} + +static int +nicvf_dev_reta_update(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE]; + int ret, i, j; + + if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) { + RTE_LOG(ERR, PMD, "The size of hash lookup table configured " + "(%d) doesn't match the number hardware can supported " + "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE); + return -EINVAL; + } + + ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE); + if (ret) + return ret; + + /* Copy RETA table */ + for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) { + for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) + if ((reta_conf[i].mask >> j) & 0x01) + tbl[j] = reta_conf[i].reta[j]; + } + + return nicvf_rss_reta_update(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE); +} + +static int +nicvf_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + + if (rss_conf->rss_key) + nicvf_rss_get_key(nic, rss_conf->rss_key); + + rss_conf->rss_key_len = RSS_HASH_KEY_BYTE_SIZE; + rss_conf->rss_hf = nicvf_rss_nic_to_ethdev(nic, nicvf_rss_get_cfg(nic)); + return 0; +} + +static int +nicvf_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + uint64_t nic_rss; + + if (rss_conf->rss_key && + rss_conf->rss_key_len != RSS_HASH_KEY_BYTE_SIZE) { + RTE_LOG(ERR, PMD, "Hash key size mismatch %d", + rss_conf->rss_key_len); + return -EINVAL; + } + + if (rss_conf->rss_key) + nicvf_rss_set_key(nic, rss_conf->rss_key); + + nic_rss = nicvf_rss_ethdev_to_nic(nic, rss_conf->rss_hf); + nicvf_rss_set_cfg(nic, nic_rss); + return 0; +} + static int nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx, uint32_t desc_cnt) @@ -601,6 +769,10 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_configure = nicvf_dev_configure, .link_update = nicvf_dev_link_update, .dev_infos_get = nicvf_dev_info_get, + .reta_update = nicvf_dev_reta_update, + .reta_query = nicvf_dev_reta_query, + .rss_hash_update = nicvf_dev_rss_hash_update, + .rss_hash_conf_get = nicvf_dev_rss_hash_conf_get, .rx_queue_setup = nicvf_dev_rx_queue_setup, .rx_queue_release = nicvf_dev_rx_queue_release, .tx_queue_setup = nicvf_dev_tx_queue_setup, -- 2.5.5