From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-eopbgr700087.outbound.protection.outlook.com [40.107.70.87]) by dpdk.org (Postfix) with ESMTP id 491F69AE8 for ; Tue, 14 Jun 2016 21:07:33 +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=HNtj3WOLsOV5Gd7c3bSFF3UdPSgXcVJeqbM1IYsdqp6RN86Keh+P85HmxHGr5kXhhSIg1/06H6z2CNb9hSSk8lZAEnfwGiWhSRNslpWURq5YahALBk1nODl1dsRxrLBJWkBo8mkEILN9XggSf65JczO26wPM3Zbp10N7GVG6jWk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 14 Jun 2016 19:07:28 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Wed, 15 Jun 2016 00:36:21 +0530 Message-ID: <1465931200-23912-7-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465931200-23912-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: MA1PR01CA0040.INDPRD01.PROD.OUTLOOK.COM (10.164.116.140) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: dccae8ae-ea5f-497c-8861-08d3948722da X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 2:zjiiZtO+AxkoE+bEyFsgEsbSVrI76LVdGf9Xi0ZQ1dt5DpHhRrmQcxI09ZCoKTNqCa5Vcgnk+t8EL9q6ljEnYmbTbtkiCUurc04GkRR2T1POocwRwZwTAIZRFZ1TV4t1cJIup8jPWcFhfVqhJC+0bCfbkA2MPrFC8eyi0SJ/B/v8vw8lj/Do4RFdkmiLhCR3; 3:4QVGdu5Lk/U+E8Py1oJx131DpxII4taG8FsETzCuz5YhP+qMLbefnG2PglnluZ6zdTdYEBHVgsc+gaq/FtvnGf+7gEFP/Tw97v3Ser5eA+T38M7xWHk4ss1ZlRUzjLeX; 25:btk/GlKegD0BA3lOcUtYrlsOyxE8he3tuQSMQ3VMQeaiQP4ffelieg+sT6GbYQQywNEi8NAVzuaqWDn9yqwOlvuL6MbR8OfCu5CPshSpKSNrR5zgiZQ57dXzsAsTGSsZsvoTyNwVL4yTyS31Dme99E7EnUa3Ahn/jpbnHQqafujQOafuvk1mtGZrEdBb31E8/3yAlB+EjgEHlA2Hpq1SC7Nztqj99gvIpvsXHrU0bfiwK9SHweSGActFEBoSmvR2i0qzB/+lUP4QcVrirEY/3Zge+Yf3MMj/hh4dNAc+pibdoe6VGN9yBPGQlmspdpugcGompFsGT0ypAe6O767I3tPJwkcQjBYM5SyMeTlWphUhjDw1gcjbohVOwrQNEY8cHWjh5Go+MjzSmdVjb3MvAV4NqK5t406CyVTcS+2/Pho= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 20:1s/tNy0s5h7uLrvH7UjIUXehjZsXb3rVJSONkDugGyZ8wybuQrvyIQIwu4JYxl/ZZP9emkcU2cPffxsMHtFoGBRMjhI9soi1CFlBlj4pkBVNlQX9wPZ5AJzNtDeBhH+yoHGwYk5IKS5bAw7TrigfTJSc0JY6OjdAehTZHKX8/UonmkFMHMKu/zQAdZ1Ch6cczqQzciVkc270Ah2USqSOJP9qeYhD5lJSqq+JWsdkOdurajIJ5dzeWp2GAvAFDcfNmxuCUHZBoxv0wN695w79inJzvKD0K5iHzUAzOJ1ws3epBWxsjnUA6T6NVg67hi7frhAuWSsTiT/dlC9mZw8+USUzDSa2PBcCXoaoETzlOyzUEtjdbUFvw4wwRvIyOjsRr9Q1ZhDYO1UH6lMquLh1TO6ugtUSwI0doejaqTdVydgOChDyp8CB0OrtpWGQ2610HcI9hj7tTkyUW6IR3F+TnqIL4WwuRGxk7YQHCfGZFA5sFptwzUtz//yJ9kU3Awq64P/mDbYOmjIWDxSu3+fq39LD4sD5Vr3Tn4H3V/slN7Eik8/tRid1/KPEhrJNacJ3dpZQVdILfFfcDxN+Jz7YgGeMJNskyor7ym9UprJY5jk= 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:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:QjwvLpl7qiWQxp4wesPKPD2BEmdstfzwW7XPGG7Ca5wqwaFV/zcio93dr9hXM0fPGR0CaJSuH+Bxm/yFt3YDLb6iHaUGfPzCBhIULi/vCurOnYNgVTglPUEBpUmbkNv+9OyOUyCwU4h1T2aKu1SdFeNqnpFPofUytN9Sxl/fM1hPEbvVFbXvvn3oE1tYNETjcdylAcrnQZw7z2rmxO/PnBEORyiDOtINNSKTjzxLAyvR89ac3+cmLcuIqp45pZBRe3AA3a8GZDPHyI6DdXHn9rB3sYnl9RMWdbMO4Ssf3bb9UEW8MNFmFBcyg5s74EVN0aYqaOCUYY13xhPjlkS37PcVrs3UY84OoQ82ZAb0EDaXTKKqPKg8UYoSShSC/S1x X-Forefront-PRVS: 09730BD177 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(69596002)(189998001)(2950100001)(48376002)(77096005)(36756003)(19580405001)(5004730100002)(19580395003)(76176999)(5009440100003)(50986999)(97736004)(5003940100001)(68736007)(110136002)(92566002)(101416001)(5008740100001)(81166006)(8676002)(229853001)(81156014)(66066001)(4326007)(50466002)(2906002)(105586002)(106356001)(2351001)(47776003)(53416004)(76506005)(42186005)(575784001)(33646002)(586003)(3846002)(6116002)(50226002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BY1PR0701MB1723; 23:cWkY/OZcWwMHCsl4vc9Mly2bC/hr6Hs51Czu/RT?= =?us-ascii?Q?eDdHl/zQ6UlytvwzIU4lc/sKU8/vUbw05UGiMqNmOE+GblfmKSLE6vhJ4BOX?= =?us-ascii?Q?FghQGTKuJfxG2K/tNZr+ly8uCSI34q9r7UlFR/u2boiMI1+ON1ufvVKiumlH?= =?us-ascii?Q?r1N60VHoKPpStfXHWBRjmK8Z32rXUBwVk9sH1vNEnMhgFsSwyty7s+uAS+Rx?= =?us-ascii?Q?p3utCrT+8XGtDNhvh0VzDR+QZj7G4cwLEe6U2h3eL3NhlJpS8OZrzAQ3gqMc?= =?us-ascii?Q?tP/JtA+AZnakxICU/mYLdisA/PHT2CK2C8KbQDrkc6Jg2M0pZwM1fj0KmGzf?= =?us-ascii?Q?XPYC0BFL4sjpvoChuTv4j4IJyfsG+l3cm8GZfvg1gidqX+HBQTBuYj8YloRP?= =?us-ascii?Q?bDt+J0hCqVEkprvbSOZRRzqpL1YE6pX/OZRYWQpU/deTL+kcEIqIL+BInS54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doeXfeR5XOqG36PmqVCoRyXnX/1zpLBhcCKQESzImfKV33iW3w==; 24:9QO/pMBDjWoMtFmts/LdyLg8y/Aet+1Tfx8LEZ0/D4vGY0G43q39Z4p1ntmOvKigvcEx6TfJ8Xy1gMOW4426Y/L0PUScYKAxCbjkjuv/NKU=; 7:0PwgAv7Tq6x1dqJyTG4Vi9TczfVvdu1D+Z79SWToeAfO+E/g4/em84rOpm6gv2OjDtNFUNAsDZ8Qx2Hjo9qCXv+1feLh5bPkxRqmNAy+vRZeY/pVEiGfCCyza+u2AuaUYUdmTKD5SF2Nthe9oTI8sbpgAkGPosTfNP0UpbEUg5xWfF43kvaHVCSEJ3Luywoex/duoK8WUnFMrQcLFOj62w== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 19:07:28.9519 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH v5 06/25] 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: Tue, 14 Jun 2016 19:07:34 -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