[2/2] net/bnxt: set Rx checksum flags in vector mode receive

Message ID 20190729212825.5077-1-lance.richardson@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [1/2] net/bnxt: fix context memory allocation |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Lance Richardson July 29, 2019, 9:28 p.m. UTC
  From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Fixed to return the checksum status of rx packets by setting
"ol_flags" correctly in vector mode receive.

These changes have been there for non vector mode receive.
In vector mode receive also indicate inner and outer checksum
errors individually in "ol_flag" to indicate L3 and L4 error.

Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c | 47 ++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
  

Comments

Ferruh Yigit July 30, 2019, 3:32 p.m. UTC | #1
On 7/29/2019 10:28 PM, Lance Richardson wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> Fixed to return the checksum status of rx packets by setting
> "ol_flags" correctly in vector mode receive.
> 
> These changes have been there for non vector mode receive.
> In vector mode receive also indicate inner and outer checksum
> errors individually in "ol_flag" to indicate L3 and L4 error.
> 
> Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")
> 
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
> Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>

Waiting ack from driver maintainers.
  
Somnath Kotur July 30, 2019, 3:45 p.m. UTC | #2
On Tue, Jul 30, 2019 at 2:58 AM Lance Richardson
<lance.richardson@broadcom.com> wrote:
>
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>
> Fixed to return the checksum status of rx packets by setting
> "ol_flags" correctly in vector mode receive.
>
> These changes have been there for non vector mode receive.
> In vector mode receive also indicate inner and outer checksum
> errors individually in "ol_flag" to indicate L3 and L4 error.
>
> Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")
>
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
> Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
> ---
>  drivers/net/bnxt/bnxt_rxtx_vec_sse.c | 47 ++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
>
> diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> index adc5020ec..2e6e83c94 100644
> --- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> +++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
> @@ -157,6 +157,52 @@ bnxt_parse_pkt_type(struct rx_pkt_cmpl *rxcmp, struct rx_pkt_cmpl_hi *rxcmp1)
>         return pkt_type;
>  }
>
> +static void
> +bnxt_parse_csum(struct rte_mbuf *mbuf, struct rx_pkt_cmpl_hi *rxcmp1)
> +{
> +       uint32_t flags;
> +
> +       flags = flags2_0xf(rxcmp1);
> +       /* IP Checksum */
> +       if (likely(IS_IP_NONTUNNEL_PKT(flags))) {
> +               if (unlikely(RX_CMP_IP_CS_ERROR(rxcmp1)))
> +                       mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
> +               else
> +                       mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
> +       } else if (IS_IP_TUNNEL_PKT(flags)) {
> +               if (unlikely(RX_CMP_IP_OUTER_CS_ERROR(rxcmp1) ||
> +                            RX_CMP_IP_CS_ERROR(rxcmp1)))
> +                       mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
> +               else
> +                       mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
> +       } else if (unlikely(RX_CMP_IP_CS_UNKNOWN(rxcmp1))) {
> +               mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
> +       }
> +
> +       /* L4 Checksum */
> +       if (likely(IS_L4_NONTUNNEL_PKT(flags))) {
> +               if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
> +                       mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
> +               else
> +                       mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
> +       } else if (IS_L4_TUNNEL_PKT(flags)) {
> +               if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
> +                       mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
> +               else
> +                       mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
> +               if (unlikely(RX_CMP_L4_OUTER_CS_ERR2(rxcmp1))) {
> +                       mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
> +               } else if (unlikely(IS_L4_TUNNEL_PKT_ONLY_INNER_L4_CS
> +                                   (flags))) {
> +                       mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_UNKNOWN;
> +               } else {
> +                       mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
> +               }
> +       } else if (unlikely(RX_CMP_L4_CS_UNKNOWN(rxcmp1))) {
> +               mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
> +       }
> +}
> +
>  uint16_t
>  bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>                    uint16_t nb_pkts)
> @@ -254,6 +300,7 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>                                 mbuf->ol_flags |= PKT_RX_VLAN;
>                         }
>
> +                       bnxt_parse_csum(mbuf, rxcmp1);
>                         mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
>
>                         rx_pkts[nb_rx_pkts++] = mbuf;
> --
> 2.17.1
>
Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
  
Somnath Kotur July 30, 2019, 3:45 p.m. UTC | #3
On Tue, Jul 30, 2019 at 9:02 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> On 7/29/2019 10:28 PM, Lance Richardson wrote:
> > From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> >
> > Fixed to return the checksum status of rx packets by setting
> > "ol_flags" correctly in vector mode receive.
> >
> > These changes have been there for non vector mode receive.
> > In vector mode receive also indicate inner and outer checksum
> > errors individually in "ol_flag" to indicate L3 and L4 error.
> >
> > Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")
> >
> > Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> > Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
> > Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
>
> Waiting ack from driver maintainers.
Ferruh,
        Just ack-ed the patch, sorry for the delay

Thanks
Som
  
Ferruh Yigit July 30, 2019, 5:23 p.m. UTC | #4
On 7/30/2019 4:45 PM, Somnath Kotur wrote:
> On Tue, Jul 30, 2019 at 2:58 AM Lance Richardson
> <lance.richardson@broadcom.com> wrote:
>>
>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>
>> Fixed to return the checksum status of rx packets by setting
>> "ol_flags" correctly in vector mode receive.
>>
>> These changes have been there for non vector mode receive.
>> In vector mode receive also indicate inner and outer checksum
>> errors individually in "ol_flag" to indicate L3 and L4 error.
>>
>> Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")
>>
>> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>> Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
>> Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
>
> Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index adc5020ec..2e6e83c94 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -157,6 +157,52 @@  bnxt_parse_pkt_type(struct rx_pkt_cmpl *rxcmp, struct rx_pkt_cmpl_hi *rxcmp1)
 	return pkt_type;
 }
 
+static void
+bnxt_parse_csum(struct rte_mbuf *mbuf, struct rx_pkt_cmpl_hi *rxcmp1)
+{
+	uint32_t flags;
+
+	flags = flags2_0xf(rxcmp1);
+	/* IP Checksum */
+	if (likely(IS_IP_NONTUNNEL_PKT(flags))) {
+		if (unlikely(RX_CMP_IP_CS_ERROR(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	} else if (IS_IP_TUNNEL_PKT(flags)) {
+		if (unlikely(RX_CMP_IP_OUTER_CS_ERROR(rxcmp1) ||
+			     RX_CMP_IP_CS_ERROR(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	} else if (unlikely(RX_CMP_IP_CS_UNKNOWN(rxcmp1))) {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+	}
+
+	/* L4 Checksum */
+	if (likely(IS_L4_NONTUNNEL_PKT(flags))) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+	} else if (IS_L4_TUNNEL_PKT(flags)) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+		if (unlikely(RX_CMP_L4_OUTER_CS_ERR2(rxcmp1))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
+		} else if (unlikely(IS_L4_TUNNEL_PKT_ONLY_INNER_L4_CS
+				    (flags))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_UNKNOWN;
+		} else {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
+		}
+	} else if (unlikely(RX_CMP_L4_CS_UNKNOWN(rxcmp1))) {
+		mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
+	}
+}
+
 uint16_t
 bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 		   uint16_t nb_pkts)
@@ -254,6 +300,7 @@  bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 				mbuf->ol_flags |= PKT_RX_VLAN;
 			}
 
+			bnxt_parse_csum(mbuf, rxcmp1);
 			mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
 
 			rx_pkts[nb_rx_pkts++] = mbuf;