From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by dpdk.org (Postfix) with ESMTP id A8F321B769 for ; Wed, 7 Feb 2018 00:24:15 +0100 (CET) Received: by mail-qk0-f193.google.com with SMTP id l29so4581770qkj.8 for ; Tue, 06 Feb 2018 15:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P/VKMkCKPBqFKB1EhRXf8Lf7Ed+jWyyJChi5XNo4mb0=; b=BBvITA6Fa3kU5oNXpLyNTmU5Ipgn6vkPn/8T3Up0+S/SBRdGE3FsO8RkDh4MqneI0p KKh5aqe5g1vKGh2Zx7rZDvBadD11tyQ/01wUDrg4HW7iPo4j7m/vjHucF2qTZ33kUw9e n/CCOwBcYJPkMj99tKkR+rowFTqQLx9Qn4hWM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P/VKMkCKPBqFKB1EhRXf8Lf7Ed+jWyyJChi5XNo4mb0=; b=RkQbF0BbaEAh9jW8U+KqwtsPhFCNiMS5s7LGIuPgqpzq/9ow1BddFuMH3nUMgByHV3 MKllatFNSo7NHvC1kI6c+L3R7NYg4zYF1LVpvvrnTGUFlYrTjYrD02YNDDQR26GS7J94 yPuPGzrlx4HIEnGSGjbdmDZGM09hmQzLzgxH6tNLbEYlFIENBf4YJ7J4ZV/yRByzARDq Dk9yheQ/skQSkqcmOJMaanwSTvqkva7BJZS3p7XZ6Z7NO03RFOP4PjvF041tNQC7eTbj ZwMmB9WjJmkSqnB1emLmkB+jMLnAIOflA+s1zisX7p5gFKg94rzd1t0ukiWZdwKHj8U8 SnbQ== X-Gm-Message-State: APf1xPAEvdFNlGlK/xem4GuZ8QipjnncI5pwajDiEmKIvpFR5tT8kDzo EY2f0y3d7ES7ibEUxpKbg6h9hp9rDnSw4loxNxAUgw== X-Google-Smtp-Source: AH8x224CiK9ULJRlxr2uVNxbiVcLRle7uTHIv0DIGBjiXCRrfPO/XnczvIE/oL1siemEveQByP0efjWBvyUs9CMBZKs= X-Received: by 10.55.210.195 with SMTP id f186mr5973517qkj.267.1517959454966; Tue, 06 Feb 2018 15:24:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.47.228 with HTTP; Tue, 6 Feb 2018 15:23:34 -0800 (PST) In-Reply-To: <20180206170758.1148-1-olivier.matz@6wind.com> References: <20180206170758.1148-1-olivier.matz@6wind.com> From: Ajit Khaparde Date: Tue, 6 Feb 2018 15:23:34 -0800 Message-ID: To: Olivier Matz Cc: dev@dpdk.org, Somnath Kotur , dpdk stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-stable] [PATCH] net/bnxt: fix packet type 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: , X-List-Received-Date: Tue, 06 Feb 2018 23:24:16 -0000 On Tue, Feb 6, 2018 at 9:07 AM, Olivier Matz wrote= : > The hw flags are not read correctly: the defines > RX_PKT_CMPL_FLAGS_ITYPE_* are not bits but values, so the should not be > tested with if (value & X) but with if ((value & MASK) =3D=3D X). > This was resulting in a wrong packet type. > > For instance, an IPv4/ICMP packet was returning a value of 7 for > the layer 4, which is undefined. > > This patch rework the way packet types are processed, to ensure > that only valid packet types will be advertised. > > Fixes: 3d2a6644eb05 ("net/bnxt: support getting ptypes") > Cc: stable@dpdk.org > > Signed-off-by: Olivier Matz > =E2=80=8BAcked-by: Ajit Khaparde =E2=80=8B > --- > drivers/net/bnxt/bnxt_rxr.c | 75 ++++++++++++++++++++++++++++-- > --------------- > 1 file changed, 47 insertions(+), 28 deletions(-) > > diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c > index 9b88a64bf..2b4044a83 100644 > --- a/drivers/net/bnxt/bnxt_rxr.c > +++ b/drivers/net/bnxt/bnxt_rxr.c > @@ -338,41 +338,60 @@ static inline struct rte_mbuf *bnxt_tpa_end( > static uint32_t > bnxt_parse_pkt_type(struct rx_pkt_cmpl *rxcmp, struct rx_pkt_cmpl_hi > *rxcmp1) > { > - uint32_t pkt_type =3D 0; > - uint32_t t_ipcs =3D 0, ip =3D 0, ip6 =3D 0; > - uint32_t tcp =3D 0, udp =3D 0, icmp =3D 0; > - uint32_t vlan =3D 0; > + uint32_t l3, pkt_type =3D 0; > + uint32_t t_ipcs =3D 0, ip6 =3D 0, vlan =3D 0; > + uint32_t flags_type; > > vlan =3D !!(rxcmp1->flags2 & > rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN)); > + pkt_type |=3D vlan ? RTE_PTYPE_L2_ETHER_VLAN : RTE_PTYPE_L2_ETHER= ; > + > t_ipcs =3D !!(rxcmp1->flags2 & > rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC)); > ip6 =3D !!(rxcmp1->flags2 & > rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_IP_TYPE)); > - icmp =3D !!(rxcmp->flags_type & > - rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_ICMP)); > - tcp =3D !!(rxcmp->flags_type & > - rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_TCP)); > - udp =3D !!(rxcmp->flags_type & > - rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_UDP)); > - ip =3D !!(rxcmp->flags_type & > - rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_IP)); > - > - pkt_type |=3D ((ip || tcp || udp || icmp) && !t_ipcs && !ip6) ? > - RTE_PTYPE_L3_IPV4_EXT_UNKNOWN : 0; > - pkt_type |=3D ((ip || tcp || udp || icmp) && !t_ipcs && ip6) ? > - RTE_PTYPE_L3_IPV6_EXT_UNKNOWN : 0; > - pkt_type |=3D (!t_ipcs && icmp) ? RTE_PTYPE_L4_ICMP : 0; > - pkt_type |=3D (!t_ipcs && udp) ? RTE_PTYPE_L4_UDP : 0; > - pkt_type |=3D (!t_ipcs && tcp) ? RTE_PTYPE_L4_TCP : 0; > - pkt_type |=3D ((ip || tcp || udp || icmp) && t_ipcs && !ip6) ? > - RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN : 0; > - pkt_type |=3D ((ip || tcp || udp || icmp) && t_ipcs && ip6) ? > - RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN : 0; > - pkt_type |=3D (t_ipcs && icmp) ? RTE_PTYPE_INNER_L4_ICMP : 0; > - pkt_type |=3D (t_ipcs && udp) ? RTE_PTYPE_INNER_L4_UDP : 0; > - pkt_type |=3D (t_ipcs && tcp) ? RTE_PTYPE_INNER_L4_TCP : 0; > - pkt_type |=3D vlan ? RTE_PTYPE_L2_ETHER_VLAN : 0; > + > + flags_type =3D rxcmp->flags_type & > + rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS_ITYPE_MASK); > + > + if (!t_ipcs && !ip6) > + l3 =3D RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; > + else if (!t_ipcs && ip6) > + l3 =3D RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; > + else if (t_ipcs && !ip6) > + l3 =3D RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; > + else > + l3 =3D RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; > + > + switch (flags_type) { > + case RTE_LE32(RX_PKT_CMPL_FLAGS_ITYPE_ICMP): > + if (!t_ipcs) > + pkt_type |=3D l3 | RTE_PTYPE_L4_ICMP; > + else > + pkt_type |=3D l3 | RTE_PTYPE_INNER_L4_ICMP; > + break; > + > + case RTE_LE32(RX_PKT_CMPL_FLAGS_ITYPE_TCP): > + if (!t_ipcs) > + pkt_type |=3D l3 | RTE_PTYPE_L4_TCP; > + else > + pkt_type |=3D l3 | RTE_PTYPE_INNER_L4_TCP; > + break; > + > + case RTE_LE32(RX_PKT_CMPL_FLAGS_ITYPE_UDP): > + if (!t_ipcs) > + pkt_type |=3D l3 | RTE_PTYPE_L4_UDP; > + else > + pkt_type |=3D l3 | RTE_PTYPE_INNER_L4_UDP; > + break; > + > + case RTE_LE32(RX_PKT_CMPL_FLAGS_ITYPE_IP): > + if (!t_ipcs) > + pkt_type |=3D l3 | RTE_PTYPE_L4_ICMP; > + else > + pkt_type |=3D l3 | RTE_PTYPE_INNER_L4_ICMP; > + break; > + } > > return pkt_type; > } > -- > 2.11.0 > >