From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0081.outbound.protection.outlook.com [104.47.36.81]) by dpdk.org (Postfix) with ESMTP id 835FDD267 for ; Sat, 25 Mar 2017 07:28:40 +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=McA6M6E0NN8mGfEi1mQS65RWJ97HDG33gq7slMfszJk=; b=W3H573nBmc8cfRfIqLRygbvC7m4Qe3/Sl0vhx//xrywD21W14zs7b6/Poklq44EcX22mQEiPsHtQJ2RgmTcKVjpMpHjyZWaqIxQ38DgU+LMj35mky0XQrWQTQxHjuVhRHx7sAxcLteW9tSmoFajw9mIWyB+HhpprsX3g3JaWyCk= 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 CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:28:36 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:45 +0530 Message-Id: <1490423097-6797-35-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-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: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: 081b344a-29b2-4f5c-5454-08d473482c9c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:2eqoj2LAu6cV107IDHDbi/p3XHasnq9TDwS16axgiPnG4jQp4JyYnQsS6H/lY8uJYFv5yjjO4DhYcsOW31UCLnPYk6pkwiTGTlbxN1jZvzVXhnzdmgbt5nOS19WZijJnIYsEnAj3lWzGK9A8CUOsK2y55eZgk6BSxqtJm5om4mJqsqOkkKp8/8fa3/+t5CGJoMcL6NridjaZY2B+x4RoiK4PdbWQHXKtXzlEvXJ/frdfVbcDQjkYO4+ksXV2ndYGvQjAxS9s34JF2hPxq1BkGA==; 25:Oum2ojg1HH7C7BBrj2nqnPHQ3cRIHWkGrFTNZVTLRogv19S5M3WcRAI2rvziENy7/nLNQ8go/0oIxzisT+dgU52dOuEUV0aKsjA9HipbimtPuCO2W4K/tE3eIQokVD6skayF9vXQ++JKEiumX61aYl4d12NgdUhAHgh/3V94X4n+KZrwYVchEokgwJ4VmWTAE7hgSSq31svRGlNbIGpLKkkkMSpvoTfjb/qSPkjKJKM7dITAURygA/rvKoR0ICy0o8IFzVYtDO3XTv6m2KHXknv34s7QEWmvTMqtMu5IRuBrFuC1px4EGDZFafgyPHq99rKSb4BICW0r7DafAW0tStTe6zZUBMOHPpmlewmVVmeiJ0GhSfxlMa4w/0XPqUS9bM6bIGTlVZuYXZhMYVO/gPXZNCExCYvdXPQhpsNtOTp7tll/BsnLWPlVoqOVJJUF2mhze18hGN2SOfFgTjbnAg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:NSMliMcXKK6HwDYqZzbsQIGSgilcrXYLr/WTEzTjgGSlCJMVK2KrZIsGwRQ9ytEliE2qHHpFzt4pwdwGAD51BNZcSvGlIHm6Mfpv3USoN9CUYGrs7DtRlRi3zSUsRYQcd7nVgnJ8LhWSIxAtRQjeB4xuSt3YzxBdcn970S32PLI05yQ1lzUiJMGPosMfUGtvD9bcbPBGrA5INZgrcnaGWtOd5X6RZMwJDVDKLIgN7HM=; 20:EFLvIqiig22s2ZmVsPjibjsIpSd8pJRZPz22pZfrA/NzMiJnutqGdPZkv4DCyfAJDMsv/TFGUqmoiLTEomhh2wr2fkf73PPhqgQY7cJhVyrc1hooUKJ0xQz+FyvYFQXKoVvMvpI38zZu1OT81uLASwsElUnlea05//p6boDy6EEMXW1geTMBD15CvQuAkXra3rrRlJSnng35NJRsCeTfJKVIYdaUYRiZeUPErKH3h6Pd5c6J8Wp1IvDbHmBVmKm3oLoqKG+4jNfj4FSWjOlZho7F7sFWkivZ6dL6uO8/2wwSuU0TroDvvJKKMVVyOpqc4+4o0y8IlZooC0zbgmeaAGlTNpInOwIEej8frquLy+9Z4LuppsJt3phZ9HptrbC3w8/YmCAspIluAws/4wlDZET9FiPS/zKuOvx0SxR8Ji5qm9fQ9pQN5r47LLovEcPzYESYpZhXVL7Xg8wfWG1jrMcqkCsGxmT20zuiVw/8eDLQX07C764fyopj7FwtBCMnwcR0Rw2CX9wy2HhfhCSdtlRZ7o80oR0bAgveTbLfHc0S5B2bZlHKrDtmUfeahGpnotRCfENcMl5EdUtG/NfjsJzDiUctI4dtxrBiXPL7YOg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:DvQRGVFVuvx8n5T9zsiYk4YxRa5chCogPeiM+GwE7Bx+qWSKBBR22pxjOjnOWXJjK7whgfM7BH89MFe03kuuzHM6LgEj9Tc/4aJfE7uxwqYDzqC5GrrKpfO0sDy3a3BquXr68/ikWVBpoxKmRHcWnvE90Ej1MwfvKYGAhW03pvYerXfqIjDC8uhJ0el3tqiLCfxjXW9trZxe834TubOa062xCt3qxVhwmu2LMwjgxtaFuo/N57ni8/PL7WxxIPKB/QJi0MPlPrcKcukh8MsrrXY2lwNYD2y1lRFf0D+hatgxNGueYSQL/u4o2XWqMqQ5yna7MU+iZC84L1GKQ5Svum1YtnHMIP4MP5tW3TN8qd06eakacQw0axXgQRoNZaXeFQJg4QSVq6T8Y96d8gJID4foca8bdNegO6BlUhqci1FDMPUIpUt+HxwvviRNdtgj63G8EnWXTD3UUKAIH5kWqamI+B++2sfr6h5lS6I5ZCTOAvvnD6tS2gRLlza33udrsEZ519pRabZ6eyqPHlM1ktZNLxDyWdHLSIoTR9rXlJP0NB/kc0iHVCwzRN8iP+rmEIx3ZxDhNOQv9Y+J9pu/FgbkeUezS+xTwwrzr8e2ek0= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(575784001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:hETXgwBJDUHN3qmCXCi1CPaVoZpLgQhY9VGlkP/R4?= =?us-ascii?Q?t7XVZDTbJyLTi0kpa+9kUHbTnb1u9ELMBbJ1I+NDBgRnuErq5NV6tqz3E3+l?= =?us-ascii?Q?Wg2N10oE8vB/cWWXsNvBOXVbe6A/v8dqp5RwXrBjJBisKlkbnllbGZuF5wPd?= =?us-ascii?Q?NvXEm1la6ANKqNpT1p1uoLxHB2I0DADBlT2IKQKHH2eeO6IroAONikqiOEWV?= =?us-ascii?Q?Y4q3yh1VGSLDMldyumqRbqj+OiQxXFohLpzCND4B8SnTjQTd6blkyNQHc54E?= =?us-ascii?Q?I6lsceBK0C92ejR2EEYeSF0U4g2S+g1QalYH/Ud4b8uGiN3ZXOY529zGkS2q?= =?us-ascii?Q?9/0uPbbiN1dLLOVjI1PxIRIAg+s7sJ1nL/EddQsnih7+H1ffBwNFOMUKTKp6?= =?us-ascii?Q?hEBRY3LwZ4AGLmlxvIFTuJ5+6Onot3J8Fq9uPD8RYZbNasMQ9Qfm3R0yJFaA?= =?us-ascii?Q?NReSpo5o/GnxyaN8M66SOTJW+iid3YRXWSOljWD7ZopQYg06UVwpg8qk8mXf?= =?us-ascii?Q?ty4rj0pWimt7YKsJ/4fSYx4iFccfK3pmhlFq7eA7hlMQQNAJCAd+bW6Ul9gg?= =?us-ascii?Q?3fMitDPv3mW4K54GyD/3Mlj2GGLqd2L+54PsRelTvsnbrV4XnRvxumXoNxeb?= =?us-ascii?Q?QJmMweLTN+LuQkh/ZaSfPcJPX3K1KmMm6iXmL1zOOJQsUuN19twG5rgUmlr3?= =?us-ascii?Q?hN+oYvQFbCuUHc3UcE3BdvoCNrAq9Pcbu8ciDOeagkSLjYsGpbURW5sNOL51?= =?us-ascii?Q?lCwitU4LTSrEwVreEHXxge/Hj+JrJ4upjySKK/WgYhMQkRbUkS1Gt9QbHwfr?= =?us-ascii?Q?ASixZMKTAvIW/nsZawlBiAdwpz1ZCwKuTHIBIa5I7pPt4QyjMY0AjdQIdU3I?= =?us-ascii?Q?tC5JUaV6tk/8voQ4aW51DaUEOe9GhlL58p3wBTFuDBvlaL1BIFFBJAQYU9lr?= =?us-ascii?Q?zyOMxxTpVFAU78qNqq9m6T11QwPdkFwlNL8Km1ZRR0kjgSGXABxHys5J4ECJ?= =?us-ascii?Q?u6Cz1g4mhP8l0s3vKjSn2pJKT7Y3XJ8NYby6aGCV7DnnRVeIIGViAIvqbOEA?= =?us-ascii?Q?6hMLhFt8k7Lnb7CGgSBYiGMw9smI9isJcPLVNUAhQ2B9q4Szw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:X1sUGODn/8p2d2TrTg5cjdzz8ch7u4/+8T5BdF8ozEI/hUgAa5lYf3S7VQ5bOgdaJP+8qG9P33zvs4Ms/NojKhUBUGmk0zwbtMlqDec2IKSy9AJazxWm1mPrsAr4x47DPP29d9cainmzDy7SoTIypSxDU3XPQI8BjQCeXaPexXP1Hyq0ylaZsRafZbxv04jT5NK7M5Rt8y9C+ljIk3Pm73DlaPUtXAyayYgyGmO7+no1H06mjZxV2Y9HgDh1828wzi/+j1Dx2KYDhiLQArARVSjWXYMpKYutFJ6QPJxam/ocYZK7x4LWDafT3ji4aFg3FVhX0/atGAbj3q+ezvelHHka9Q5k1lhNpA89KKM8UN3w9pgDIDiudBMHlQ9atP3E+aqZwHYj9Klr0Tt8lR4hbQ==; 5:TpgCC7Fk5xARQ80bax2V2eNlmg0bX5p1eNA924wIM5jFmmhcTOcD+78Di5LPhSb5n5CYCHgAIIwZk+sSGh9P44FXyEhFBVNqnze5TkvBAwIKd1KseNgoBsluq6VB8hrcRrS82uWZOhwypxyK49ag7g==; 24:Pmv+jP63/BZI3Fr4Wl8Wdp3VqF9xsvFCdoFczBRNlP+moyamu/LfOdhagS9lSghZQzS74fi+WbGVT2UQVMkCiOElipP16xzRPzkI0XBg4CY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:So7MWmWQeumPzAkrfFi+p6uJxeJOySczrkg/l3bnHaoQOm6l+uJBNhkuCjohCcXnbL8xsywt0Nqy1X1eKx8ng+qt7qixkGnRxS5dBX0e1hg5QUIc6dPanI/ekzATmmAqueEj0mRsjdzqH0ZMuUk0AT+2JSLL00K1k+sfc8x6vOnGG9mvdI4fuC8zAwmBjj0SmKRP+yyeNccRoccZbzrUDAOKxdBeJ9M5sD5T+hA4XsO2Z0tHpuz7KA73zUVMPPJIRfWR+AeDoGvbAzBOXANWsdSHV96yFkNwPoOROcQ33MGpAoQ0HuZPNEI0S0HND/9ojfi44eCHVhWFEaTPBYuiEw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:28:36.5365 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 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: Sat, 25 Mar 2017 06:28:41 -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 --- doc/guides/nics/features/liquidio.ini | 3 + 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 ++ 5 files changed, 402 insertions(+) diff --git a/doc/guides/nics/features/liquidio.ini b/doc/guides/nics/features/liquidio.ini index 29df586..8760849 100644 --- a/doc/guides/nics/features/liquidio.ini +++ b/doc/guides/nics/features/liquidio.ini @@ -8,6 +8,9 @@ Link status = Y Link status event = Y Jumbo frame = Y Scattered Rx = Y +RSS hash = Y +RSS key update = Y +RSS reta update = Y CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y 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