From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0078.outbound.protection.outlook.com [207.46.100.78]) by dpdk.org (Postfix) with ESMTP id 39AFD5A9B for ; Sat, 7 May 2016 17:18:26 +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=okyyXfwbYdX02nOkdt8bN/H0Wov1hHeB8VmK9YwohNs=; b=VvM7DF5MqDA69+xLmwpo/oeFvdff8oQ+lvkvVZxqgJwZLg5O9hV4bEmYlNyEAo4c6do86I3eU4P7xQXVSrITMS4zF1+XQeK8DtDprMnmbFlVpemTQG+1lBzs94iFnEHKusS5/sC9jH8sOfo4MiQauLJVFZV02i/3J2Px9SknZac= 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.10.92) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.492.11; Sat, 7 May 2016 15:18:20 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sat, 7 May 2016 20:46:27 +0530 Message-ID: <1462634198-2289-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.10.92] X-ClientProxiedBy: PN1PR01CA0050.INDPRD01.PROD.OUTLOOK.COM (10.164.136.150) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 58a4d678-9050-4402-af3e-08d3768ad599 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:xj1Zo4ajbEfDKIrBRbXbJSyjpWZl7pw/zh3QGBQwHEH8zhCT9rjJDyTb9M0YzliQoBqB9GaSL9bEZzoUVmsEcmMtf4sdIjNChM6FVc4YE/RY+GyL38MvWybiqifpF5CvD63KyW9fCRpfatEed72zVRtYZvHUuXh9U2RM7GJv1lljws1LhFeQZ/uHyepqZ7H3; 3:8lTfKoRWFrp0459DutlLpUC3/60yMVzfn8WfSENRiKWwXiM+7crAxCNeUD/sn09bXENaI55csjP04SHucbqfHGXCeqDyvoLsdnO9UEgsgDD+QGCGqtWCyNNGafdeAO+T X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:1Z9x3295YADOZpvpJ9zuPIJjLwDig1ZjwAVZHzzxHAC3KSpNMJ3KiQKVQBpV0l9be5+YHbtpExyeoPJVWGCQjJX5+nbxCj6gs2RoCVply45hsxGyYSNhTBWZcqaqmmEfoQFTAFV9badxVYK36YV+bE5CrIXoB1T1Th6CYqc73pr77qOIds/QxKN0soVqtjtteuuycLf99FePZLykuOheVOOiBxizz3NR5an0mslT8Oo4ACk0ghK13SMuXhhbrey1g92F+WHbp/+E6bNHJjIyELqZZ5JuJ8fefCzY0OMyV0erfu/EmVDO25mr8PPbvbB9rNmHl5UoxQthV7HV1hOlzj/nBNVkTvVVCQMuoSUzk4FVgEteuxKOQC4Hyy5ifg4aBSXTbO8IZob/TVIcHe7/c7KXTAvYB1+WVUac0TKOENKzMWIIeMbBZU0IJ718lzaL7+QnRX2Zh8VwK0NOBmc/kk6OVMRR0iU8dag1e+j4GsRK23V1MSERvYfFHlionM5hJ1/PL6qg8qjNMLthDj1bP2j1WusdP7LKrbRjPQQRtfIul96lbrzhtnP1HYMQJr8DQqLR+Txh3Yub6F6H3nhgB9pS284/paS965wch6eVWTcIcVQQx8mVRltQxLR0SegGSVJLBb6hU0YO3bSwikyfOkkeMpHMMrB25/M8bF3hulgkqLjAUZ92EmxeAyOw9Ctj+b4dbkK9AyxKDjVHSt4bUB4Lsii0J+js9YTkegmtYaZnAIaR5QpPbl9z/rQgIXmf X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:Uq4cyQMEYMtoHcA9Q+lfovpEZHlnWFbUWYEgaU+Nt6WZ4d8EiLKZWaRKikPUcFUqvExhMa8vmrs0A3zrNNGkAFgzE/wco2Rs0P03Cqcxrol9mrByrDrRvnR96TqU1KoXJoH0cxyfwO6nK9ijpboiBe/taZ87pKIk+Hfejqe1Aai08JiYOVeebf6017NfAq5BJ1hW2RI6nfhZ4YQ8IIXQY9QjonWSIXaEjoeT/SPLEOstQ0cWHPOYzWvVumjKKkhNFhoLOde0Gd4xpDekKUHgYklGyTrQpm2p3DkQ2Ym9loEhTrkmtxN+V1CYIHDieP79PQYuhOAArDpYHUdbuRS9M3M5tkpqREa76+lm/hRB2lcECkeE6WWB9FpJH0+5pipptu80Xn7MH7JT8PXyNZ+onM1GS0HACp915KBzd5F/fm7xKPOQk60D1k7ZqzTztrwYjmZ4Sx5PL84TPyjxNEjOrlIPZIsTALFrNpc+39p6tZdooNi802nHItxr7SPTN2+YkrLCe3eCnAaKcISWEWK4mYbmXu+5IObd2+/LxcfYEHDaggGXbj4LbKlSGddkRI4xv4Rj1V/nczWNAXWGRBaLzhwZnjJ8yCrGhnn4rA5hCgs= 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)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:hiAjEZo0SYXCCnZmS0NepJQCha+xacRnweuz3G84xurCmCNB8h5rRa5bBXzVpYZgZSFnfwVbleSQTcgPKRvoZmbH5+RAyo4oA8UiCorKUp147L/Y+TrU6MO7z7EwjSI3WuRFF73wNh6EbSb1gXA8kLwvncCsSBOb+jfRgPIrGX8R7E0rudoomxrTS6OEGOVVQvB7JjiWCavJYqKI/9ihws8gPbfsg8OybwpiZ9eDwBiAetfufZ9hlBh6R6brDQU/D25p3DlliF0RN0Ks4dXGfbRpnUHdgUYF6s+UHtdB7oCXvTj/Mz8QE7/yaECph5zcIvsvy/XCxdPddx7jghVHuAI2MbJyIiJt3pYdG49rjY/rD92Y/iqkMEWkYcnylAFf X-Forefront-PRVS: 09352FD734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(50226002)(77096005)(2950100001)(48376002)(81166005)(50466002)(66066001)(47776003)(92566002)(5003940100001)(4326007)(2906002)(110136002)(50986999)(2351001)(33646002)(586003)(3846002)(6116002)(229853001)(5004730100002)(76176999)(19580395003)(19580405001)(189998001)(5008740100001)(42186005)(36756003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 23:ptLz/bJSE0ODfW5JsFzdqYVl8PE6jQMPsC1mRnqQrqOPVlygAEJnG84MpwEVNVuXzWFS6t0ALaYenUIKU+KV4Wg1QrxRjpEGzgCuLNEtAgbYszv8rZcmL3Ksn6i/xnoW9GagAxfsny5AU+2LMv9F/5lptD8gJpYzLTSm+x/rnsVA8fLMM7UF462s2xEQKUftRTn0Zrx8JhqRdpN3BtGpiFw5dy6DRvzB9BZw67t/Efth7HIjhuRJoGgDc2xldLeipTWrnOULe71Rwf0dM3aaTRMx0L9Qrs3cC3uaPhAFSfIaxo/TwD+hq4A2vw0fqBN+PpstMsb6URZYChEZQlnC3qx3iy8RyWcnJNIvxYRfr0w7FXw3T8+sKXKAh8k67SMhb7B5FP6TO/HnYvIRwUi2Jrlpqu72MBTQcA2bo7N7NB9uKW65wPAc992y3Z7m4YHHWU/xw5sA6h7YbzJ7+8eA0cPfbT6TXwX3l+xGIxy2ffk8LUApun10mfMGommqlOh1xvm2nZLqF+2nqrmXwaGRLP2ApOfyjV8d4Y/OuOaCUfseB4bfmmZzKqIdCHT1vqbKGlzXiwdH0FvZbjDtL+viIPIJA+GYnqFg1aGUpzNqwTUerito3ITtL1zdFt7mveV5vtQP0pA4Nhn6j1t7tnLY37Z7eyV3XB8Chq5cxtrwDM6CzR78TE2hyz4inxK9sIAesyNPXatpj4vHYK98ZynDrVQHHtVHltJgeJ3dvWDYzbRXEUcziT0agC67mOT5GwCslkKciv6UkOpWBt7Y/0aUwP6A7QqPl4IFb7EbxBXnKvfpG+D4pg/2uMHGU+ujRi3ctsLmsxcIlhaSFh/Ij5ARbrXFE6sCwAJ50pietS8e+v/C/j6jAUhViIZHx1JgDdTX X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 5:MfZNa40our7KBI4n0jaC7tJY3oj4AIhfAv5TPP5oTttXcfHB9qx61OU2C1QS9Vb/eX2VHmyM1MaAHxvC2faR5cadhSeNlQFIFKmNRmS/yko4epglLMT1KlhZQFPg1xfp5toS60L3M6HXl5RiQyytTA==; 24:7Y6PQhMp4kld25MGzib8n3WC+6woMMNc3rjJqk3uCj2A65QeIftazFa8H+aaLxMSmRebi1akg31D4SM49eF18Sp0O7xJe2y9b/2ZWch8CgU=; 7:UXRxXxTADCLGig4h8TYG4/MY2Zfdi9pccabeog7PSbdDplTAzImRfw7uD59qJRbCvR3TjpqF8B7U8rYDbOVVVsHQlTbJ5SjNNzIT0PeCJb4lhRUscd1zdzVYgq/bDeBPAOBpJXYdg3Iom/aOCce+xxmm5zmLSR51nMFZX9yv7Kl9id1HKyYZTcs4ES6CMec3 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2016 15:18:20.6960 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH 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: Sat, 07 May 2016 15:18:27 -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 b99b4bb..2f4b08e 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.1.0