From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0066.outbound.protection.outlook.com [157.56.111.66]) by dpdk.org (Postfix) with ESMTP id 63A43D049 for ; Fri, 17 Jun 2016 15:31:03 +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=IUDcVjHa94avApGcJOf2OXyPeBQ1ELqugSW+Ndu2WNA=; b=ln40ZBYyivZLmEZYH6hYRTZHiAbxZgute8QwOLH+fvLX/e7V5LUZpKMAon1PH+6MiIFMKsH1VLcsT/zFbWslfOfYfQFHtTgHuzVoR990hImEYfBElUqMXJQ9DAP780qa5z5Sii3tCY4lLqUdgnftzGYjktS489pYwSuWuYbLzDU= 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:30:58 +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:33 +0530 Message-ID: <1466170194-28393-7-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: 9a45db9d-f6d0-43b6-71c0-08d396b3a035 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:7TMgsS6vnvN3cqQ3WCxQvPuROCHcx4xJxDVZPMPKOxgQYxmxW+SC6Zyhut6R1McZEIg/f05D9PcSLVvOTqsTdqxEzFYVLEA83iqzHBoVx70nhiTwxP1WNl4Ijx7HBijcLuM0u2IAWyCzCtsIYLjK6hfXC2lVHsJEqo6br5chKsbCIu7jvgmRkj5YWrde0+69; 3:37hOjLQsz20G+fTCjPH3OVXyq4Zy/TOhPr5lNJ8iufBVUbMZEJMdwcEQohf2j8Xj3oIwHIl9wdC5Vd9nTEl/LELuwoTTYdUpirVuml/bcd9DumWAPwPmNrAkY5zqjV/m; 25:Vo+TFeuxmj7sbCLk+lfIyE3lFeZ2fOZ+WPilLv3b/CdbFpR/U9OublJbXrlNwPFCRPS4zuxnS78nk4ykm30xf17rZIIvSQwIkoCazwxj+zT+ZTk9+f/dxXcCk1zdLcAQBpIIGboKslAhUzB1KPU4KFM2lbRjtaHhzWOM+QxwTGmlJzmGIBxOFnDhlsy1PppFt57j85pWM7u+BUI7pDtYQUGb7Ixt5g70I4IUv/fnMabkTPswX2n5doWnq2aU1gT5FMLd5eeROD75hRKzg6RLMB1jQ2wWkZYSLA5u/XhHzUgkmupP/2NHsblSiQz9rfq2D+5XnJmwhZ68xOLzF7lrqQeXmjmA1hFWUmaudCAx8kwZFJCXIJWBDxJgQdqkWFQPohH+SoNRFfxIA8LknH9gvHg3Z9FrRCciqrh+AuyCTK0= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:ChB4dpLIraHfr0nZ5MdCIXD7vA2BMndoyMmNtnIifqrDkjCHOiOELnzY3MaG5s2DSLKCXCPhlAd9RdTPFdha9Moc4Lv71OfcnhY24gwd05YZjv3Kw33/lolarDM0HQUIKNJd4ZkgD/1BQWK6U7N3untSxX2bVjvu9/oBfWJwtvDiM9FIgg1L1DfG8afgtVIcuXJX+/OJP2++zlaTrA5soLL0sUysKzt0YCYEmOqAOAWiAnirA/nGdMcAeWLAuMBMsuFEMtNv4dA2EWaQV6gaAVgfUhUWoY+wK0cAZfA0Kjp3yh7muM5LdnLrm/MuPXarGyUxnbzofszgFNF2TrFld56fCk4HNq/5kcFjIIRZ69o2Lnw6AoHopffLYR4r8aLow+NCunSZW3Y3z4IJ/UNATYbY1AAXZKBktU84a7RtUd9P/s1Z6YduTA7p9r5iiR5QSXb9mW1PJiqgqrKwBVfJ6Cko92OM3ot5RYm8GjCs4vWBj1BaS9aJ8Z3P0S8xXKs8DKM4hhsC7z/2zVxAzAr43st6eIDRwnNxCcbfAQlSlXRUoCQw6t/Z5QhPjkCbS5ZjnB+wW0mF1CWY5Tnfh2X0EOC7UiMYNLUWPSdE4LU3csY= 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:51OnEj0NgQfJG1l8pnGvqw0GISA/Xl8kJ/aDsi9UyX2iZ9abMV3nJ/9zSERmhu/BYWOSKS3GC4BLoFsXDUlq3lJxiMk1iz2pYMRvoEg/JiLfgj2e/fRn37C5VQYqT87JmpSYMSbm9SYUlw66uLv9k30OK3Q57LgIIE9foaXrPcFvDgeARVInLMjhcyAOMheBs1EHG4gLUXy8SaBFL4IAE+w4PR9aVx0A2oGvL0QxcNKOeLxs3QIEyegMWMNijhtjsSz3dAldP3VQ/VO11g/aggeLK1oilN23+CxjC3L6/8xnQjVeylhC584KjakJsaAhOpk2k8N2ywWnK+4JhCGoXbftsEBlXwe6LBlT4LowQTPGxgMhh2CLo9QTlTHLBnAp 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)(575784001)(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:kf9p9H0TJm6AZIN5Cvw8IOAE80lOPnYrj5nbZuh?= =?us-ascii?Q?ODFIS94208bxwxQFZAraq/BAsDN5WjDFx/20WoZ+v3yW2aL9RlND9jZE2qXb?= =?us-ascii?Q?bshPX+JaqcwB+ufSsiQ24G1aevSHXfC6x2YJcGwROFO2RHjNhdlGWkFfEUyl?= =?us-ascii?Q?bx4tEQJ6tow5hUtuh2DGwiRsrIXvaA81J/U/Z1QkG4GwcHkmHjE/eMAAIt3c?= =?us-ascii?Q?MymyYFsYsCajDnHHjHQJmOfQzK40PhJX1jZEJKaB1uQv7YMMSEHaxfrkPg3V?= =?us-ascii?Q?nTJ1GPcsHT9pLuOUWaMx5CO4p3nv5Hg62EoGTUIrgJI1a2/+Ypy3/Svjvz6F?= =?us-ascii?Q?pGL1Ye2LH7K6IpT/zecNW0mAGDhQJPN6FsD2+J05xJozSFe4QmXfRpQdfPcb?= =?us-ascii?Q?aG8beCJVkTWYmSDDLbiGD/r8BmyC8xZmtd0llsaYSaSlJo6kEbC3vczvaKus?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+dyNkbi3ujkicGTzWff0hswsQ9JCH3w9vrdn40qBHjKC+DMdlDHu/o8blCnJKkfn0Zs=; 5:9mkYFc9Q/uwAV/7lZVweWhiCpRzqPB24/mFWeAS92SlUDglPNQVWs0e7Bksrn+xVlrID3wb+JxuUwH2oSn8Erwqln4alJfI/5ETyo5K7BNvUIqVe3ppb4IfitEfJBJX50apmYpXXa/J/MoKHJnv9FQ==; 24:JvEoEPc2DjCnuh97I26GcwmwLkD921rX5wHLG+bTDc8nMXhAUexa7x9hK0bfJko8UGHO/hRh31wOWi+RJvb6d18/c8eyzSGLn+LYzQFhtac=; 7:lq8XPSnEBf897wzKKf8fGqmnAGXZwM0diuO2RMkM5aX+/gOT5ud58EdkRNN3gnyWISF04CNHjCLKpgBpGmJwl5mehQxxCvz8TgjoySz/2Y4xKzT7JFtxwHTO6UEazTggg+bQ40+pzxxbI0/L++epZ4xgQNlZnPOLl9uxf5yyou05iH03CqFoePzQuj2E9krePW7npP9emGca5cH86IOP0w== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:30:58.1946 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 06/27] net/thunderx/base: add RSS and reta configuration HW APIs 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:03 -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/base/nicvf_hw.c | 129 +++++++++++++++++++++++++++++++++++ drivers/net/thunderx/base/nicvf_hw.h | 20 ++++++ 2 files changed, 149 insertions(+) diff --git a/drivers/net/thunderx/base/nicvf_hw.c b/drivers/net/thunderx/base/nicvf_hw.c index ec24f9c..3366aa5 100644 --- a/drivers/net/thunderx/base/nicvf_hw.c +++ b/drivers/net/thunderx/base/nicvf_hw.c @@ -721,6 +721,135 @@ nicvf_vlan_hw_strip(struct nicvf *nic, bool enable) nicvf_reg_write(nic, NIC_VNIC_RQ_GEN_CFG, val); } +void +nicvf_rss_set_key(struct nicvf *nic, uint8_t *key) +{ + int idx; + uint64_t addr, val; + uint64_t *keyptr = (uint64_t *)key; + + addr = NIC_VNIC_RSS_KEY_0_4; + for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) { + val = nicvf_cpu_to_be_64(*keyptr); + nicvf_reg_write(nic, addr, val); + addr += sizeof(uint64_t); + keyptr++; + } +} + +void +nicvf_rss_get_key(struct nicvf *nic, uint8_t *key) +{ + int idx; + uint64_t addr, val; + uint64_t *keyptr = (uint64_t *)key; + + addr = NIC_VNIC_RSS_KEY_0_4; + for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) { + val = nicvf_reg_read(nic, addr); + *keyptr = nicvf_be_to_cpu_64(val); + addr += sizeof(uint64_t); + keyptr++; + } +} + +void +nicvf_rss_set_cfg(struct nicvf *nic, uint64_t val) +{ + nicvf_reg_write(nic, NIC_VNIC_RSS_CFG, val); +} + +uint64_t +nicvf_rss_get_cfg(struct nicvf *nic) +{ + return nicvf_reg_read(nic, NIC_VNIC_RSS_CFG); +} + +int +nicvf_rss_reta_update(struct nicvf *nic, uint8_t *tbl, uint32_t max_count) +{ + uint32_t idx; + struct nicvf_rss_reta_info *rss = &nic->rss_info; + + /* result will be stored in nic->rss_info.rss_size */ + if (nicvf_mbox_get_rss_size(nic)) + return NICVF_ERR_RSS_GET_SZ; + + assert(rss->rss_size > 0); + rss->hash_bits = (uint8_t)log2(rss->rss_size); + for (idx = 0; idx < rss->rss_size && idx < max_count; idx++) + rss->ind_tbl[idx] = tbl[idx]; + + if (nicvf_mbox_config_rss(nic)) + return NICVF_ERR_RSS_TBL_UPDATE; + + return NICVF_OK; +} + +int +nicvf_rss_reta_query(struct nicvf *nic, uint8_t *tbl, uint32_t max_count) +{ + uint32_t idx; + struct nicvf_rss_reta_info *rss = &nic->rss_info; + + /* result will be stored in nic->rss_info.rss_size */ + if (nicvf_mbox_get_rss_size(nic)) + return NICVF_ERR_RSS_GET_SZ; + + assert(rss->rss_size > 0); + rss->hash_bits = (uint8_t)log2(rss->rss_size); + for (idx = 0; idx < rss->rss_size && idx < max_count; idx++) + tbl[idx] = rss->ind_tbl[idx]; + + return NICVF_OK; +} + +int +nicvf_rss_config(struct nicvf *nic, uint32_t qcnt, uint64_t cfg) +{ + uint32_t idx; + uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE]; + uint8_t default_key[RSS_HASH_KEY_BYTE_SIZE] = { + 0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD, + 0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD, + 0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD, + 0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD, + 0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD + }; + + if (nic->cpi_alg != CPI_ALG_NONE) + return -EINVAL; + + if (cfg == 0) + return -EINVAL; + + /* Update default RSS key and cfg */ + nicvf_rss_set_key(nic, default_key); + nicvf_rss_set_cfg(nic, cfg); + + /* Update default RSS RETA */ + for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++) + default_reta[idx] = idx % qcnt; + + return nicvf_rss_reta_update(nic, default_reta, + NIC_MAX_RSS_IDR_TBL_SIZE); +} + +int +nicvf_rss_term(struct nicvf *nic) +{ + uint32_t idx; + uint8_t disable_rss[NIC_MAX_RSS_IDR_TBL_SIZE]; + + nicvf_rss_set_cfg(nic, 0); + /* Redirect the output to 0th queue */ + for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++) + disable_rss[idx] = 0; + + return nicvf_rss_reta_update(nic, disable_rss, + NIC_MAX_RSS_IDR_TBL_SIZE); +} + int nicvf_loopback_config(struct nicvf *nic, bool enable) { diff --git a/drivers/net/thunderx/base/nicvf_hw.h b/drivers/net/thunderx/base/nicvf_hw.h index dc9f4f1..a7ae531 100644 --- a/drivers/net/thunderx/base/nicvf_hw.h +++ b/drivers/net/thunderx/base/nicvf_hw.h @@ -76,10 +76,18 @@ enum nicvf_err_e { NICVF_ERR_SQ_PF_CFG, /* -8175 */ NICVF_ERR_LOOPBACK_CFG, /* -8174 */ NICVF_ERR_BASE_INIT, /* -8173 */ + NICVF_ERR_RSS_TBL_UPDATE,/* -8172 */ + NICVF_ERR_RSS_GET_SZ, /* -8171 */ }; typedef nicvf_phys_addr_t (*rbdr_pool_get_handler)(void *opaque); +struct nicvf_rss_reta_info { + uint8_t hash_bits; + uint16_t rss_size; + uint8_t ind_tbl[NIC_MAX_RSS_IDR_TBL_SIZE]; +}; + /* Common structs used in DPDK and base layer are defined in DPDK layer */ #include "../nicvf_struct.h" @@ -171,6 +179,18 @@ uint32_t nicvf_qsize_sq_roundup(uint32_t val); void nicvf_vlan_hw_strip(struct nicvf *nic, bool enable); +int nicvf_rss_config(struct nicvf *nic, uint32_t qcnt, uint64_t cfg); +int nicvf_rss_term(struct nicvf *nic); + +int nicvf_rss_reta_update(struct nicvf *nic, uint8_t *tbl, uint32_t max_count); +int nicvf_rss_reta_query(struct nicvf *nic, uint8_t *tbl, uint32_t max_count); + +void nicvf_rss_set_key(struct nicvf *nic, uint8_t *key); +void nicvf_rss_get_key(struct nicvf *nic, uint8_t *key); + +void nicvf_rss_set_cfg(struct nicvf *nic, uint64_t val); +uint64_t nicvf_rss_get_cfg(struct nicvf *nic); + int nicvf_loopback_config(struct nicvf *nic, bool enable); #endif /* _THUNDERX_NICVF_HW_H */ -- 2.5.5