From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0054.outbound.protection.outlook.com [157.56.111.54]) by dpdk.org (Postfix) with ESMTP id 1A9B79AE4 for ; Tue, 7 Jun 2016 18:41:57 +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=Sr5OO3xFleZ3bs5z/4+yVVDN3/rgOZuhONGgc7/gxik=; b=EAxqMk0HlLr0dyGZG4p6gofmGxpdOUqlmcdXLOBe1ffIBMsyOalea19/Lr2qzkGHYEzH/XuGGE2L5MeZnFDka0xZRdC0+SjweKIUAjPuMTKkyYe6T3bl8/sMWHVJOJLG7p7jS1aGVOwUOtAThg5VitiF+CfP9/qbkVD8up/TQBI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 7 Jun 2016 16:41:52 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Tue, 7 Jun 2016 22:10:21 +0530 Message-ID: <1465317632-11471-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0054.INDPRD01.PROD.OUTLOOK.COM (10.164.146.154) To BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) X-MS-Office365-Filtering-Correlation-Id: 2010d679-aed7-466f-3785-08d38ef2a2e8 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 2:1ArpAKVjkoXNe9gnGJTw9qAMY/dHKKDAKPsuS482NnGOsjxA3hi5MecPCuHscR13uImMvXCO38egteLxDcD/hFu22Se6gEbHcrdS1e4wBvsLjI8rK/LMpAEYbW1vzBaIzH/z/xknz0LaPs+izSfjUpYHuf6NtNSp41ElKIHPY0jtGSwq/tEyrPI+TIdwJy6p; 3:njJRXvCmH9fdOwxZJAzMBFbXNgoFe5yVFymf6mZXAmFxuYgC8jvguogU74VzitCt0LEnfm74e52qo/HLCeNM1lIrDbx9femOHjikKyoXW1XfBSRc6SMg7kNS51UmufY1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 25:o/e/xBzVvASpeiyd3SpRW2bY+eL0oScI9Nmnu+wHjbA8Zz1q/lWyXlSTmQ0lImRAJ4yWQfLUaYXvK78ThRxlAbjVndFOIHtm6UQOLoBcg5mAuwN0as2zFLPE2yapjF+lyi2vyw7PqVtWBQ2E5Ln33OhtpUyk6QzwUjq6pB2fEc/t8Ul2V1+sBgj7AvrD3k5u5SsbNqO64NT/1SJIrLcalTx5cHW9pDI5nZididcA86ix1zOy8EunnaY33oP69nhinL7bSuAJxEj+ai3eiJq0+zwxytIs4U/5mJ1VMIcbr7kvZEce3C4AHvH1u0eL0gK2BDuKZJIbdF41kZ2yw6KXSpxFeJiNyJV9okIR06UZ4i3nix48kH99vhlkNJ/PFyd4h7G47ptV5Q9NJXzCOd3aSfnuGrNcyOznOmnrp1osogk0lw/uvGsr6PTozWUjrVhEryOxCs5q65MF37aBdPt9VMr1yfZjT7dmitOjDcswn05ckGNB8CVVwOd00wI3R3YwZc8UEprCBfif0XRlPVM1O0ZfucTP5G9zsDSuiJWaJ9K0DtadJXrXvS65oNDdhOfJd4eaMTzHkrMlMVnQLDTjPE1LfqD7h0Pmym1fX37MBZ5HlTkETr/+DxZKq0fG1alWsA3ymTgiIISPZcqE71R8asw6/EfN7QRSj5CTFJ2uHH7nPTooFq8ErUKOzfXe7tGsegiiehtN0orq0Pfk+LEbbiYic+1fvCMc7SakrWAWLQ37kmr4W+VPwr0n4vBN3UDx X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 20:6qIBnkuDZyEmqYYElvKpbsO04ffqcWU6bSUPoG7Y4qFXLQRhblST7OXbuuqeBUVNXy0/Zn7mtcrjIyNsT7fdrCNKG0Fq3S6R+nu8CSgnIdMkH73DkS8M8LB9LyvIwSQ9R6DbIsoBWITndSDc7aSlc/WZuvBGbMYa5O1hsP8++SX1YouDh5AOxQ4gWim5QIP5xZCxZyegZIUqZsWsCO/nZMP0+6tq4PD5MbJg8j5Pmb1/DelkirITTeri3Jhl0D6Vwd0ntWyThnroNCrRuQ0rbDKnbT27kZmNW5K9NF5ttHwJKzLe8wsr8Ap7EXpqen+83igUBpRBVmgqb87bqluQNscotHA53ErV0r3R7U3C332hpFJ/lpcQqQjeFHiUAa2iITxVzcNmTiyZr8LPGnI11416q65AJtAV2le00LJTUS6hdA8KDuPJEIPhGUfSvqT+Yck4WZ8LM8AQwjTKVFNaAiAGt80NJOJbP7WVkvDvfrCJqKiQ2f4S/QqrfIifEDILTL958f6vjjabkjHO95WXTitu28PUDWea1WeJJa3PcLXWx8f6hAYKFgekUtvA0Br+Kd34Tkhki0j4T1J8257f9fEuKlljxnRP85BfNdATTsk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN3PR0701MB1719; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 4:fKZazU58netH1DVaaw7wBRLJGikuCqMvbct1cSfPx515tSbcdxALAuML3XlSykgugfzrbtcQ52n9mmed5k/MSimQUuSew+HWB4Pue0TX1axxhAimUcwSEI0kNEUIY68OcuZc8BaL/VZRmLkSeH9xOcecqgCpEEJfyQy3qLF8awqxMhep95fbn54G5xkgjdj4rCPjPuLD1qOLxBLwewmCjX/jd4d5MuTZRuCem+Bf6L9Qg3lQMiCW5h1E4hY+rhr05y9po/p+Md73RhEK/g0hg3BVM9R0qoa7jdgeQPcsxpF5TCTL8K9iyjHnlF9n7IEPDSshmQlcVy9WAvuwst3bc7wDmsPHaTtsAYalkLamQKHjI1/r1v8aJtrHdCg2O/Wd X-Forefront-PRVS: 09669DB681 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(199003)(189002)(81166006)(8676002)(81156014)(47776003)(66066001)(36756003)(92566002)(2950100001)(586003)(2351001)(48376002)(76506005)(42186005)(50466002)(4326007)(77096005)(3846002)(6116002)(5003940100001)(53416004)(5004730100002)(575784001)(105586002)(97736004)(2906002)(5008740100001)(106356001)(189998001)(19580395003)(69596002)(101416001)(110136002)(19580405001)(68736007)(33646002)(76176999)(50986999)(229853001)(50226002)(5009440100003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1719; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1719; 23:3UtZARpWY7fuKh7Rx/C3NpQT+buHn+OStiyoIX5?= =?us-ascii?Q?j4se8HEqdWh5wRTyyJlcmvXeBGjNB5d3qlINjfupP5Xko7gmftM4j0V0YUQ5?= =?us-ascii?Q?/UNfoPXQ4rZyLe9g8ezWqUZfvNMtL2V6yP3YyINlSHDlajWxR2+YZwhMPiGS?= =?us-ascii?Q?phuQ69pJV6tflA4gHS/ga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XRiRLG2?= =?us-ascii?Q?U6ADnKVYyh/GZ8ZwQzgVysyAHMCADZ9tc5sNt+uzvtHlHinN1niO159TfjKb?= =?us-ascii?Q?surBD8k/nXrpmJrak/I1/Raw6zb/ah7erGToCRZUpufUXOCitwtnmbHrJq+h?= =?us-ascii?Q?G5h5fOlBdAW2vJiQ=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 5:MuY3fYuWIKBQUY3ABzEnAuQyYarLWkkaRT1ArU/s2pQsW+azVpwCJ+1lXgqjegKGl1bTZEY4ONcOKR2y5R4t9Ka6Ns0BMUlaIh4CbnetBnS5lmgek9kxRmLWBG98L8EgSnhNI0K+1AmcWP3sOhQy6Q==; 24:8IziuBbQtXHcvHgsTy8DepXMqbdzescCidR3sb/L7kZVnIgQrR5PBPAR6VE3oaPHjGFwExdkTdeIsbK0WUZ7r+Ac7WqIeTi9RQVPgO+uiWQ=; 7:BApmRyIdmr2cLkuQNvlR7YD9LJnrU0P4/HkY36Ahv7TAUqrzypC7+VgNsMciAJcs4wTFXcm6QXR5HGkSAKJGX2GrLVIyVIddQtu++F6d2FlKgS8l8P8JwVAwfqIk6/46PNVvUrJ1L/mgUBLUcH92iybd1O52VfOKI+7YXFfVbiCfXO0ZCLQmEF3QhAtBTD0b0Ne56oW1tILjNH8j8abwWmPzsteHm7anfTcLLAvO2uY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2016 16:41:52.7118 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1719 Subject: [dpdk-dev] [PATCH v3 09/20] thunderx/nicvf: 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: Tue, 07 Jun 2016 16:41:57 -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 --- drivers/net/thunderx/nicvf_ethdev.c | 182 ++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 0891a26..efe0e05 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -73,6 +73,16 @@ static int nicvf_dev_configure(struct rte_eth_dev *dev); static int nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static void nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); +static int nicvf_dev_reta_update(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size); +static int nicvf_dev_reta_query(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size); +static int nicvf_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf); +static int nicvf_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf); static int nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, @@ -185,6 +195,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) @@ -618,6 +796,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