From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D603A04F5 for ; Wed, 11 Dec 2019 22:28:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DA4A1BDFD; Wed, 11 Dec 2019 22:28:00 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 745281BE83 for ; Wed, 11 Dec 2019 22:27:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576099678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kasdER4Na8ygwOZZ+ic/nniTZ4dQReHiI6WnRgQPTr4=; b=Avq9p7JP/oIiZPgt4uw7bSrLuUCQ7rJaKI3UbjBeiW95DoPekyDgOPjS4U6LHOxClGWLBc VDv/wcrbS/ifBL4+Bwb5M0QW2lRXlwqMqWFO61jgzxiOVAo+taCrsRaQPsNh06tUn+gV1y VInJM+JsynV9LgsDmVwmblptGPn+Rus= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-wjkFj8BKNPCSvmhXX48BKQ-1; Wed, 11 Dec 2019 16:27:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C6FB477; Wed, 11 Dec 2019 21:27:55 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 663CC10013A1; Wed, 11 Dec 2019 21:27:54 +0000 (UTC) From: Kevin Traynor To: Xiaoyu Min Cc: Ori Kam , dpdk stable Date: Wed, 11 Dec 2019 21:26:06 +0000 Message-Id: <20191211212702.27851-14-ktraynor@redhat.com> In-Reply-To: <20191211212702.27851-1-ktraynor@redhat.com> References: <20191211212702.27851-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: wjkFj8BKNPCSvmhXX48BKQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'ethdev: fix expand RSS flows' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/17/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/5136c9fb9075bdb2e9= 215dadebc388cb3875df35 Thanks. Kevin. --- >From 5136c9fb9075bdb2e9215dadebc388cb3875df35 Mon Sep 17 00:00:00 2001 From: Xiaoyu Min Date: Tue, 5 Nov 2019 15:42:43 +0200 Subject: [PATCH] ethdev: fix expand RSS flows [ upstream commit fc2dd8dd492fade39a4c4de037ff3c869daff47d ] rte_flow_expand_rss expands rte_flow item list based on the RSS types. In another word, some additional rules are added if the user specified items are not complete enough according to the RSS type, for example: ... pattern eth / end actions rss type tcp end ... User only provides item eth but want to do RSS on tcp traffic. The pattern is not complete enough to filter TCP traffic only. This will be a problem for some HWs. So some PMDs use rte_flow_expand_rss to expand above user provided flow to: ... pattern eth / end actions rss types tcp ... pattern eth / ipv4 / tcp / end actions rss types tcp ... ... pattern eth / ipv6 / tcp / end actions rss types tcp ... in order to filter TCP traffic only and do RSS correctly. However the current expansion cannot handle pattern as below, which provides ethertype or ip next proto instead of providing an item: ... pattern eth type is 0x86DD / end actions rss types tcp ... rte_flow_expand_rss will expand above flow to: ... pattern eth type is 0x86DD / ipv4 / tcp end ... which has conflicting values: 0x86DD vs. ipv4 and some HWs will refuse to create flow. This patch will fix above by checking the last item's spec and to expand RSS flows correctly. Currently only support to complete item list based on ether type or ip next proto. Fixes: 4ed05fcd441b ("ethdev: add flow API to expand RSS flows") Signed-off-by: Xiaoyu Min Acked-by: Ori Kam --- lib/librte_ethdev/rte_flow.c | 132 +++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 5 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 3277be1ed..d545b15f5 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -158,4 +158,65 @@ flow_err(uint16_t port_id, int ret, struct rte_flow_er= ror *error) } =20 +static enum rte_flow_item_type +rte_flow_expand_rss_item_complete(const struct rte_flow_item *item) +{ +=09enum rte_flow_item_type ret =3D RTE_FLOW_ITEM_TYPE_VOID; +=09uint16_t ether_type =3D 0; +=09uint8_t ip_next_proto =3D 0; + +=09if (item =3D=3D NULL || item->spec =3D=3D NULL) +=09=09return ret; +=09switch (item->type) { +=09case RTE_FLOW_ITEM_TYPE_ETH: +=09=09ether_type =3D ((const struct rte_flow_item_eth *) +=09=09=09=09(item->spec))->type; +=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv4) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV4; +=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv6) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV6; +=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_VLAN) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_VLAN; +=09=09break; +=09case RTE_FLOW_ITEM_TYPE_VLAN: +=09=09ether_type =3D ((const struct rte_flow_item_vlan *) +=09=09=09=09(item->spec))->inner_type; +=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv4) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV4; +=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv6) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV6; +=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_VLAN) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_VLAN; +=09=09break; +=09case RTE_FLOW_ITEM_TYPE_IPV4: +=09=09ip_next_proto =3D ((const struct rte_flow_item_ipv4 *) +=09=09=09=09(item->spec))->hdr.next_proto_id; +=09=09if (ip_next_proto =3D=3D IPPROTO_UDP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_UDP; +=09=09else if (ip_next_proto =3D=3D IPPROTO_TCP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_TCP; +=09=09else if (ip_next_proto =3D=3D IPPROTO_IP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV4; +=09=09else if (ip_next_proto =3D=3D IPPROTO_IPV6) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV6; +=09=09break; +=09case RTE_FLOW_ITEM_TYPE_IPV6: +=09=09ip_next_proto =3D ((const struct rte_flow_item_ipv6 *) +=09=09=09=09(item->spec))->hdr.proto; +=09=09if (ip_next_proto =3D=3D IPPROTO_UDP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_UDP; +=09=09else if (ip_next_proto =3D=3D IPPROTO_TCP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_TCP; +=09=09else if (ip_next_proto =3D=3D IPPROTO_IP) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV4; +=09=09else if (ip_next_proto =3D=3D IPPROTO_IPV6) +=09=09=09ret =3D RTE_FLOW_ITEM_TYPE_IPV6; +=09=09break; +=09default: +=09=09ret =3D RTE_FLOW_ITEM_TYPE_VOID; +=09=09break; +=09} +=09return ret; +} + /* Get generic flow operations structure from a port. */ const struct rte_flow_ops * @@ -917,4 +978,9 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, si= ze_t size, =09size_t user_pattern_size =3D 0; =09void *addr =3D NULL; +=09const struct rte_flow_expand_node *next =3D NULL; +=09struct rte_flow_item missed_item; +=09int missed =3D 0; +=09int elt =3D 0; +=09const struct rte_flow_item *last_item =3D NULL; =20 =09lsize =3D offsetof(struct rte_flow_expand_rss, entry) + @@ -927,6 +993,6 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, si= ze_t size, =09} =09for (item =3D pattern; item->type !=3D RTE_FLOW_ITEM_TYPE_END; item++) = { -=09=09const struct rte_flow_expand_node *next =3D NULL; - +=09=09if (item->type !=3D RTE_FLOW_ITEM_TYPE_VOID) +=09=09=09last_item =3D item; =09=09for (i =3D 0; node->next && node->next[i]; ++i) { =09=09=09next =3D &graph[node->next[i]]; @@ -949,4 +1015,39 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, =09memset(flow_items, 0, sizeof(flow_items)); =09user_pattern_size -=3D sizeof(*item); +=09/* +=09 * Check if the last valid item has spec set +=09 * and need complete pattern. +=09 */ +=09missed_item.type =3D rte_flow_expand_rss_item_complete(last_item); +=09if (missed_item.type !=3D RTE_FLOW_ITEM_TYPE_VOID) { +=09=09next =3D NULL; +=09=09missed =3D 1; +=09=09for (i =3D 0; node->next && node->next[i]; ++i) { +=09=09=09next =3D &graph[node->next[i]]; +=09=09=09if (next->type =3D=3D missed_item.type) { +=09=09=09=09flow_items[0].type =3D missed_item.type; +=09=09=09=09flow_items[1].type =3D RTE_FLOW_ITEM_TYPE_END; +=09=09=09=09break; +=09=09=09} +=09=09=09next =3D NULL; +=09=09} +=09} +=09if (next && missed) { +=09=09elt =3D 2; /* missed item + item end. */ +=09=09node =3D next; +=09=09lsize +=3D elt * sizeof(*item) + user_pattern_size; +=09=09if ((node->rss_types & types) && lsize <=3D size) { +=09=09=09buf->entry[buf->entries].priority =3D 1; +=09=09=09buf->entry[buf->entries].pattern =3D addr; +=09=09=09buf->entries++; +=09=09=09rte_memcpy(addr, buf->entry[0].pattern, +=09=09=09=09 user_pattern_size); +=09=09=09addr =3D (void *)(((uintptr_t)addr) + user_pattern_size); +=09=09=09rte_memcpy(addr, flow_items, elt * sizeof(*item)); +=09=09=09addr =3D (void *)(((uintptr_t)addr) + +=09=09=09=09=09elt * sizeof(*item)); +=09=09} +=09} +=09memset(flow_items, 0, sizeof(flow_items)); =09next_node =3D node->next; =09stack[stack_pos] =3D next_node; @@ -961,6 +1062,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, s= ize_t size, =09=09=09 * plus the addition END item. =09=09=09 */ -=09=09=09int elt =3D stack_pos + 2; - +=09=09=09elt =3D stack_pos + 2; =09=09=09flow_items[stack_pos + 1].type =3D RTE_FLOW_ITEM_TYPE_END; =09=09=09lsize +=3D elt * sizeof(*item) + user_pattern_size; @@ -969,5 +1069,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, s= ize_t size, =20 =09=09=09=09buf->entry[buf->entries].priority =3D -=09=09=09=09=09stack_pos + 1; +=09=09=09=09=09stack_pos + 1 + missed; =09=09=09=09buf->entry[buf->entries].pattern =3D addr; =09=09=09=09buf->entries++; @@ -976,4 +1076,8 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, s= ize_t size, =09=09=09=09addr =3D (void *)(((uintptr_t)addr) + =09=09=09=09=09=09user_pattern_size); +=09=09=09=09rte_memcpy(addr, &missed_item, +=09=09=09=09=09 missed * sizeof(*item)); +=09=09=09=09addr =3D (void *)(((uintptr_t)addr) + +=09=09=09=09=09missed * sizeof(*item)); =09=09=09=09rte_memcpy(addr, flow_items, n); =09=09=09=09addr =3D (void *)(((uintptr_t)addr) + n); @@ -1000,4 +1104,22 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf,= size_t size, =09=09node =3D *next_node ? &graph[*next_node] : NULL; =09}; +=09/* no expanded flows but we have missed item, create one rule for it */ +=09if (buf->entries =3D=3D 1 && missed !=3D 0) { +=09=09elt =3D 2; +=09=09lsize +=3D elt * sizeof(*item) + user_pattern_size; +=09=09if (lsize <=3D size) { +=09=09=09buf->entry[buf->entries].priority =3D 1; +=09=09=09buf->entry[buf->entries].pattern =3D addr; +=09=09=09buf->entries++; +=09=09=09flow_items[0].type =3D missed_item.type; +=09=09=09flow_items[1].type =3D RTE_FLOW_ITEM_TYPE_END; +=09=09=09rte_memcpy(addr, buf->entry[0].pattern, +=09=09=09=09 user_pattern_size); +=09=09=09addr =3D (void *)(((uintptr_t)addr) + user_pattern_size); +=09=09=09rte_memcpy(addr, flow_items, elt * sizeof(*item)); +=09=09=09addr =3D (void *)(((uintptr_t)addr) + +=09=09=09=09=09elt * sizeof(*item)); +=09=09} +=09} =09return lsize; } --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-11 21:24:13.897111509 +0000 +++ 0014-ethdev-fix-expand-RSS-flows.patch=092019-12-11 21:24:12.596652685 = +0000 @@ -1 +1 @@ -From fc2dd8dd492fade39a4c4de037ff3c869daff47d Mon Sep 17 00:00:00 2001 +From 5136c9fb9075bdb2e9215dadebc388cb3875df35 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit fc2dd8dd492fade39a4c4de037ff3c869daff47d ] + @@ -44 +45,0 @@ -Cc: stable@dpdk.org @@ -53 +54 @@ -index 33e30111a..8ec9c90cd 100644 +index 3277be1ed..d545b15f5 100644 @@ -56 +57 @@ -@@ -214,4 +214,65 @@ flow_err(uint16_t port_id, int ret, struct rte_flow_e= rror *error) +@@ -158,4 +158,65 @@ flow_err(uint16_t port_id, int ret, struct rte_flow_e= rror *error) @@ -72 +73 @@ -+=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_IPV4) ++=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv4) @@ -74 +75 @@ -+=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_IPV6) ++=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv6) @@ -76 +77 @@ -+=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_VLAN) ++=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_VLAN) @@ -82 +83 @@ -+=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_IPV4) ++=09=09if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv4) @@ -84 +85 @@ -+=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_IPV6) ++=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_IPv6) @@ -86 +87 @@ -+=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D RTE_ETHER_TYPE_VLAN) ++=09=09else if (rte_be_to_cpu_16(ether_type) =3D=3D ETHER_TYPE_VLAN) @@ -122 +123 @@ -@@ -973,4 +1034,9 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, +@@ -917,4 +978,9 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, s= ize_t size, @@ -132 +133 @@ -@@ -983,6 +1049,6 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, +@@ -927,6 +993,6 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, s= ize_t size, @@ -141 +142 @@ -@@ -1005,4 +1071,39 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf= , size_t size, +@@ -949,4 +1015,39 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf,= size_t size, @@ -181 +182 @@ -@@ -1017,6 +1118,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf,= size_t size, +@@ -961,6 +1062,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, @@ -189 +190 @@ -@@ -1025,5 +1125,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf,= size_t size, +@@ -969,5 +1069,5 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, @@ -196 +197 @@ -@@ -1032,4 +1132,8 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf,= size_t size, +@@ -976,4 +1076,8 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, = size_t size, @@ -205 +206 @@ -@@ -1056,4 +1160,22 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf= , size_t size, +@@ -1000,4 +1104,22 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf= , size_t size,