netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sharathv@codeaurora.org
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, elder@kernel.org, cpratapa@codeaurora.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v7 3/3] net: ethernet: rmnet: Add support for MAPv5 egress packets
Date: Wed, 02 Jun 2021 00:38:49 +0530	[thread overview]
Message-ID: <bea88cea5094f7fec640a5d867b5a31a@codeaurora.org> (raw)
In-Reply-To: <20210528161131.5f7b9920@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>

On 2021-05-29 04:41, Jakub Kicinski wrote:
> On Thu, 27 May 2021 14:18:42 +0530 Sharath Chandra Vurukala wrote:
>> Adding support for MAPv5 egress packets.
>> 
>> This involves adding the MAPv5 header and setting the 
>> csum_valid_required
>> in the checksum header to request HW compute the checksum.
>> 
>> Corresponding stats are incremented based on whether the checksum is
>> computed in software or HW.
>> 
>> New stat has been added which represents the count of packets whose
>> checksum is calculated by the HW.
>> 
>> Signed-off-by: Sharath Chandra Vurukala <sharathv@codeaurora.org>
> 
>> +static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
>> +						struct rmnet_port *port,
>> +						struct net_device *orig_dev)
>> +{
>> +	struct rmnet_priv *priv = netdev_priv(orig_dev);
>> +	struct rmnet_map_v5_csum_header *ul_header;
>> +
>> +	if (!(port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5))
>> +		return;
> 
> how can we get here if this condition is not met? Looks like defensive
> programming.
> 

Yes we get here only for the MAPv5 case, as you think this is just a 
defensive code.
will remove this in next patch.

>> +	ul_header = skb_push(skb, sizeof(*ul_header));
> 
> Are you making sure you can modify head? I only see a check if there is
> enough headroom but not if head is writable (skb_cow_head()).
> 

TSkb_cow_head() changes will be done in the rmnet_map_egress_handler() 
in the next patch.

>> +	memset(ul_header, 0, sizeof(*ul_header));
>> +	ul_header->header_info = 
>> u8_encode_bits(RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD,
>> +						MAPV5_HDRINFO_HDR_TYPE_FMASK);
> 
> Is prepending the header required even when packet doesn't need
> checksuming?
> 
>> +	if (skb->ip_summed == CHECKSUM_PARTIAL) {
>> +		void *iph = (char *)ul_header + sizeof(*ul_header);
> 
> ip_hdr(skb)
> 

>> +		__sum16 *check;
>> +		void *trans;
>> +		u8 proto;
>> +
>> +		if (skb->protocol == htons(ETH_P_IP)) {
>> +			u16 ip_len = ((struct iphdr *)iph)->ihl * 4;
>> +
>> +			proto = ((struct iphdr *)iph)->protocol;
>> +			trans = iph + ip_len;
>> +		} else if (skb->protocol == htons(ETH_P_IPV6)) {
>> +#if IS_ENABLED(CONFIG_IPV6)
>> +			u16 ip_len = sizeof(struct ipv6hdr);
>> +
>> +			proto = ((struct ipv6hdr *)iph)->nexthdr;
>> +			trans = iph + ip_len;
>> +#else
>> +			priv->stats.csum_err_invalid_ip_version++;
>> +			goto sw_csum;
>> +#endif /* CONFIG_IPV6 */
>> +		} else {
>> +			priv->stats.csum_err_invalid_ip_version++;
>> +			goto sw_csum;
>> +		}
>> +
>> +		check = rmnet_map_get_csum_field(proto, trans);
>> +		if (check) {
>> +			skb->ip_summed = CHECKSUM_NONE;
>> +			/* Ask for checksum offloading */
>> +			ul_header->csum_info |= MAPV5_CSUMINFO_VALID_FLAG;
>> +			priv->stats.csum_hw++;
>> +			return;
> 
> Please try to keep the success path unindented.
> 

Sure will take care of these comments in next patch.
>> +		}
>> +	}
>> +
>> +sw_csum:
>> +	priv->stats.csum_sw++;
>> +}

  reply	other threads:[~2021-06-01 19:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27  8:48 [PATCH net-next v7 0/3] net: qualcomm: rmnet: Enable Mapv5 Sharath Chandra Vurukala
2021-05-27  8:48 ` [PATCH net-next v7 1/3] docs: networking: Add documentation for MAPv5 Sharath Chandra Vurukala
2021-05-27  8:48 ` [PATCH net-next v7 2/3] net: ethernet: rmnet: Support for ingress MAPv5 checksum offload Sharath Chandra Vurukala
2021-05-28 22:58   ` Jakub Kicinski
2021-05-31 14:34     ` Alex Elder
2021-06-01 19:06     ` sharathv
2021-05-27  8:48 ` [PATCH net-next v7 3/3] net: ethernet: rmnet: Add support for MAPv5 egress packets Sharath Chandra Vurukala
2021-05-28 23:11   ` Jakub Kicinski
2021-06-01 19:08     ` sharathv [this message]
2021-05-28  8:00 ` [PATCH net-next v7 0/3] net: qualcomm: rmnet: Enable Mapv5 subashab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bea88cea5094f7fec640a5d867b5a31a@codeaurora.org \
    --to=sharathv@codeaurora.org \
    --cc=cpratapa@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=elder@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).