[dpdk-dev] net/ena: TX L4 offloads should not be set in RX path

Message ID 1516894063-8551-1-git-send-email-rk@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Rafal Kozik Jan. 25, 2018, 3:27 p.m. UTC
  Information about received packet type detected by NIC should be
stored in packet_type field of rte_mbuf. TX L4 offload flags should
not be set in RX path. Only fields that could be set in of_flags
during packet receiving are information if L4 and L3 checksum is
correct.

Fixes: 1173fca25af9 ("ena: add polling-mode driver")

Reported-by: Matthew Smith <mgsmith@netgate.com>
Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Comments

Michal Krawczyk Jan. 25, 2018, 4:13 p.m. UTC | #1
2018-01-25 16:27 GMT+01:00 Rafal Kozik <rk@semihalf.com>:
>
> Information about received packet type detected by NIC should be
> stored in packet_type field of rte_mbuf. TX L4 offload flags should
> not be set in RX path. Only fields that could be set in of_flags
> during packet receiving are information if L4 and L3 checksum is
> correct.
>
> Fixes: 1173fca25af9 ("ena: add polling-mode driver")
>
> Reported-by: Matthew Smith <mgsmith@netgate.com>
> Signed-off-by: Rafal Kozik <rk@semihalf.com>
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
> ---
>  drivers/net/ena/ena_ethdev.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index 83e0ae2..1e2af80 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -275,16 +275,17 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>                                        struct ena_com_rx_ctx *ena_rx_ctx)
>  {
>         uint64_t ol_flags = 0;
> +       uint32_t packet_type = 0;
>
>         if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP)
> -               ol_flags |= PKT_TX_TCP_CKSUM;
> +               packet_type |= RTE_PTYPE_L4_TCP;
>         else if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)
> -               ol_flags |= PKT_TX_UDP_CKSUM;
> +               packet_type |= RTE_PTYPE_L4_UDP;
>
>         if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4)
> -               ol_flags |= PKT_TX_IPV4;
> +               packet_type |= RTE_PTYPE_L3_IPV4;
>         else if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV6)
> -               ol_flags |= PKT_TX_IPV6;
> +               packet_type |= RTE_PTYPE_L3_IPV6;
>
>         if (unlikely(ena_rx_ctx->l4_csum_err))
>                 ol_flags |= PKT_RX_L4_CKSUM_BAD;
> @@ -292,6 +293,7 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>                 ol_flags |= PKT_RX_IP_CKSUM_BAD;
>
>         mbuf->ol_flags = ol_flags;
> +       mbuf->packet_type = packet_type;
>  }
>
>  static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,
> --
> 2.7.4
>
  
Ferruh Yigit Jan. 26, 2018, 3:48 p.m. UTC | #2
On 1/25/2018 4:13 PM, Michał Krawczyk wrote:
> 2018-01-25 16:27 GMT+01:00 Rafal Kozik <rk@semihalf.com>:
>>
>> Information about received packet type detected by NIC should be
>> stored in packet_type field of rte_mbuf. TX L4 offload flags should
>> not be set in RX path. Only fields that could be set in of_flags
>> during packet receiving are information if L4 and L3 checksum is
>> correct.
>>
>> Fixes: 1173fca25af9 ("ena: add polling-mode driver")

    Cc: stable@dpdk.org

>>
>> Reported-by: Matthew Smith <mgsmith@netgate.com>
>> Signed-off-by: Rafal Kozik <rk@semihalf.com>
> Signed-off-by: Michal Krawczyk <mk@semihalf.com>

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

Patch

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 83e0ae2..1e2af80 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -275,16 +275,17 @@  static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 				       struct ena_com_rx_ctx *ena_rx_ctx)
 {
 	uint64_t ol_flags = 0;
+	uint32_t packet_type = 0;
 
 	if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP)
-		ol_flags |= PKT_TX_TCP_CKSUM;
+		packet_type |= RTE_PTYPE_L4_TCP;
 	else if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)
-		ol_flags |= PKT_TX_UDP_CKSUM;
+		packet_type |= RTE_PTYPE_L4_UDP;
 
 	if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4)
-		ol_flags |= PKT_TX_IPV4;
+		packet_type |= RTE_PTYPE_L3_IPV4;
 	else if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV6)
-		ol_flags |= PKT_TX_IPV6;
+		packet_type |= RTE_PTYPE_L3_IPV6;
 
 	if (unlikely(ena_rx_ctx->l4_csum_err))
 		ol_flags |= PKT_RX_L4_CKSUM_BAD;
@@ -292,6 +293,7 @@  static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 		ol_flags |= PKT_RX_IP_CKSUM_BAD;
 
 	mbuf->ol_flags = ol_flags;
+	mbuf->packet_type = packet_type;
 }
 
 static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,