From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0058.outbound.protection.outlook.com [104.47.0.58]) by dpdk.org (Postfix) with ESMTP id C45AB4C94 for ; Fri, 9 Nov 2018 09:13:46 +0100 (CET) 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:X-MS-Exchange-SenderADCheck; bh=zqVQGOO/Y5sDNUVEWFlFh9JvCG9zCruZ4fzKBd4GvzM=; b=qwUQ1cFURsLISg5osZoAEhi7ybvWLcNaZb1jyfWiCqoCTgPtKtr7X2kXh6XqtsLzjHKceE9dpHWpjCatjqWhCI4OUR3eCWNTTTpujHPQgmhZlrO2lioef7aY1bCFOf+y0TK9jfDrKzk8HaH8j0S7z6T8xxsBx/fG6ggZfMoNRUU= Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com (52.134.8.154) by VI1PR0502MB3982.eurprd05.prod.outlook.com (52.134.18.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Fri, 9 Nov 2018 08:13:45 +0000 Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::84d3:8812:d45c:98e4]) by VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::84d3:8812:d45c:98e4%4]) with mapi id 15.20.1294.034; Fri, 9 Nov 2018 08:13:45 +0000 From: Ophir Munk To: Yongseok Koh , Adrien Mazarguil , Andrew Rybchenko CC: Ferruh Yigit , "dev@dpdk.org" , Thomas Monjalon , Asaf Penso , Shahaf Shuler , Olga Shern Thread-Topic: [dpdk-dev] [PATCH v2] ethdev: document RSS default key and types Thread-Index: AQHUdnuTE9UKU0bjB02/QczzO0OvtKVEDEOAgAAxJTCAABurAIAADKLwgAAevoCAAQ4DkIAA8DCAgACWZaA= Date: Fri, 9 Nov 2018 08:13:44 +0000 Message-ID: References: <1541259953-4273-1-git-send-email-ophirmu@mellanox.com> <1541582611-1609-1-git-send-email-ophirmu@mellanox.com> <20181107093109.GG4638@6wind.com> <20181107140604.GL4638@6wind.com> <20181107164118.GM4638@6wind.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: [109.186.53.234] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0502MB3982; 6:aiKvhSXfQY7r5e0FG4HJimJHYIO6x1o4nHHZYRNaWXeXCE81b1dx22jisTmjaYsF9EsQDpNs81SNqi9TfRPi9s9vdNfer8L18E9bBB5HB1EYJTAvcwzAFPSvF/bvAhv2EA3RKQt9k1uWg2G431MM7wb6JxgQPrFVHwDlwaXUgCeZ6MUZTtc8fWJxd+wbQmfdM37pcXZzooAFCS1AiDLLsgXVz9y+UMvMR7ExmhRlnGtPwVmFZz6FqVun49U831G/ib0lLy50pwwd7aD1seafRjlbFkN26+D2Xx7RbcGW+voTQUr72v+eCr3ifp880/8ID2q3jGqVFDLHv2L9tITdSZ08T5KwA8B01sn53wvgzeU4NgdIKDzXi8nEZZMiUuXo5vzBYBOhD3+4b9ipi+4Ljv5Se4iFAlnUgyjBy4m88H/qnTk3qOsD7ATVwDa1Pzi+mg/zA+tBekmFaiUQUEqeXQ==; 5:LOw7BwLXZ+ZcxbSZX2GlI3jzQtsTtKvEIOZ6E4/+HQCsz4HtJztBE+OEj2sNgRPaH5gfPvhJD05bAAIyNBt5/UnfiJS0/osZghulaI1V0YgqYXpHzUSx3UfGAQ2L4bsqvEaNtLxQwB+BGLPviMZVgGyLVSLVivuPecxKoYM3RlA=; 7:u+n0hNHDbxgOgpjVsHc//hjzgePyETMYOSL/1kPYSy8Zu4ULc48BE6YqaAcjvwlheCCeVf15Ae4eDn1YKBLp1cKlCj1JKsW58lZ+haXfQRKdn43nLj8ABOpFvrH9G7N7bfcIQIt72S6R0BrV17lAXw== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 573e0a66-f04f-4011-1197-08d6461b44d0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0502MB3982; x-ms-traffictypediagnostic: VI1PR0502MB3982: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(278428928389397)(45079756050767)(189930954265078)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR0502MB3982; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB3982; x-forefront-prvs: 08512C5403 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(136003)(366004)(39860400002)(13464003)(189003)(199004)(45080400002)(3846002)(966005)(229853002)(575784001)(6116002)(446003)(11346002)(4326008)(33656002)(25786009)(86362001)(106356001)(26005)(14454004)(105586002)(6506007)(99286004)(76176011)(66066001)(53546011)(478600001)(7696005)(102836004)(93886005)(2906002)(54906003)(110136005)(316002)(186003)(68736007)(486006)(6246003)(97736004)(81166006)(256004)(81156014)(14444005)(476003)(6436002)(9686003)(6306002)(55016002)(2900100001)(7736002)(8936002)(5660300001)(305945005)(53936002)(74316002)(71190400001)(71200400001)(4744004)(107886003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3982; H:VI1PR0502MB3743.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: 9YgWW6+pSfFyr7M0qkEbNim2k2v1QVDAXN6ZBOfewnxkQyMg0qIRolMTiqqiLlTqU+H+gXZ1ErrMx8r4hHk/bPro75hJzj0hzzBCxH7qVDHH0JTNfPwZViwtG4v0TqwHqu0KRnG+BD8LsVZaXD1waSgba/O8WX36VdIyCTbyhBorphyDMncNqDBvhirvOLBdm9tl/VzZjP8iMWqReKWwcibnDN7bbidSSrr+Rnv+Mb4If23tCh/X3kGKBWVsmT/22GlnZ/hDWBPdin5yMK86GTvbjZe/BPxflw9l2DD3PmwKQaRpycvHPcGPOH/F/nCIRPLY2853N5mYrRX/5O//qLYHgMkHm3stKIymb2b+1dA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 573e0a66-f04f-4011-1197-08d6461b44d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2018 08:13:44.9395 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3982 Subject: Re: [dpdk-dev] [PATCH v2] ethdev: document RSS default key and types 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: Fri, 09 Nov 2018 08:13:47 -0000 > -----Original Message----- > From: Yongseok Koh > Sent: Friday, November 09, 2018 1:07 AM > To: Ophir Munk ; Adrien Mazarguil > ; Andrew Rybchenko > > Cc: Ferruh Yigit ; dev@dpdk.org; Thomas Monjalon > ; Asaf Penso ; Shahaf > Shuler ; Olga Shern > Subject: Re: [dpdk-dev] [PATCH v2] ethdev: document RSS default key and > types >=20 >=20 > > On Nov 8, 2018, at 12:50 AM, Ophir Munk > wrote: > > > > > > > >> -----Original Message----- > >> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > >> Sent: Wednesday, November 07, 2018 6:41 PM > >> To: Ophir Munk > >> Cc: Ferruh Yigit ; Andrew Rybchenko > >> ; dev@dpdk.org; Thomas Monjalon > >> ; Asaf Penso ; Shahaf > Shuler > >> ; Olga Shern > >> Subject: Re: [dpdk-dev] [PATCH v2] ethdev: document RSS default key > >> and types > >> > >> On Wed, Nov 07, 2018 at 03:13:07PM +0000, Ophir Munk wrote: > >>> > >>>> -----Original Message----- > >>>> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > >>>> Sent: Wednesday, November 07, 2018 4:06 PM > >>>> To: Ophir Munk > >>>> Cc: Ferruh Yigit ; Andrew Rybchenko > >>>> ; dev@dpdk.org; Thomas Monjalon > >>>> ; Asaf Penso ; Shahaf > >>>> Shuler ; Olga Shern > >>>> Subject: Re: [dpdk-dev] [PATCH v2] ethdev: document RSS default key > >>>> and types > >>>> > >>>> On Wed, Nov 07, 2018 at 12:39:24PM +0000, Ophir Munk wrote: > >>>>>> -----Original Message----- > >>>>>> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] > >>>>>> Sent: Wednesday, November 07, 2018 11:31 AM > >>>>>> To: Ophir Munk > >>>>>> Cc: Ferruh Yigit ; Andrew Rybchenko > >>>>>> ; dev@dpdk.org; Thomas Monjalon > >>>>>> ; Asaf Penso ; > >> Shahaf > >>>>>> Shuler ; Olga Shern > >> > >>>>>> Subject: Re: [dpdk-dev] [PATCH v2] ethdev: document RSS default > >>>>>> key and types > >>>>>> > >>>>>> On Wed, Nov 07, 2018 at 09:23:42AM +0000, Ophir Munk wrote: > >>>>>>> struct rte_flow_action_rss include fields 'key' and 'types'. > >>>>>>> Field 'key' is a pointer to bytes array (uint8_t *) which > >>>>>>> contains the specific RSS hash key. > >>>>>>> If an application is only interested in default RSS operation it > >>>>>>> should not care about the specific hash key. The application can > >>>>>>> set the hash key to NULL such that any PMD uses its > >> default RSS key. > >>>>>>> > >>>>>>> Field 'types' is a uint64_t bits flag used to specify a specific > >>>>>>> RSS hash type such as ETH_RSS_IP (see ETH_RSS_*). > >>>>>>> If an application does not care about the specific RSS type it > >>>>>>> can set this field to 0 such that any PMD uses its default type. > >>>>>>> > >>>>>>> Signed-off-by: Ophir Munk > >>>>>>> --- > >>>>>>> lib/librte_ethdev/rte_flow.h | 9 +++++++-- > >>>>>>> 1 file changed, 7 insertions(+), 2 deletions(-) > >>>>>>> > >>>>>>> diff --git a/lib/librte_ethdev/rte_flow.h > >>>>>>> b/lib/librte_ethdev/rte_flow.h index c0fe879..ca9e135 100644 > >>>>>>> --- a/lib/librte_ethdev/rte_flow.h > >>>>>>> +++ b/lib/librte_ethdev/rte_flow.h > >>>>>>> @@ -1782,10 +1782,15 @@ struct rte_flow_action_rss { > >>>>>>> * through. > >>>>>>> */ > >>>>>>> uint32_t level; > >>>>>>> - uint64_t types; /**< Specific RSS hash types (see > >> ETH_RSS_*). */ > >>>>>>> + /** > >>>>>>> + * Specific RSS hash types (see ETH_RSS_*), > >>>>>>> + * or 0 for PMD specific default. > >>>>>>> + */ > >>>>>>> + uint64_t types; > >>>>>>> uint32_t key_len; /**< Hash key length in bytes. */ > >>>>>>> uint32_t queue_num; /**< Number of entries in @p queue. > >> */ > >>>>>>> - const uint8_t *key; /**< Hash key. */ > >>>>>>> + /** Hash key, or NULL for PMD specific default key. */ > >>>>>>> + const uint8_t *key; > >>>>>> > >>>>>> I'd suggest to document that on key_len instead. If key_len is > >>>>>> nonzero, key cannot be NULL anyway. > >>>>> > >>>>> The decision if a key/len combination is valid is done in the PMD > >>>>> action > >>>> validation API. > >>>>> For example, in MLX5 key=3D=3DNULL and key_len=3D=3D40 is accepted. > >>>>> The combination key=3D=3DNULL and key_len=3D=3D0 should always succ= eeds, > >>>> however the "must" parameter for RSS default is key=3D=3DNULL and no= t > >>>> key_len=3D=3D0. > >>>> > >>>> I understand this is how the mlx5 PMD implemented it, but my point > >>>> is that it makes more sense API-wise to define key_len =3D=3D 0 as t= he > >>>> trigger for a default RSS hash key than key =3D=3D NULL. > >>>> > >>>> My suggestion is to follow the same trend as memcpy(), mmap(), > >>>> snprintf() and other well-known functions that take a size when > >>>> dealing with NULL/undefined pointers. Only size matters! :) > >>>> > >>> > >>> Please let's stay backward compatible and consistent with previous > >>> dpdk releases where key=3D=3DNULL is used in struct rte_eth_rss_conf > >>> (see > >> code snippet in [1]). > >> > >> And I thought I wouldn't hear again from that structure after > >> ac8d22de2394 > >> ("ethdev: flatten RSS configuration in flow API") got rid of it in > >> rte_flow > >> :) > >> > >> There is no need to be backward compatible with it particularly if > >> doing so improves consistency (assuming you agree it does). > >> > >> Take "rss_hf" versus "types" fields for instance [2]. Unsetting the > >> former disables RSS completely while unsetting the latter provides > >> default RSS settings for that flow rule, simply because a RSS action > >> that doesn't do RSS makes no sense (one could provide a single queue f= or > that). > >> > >> Regarding "key_len", have a look at this other message [3] in the > >> same thread which clearly states that i40e expects a zero key length > >> to trigger default RSS, it doesn't rely on a NULL pointer. > >> > >> Generally speaking, I'm pushing for zero values in action objects to > >> result in a safe default behavior. A nonzero key_len with a NULL key > >> may result in a crash, while the reverse is inherently safer since > >> one doesn't even need to check the size or pointer validity, e.g.: > >> > >> memcpy(target_device_rss_stuff, rss_conf->key, rss_conf->key_len); > >> > >> What's not to like? > >> > > > > Some think key=3D=3DNULL && key_len!=3D0 is senseless while other think > key!=3DNULL && key_len=3D=3D0 is senseless. > > Let's agree on both key=3D=3DNULL && key_len=3D=3D0. >=20 > A bug's already been found by our QA team. The following command > crashes. > flow create 0 ingress pattern eth / ipv6 / udp / end actions rss queues= 0 end > level 2 types udp end key_len 40 / end >=20 > due to null pointer access in the following code: >=20 > lib/librte_ethdev/rte_flow.c > @@ -464,7 +464,7 @@ rte_flow_conv_action_conf(void *buf, const size_t > size, > }), > size > sizeof(*dst.rss) ? sizeof(*dst.rss) : s= ize); > off =3D sizeof(*dst.rss); > if (src.rss->key_len) { > off =3D RTE_ALIGN_CEIL(off, sizeof(*dst.rss->key)= ); > tmp =3D sizeof(*src.rss->key) * src.rss->key_len; > if (size >=3D off + tmp) > dst.rss->key =3D rte_memcpy > ((void *)((uintptr_t)dst.rss + of= f), > src.rss->key, tmp); > off +=3D tmp; > } >=20 >=20 > I wanted to submit a patch to add a sanity check, >=20 > - if (src.rss->key_len) { > + if (src.rss->key && src.rss->key_len) { >=20 > but looks like we should conclude this thread first? > Or, does the fix make any sense regardless of having key_len=3D0 or key= =3Dnull > for default key? > Having more sanity check is no harm usually... >=20 >=20 > Thanks, > Yongseok >=20 The setfault is the result of commit a4391f8bae ("app/testpmd: set default = RSS key as null"). Reverting this commit should fix the segfault but it also means there is no= way to set default key (key=3DNULL) with testpmd. Need to check if this is only a testpmd limitation and not all applications= limitation. We should decide how an application can set default RSS without knowing any= thing about keys. >=20 > > > >> [2] "Re: [PATCH v2 07/15] ethdev: flatten RSS configuration in flow AP= I" > >> > >> > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fma > >> i > >> ls.dpdk.org%2Farchives%2Fdev%2F2018- > >> > April%2F096235.html&data=3D02%7C01%7Cophirmu%40mellanox.com% > >> > 7C4fdd2e5a838047c152c408d644cfe439%7Ca652971c7d2e4d9ba6a4d14925 > >> > 6f461b%7C0%7C0%7C636772057013784575&sdata=3D6JsomMO68lJoiNd > >> ehRaNdn2xG9BSAgqCjxwpJJJOP8A%3D&reserved=3D0 > >> > >> [3] "Re: [dpdk-dev] [PATCH v6 07/16] ethdev: flatten RSS configuration= in > >> flow API" > >> > >> > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fma > >> i > >> ls.dpdk.org%2Farchives%2Fdev%2F2018- > >> > May%2F100128.html&data=3D02%7C01%7Cophirmu%40mellanox.com%7 > >> > C4fdd2e5a838047c152c408d644cfe439%7Ca652971c7d2e4d9ba6a4d149256 > >> > f461b%7C0%7C0%7C636772057013784575&sdata=3DTXDTKLho8qyKlH%2 > >> FqBturGHWhvdfaACuMoqvl0eOjfcU%3D&reserved=3D0 > >> > >>> We should avoid confusing applications with setting key=3D=3DNULL wit= h > >> legacy RSS and key_len=3D=3D0 with rte_flows. > >>> > >>> With regard to trends APIs - I was thinking about free() where a > >>> NULL pointer is acceptable :) > >> > >> Yeah, though free() doesn't take a size. On the other hand the > >> behavior of > >> realloc() is much more interesting when faced with a zero size :) > >> That's probably one of the few exceptions so I guess my point still st= ands. > >> > >>> > >>> [1] > >>> File lib/librte_ethdev/rte_ethdev.h: > >>> > >>> /** > >>> * A structure used to configure the Receive Side Scaling (RSS) > >>> feature > >>> * of an Ethernet port. > >>> * If not NULL, the *rss_key* pointer of the *rss_conf* structure > >>> points > >>> * to an array holding the RSS key to use for hashing specific header > >>> * fields of received packets. The length of this array should be > >>> indicated > >>> * by *rss_key_len* below. Otherwise, a default random hash key is > >>> used by > >>> * the device driver. > >>> * > >>> * The *rss_key_len* field of the *rss_conf* structure indicates the > >>> length > >>> * in bytes of the array pointed by *rss_key*. To be compatible, this > >>> length > >>> * will be checked in i40e only. Others assume 40 bytes to be used as > >> before. > >>> * > >>> * .......... > >>> */ > >>> struct rte_eth_rss_conf { > >>> uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */ > >>> uint8_t rss_key_len; /**< hash key length in bytes. */ > >>> uint64_t rss_hf; /**< Hash functions to apply - see below. */ > >>> }; > >> > >> -- > >> Adrien Mazarguil > >> 6WIND