From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0084.outbound.protection.outlook.com [104.47.1.84]) by dpdk.org (Postfix) with ESMTP id 6C06CAAD2 for ; Wed, 9 May 2018 13:54:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WYgoIl8qCSH1w7LmS0eqF23TWWzzX6xKl/PmvebUkiI=; b=AL04XChECudO4KB/TRirOmtP6f4bVI2I/QGZ6HtsYs5u6SMzlks/5YJKbCkHjpoUz/34cC2+zAqncoocgAk8syR833soyAF9vzhN/wa3ULqq/BTyOnqGC/h07Q1t/FMGCMaH5B9x9ydMSQQfyjFyPfSUqYxmkNrAY+rZA9wkxFs= Received: from HE1PR0501MB2314.eurprd05.prod.outlook.com (10.168.34.19) by HE1PR0501MB2443.eurprd05.prod.outlook.com (10.168.126.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.19; Wed, 9 May 2018 11:54:01 +0000 Received: from HE1PR0501MB2314.eurprd05.prod.outlook.com ([fe80::1071:70d0:eac1:5d97]) by HE1PR0501MB2314.eurprd05.prod.outlook.com ([fe80::1071:70d0:eac1:5d97%18]) with mapi id 15.20.0735.021; Wed, 9 May 2018 11:54:02 +0000 From: Ophir Munk To: Shahaf Shuler , "dev@dpdk.org" , Adrien Mazarguil CC: Thomas Monjalon , Olga Shern Thread-Topic: [PATCH v1] net/mlx4: report on supported RSS hash functions Thread-Index: AQHT5uNOIKWeHgXiR0+3ApeEKi2E8KQnJVAAgAAZ8fA= Date: Wed, 9 May 2018 11:54:01 +0000 Message-ID: References: <1525794195-25082-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR0501MB2443; 7:FwJKqD7Rf1O06Y5SeBnsigaw2ap1ZQ925rU024crKsUddOsOZoHrXb1Ov64v2AiEsZSYv3Dp66v7fYu5xtA9A2QkTKIw/YO9QYO0u2AdvX0GaHRR1TXHtT5eA11L4mif7IFPT35OB3jqyPEDPH2OL0RtBc4P0Ox+bisuptLsV32CuszXCjjUruLTUVCC/326MjVbavmkpT5wPyjUV1GeyyhafYyWmf/MbI25rIScuk88t8g29cqcnHvL8jDF5fWw x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2443; x-ms-traffictypediagnostic: HE1PR0501MB2443: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:HE1PR0501MB2443; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2443; x-forefront-prvs: 0667289FF8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(396003)(366004)(39380400002)(376002)(346002)(39860400002)(13464003)(189003)(199004)(74316002)(478600001)(316002)(110136005)(11346002)(2906002)(25786009)(106356001)(3280700002)(97736004)(5660300001)(14454004)(33656002)(486006)(3660700001)(105586002)(68736007)(54906003)(53546011)(8676002)(476003)(26005)(81166006)(6116002)(6436002)(81156014)(6246003)(66066001)(229853002)(7736002)(7696005)(102836004)(3846002)(76176011)(446003)(99286004)(6506007)(55016002)(5250100002)(2501003)(9686003)(86362001)(2900100001)(4326008)(53936002)(8936002)(305945005)(107886003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2443; H:HE1PR0501MB2314.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Hacb1QeOkNs27fmde7PD2sYSE0pXh+L0aTgNy8VoqI3uHoTZgrMJDo3vdcpLvXvJViJLGCJRZjxAJNPre+8qQV9Z04qSkiZV1pUn/8BBuivBJW0T8ZpdEfCMpos2ecwG/jq4kOrQfHvmtvPKhKz1Ps0UKMyZ3JTrYDSdgyk6gVTKo30/a0iTxuqPK1gV4zEy spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: acf60271-1e30-477b-6ae4-08d5b5a38ead X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: acf60271-1e30-477b-6ae4-08d5b5a38ead X-MS-Exchange-CrossTenant-originalarrivaltime: 09 May 2018 11:54:01.8944 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2443 Subject: Re: [dpdk-dev] [PATCH v1] net/mlx4: report on supported RSS hash functions 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: Wed, 09 May 2018 11:54:03 -0000 Hi Shahaf, > -----Original Message----- > From: Shahaf Shuler > Sent: Wednesday, May 09, 2018 12:39 PM > To: Ophir Munk ; dev@dpdk.org; Adrien > Mazarguil > Cc: Thomas Monjalon ; Olga Shern > > Subject: RE: [PATCH v1] net/mlx4: report on supported RSS hash functions >=20 > Hi Ophir, >=20 > Tuesday, May 8, 2018 6:43 PM, Ophir Munk: > > Subject: [PATCH v1] net/mlx4: report on supported RSS hash functions > > > > Report on mlx4 supported RSS functions as part of dev_infos_get callbac= k. > > Previous to this commit RSS support was reported as none. Since the > > introduction of [1] it is required that all RSS configurations will be = verified. > > > > [1] commit 8863a1fbfc66 ("ethdev: add supported hash function check") > > > > Signed-off-by: Ophir Munk > > --- > > drivers/net/mlx4/mlx4_ethdev.c | 51 > > ++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 51 insertions(+) > > > > diff --git a/drivers/net/mlx4/mlx4_ethdev.c > > b/drivers/net/mlx4/mlx4_ethdev.c index 9a76670..2a1533c 100644 > > --- a/drivers/net/mlx4/mlx4_ethdev.c > > +++ b/drivers/net/mlx4/mlx4_ethdev.c > > @@ -545,6 +545,55 @@ mlx4_mac_addr_set(struct rte_eth_dev *dev, > struct > > ether_addr *mac_addr) } > > > > /** > > + * Convert verbs RSS types to their DPDK equivalents. > > + * > > + * This function returns a group of RSS dpdk types given their > > +equivalent group > > + * of verbs types. > > + * For example both source IPv4 and destination IPv4 verbs types are > > +converted > > + * into their equivalent RSS group types. If each of these verbs > > +types existed > > + * exclusively - no conversion would take place. > > + * > > + * @param types > > + * RSS hash types in verbs format > > + * > > + * @return > > + * A valid dpdk RSS hash fields supported by mlx4 (may return 0) > > + */ > > +static uint64_t > > +mlx4_ibv_to_dpdk_rss_types(uint64_t types) { > > + enum { IPV4, IPV6, TCP, UDP, }; > > + const uint64_t in[] =3D { > > + [IPV4] =3D IBV_RX_HASH_SRC_IPV4 | > > IBV_RX_HASH_DST_IPV4, > > + [IPV6] =3D IBV_RX_HASH_SRC_IPV6 | > > IBV_RX_HASH_DST_IPV6, > > + [TCP] =3D IBV_RX_HASH_SRC_PORT_TCP | > > IBV_RX_HASH_DST_PORT_TCP, > > + [UDP] =3D IBV_RX_HASH_SRC_PORT_UDP | > > IBV_RX_HASH_DST_PORT_UDP, > > + }; > > + const uint64_t out[RTE_DIM(in)] =3D { > > + [IPV4] =3D (ETH_RSS_IPV4 | > > + ETH_RSS_FRAG_IPV4 | > > + ETH_RSS_NONFRAG_IPV4_OTHER), > > + [IPV6] =3D (ETH_RSS_IPV6 | > > + ETH_RSS_FRAG_IPV6 | > > + ETH_RSS_NONFRAG_IPV6_OTHER | > > + ETH_RSS_IPV6_EX), > > + [TCP] =3D (ETH_RSS_NONFRAG_IPV4_TCP | > > + ETH_RSS_NONFRAG_IPV6_TCP | > > + ETH_RSS_IPV6_TCP_EX), > > + [UDP] =3D (ETH_RSS_NONFRAG_IPV4_UDP | > > + ETH_RSS_NONFRAG_IPV6_UDP | > > + ETH_RSS_IPV6_UDP_EX), > > + }; >=20 > Since above are constants, why not defining a global array of structs > containing the ibv_hash and the equivalent dpdk_hash, instead of recreati= ng > it for each call? The array is recreated because it should have been declared as "static cons= t" rather than just "const". I prefer this fix. Alternatively it could have been defined globally outside of the function a= s suggested which would have avoided recreation as well. All of those claims are confirmed by inspecting the assembly code of the ab= ove alternatives. > There is a similar concept on mlx5_flow.c: >=20 > /* Initialization data for hash RX queues. */ > const struct hash_rxq_init hash_rxq_init[] =3D { > [HASH_RXQ_TCPV4] =3D { > .hash_fields =3D (IBV_RX_HASH_SRC_IPV4 | > IBV_RX_HASH_DST_IPV4 | > IBV_RX_HASH_SRC_PORT_TCP | > IBV_RX_HASH_DST_PORT_TCP), > .dpdk_rss_hf =3D ETH_RSS_NONFRAG_IPV4_TCP, > .flow_priority =3D 0, > .ip_version =3D MLX5_IPV4, > }, >=20 I was inspired from "the reversed" function in mlx4_flow.c which defines co= nstants inside the function as well, see [1]. To fix the constants recreation both functions should be handled together. I suggest: 1. Moving mlx4_ibv_to_dpdk_rss_types() function as is from mlx4_ether.c to = mlx4_flow.c so it will be adjacent to mlx4_conv_rss_types() function. 2. Sending a new patch that avoids constants recreation in the 2 functions.= =20 [1] uint64_t mlx4_conv_rss_types(struct priv *priv, uint64_t types) { enum { IPV4, IPV6, TCP, UDP, }; const uint64_t in[] =3D { [IPV4] =3D (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV4_OTHER), [IPV6] =3D (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_NONFRAG_IPV6_OTHER | ETH_RSS_IPV6_EX | ETH_RSS_IPV6_TCP_EX | ETH_RSS_IPV6_UDP_EX), [TCP] =3D (ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_IPV6_TCP_EX), [UDP] =3D (ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_IPV6_UDP_EX), }; const uint64_t out[RTE_DIM(in)] =3D { [IPV4] =3D IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4, [IPV6] =3D IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6, [TCP] =3D IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP, [UDP] =3D IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP, }; uint64_t seen =3D 0; uint64_t conv =3D 0; unsigned int i; if (types =3D=3D (uint64_t)-1) return priv->hw_rss_sup; for (i =3D 0; i !=3D RTE_DIM(in); ++i) if (types & in[i]) { seen |=3D types & in[i]; conv |=3D out[i]; } if ((conv & priv->hw_rss_sup) =3D=3D conv && !(types & ~seen)) return conv; rte_errno =3D ENOTSUP; return (uint64_t)-1; } > > + uint64_t conv =3D 0; > > + unsigned int i; > > + > > + for (i =3D 0; i !=3D RTE_DIM(in); ++i) > > + if ((types & in[i]) =3D=3D in[i]) > > + conv |=3D out[i]; > > + return conv; > > +} > > + > > +/** > > * DPDK callback to get information about the device. > > * > > * @param dev > > @@ -587,6 +636,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, > struct > > rte_eth_dev_info *info) > > ETH_LINK_SPEED_20G | > > ETH_LINK_SPEED_40G | > > ETH_LINK_SPEED_56G; > > + info->flow_type_rss_offloads =3D mlx4_ibv_to_dpdk_rss_types( > > + priv->hw_rss_sup); > > } > > > > /** > > -- > > 2.7.4