From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0070.outbound.protection.outlook.com [157.56.110.70]) by dpdk.org (Postfix) with ESMTP id 10B9F5AB2 for ; Sun, 29 May 2016 18:48:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=fZlOkWhUTdivdvcZzr/745oP8cWR0Fr33fdW0wghMn8=; b=OvQlhP4jZMDz9OTH9xCWgwEVZIXThxgPM+whFovBeMciYkDxNnVPRDIucNJOnNeMn/l23JJEs5Dda9Z0mKfEcSa2ZADg74n7alLevZNQCB/4j2exQkQWCehigxmw1XjVjV7czf0hTEsrCNYMk8GOl6Kv6XGdDnEYvHDaCeoDSq8= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.187.184) by CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) with Microsoft SMTP Server (TLS) id 15.1.506.9; Sun, 29 May 2016 16:48:42 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sun, 29 May 2016 22:16:53 +0530 Message-ID: <1464540424-12631-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.187.184] X-ClientProxiedBy: BM1PR01CA0003.INDPRD01.PROD.OUTLOOK.COM (10.163.198.138) To CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) X-MS-Office365-Filtering-Correlation-Id: fa72b44c-ace8-4b2a-6cb4-08d387e119eb X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 2:IOrvBttqWYB1JnWZJt4OalDC3PmaSJxf25PjG2JAB/MsMF9NoTuznNFqKZK1KN+R63/n41DRHJd8+wY7f/7lOms1+Qa2RIoZX0DxX/7Ml787iNqdAHGBhYuHavDfIAmL5s1hSB+HUL9TxcuFnvdqsrNxrHGQ3TRyl7C4a7YnTGm6tqSXNouNdy7xa5S233lx; 3:pOtnMKxEsJ8M/AQQ6QSVZZ5PNWGf4Cuj+n497Cb9nNazQKiAkgWfyfJlVxxxsoEQ7OmFIkIjs4bWkB2gCfTMAPPAuGPqFEvr7T/UxbvZbReKh77DUijJgq0XUtgvkeRW X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 25:y6KKonO2Wg6vB5UFRnkvmY8DEDaqsbEWhx10w3fwn+RbjO3qnY+fh3W0ybCInwQIyxQsVcKxhwE13f84hfv8txYIqGvXE5wYoPfLvq039gJohI0X/+tnqgjaZz70p6LHjscc180m5jeeuufUF09NIq5//02+11gIXupH6vSSUfMSIPJczCSY/bdmEgTfn+wrIzzfKiwjFDSuiLsuQn+JOU0S3iTP6M5t/EJdiTTFfQPV9rjy3cHaSoinnzvI341y7EZFmhau2ZKXQ0aaKG1T/EjpDmplIgU5Kum71XfoqgrSSmK0+Oa7F7Fra2+UVDhNL+SdZDEey6wovUrUV3JpvlgKQbrME9RjUdnjM0KqbAX2CeLtFagBU9JZct6mLKWBdz9e8oOhoEvAkfwZO5O7j6L/7r1c9luLpU/wnKSxtZIXgpjLrGyA2gVYNUzgi4TKU9c0vrP6ZBZrfPIXOIqC3yJg3ym+GSxtZlxWKjJp/6ViF7o+hRG1xtrgFM55yvcqObZlDj8M4fFmGO3Lqd+ms5t09ISsj0jyKVCdnkp79kQFW3s2ZqgkCganw56hChNPlbJRYrBZYLXA1wx8uamtQbn30aCrm87nHAkw44DTBMdXOcDIOoBjKnKmLSQ6Z4KfJdHOtnBZ7cDvB1NTv8tceyxLpY9eLaLkMF4lfZaLWpdl6SzQc89NuNtaWwWQtluP4FcrYoeAYY6AY7XwovVFxQKwOm8pM1PxS5XXa75hNiHJ3ePgMCNKj5uFRneSBiu2 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 20:0FlJHH/MgfTH3SGjgKehdx91k6sBHJhbxZBoMWhDh1I+JW4osyc9fdPDm3X5AOqVgH7UU8pKGu1CQdGf/icpEwXeOUl8sIJmTOwU7ja/LwKsiGwNuHb3uwZUXilkV+Ax8RIxkLvMDXl5/xasmky26DO/V1t6n06LCiHQVRwtEjiFww7p/HCi9PywezUnkZNRt46s1v+GHpB9r5js5muEdN7CQMLoyx0TMNC/3VYiLch4hBWY2QFgKT6DcCBgOoMb3UmiK1kbKDuUjwjahVrUu3GYAPiLCDgkvnDlWMU7oN9srQe6P4Ll5UEcgn/G/5ZdGnlvwohRtLNzCMnX/NCINJ0MRJCAUv5f7cb0v5o6gslkiFSwCYbQF6moze0lrpBn66tLxypLwBPmzeqPfj5FCzrg3pr2HFDtgS6O9B0hxM4FeyQDyBEeJBKLFzLU0UCFA4UvZ4FvNbWu0tzxeYHjAWGE/kv3NYyCiXPM3B77qJ5MZ+97e7pKN8nCAJsAm8S/fMDwTfFgGb3ap2mwBRm2fOHKuo8kPVLp3dDF/KAw+IVWPgrby13RawnlRjd7NINjjND0ay7wIwePdXOG/q2pJP2rMzqeuO6wLHb6Ybely1Q= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:CY1PR0701MB1725; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 4:vzaPLx6BuSF8aGeyTWm02qvOZ9V1SZrrkcZvJVE4wg33xudI18wv22PKWMKyhAOJmir4aSp4oIfTEZhnSvoG4oMkjHejPWA6ISOvJCdr+02yD5aKn0c8z7R2smmJUjXSRTc9PtN85UpeObC6SPIeUriz4wlc3HSnS/M2/WxpMgnebXhe08PUKo6sFewRlL3JpBI6jTm5scA/ABGHPZ6G+z+S63wNX4PlRNZTKquIaw4Js7evR7wdx0aTCoSPGHg3rqMl3DG2p0NhMLp5e1QH8mIzSGzh3FU77veSOzsrVo4/Kw308ie+tuZE/Qhe9971LqVUhQobMJgRH4eFk1azGtVWk+Rbdv3fGbV54WDpRXnB3q3h2LhZbJOlbsq18Tme X-Forefront-PRVS: 0957AD37A0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(4326007)(92566002)(189998001)(2351001)(81166006)(33646002)(76176999)(229853001)(2950100001)(50986999)(19580405001)(19580395003)(36756003)(50466002)(110136002)(8676002)(2906002)(586003)(3846002)(77096005)(5004730100002)(5003940100001)(50226002)(66066001)(47776003)(48376002)(42186005)(5008740100001)(6116002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1725; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 23:rJULPuT36YMR8P0wwyCYeHNlF9PSqVgT+AUC4OfSCOHXIMSzP6tfmJP84WWmEMxx4wxrXI6AI0R4+cJe5AXgpJs7mEluyzbFOBnZ54U4XBYlYg/59VQbKTnlp63TmjfpD/gDcQ6K7aDGaWEvXi2wQtFxISzwZpoMHiPozytdpsyYBM47xDV/XbGK/BgxuzhS+QX+C9J3zkwKUe+jP4oOZ6/+s3Lr9jEzrlqfaGeMPGMOVQNxf2IVRpWT7UslUKiP65iqTCgeFgG12t3I29hfNWxFO9ijWW1IrqvH2FWJO86zNUZ3dOZw2t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oCzl SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2016 16:48:42.3496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1725 Subject: [dpdk-dev] [PATCH v2 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: Sun, 29 May 2016 16:48:48 -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 3b7cdde..87286fe 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, @@ -207,6 +217,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) @@ -640,6 +818,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