From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0093.outbound.protection.outlook.com [207.46.100.93]) by dpdk.org (Postfix) with ESMTP id B7C773978 for ; Mon, 13 Jun 2016 15:57:21 +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=ceg4TwyUh/73pvJfEQ5sxo+bbCo8udDlmkRZ4yGWrro=; b=RGEi/PX4tDbqlDkFWUGvQTV+Nbh5dSIuWyYLDiwSimb0mcFGNRQ5IK28YV7S8tiCrbuskIjxDrgkOmReyQajBQhm2Cr9lMl2LOXYpoppkxqF5yO5MYSoAj6FLBAUz6l0mMpTakjtg96z7ZRIWWBC2VaFzSe035chD/rbiJ0LYEw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.21.3) by BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 13:57:13 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Mon, 13 Jun 2016 19:25:33 +0530 Message-ID: <1465826143-22159-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465317632-11471-2-git-send-email-jerin.jacob@caviumnetworks.com> <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.21.3] X-ClientProxiedBy: BM1PR01CA0031.INDPRD01.PROD.OUTLOOK.COM (10.163.198.166) To BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) X-MS-Office365-Filtering-Correlation-Id: afce0acc-6095-4a63-7e3a-08d39392a160 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 2:n8aWbt8AKZLzaw8KPeszCMbAs3rpySNUybpqnyfLe9k2Q1e+Qg7xx2hwuLYYuybo3cQcr66S2aBeQTKoMeS4kZJ3PT5HKDwW41swx+aKrCX/H7XsEzC63egYHCFI8xPFD6zdZ/FG+1LtZ5H7/eXRdUamekAXqA9h4LRmrByIswWcwroWDgTfzSES18FarwDp; 3:OqC3HVccXtKvI5p/LtmqcuCNhLrGe/rjZYx4cWYmsorsjIAwA4291JinlnPw0ywrY5inSN1OaNjbzQlo5Dd5CeV++N2/6XTtS2yGwlogF3Zn/J14zP3VwyqP1bwufWlM X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 25:7TxOPKCHK4luhd2fKaZEBzRPWo9S7996gQRPStpk3hj33vZoYYCBW6JvxU/gjYZ5aEA9y5aZtmfxBNQhdzS2GDW3GiThZrnqaxuNNzblqOwto4djqqyy+OXq/2siG6SyoBRMdVG2yg7FY8ls+oHtSm03wDDac+A0C2Ay1idom/lZJuKXRlYG/ioc9QjXZfIeNdNFHL7LQUv/7lp4WDcJj3nTN92e7lKBHlKlgrLZwZKPm1gXOHwc7suL7xqKOLh/u9vg/KYJxAosDNgQzYA5wcV6AyxuXsrqR7SK9ZD2t61NmIK6kJPHSoLwKhwPM4+H0C2oZFIIc3AtTrOQ+EaDZuPEym1wF96CagoN7ufJRRMUQ8aUN7Yy8YG31FAy/1o9lm5nNL5RtSbOIAXGHquf/IoBu6ARYLaUaFvx7n0ThTHBlIlX/P1rj5UvLJnT2AiNh3ikx+1YZ6ll5iGJYL+Mu23tgTisnLX4mZOQfpFwxYLpPRA6XvGDJhoqZIA0sJNmpQWgfyjhCtPJwNqCr00nnguUYiLD0lk0jGqrCBYBoI2lqmKaQp5ma478Pv+11vUWh+u+ZBCDBGuZjGdN/lYnqbj+9niOfS1o6pRVi07J+HeyLRq0D8l8qfdvakec8zBe6fUvbUcUpBNdoGLZewu9HUdglFRAirtd5xYN7MFwMkg8Y0jR2nsrBOqchL+UomhaV+vcF9SAtoPu9bK5yWrt7zoyRggiTx8pwGdrw06DUxMIxDK00a06mqZdzr2cBm+44z6dap7ZQRbiFWgwVf8Q0g== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 20:G0m+IodWUAlmuqb0lsRWj79TVZP1YutPgtwhyxgCK8/D8VXl/rQ/6U/yuRnKVcxH8T7vUm1EVgBZQvONc35pdxq4KwFXgpyaT4FSUB+XCAeG7x49pP/2892SFx8Ds99YVmU811fL+IwmAJDZEezK5tA3YSGLVx3SbsPDfDpPVoJkN0e7qNOi1I5ZJK2y2Sw6tnjVCdXu3hKBba9FJLyxUqN+VRvg0Rsu1XyDqu+ZQVQqSNZvmGKC/B6sQMth3AvRhWhKlTRFOhQfjOondnKkS09yrNXAEAm4g/Ms/w2S0XJxanO/VbKuFIwbDcQNkxLGmykdt3YhMBigsCYoSO7ECuPSQoNjb1WbNDoxXZgAY2skjgC7VSX6H2q8wLC8pfmhN7yUCNhBiXAtefhR3SHi/aAC7uUCV5XR9P12wf4HmoFagY28nPHjgGE3XAnl7qiZFNzTjnwROGNAaJcE0p6n0kB2IYl+8l7WoOQpFFl6rjrertJIOCwGXf2TmAmXenBvxpuy5hM6g+EnzYSLSIrjMkR4EShpiIVp7EbSqGTXo/GwDKswRtBIOya2KRB4J359MObZQtijHqj0SD+RqoYdk3YfdpDQ99Jv8DjEDyFBU98= 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:BN3PR0701MB1717; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 4:bMcbzsRPse+uF9vnvDKDcK8A+ZNGolPY3Lcq63GEQ44uqZqllrEkGo6ymsUUbQstnrZVivNEnMZWo+0Zm5drhrmgqk4A+YIB1r0kQTXsTRwWXLMC+I3xw6L91wvSL28OL1s7sBkOAN/yIlMKZskb5t2+CZ1Ap4lipqMLxxsUPZYBVMeZUgyFteqzG/tmxB0XI5NznlnjYXJ+fF0xmLudsdDqGxQjfXcy7FX/1ERV4z8aOY7Swn6TShoCSR1ZVjUgfJ034mFVfn+sFQuPGBy/Ljt/XkVqlTW+sP+XL5Bh+z+82epno82mo7ilFpRe9gcaSOEp4xc9hUEX8HHDsxVSnpGabGNR/AMjDuNUTB5Je2AqtZJQ7CR12P6Ud9VveasiM9xscBZHYQsv7HspEk+x/gFpnScCx1fOp+pUecDXn0M= X-Forefront-PRVS: 0972DEC1D9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(50466002)(48376002)(101416001)(42186005)(50986999)(92566002)(76176999)(105586002)(106356001)(33646002)(2351001)(5004730100002)(47776003)(66066001)(36756003)(586003)(3846002)(6116002)(19580405001)(19580395003)(77096005)(8676002)(2906002)(81156014)(81166006)(4326007)(189998001)(97736004)(2950100001)(110136002)(5008740100001)(229853001)(5003940100001)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1717; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BN3PR0701MB1717; 23:hCVW1H3oIw5GdZa+/XwKGnEkHnryDo/qhzTCGlE?= =?us-ascii?Q?D+evUBp+DRA70tLW7qBG/mnbLBaznZHP2vNEuGsdesVkS1B6oFArgjQu8n2q?= =?us-ascii?Q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050B2AJ+scIxwLjW?= =?us-ascii?Q?LE+vyAqXVcwxcszjyV29/ceoK6SpbXbeHHvnrXgnPm25lFKVTWeTJtenMPE6?= =?us-ascii?Q?4ZNUuS6sbuCbleoetKXQr2MQfYbU1?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 6:w+kfesFjdEsRJRLNxcZGAGjg5w4ZTkTuzHeKeeHrtz0zIzaDtIHgPOyWtXnQVFNnoB4oqxTcfvQXzWBT7WIDo+lloWtiHCHHqrB04RPffHu18hlvRKNrYe/vBAe2a/fthkJtbMdHqhbm6jdUr0gIbK5oQLL4K6QG29eGvA/xhh9+w8FURfeBITKbltlXXDyrEejOXbOmrSRW1clE18CZcIlUn6I75TwtjP+UGgSgtBUVO8RIo1W0sdsDd44faqXVc/G98xg2JTOo1Fr2wRtCdyRFBsa9pk2Qx0QHQOHsMoU=; 5:O1jBoCgyXRHhhCyggv4AfOuvt8x6+byED50d1jNpx8gwoigJb7McDoQp0LgNgsaG9izDgDGIn95vuZy7rHt5wPI7VCriLfKaom3gQxeRL0HoooQFGcwziY8xxcW6ZVv6hSpLH/O0xyFG7bsolSxG9g==; 24:P6wVPHp3F+hQwXWBufCtj5uHbA6Up94ILH2yXDR7hhj8EE7V9D9NkViZ3DegB5gNWUKk7txNK+gmHLhy0s7Du0TjOEEvPymVIq1wbMldhE4=; 7:5yhiM5kevof+WQtrbtZsyZpoYjMGoHQduDT6TwwBwfjUyubEpQnwrFFwKrarIhsfGTVQp4CcQOVuJjtGUnnwFO5yGQ41nqjnXoTgb+wQ3UZqPdyY4HFvvJcj8AbKwa/S3oT55bhF62AN22b0f2b3KguWvQjDwM5O39PhQu7CbXOhX1yvzUihMMsS0bn2tjvSWDGmeF3xp0weBfS6ICT+AbqOXII5DTvSqlkjCBwwQOc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2016 13:57:13.3254 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1717 Subject: [dpdk-dev] [PATCH v4 09/19] 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: Mon, 13 Jun 2016 13:57:22 -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 167149e..1d5bea7 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