From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0050.outbound.protection.outlook.com [104.47.42.50]) by dpdk.org (Postfix) with ESMTP id A3C23FA46 for ; Thu, 2 Mar 2017 12:39:43 +0100 (CET) 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=EnsNWu+NfhdITiNeKapcIr5i2mJu1IjIyyJ2ujPatIk=; b=JiA6Z3NnEF8vf32JZXqXxb3iPo/ivm1SpB4S0SbWF7RzcZWsj2R1dPdnHPLRzrHTHqk/IYAR40Z8M8BwKk4DAGJwuHDKLy0ziJM00qI1taPhiLEw4ppPlIvLnTDeulRAELMOE214BcRMYiyYEuSuvCVaHAziR7YpjzN2WaYuzYs= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:39:40 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:39 +0530 Message-Id: <1488454371-3342-35-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: 4e91e3d5-f173-4b27-a453-08d46160d1a5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:fQ5uKWhawxulCmzVX2DuoDn9QTLZPrn+T/yPzik5AQPUkeHn8DRuqzuzh9vEGO7e7WFelTYC0fkVCVpetgSa9QsfWb8j1JD/Y9gRLHaKe04keJSd8Y2Qw7C2XsAEo5YvMS/rcwCH3fhLkp4zD0JQecL3GP3jI7h7gVAGrSe33jWoHkvlCs0/0PDLJDheMehXFbAcnm8GAa8uO4WatlAu9ggKZG9wQS4+9rzVT6qeHnY/V3r7purfbfpxlUmIpoyJgd9dMc1b+gWPTN4gXYYW3w==; 25:9J+ufysydgxyQF8NslTK2hAd4YBMA4Wk+H8dWBXsw9ktO+BWa1Msi/VI93rP43oEdWRwjR1THX15XeZRMQAZJetnXSR7w/ypw6iVhZ3jr2EJsGSv4+ui1seO3YW3aaf/hKU4YcSXnPlbkMvQp6KVm+1e31UVbIqiGZkVX1e3/RZBnvqeJAqp3OkVF7mBWacOgcKL3+1ORQWj88bJWOSH33wY9sp7Lc9AAABLGiwkITD6xfik+IW/K26tWJJVOfID00WYju2vsLdV7UZUK0kcxJRnRRunhrhsiEdnZ86X+kAewKdvj/8WJSUW3jlv5ShtyGnJ7VTWFXGdqwNZV63ZZxSdTjBGM2t4fvd37UCOALjwmjOiYFUA8Vl0SysEJxPLLqyQTEslJ1on6hJxxjKGYi4MV7MONTApcOXKN+9l/C48+g1ey+EWKNqHKXSfccDpHAgJJeSlht/OWvVORuNwgg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:SB6NLR2OUCuoVDAfhcZ8vCFh+TDHtmpnLYEchRGNrDzjQD/ZxvHMARjK1z+TEYhp6ZsmwOeTzCk+O5RLikFHtmgkkdEoI+4r54GOk7u1/+7X6+NaaRd9vaqcMXQKB/ZhURSt46pnlDHsDh1taXi3qwQHtm32UNVzoNRlH6iCEIssMd1XW/JqDjSk7/HwyAWtsOxpetOS8iZ+nBstNPgDT8m3L+GgGlB42BZCybxGmDlo4FXzgEaqP1HQGgxTxjw+; 20:qjCeoOz1oyYzfb2TZMibo/gL94PIZ4KyK2YuZEcJrCWUGLEBav/RaAsrCBYp86DDzIHOVbdmz1pX9xcJZCcF3H/m071Y7azdV+/MVhi6nfBLPEKUidpENiUuD/IHlxkaRUKmXlNpFGWF1+lXqfpqozHFo8Jzo5UoP8OkUZBhZyCSd0J3CrJ/z8aslnMz2U/ioOPxQr2kPrmIdNb+dtCxesAWLqTpzb/qUCCkxxnf9enFAF9Tm42zW1/2HPHbhSttEX2wvJd/RA2d/MJkrPBkJwoTYYgQqOoHwLoy4H7kyhulW+kF7+LSY1ZziUpDyNtjq8YxGMri13krSjA6JYnYMNbblxcQPz8O/gQrYe6bvXWXj2L8wdvjNswFgK7/E8Eoz9vEdGXVQvxrKJ05QPxk2rB573C+VsANnBkHXbQ+X0cwBBm/pkRD4/jjbFiQObEgINFKtY4pGqMx3DcXfm4ZS3FRhQtI3XaEeWt+ei5CpxOLkFbNOmh05cKZIreqOcUsmpAtHZriY+GiY9o8MxNxffhCCb3G97g+FVsDR/hk8n3L3nes1OsB3sSoNlyUp1cma3FtVW5M9GvAsqTOayG9AsKRySXbWx1gO/gZwIR3cmY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148)(6042181); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:gXJfbHI27nUcoRwfZIwSpGyDxHDhx1p1a0/9wMoRVlHMvdCW2PLhgMizmjFPCKLC0oIQ7aY3WO7/NLk7A51ZgQuXsH8uj/i5GzNOsABcv9ybVCUVvG3VA0Q1BorLH7UJlhOyaiWpwX5+4FXR9TcBkUnwK1WNUEFqiGifLv9MzhtdWES6xBqP+WxtE+64Dt/m+uhwuW361LamR2zPC9a+2PlfM3t7C7PQ6aGHbrt9rAJJP7nD5TwWA19Mo3YEGwla7TSBxtWNDdQNg/HxCPyyxGggIucTTPW3b7CZDwfQqAHIsuakGzFkSOeqrq3KJkbZDb7XGc9DdSsy1nm4eGN7BdCwGhpXCQs9GIZeB0CahkKSJ1oMY5cOLihQtIVlAcJLPR2XL5GBkE9yW3SaLVLWfeR801DsYENTGlgZNjk8CKArY1CsTUEZxvjgBtRY2GBMaAHfyh00UpPAc/0XdhQ293Smf2LIqM7eT28Nec9HICGMkSsPdsXffCgMROh4LXh98VzX+MV6n3/UuM13EpoeMqO2QUWLKPP2fbK4pdw5FbBlPmksKpJAMNM/04+ugnH29QSPhq2LP789DYC6HFPoMtHPhpzcp5dncvJT1vD/cbtoOiUn1bxLNVMIsy9Z5oD9 X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(2950100002)(6916009)(42882006)(575784001)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277; 23:k/AY//z+JMOcO9Z8mT9G7/UYl1HLkiS5f0oz0pyBQ?= =?us-ascii?Q?lTCS2C+9h0+YHLumlxFwFIFtwF/ch5yECY32AuqqYuI/rcDInCrfoLlR7Qqg?= =?us-ascii?Q?mIZXhuKyKQ2loxWdEzSYmUz4n0Mv9ULGISLGpzTFxIYVWXSDKSQyMlKvcAYW?= =?us-ascii?Q?/0xWixLGieRe7GgXKwIsSE7B5PZSMj05c77bmpu2lfwcApdDAnWAJpO9WiB7?= =?us-ascii?Q?VqIrkxphlYHuiqMn/ugSxQCuoIuCiY+HicLvr4UAI52OV8Ysa3h8A7eO50Rr?= =?us-ascii?Q?lvDdnr3NMcA1y8fmv62eoUPe5dBoq+vaZIk01vAAr3hE4RsUEQ+ZC3y/MqCr?= =?us-ascii?Q?ZEyPreCRHHeBIgWaAP5R9LDKaBouAdg+36pjwTX2odB5kVZNwh0+VlREk3/l?= =?us-ascii?Q?gK5gNbQ0ksiaL4XiKDMpwI+HXq2ZbJwGdzkAh0eHaZPcThQqTloQuHcf8A1j?= =?us-ascii?Q?Zmo6GAEHogSPjX6EwGFa6bJZA83nRQWX3FhR6bBZg7+p9D0o5xpGwd76wMUI?= =?us-ascii?Q?x0TOqDyKsaVQ4kmmH3fOqW9YGSGnDBgZbC7uZ17YtOeJ1UeIoVljr3zqxRbA?= =?us-ascii?Q?Kq4HOMBGyl6Ulhs26FbhJOcvQxS5wD2ImAXJ6uuAF0F2UwBUjblhEqjLl/lN?= =?us-ascii?Q?nSzbBlllQ3MALWkFWAIG9fzJkTaHtf61dB7YU5fm/a97/dBeeF7qeovqLMC6?= =?us-ascii?Q?6SJ+nDW6kJ23ue4GZxpwqzTy+UBDAOeAyl4Uw975L+VqryhRqGmo8RL4zjOs?= =?us-ascii?Q?2j5LteqqErbMczQvA3BGKhp4TmsidTdGRokHoy5R41QJq2QDO2uQNRblK4u0?= =?us-ascii?Q?XQw3qTv4MEEMeSsrRZ/Ib+e+uiOkQ/luOAj+qf6x8kbNwWUVwcKFj5mWIV3D?= =?us-ascii?Q?53RkKohnR+X2q6PnYtbNXuVFlkrzC5hSy6iic9g6wAEeXko5ZqmVPSzCd2Jm?= =?us-ascii?Q?vuwmrd7Aie/o7UkH/EyqOjsLFlKZzCeps5drAUfrorS4qWpILbX6QswVuRSL?= =?us-ascii?Q?kdTlDi2A79PXoVjgS2YcOMzvKNIoIl/T+tO/3k71f0+PdHFjjpGmkEP1KYzG?= =?us-ascii?Q?erCIoJ2ahUXQrGDKuOMehn+yqMN?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 6:qP+tCQ2P8uOK2jwDj3sRJx4eAxbNWUCHVZ5yFJsD54kdXhnuJtskgL1L8l6PendmYnNm+hDmwB6C117whDaMy0Taei2sd+s4AbW/dZEcKrrAeCsWKiNDl3VQtD2/Kjkn7vFSzn+M62HXynosVIvBSIf7rymTD7O6b1ds0f6m1KO++WOdpCO2LpPdwyBWCOMDBC/6K1VgQmET4Y5ehp5eRCimmCByyXYo4xeOM2Wyu6mNobhxPP4QhzmwzIkmSmXR4ynuNQ73bug/E8VlGu9+dZzkp38gZJFKW5gjdIKqiefu1cwZZfIODsBKohYQ2X5+3YlVuHbOo0J70GQPARjtWvqNaACdx/OBHlBKgD2jfYRw+mcHmBcsstBJEU25/5mreEbWwj68WpdFIOSzfzXn2Q==; 5:vVBc3KdSkrOzuC17C6kBhGuTL3oHi7PhAM6HFjQ03CwAutlwLzc0zj63/0Lzr0BSvh0ktuSNxUB+4DFaJsiNYoIH9y+ofm/hF68k5xidsI+LRsoD9tLs5FSOwebQFt+32bn2TAXITf7wnLgvq8yHig==; 24:LtsrrDuU368sjQM4cgpkpV4HgqsHFxhZXOJNHq5L/kEG94H4gkBNLRj7t+TrKJ7AxWfUJD/VoV3Swz1Z/UX5wXXcSetEM/pW3iWb1z1PV6A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:kbTabYUxij7aMpDzGYVumfs3SVsqf3PUbsacUM0GFKVlWtC9vdSUpIfqqFQp3VkK+DBzBhNRCMSs79ydB9TOu/C8IW499jQOa2GEwBSAX+e/GG8/CfRwK1E5ZiQemq8ihqsq1ACHbbtpRQF2D3Wz9v4d+mJeMXIGaZFCCwWWr7qzlQUQAJnQ1uj8pmzqCsoKa31ttT4rkj+GHddqlQPVZPCg1UivStEP+mTicQbVnXYUD6CYtZ3oPrzdJFFGe0raBIJuFEPqAZBcevzGyBwFJpm5eLfhczFR+/0ttreU9vCdixZ+Zv5PWmsmlrcqT3ldNDm9yDGCKTgiIZ35gLYZDQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:39:40.2661 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 34/46] net/liquidio: add RSS support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Mar 2017 11:39:44 -0000 Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/base/lio_hw_defs.h | 26 +++ drivers/net/liquidio/lio_ethdev.c | 336 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 21 ++ drivers/net/liquidio/lio_struct.h | 16 ++ 4 files changed, 399 insertions(+) diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 59668c0..8272162 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -130,12 +130,38 @@ enum octeon_tag_type { /* NIC Command types */ #define LIO_CMD_RX_CTL 0x4 +#define LIO_CMD_SET_RSS 0xD /* RX(packets coming from wire) Checksum verification flags */ /* TCP/UDP csum */ #define LIO_L4_CSUM_VERIFIED 0x1 #define LIO_IP_CSUM_VERIFIED 0x2 +/* RSS */ +#define LIO_RSS_PARAM_DISABLE_RSS 0x10 +#define LIO_RSS_PARAM_HASH_KEY_UNCHANGED 0x08 +#define LIO_RSS_PARAM_ITABLE_UNCHANGED 0x04 +#define LIO_RSS_PARAM_HASH_INFO_UNCHANGED 0x02 + +#define LIO_RSS_HASH_IPV4 0x100 +#define LIO_RSS_HASH_TCP_IPV4 0x200 +#define LIO_RSS_HASH_IPV6 0x400 +#define LIO_RSS_HASH_TCP_IPV6 0x1000 +#define LIO_RSS_HASH_IPV6_EX 0x800 +#define LIO_RSS_HASH_TCP_IPV6_EX 0x2000 + +#define LIO_RSS_OFFLOAD_ALL ( \ + LIO_RSS_HASH_IPV4 | \ + LIO_RSS_HASH_TCP_IPV4 | \ + LIO_RSS_HASH_IPV6 | \ + LIO_RSS_HASH_TCP_IPV6 | \ + LIO_RSS_HASH_IPV6_EX | \ + LIO_RSS_HASH_TCP_IPV6_EX) + +#define LIO_RSS_MAX_TABLE_SZ 128 +#define LIO_RSS_MAX_KEY_SZ 40 +#define LIO_RSS_PARAM_SIZE 16 + /* Interface flags communicated between host driver and core app. */ enum lio_ifflags { LIO_IFFLAG_UNICAST = 0x10 diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index c698c70..58a932e 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -41,6 +41,15 @@ #include "lio_ethdev.h" #include "lio_rxtx.h" +/* Default RSS key in use */ +static uint8_t lio_rss_key[40] = { + 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, + 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, + 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, + 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, + 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA, +}; + /* Wait for control command to reach nic. */ static uint16_t lio_wait_for_ctrl_cmd(struct lio_device *lio_dev, @@ -96,6 +105,267 @@ return 0; } +static int +lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + struct lio_rss_set *rss_param; + struct lio_dev_ctrl_cmd ctrl_cmd; + struct lio_ctrl_pkt ctrl_pkt; + int i, j, index; + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down, can't update reta\n", + lio_dev->port_id); + return -EINVAL; + } + + if (reta_size != LIO_RSS_MAX_TABLE_SZ) { + lio_dev_err(lio_dev, + "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n", + reta_size, LIO_RSS_MAX_TABLE_SZ); + return -EINVAL; + } + + /* flush added to prevent cmd failure + * incase the queue is full + */ + lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); + + memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); + memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); + + rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0]; + + ctrl_cmd.eth_dev = eth_dev; + ctrl_cmd.cond = 0; + + ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS; + ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3; + ctrl_pkt.ctrl_cmd = &ctrl_cmd; + + rss_param->param.flags = 0xF; + rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED; + rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ; + + for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) { + for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) { + if ((reta_conf[i].mask) & ((uint64_t)1 << j)) { + index = (i * RTE_RETA_GROUP_SIZE) + j; + rss_state->itable[index] = reta_conf[i].reta[j]; + } + } + } + + rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ; + memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size); + + lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3); + + if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { + lio_dev_err(lio_dev, "Failed to set rss hash\n"); + return -1; + } + + if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { + lio_dev_err(lio_dev, "Set rss hash timed out\n"); + return -1; + } + + return 0; +} + +static int +lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + int i, num; + + if (reta_size != LIO_RSS_MAX_TABLE_SZ) { + lio_dev_err(lio_dev, + "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n", + reta_size, LIO_RSS_MAX_TABLE_SZ); + return -EINVAL; + } + + num = reta_size / RTE_RETA_GROUP_SIZE; + + for (i = 0; i < num; i++) { + memcpy(reta_conf->reta, + &rss_state->itable[i * RTE_RETA_GROUP_SIZE], + RTE_RETA_GROUP_SIZE); + reta_conf++; + } + + return 0; +} + +static int +lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + uint8_t *hash_key = NULL; + uint64_t rss_hf = 0; + + if (rss_state->hash_disable) { + lio_dev_info(lio_dev, "RSS disabled in nic\n"); + rss_conf->rss_hf = 0; + return 0; + } + + /* Get key value */ + hash_key = rss_conf->rss_key; + if (hash_key != NULL) + memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size); + + if (rss_state->ip) + rss_hf |= ETH_RSS_IPV4; + if (rss_state->tcp_hash) + rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP; + if (rss_state->ipv6) + rss_hf |= ETH_RSS_IPV6; + if (rss_state->ipv6_tcp_hash) + rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP; + if (rss_state->ipv6_ex) + rss_hf |= ETH_RSS_IPV6_EX; + if (rss_state->ipv6_tcp_ex_hash) + rss_hf |= ETH_RSS_IPV6_TCP_EX; + + rss_conf->rss_hf = rss_hf; + + return 0; +} + +static int +lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + struct lio_rss_set *rss_param; + struct lio_dev_ctrl_cmd ctrl_cmd; + struct lio_ctrl_pkt ctrl_pkt; + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down, can't update hash\n", + lio_dev->port_id); + return -EINVAL; + } + + /* flush added to prevent cmd failure + * incase the queue is full + */ + lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); + + memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); + memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); + + rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0]; + + ctrl_cmd.eth_dev = eth_dev; + ctrl_cmd.cond = 0; + + ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS; + ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3; + ctrl_pkt.ctrl_cmd = &ctrl_cmd; + + rss_param->param.flags = 0xF; + + if (rss_conf->rss_key) { + rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED; + rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ; + rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ; + memcpy(rss_state->hash_key, rss_conf->rss_key, + rss_state->hash_key_size); + memcpy(rss_param->key, rss_state->hash_key, + rss_state->hash_key_size); + } + + if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) { + /* Can't disable rss through hash flags, + * if it is enabled by default during init + */ + if (!rss_state->hash_disable) + return -EINVAL; + + /* This is for --disable-rss during testpmd launch */ + rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS; + } else { + uint32_t hashinfo = 0; + + /* Can't enable rss if disabled by default during init */ + if (rss_state->hash_disable) + return -EINVAL; + + if (rss_conf->rss_hf & ETH_RSS_IPV4) { + hashinfo |= LIO_RSS_HASH_IPV4; + rss_state->ip = 1; + } else { + rss_state->ip = 0; + } + + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) { + hashinfo |= LIO_RSS_HASH_TCP_IPV4; + rss_state->tcp_hash = 1; + } else { + rss_state->tcp_hash = 0; + } + + if (rss_conf->rss_hf & ETH_RSS_IPV6) { + hashinfo |= LIO_RSS_HASH_IPV6; + rss_state->ipv6 = 1; + } else { + rss_state->ipv6 = 0; + } + + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) { + hashinfo |= LIO_RSS_HASH_TCP_IPV6; + rss_state->ipv6_tcp_hash = 1; + } else { + rss_state->ipv6_tcp_hash = 0; + } + + if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) { + hashinfo |= LIO_RSS_HASH_IPV6_EX; + rss_state->ipv6_ex = 1; + } else { + rss_state->ipv6_ex = 0; + } + + if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) { + hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX; + rss_state->ipv6_tcp_ex_hash = 1; + } else { + rss_state->ipv6_tcp_ex_hash = 0; + } + + rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED; + rss_param->param.hashinfo = hashinfo; + } + + lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3); + + if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { + lio_dev_err(lio_dev, "Failed to set rss hash\n"); + return -1; + } + + if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { + lio_dev_err(lio_dev, "Set rss hash timed out\n"); + return -1; + } + + return 0; +} + /** * Atomically writes the link status information into global * structure rte_eth_dev. @@ -179,6 +449,65 @@ return 0; } +static void +lio_dev_rss_configure(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + struct rte_eth_rss_reta_entry64 reta_conf[8]; + struct rte_eth_rss_conf rss_conf; + uint16_t i; + + /* Configure the RSS key and the RSS protocols used to compute + * the RSS hash of input packets. + */ + rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf; + if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) { + rss_state->hash_disable = 1; + lio_dev_rss_hash_update(eth_dev, &rss_conf); + return; + } + + if (rss_conf.rss_key == NULL) + rss_conf.rss_key = lio_rss_key; /* Default hash key */ + + lio_dev_rss_hash_update(eth_dev, &rss_conf); + + memset(reta_conf, 0, sizeof(reta_conf)); + for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) { + uint8_t q_idx, conf_idx, reta_idx; + + q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ? + i % eth_dev->data->nb_rx_queues : 0); + conf_idx = i / RTE_RETA_GROUP_SIZE; + reta_idx = i % RTE_RETA_GROUP_SIZE; + reta_conf[conf_idx].reta[reta_idx] = q_idx; + reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx); + } + + lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ); +} + +static void +lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_rss_ctx *rss_state = &lio_dev->rss_state; + struct rte_eth_rss_conf rss_conf; + + switch (eth_dev->data->dev_conf.rxmode.mq_mode) { + case ETH_MQ_RX_RSS: + lio_dev_rss_configure(eth_dev); + break; + case ETH_MQ_RX_NONE: + /* if mq_mode is none, disable rss mode. */ + default: + memset(&rss_conf, 0, sizeof(rss_conf)); + rss_state->hash_disable = 1; + lio_dev_rss_hash_update(eth_dev, &rss_conf); + } +} + /** * Setup our receive queue/ringbuffer. This is the * queue the Octeon uses to send us packets and @@ -464,6 +793,9 @@ lio_dev->intf_open = 1; rte_mb(); + /* Configure RSS if device configured with multiple RX queues. */ + lio_dev_mq_rx_configure(eth_dev); + /* start polling for lsc */ ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check, @@ -659,6 +991,10 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) .rx_queue_release = lio_dev_rx_queue_release, .tx_queue_setup = lio_dev_tx_queue_setup, .tx_queue_release = lio_dev_tx_queue_release, + .reta_update = lio_dev_rss_reta_update, + .reta_query = lio_dev_rss_reta_query, + .rss_hash_conf_get = lio_dev_rss_hash_conf_get, + .rss_hash_update = lio_dev_rss_hash_update, }; static void diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index 7b5343a..6543061 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -92,4 +92,25 @@ struct lio_link_status_resp { struct octeon_link_info link_info; uint64_t status; }; + +struct lio_rss_set { + struct param { +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN + uint64_t flags : 16; + uint64_t hashinfo : 32; + uint64_t itablesize : 16; + uint64_t hashkeysize : 16; + uint64_t reserved : 48; +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t itablesize : 16; + uint64_t hashinfo : 32; + uint64_t flags : 16; + uint64_t reserved : 48; + uint64_t hashkeysize : 16; +#endif + } param; + + uint8_t itable[LIO_RSS_MAX_TABLE_SZ]; + uint8_t key[LIO_RSS_MAX_KEY_SZ]; +}; #endif /* _LIO_ETHDEV_H_ */ diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index da08fe4..c2293f7 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -357,6 +357,21 @@ struct lio_gather { struct lio_sg_entry *sg; }; +struct lio_rss_ctx { + uint16_t hash_key_size; + uint8_t hash_key[LIO_RSS_MAX_KEY_SZ]; + /* Ideally a factor of number of queues */ + uint8_t itable[LIO_RSS_MAX_TABLE_SZ]; + uint8_t itable_size; + uint8_t ip; + uint8_t tcp_hash; + uint8_t ipv6; + uint8_t ipv6_tcp_hash; + uint8_t ipv6_ex; + uint8_t ipv6_tcp_ex_hash; + uint8_t hash_disable; +}; + struct lio_io_enable { uint64_t iq; uint64_t oq; @@ -619,6 +634,7 @@ struct lio_device { uint8_t nb_rx_queues; uint8_t nb_tx_queues; uint8_t port_configured; + struct lio_rss_ctx rss_state; uint8_t port_id; }; #endif /* _LIO_STRUCT_H_ */ -- 1.8.3.1