Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp794183pxj; Fri, 28 May 2021 16:18:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJFOVkqLpqLnaTPzhqNygDebQgV5MxWKvYcDfayHCgKIxOGN393ytRPtt5WpC39vIWIpw1 X-Received: by 2002:a17:906:77dc:: with SMTP id m28mr11092619ejn.23.1622243912104; Fri, 28 May 2021 16:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622243912; cv=none; d=google.com; s=arc-20160816; b=pdlG9YpxBsnQKQxxBzaBcCydcRRPG8OeZZNLJVIOJyST9scd9lt76QJxOxALgABuoo mfWJ1yR/40hNvMJEG0WtO5FPc2YyPTxvQ8PLLP1jTiR/EF7cL9iaIXti/dpB1mZlInhL vWUzsz3FiwqaSQf2ZR7b8haoWd/Z+tSZpBxK2NgzyWB+FnvJFyKFfGI31mKj8lu1R6oS cEJkPVPWOLJquo8XLYEAm/fP7ibjmRPlrGxaO646eV6f6/hCG+ENicv81ULZf5p8QfTh iAzY+0SQw3eH7TCfWZ1XZSpkfW03fdXl3mApueGFAxG0JSpmZCmB5kOnRAbnyIQk1BXr 4xVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=l6vm94jiAzKbvNmqdrqc7Bg2DSYDB1mUjUJyqVyMc/4=; b=hFzDuyAM1l8DeZl+I2yKEcpOHd/0GTQCAhFbaFcykjPy0TozWFH4NMzCOc7CCkSW7A saLda4quJphIU4gGpynlVvO37JGWqSCt/OL1G8UmgnYuQN0yZqWe2r35L8K+2uS2d5dc xXOKNJXuYVGxAEezF/4UX5j91orjk9/ImwjAJdZHpBH9MVJdskKwewu3a8ZhKc8OKG+B JpuydzqjpSo7eTpzOPVdfiQOzksAqwtXNay1cadVDuiGRphTrpMmNGvXg33GaxikI/q8 rRmG+qU1do63Hjx5Z37/1cK5ufuBtOhIEjbl/DRPPRx9Po7bqPZHlldQtzBHVEDnGQK9 zdOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qsBPeIy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv9si5706121ejb.100.2021.05.28.16.18.09; Fri, 28 May 2021 16:18:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qsBPeIy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbhE1XNL (ORCPT + 99 others); Fri, 28 May 2021 19:13:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:59104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbhE1XNH (ORCPT ); Fri, 28 May 2021 19:13:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FC68613EB; Fri, 28 May 2021 23:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622243492; bh=6R6S4sFCJq92IstxTP9ek22qzcdli0PcwyHoyNTTrkU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qsBPeIy9Mj1YUWEX30WNcd5Nlp6nThlJQ/ma7GuKMXqlx0Oh5VQG0myAIWoLfRH3N 8LB4P6BLQuYVb8HOuQEBdzxGIKL/BPHxtdvNZdkCheE8hX4IZaHailXDw8q2qpTs4t 8cDArsgG+D1BAK6toogvZXTjucPP7+/KUtnAZBVhmV0VhIATiOEIuMxR3YVz/LhcEu YWsMbmQxzlMheFjnxGYodZKPOhtUz37G+pIT+MmZ94snbMJDziSZQWHR+MUzchqi5a /zG5Qjrg59El7yZGywKCf7UaixonmaJQl0ed8cuAMeqhw8Bh8l4WR4kFx5V4EvUFtB 45VNy8LsMP0XQ== Date: Fri, 28 May 2021 16:11:31 -0700 From: Jakub Kicinski To: Sharath Chandra Vurukala 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 Message-ID: <20210528161131.5f7b9920@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> In-Reply-To: <1622105322-2975-4-git-send-email-sharathv@codeaurora.org> References: <1622105322-2975-1-git-send-email-sharathv@codeaurora.org> <1622105322-2975-4-git-send-email-sharathv@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > +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. > + 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()). > + 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. > + } > + } > + > +sw_csum: > + priv->stats.csum_sw++; > +}