diff mbox

[dpdk-dev] net/enic: set L4 checksum flags for IPv6 packets

Message ID 20180123010529.17748-1-johndale@cisco.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show

Checks

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

Commit Message

John Daley Jan. 23, 2018, 1:05 a.m. UTC
From: Hyong Youb Kim <hyonkim@cisco.com>

enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
for IPv4.  The hardware actually validates the TCP/UDP checksum of
IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
---
 drivers/net/enic/enic_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ferruh Yigit Jan. 24, 2018, 5:18 p.m. UTC | #1
On 1/23/2018 1:05 AM, John Daley wrote:
> From: Hyong Youb Kim <hyonkim@cisco.com>
> 
> enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
> for IPv4.  The hardware actually validates the TCP/UDP checksum of
> IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.
> 
> Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
> Reviewed-by: John Daley <johndale@cisco.com>
> ---
>  drivers/net/enic/enic_rxtx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c
> index 98902caa0..8157697a0 100644
> --- a/drivers/net/enic/enic_rxtx.c
> +++ b/drivers/net/enic/enic_rxtx.c
> @@ -185,14 +185,14 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
>  	}
>  
>  	/* checksum flags */
> -	if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
> +	if (mbuf->packet_type & (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV6)) {
>  		if (!enic_cq_rx_desc_csum_not_calc(cqrd)) {
>  			uint32_t l4_flags;
>  			l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
>  
>  			if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
>  				pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
> -			else
> +			else if (mbuf->packet_type & RTE_PTYPE_L3_IPV4)

This looks like conflicting with commit log.
Is pkt_flags intentionally not set for this case?
If so can you update commit log to say only PKT_RX_IP_CKSUM_GOOD set for ipv6?

>  				pkt_flags |= PKT_RX_IP_CKSUM_BAD;
>  
>  			if (l4_flags == RTE_PTYPE_L4_UDP ||
>
Hyong Youb Kim Jan. 24, 2018, 5:30 p.m. UTC | #2
On Wed, Jan 24, 2018 at 05:18:37PM +0000, Ferruh Yigit wrote:
> On 1/23/2018 1:05 AM, John Daley wrote:
> > From: Hyong Youb Kim <hyonkim@cisco.com>
> > 
> > enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
> > for IPv4.  The hardware actually validates the TCP/UDP checksum of
> > IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.
[...]
> >  	/* checksum flags */
> > -	if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
> > +	if (mbuf->packet_type & (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV6)) {
> >  		if (!enic_cq_rx_desc_csum_not_calc(cqrd)) {
> >  			uint32_t l4_flags;
> >  			l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
> >  
> >  			if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
> >  				pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
> > -			else
> > +			else if (mbuf->packet_type & RTE_PTYPE_L3_IPV4)
> 
> This looks like conflicting with commit log.
> Is pkt_flags intentionally not set for this case?
> If so can you update commit log to say only PKT_RX_IP_CKSUM_GOOD set for ipv6?
> 
> >  				pkt_flags |= PKT_RX_IP_CKSUM_BAD;

Yes, it is intentional. IPv6 has no IP header checksum, and
PKT_RX_IP_CKSUM_{GOOD,BAD} does not apply. So, the code does not set
PKT_RX_IP_CKSUM for IPv6. As the commit log says, for IPv6, we are
only setting L4 checksum flags.

-Hyong
Ferruh Yigit Jan. 24, 2018, 5:45 p.m. UTC | #3
On 1/24/2018 5:30 PM, Hyong Youb Kim wrote:
> On Wed, Jan 24, 2018 at 05:18:37PM +0000, Ferruh Yigit wrote:
>> On 1/23/2018 1:05 AM, John Daley wrote:
>>> From: Hyong Youb Kim <hyonkim@cisco.com>
>>>
>>> enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
>>> for IPv4.  The hardware actually validates the TCP/UDP checksum of
>>> IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.
> [...]
>>>  	/* checksum flags */
>>> -	if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
>>> +	if (mbuf->packet_type & (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV6)) {
>>>  		if (!enic_cq_rx_desc_csum_not_calc(cqrd)) {
>>>  			uint32_t l4_flags;
>>>  			l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
>>>  
>>>  			if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
>>>  				pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
>>> -			else
>>> +			else if (mbuf->packet_type & RTE_PTYPE_L3_IPV4)
>>
>> This looks like conflicting with commit log.
>> Is pkt_flags intentionally not set for this case?
>> If so can you update commit log to say only PKT_RX_IP_CKSUM_GOOD set for ipv6?
>>
>>>  				pkt_flags |= PKT_RX_IP_CKSUM_BAD;
> 
> Yes, it is intentional. IPv6 has no IP header checksum, and
> PKT_RX_IP_CKSUM_{GOOD,BAD} does not apply. So, the code does not set
> PKT_RX_IP_CKSUM for IPv6. As the commit log says, for IPv6, we are
> only setting L4 checksum flags.

Ahh, I see.
And I assume enic_cq_rx_desc_ipv4_csum_ok() always false for IPv6.

> 
> -Hyong
>
Hyong Youb Kim Jan. 24, 2018, 5:48 p.m. UTC | #4
On Wed, Jan 24, 2018 at 05:45:48PM +0000, Ferruh Yigit wrote:
> On 1/24/2018 5:30 PM, Hyong Youb Kim wrote:
> > On Wed, Jan 24, 2018 at 05:18:37PM +0000, Ferruh Yigit wrote:
> >> On 1/23/2018 1:05 AM, John Daley wrote:
> >>> From: Hyong Youb Kim <hyonkim@cisco.com>
> >>>
> >>> enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
> >>> for IPv4.  The hardware actually validates the TCP/UDP checksum of
> >>> IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.
> > [...]
> >>>  	/* checksum flags */
> >>> -	if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
> >>> +	if (mbuf->packet_type & (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV6)) {
> >>>  		if (!enic_cq_rx_desc_csum_not_calc(cqrd)) {
> >>>  			uint32_t l4_flags;
> >>>  			l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
> >>>  
> >>>  			if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
> >>>  				pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
> >>> -			else
> >>> +			else if (mbuf->packet_type & RTE_PTYPE_L3_IPV4)
> >>
> >> This looks like conflicting with commit log.
> >> Is pkt_flags intentionally not set for this case?
> >> If so can you update commit log to say only PKT_RX_IP_CKSUM_GOOD set for ipv6?
> >>
> >>>  				pkt_flags |= PKT_RX_IP_CKSUM_BAD;
> > 
> > Yes, it is intentional. IPv6 has no IP header checksum, and
> > PKT_RX_IP_CKSUM_{GOOD,BAD} does not apply. So, the code does not set
> > PKT_RX_IP_CKSUM for IPv6. As the commit log says, for IPv6, we are
> > only setting L4 checksum flags.
> 
> Ahh, I see.
> And I assume enic_cq_rx_desc_ipv4_csum_ok() always false for IPv6.
> 

Yes, that is correct. enic_cq_rx_desc_ipv4_csum_ok() returns true only
for IPv4. It is a bit confusing..

-Hyong
Ferruh Yigit Jan. 24, 2018, 5:48 p.m. UTC | #5
On 1/23/2018 1:05 AM, John Daley wrote:
> From: Hyong Youb Kim <hyonkim@cisco.com>
> 
> enic_cq_rx_to_pkt_flags() currently sets checksum good/bad flags only
> for IPv4.  The hardware actually validates the TCP/UDP checksum of
> IPv6 packets too. Set PKT_RX_L4_CKSUM_{GOOD,BAD} accordingly.
> 
> Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
> Reviewed-by: John Daley <johndale@cisco.com>

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

Patch

diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c
index 98902caa0..8157697a0 100644
--- a/drivers/net/enic/enic_rxtx.c
+++ b/drivers/net/enic/enic_rxtx.c
@@ -185,14 +185,14 @@  enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
 	}
 
 	/* checksum flags */
-	if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
+	if (mbuf->packet_type & (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV6)) {
 		if (!enic_cq_rx_desc_csum_not_calc(cqrd)) {
 			uint32_t l4_flags;
 			l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
 
 			if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
 				pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
-			else
+			else if (mbuf->packet_type & RTE_PTYPE_L3_IPV4)
 				pkt_flags |= PKT_RX_IP_CKSUM_BAD;
 
 			if (l4_flags == RTE_PTYPE_L4_UDP ||