From patchwork Fri Jun 11 19:05:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458508 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1209796jae; Fri, 11 Jun 2021 12:06:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAXv0Mv6/PDWISoEmblAeq4LHkLpoHYBsr2Kv6nXGoKXmEouqUIoX2pJpqgGqdC2jZCu4H X-Received: by 2002:a17:906:5049:: with SMTP id e9mr4939727ejk.30.1623438367400; Fri, 11 Jun 2021 12:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438367; cv=none; d=google.com; s=arc-20160816; b=lg2ByuBHgSthPmoCcYuX2vk0itk6kL6tLOyPBX43mvyYtCCGN44fC4b9+vJFN7nwsw A2q1Ifju8zToO4nwyYBlLLTxrGB7ztS8OVXlZQIxLYD/fUoKZweWrfry9I0Y9GgkYBGX PweWJvzBh4ILrYTqnyVazfBW1V5iFqbizU4bsBdPQElgKDQ5ODVUtOC5zqilVqY5QTBs 8V+qjUCq8peU7ixjReaKH8uWpd/VpwIkYjS4vcFScc5suzxBP7m1F6DmPL+jl40Nw1ap DHRqoqposwC02vDlRta/hMNOzF8iP+V4+3iSBL/AHelNo6j8SGO/ZkxrRRQ5xKy5Y1e2 uMpA== 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:date:subject:cc:to:from :dkim-signature; bh=vZEwEVBDEvCxZgVoTN4odpB95bOFDOiTrujBE+grmHw=; b=kPYc6RDTrt1SxgsnuJ2iMHgFvQUSngTJw2bTfxd07oWNUX3MctRF9v6Pd5tbBKqVuf S8V+DiYK1aAsq+XrMo1cDFTBTu1qSLegnvY6NZ1V9+gMtsLoxn1Zto0h33bioB9GZlC5 0NPW82by6AJh32Bna6PczHlUbT2ExmRs9kmJFBEwqp//ycWPGleJDVXndPj0fOWWtrYg c0IKHkkYd7V60mfKJH5Glwkj1VNB8yMji83oZD+QQZVbe1K1Aq9a+257JLPfG4yBnkrd GVsPdbtUMZQ65PKrFvGbJI1MVZuCMFM0wgCW61y6JykdyEOfHBUYQhgdPTDda3jNVEm7 +X8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GODL4EQk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5229320ejc.650.2021.06.11.12.06.07; Fri, 11 Jun 2021 12:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=GODL4EQk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbhFKTHh (ORCPT + 8 others); Fri, 11 Jun 2021 15:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231222AbhFKTHf (ORCPT ); Fri, 11 Jun 2021 15:07:35 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15479C0617AF for ; Fri, 11 Jun 2021 12:05:36 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id i13so6118747ilk.3 for ; Fri, 11 Jun 2021 12:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vZEwEVBDEvCxZgVoTN4odpB95bOFDOiTrujBE+grmHw=; b=GODL4EQkGQXW7NnrcMbNEp9Q7LZU1Uas5K0o2f6nyIiJdB/Vy0H9OKhwx9CUrxvv+D bbReoR4eQEW81BQQL/T3CFaG5cYhqpshijVgZYecg8EyCu5Bqictl7u16lArAH+VC3jq lo8mXnF7nSj+82us+iIUwuktPkS1dzZaMlxlYPSXNW+ml5n6HMLW1YYRInRmmJWX9y73 xRqfUla7wO8cOGtGQPgLbLp68swLewAPgMosWlZYJ3jKO15w2FtGiD2HVJuPtUZ8Jhu6 goBLUyOeiNM+kshrpEy7lB2EsBo9tphJLgnjkj61/EwCcb2gMSsaoVhAPIiVOthIdxH8 DLTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vZEwEVBDEvCxZgVoTN4odpB95bOFDOiTrujBE+grmHw=; b=dMwj1HD/mAuNliK0AcGWgS7lFEaeOovtnBHqfmy037rfr8pFhPa5EgeCyH825UV0y0 ib4yMg8wyxjZCNVt6V3ZRoF4SV0X7XizYHnMokE8FBe1Ccl7XEIauKdkoY1K6XAVyLGs P9UYOb+tVlBW/FsA/3e0LRH/2gucBMc3z9P6vJZlcwTbc3wkoM/rBCx3PPSu2wBomHin sTnoDQWmyu7IV2Dud5uHrvTrgFndxBlx2kI0AiS0C59agg2FqNOkMf4rYERke579wHTP syfJU60J3iPBYHnlpPqxJx47BXRcLxZoR6W+Q87NSRE4UFpVLFT0LOk8tZ4MMk72I8pV ZxrA== X-Gm-Message-State: AOAM533nsqqIP9KXzMLWkIoD53ETkKJVbWxseBjG5531fKD1JHQGqZm6 CQo0xOyyGzXHQHh5bI7KCRWvmg== X-Received: by 2002:a05:6e02:1153:: with SMTP id o19mr4404755ill.136.1623438335567; Fri, 11 Jun 2021 12:05:35 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:35 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/8] net: qualcomm: rmnet: use ip_is_fragment() Date: Fri, 11 Jun 2021 14:05:22 -0500 Message-Id: <20210611190529.3085813-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv4_dl_csum_trailer() use ip_is_fragment() to determine whether a socket buffer contains a packet fragment. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index cecf72be51029..34bd1a98a1015 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -50,8 +50,9 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, __be16 addend; ip4h = (struct iphdr *)(skb->data); - if ((ntohs(ip4h->frag_off) & IP_MF) || - ((ntohs(ip4h->frag_off) & IP_OFFSET) > 0)) { + + /* We don't support checksum offload on IPv4 fragments */ + if (ip_is_fragment(ip4h)) { priv->stats.csum_fragmented_pkt++; return -EOPNOTSUPP; } From patchwork Fri Jun 11 19:05:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458514 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1210989jae; Fri, 11 Jun 2021 12:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3Guf26kYJahxAabXxxUVCuPbwYphg1Fz3gMaQfsWwZKRtUNv3EDr+E/udyjL3wWcJ1V29 X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr5080496edb.334.1623438453436; Fri, 11 Jun 2021 12:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438453; cv=none; d=google.com; s=arc-20160816; b=TAffqIf/VZa7GN1PpXeI7xG/fnenOa8v0rvcjvzM+ul1B2THquyInn1Gb6yKUh4Kjz LuBIosf7alTcKMen6Zs2DxJS7rS+wll5mmPEkw6icBxKe/Bc5JSTpdPD6U+exvQRV7wK CPMXyX7JEz/GX3b0UwPrTAXFUzNdP+dixCAwWQpqoov6ME9V/FqCFWzAszjN7IbEgY4g gDGSXQuaVUtL+DAsfbp1tKZEGJr5/HpTenl5XVlTm9lru6Q4RWLBHsR4jZC7TKIC4Abn Mu3DzG5Nal0QTiYm4VpHHdZXoZUexbzkryhw+mWbnUmoAIBLEgWCqZNyJQ+r/YeYovhe Tc0Q== 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:date:subject:cc:to:from :dkim-signature; bh=xQ8UF2rlnCWAYB0xLk3oBUl3NTh+oujcDIz3DNhAnpo=; b=QiGJRE81Zu7K47vqWGmdSgZyFJcpWgf2NR3/FCDTr8ZSf2sRi/h49E1I8TEjGc0o0l CioovN2pwJY0k6DaiFj0Z0ftNp2ulpl9mcsjujKM6q04kRKws7SHV/u5CrGImUrS11zI dm+Htzu/nY2wSJEcbPs8L9Pr6JmKO6NAmEByJu4GqZ9SZUBAMQ7KkQdOpfD0YCHo0+J7 PS04YTuHrlLhnU9d/OL9vBzsV59tWLB3+JJtBGc73XED6ERh8ysxRC/1hMdjuaOFJoGK /t5yH6U7gDRQQEVCk5vFA7DvajVNMIxJ9t9zweiElpRxdRQ9AW6ZZpiuixYAekwyHvLX /F1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UEMHF8P4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si5248389edh.532.2021.06.11.12.07.33; Fri, 11 Jun 2021 12:07:33 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=UEMHF8P4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbhFKTIu (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:50 -0400 Received: from mail-io1-f43.google.com ([209.85.166.43]:41711 "EHLO mail-io1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbhFKTIq (ORCPT ); Fri, 11 Jun 2021 15:08:46 -0400 Received: by mail-io1-f43.google.com with SMTP id p66so30415430iod.8 for ; Fri, 11 Jun 2021 12:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xQ8UF2rlnCWAYB0xLk3oBUl3NTh+oujcDIz3DNhAnpo=; b=UEMHF8P4VjbABDccJ6fPGtQSycydNVCzERiATqZHKB3FvCpPL6shlgBesVFL20Ki4i F9Nt3Je/Nv4mQO+svBJ1lnp+QUyhsl09QJeyRJ1xk3UjfadTuRSl7kyTcgBqx0MIRNdy vxCpt9BMo24/TY8unkCpNbOwY3g0NB5y/5/CqoaWyXDvvRC0e4iA6Tmt03dnAzcNIJLa MEInNRmsYKefLFJ7Wlmk4NxstzMbBQDAbqS9inzz4+EJlBvgiwt6SwHKNGi9kX3nomMu xibfEYUzWXnhjCfZk6fSfQOF2RWjyeJ6O024DAnPFyApSkj9Bn2JPr3FjjyE+IOq/l1V wMwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xQ8UF2rlnCWAYB0xLk3oBUl3NTh+oujcDIz3DNhAnpo=; b=C2Zw68Oa8j2EhsM7KNfKJ6/2rnWHfgWqoA6GXRszHnqZ7eW99arLnhgzDRgWvPaD91 F0rHXMj8GpeqYSdGif92l7SF3oiX1ZLcYBdchkALfjtxwOQs6sgZQDE6XO14t9tGEciq QJZ/rf0qOeS7qqaLkyyGxr0wy4Ghv3i0mtSpWZnSUlQTqrpz1nhUcj/WPK8KD0XWaL62 S4Mdne2rgpLLmk1QCtUmlR97LoIT+YuPrWbSRUuPaHRr+jTQkvQvJOxF+OuFoN6Z/Aj7 7xmXs8yCAzYR9/RLWXrD0djGIfjnxuVNIYNsLovMWCxgiGPqjYWId17JQoXXqnM91Sml C+1w== X-Gm-Message-State: AOAM532QcdAbZG6WhnuNu9mn9KfVULEDhHQYbAAtv9Z2gKQizIni/RyA R0tuJHVIO1hTLBqrVQXCy4M3XQ== X-Received: by 2002:a05:6638:1602:: with SMTP id x2mr5241197jas.130.1623438336455; Fri, 11 Jun 2021 12:05:36 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:36 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/8] net: qualcomm: rmnet: eliminate some ifdefs Date: Fri, 11 Jun 2021 14:05:23 -0500 Message-Id: <20210611190529.3085813-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If IPV6 is not enabled in the kernel configuration, the RMNet checksum code indicates a buffer containing an IPv6 packet is not supported. The same thing happens if a buffer contains something other than an IPv4 or IPv6 packet. We can rearrange things a bit in two functions so that some #ifdef calls can simply be eliminated. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 34bd1a98a1015..b8e504ac7fb1e 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -431,21 +431,15 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len) return -EINVAL; } - if (skb->protocol == htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) return rmnet_map_ipv4_dl_csum_trailer(skb, csum_trailer, priv); - } else if (skb->protocol == htons(ETH_P_IPV6)) { -#if IS_ENABLED(CONFIG_IPV6) + + if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6)) return rmnet_map_ipv6_dl_csum_trailer(skb, csum_trailer, priv); -#else - priv->stats.csum_err_invalid_ip_version++; - return -EPROTONOSUPPORT; -#endif - } else { - priv->stats.csum_err_invalid_ip_version++; - return -EPROTONOSUPPORT; - } - return 0; + priv->stats.csum_err_invalid_ip_version++; + + return -EPROTONOSUPPORT; } static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb, @@ -462,28 +456,26 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb, (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))) goto sw_csum; - if (skb->ip_summed == CHECKSUM_PARTIAL) { - iphdr = (char *)ul_header + - sizeof(struct rmnet_map_ul_csum_header); + if (skb->ip_summed != CHECKSUM_PARTIAL) + goto sw_csum; - if (skb->protocol == htons(ETH_P_IP)) { - rmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb); - priv->stats.csum_hw++; - return; - } else if (skb->protocol == htons(ETH_P_IPV6)) { -#if IS_ENABLED(CONFIG_IPV6) - rmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb); - priv->stats.csum_hw++; - return; -#else - priv->stats.csum_err_invalid_ip_version++; - goto sw_csum; -#endif - } else { - priv->stats.csum_err_invalid_ip_version++; - } + iphdr = (char *)ul_header + + sizeof(struct rmnet_map_ul_csum_header); + + if (skb->protocol == htons(ETH_P_IP)) { + rmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb); + priv->stats.csum_hw++; + return; + } + + if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6)) { + rmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb); + priv->stats.csum_hw++; + return; } + priv->stats.csum_err_invalid_ip_version++; + sw_csum: memset(ul_header, 0, sizeof(*ul_header)); From patchwork Fri Jun 11 19:05:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458512 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1210270jae; Fri, 11 Jun 2021 12:06:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4fbufic9+P1FBzFg2uBJmsFddZ9raLgNHOroAEJfUoq0PXubx6TAQ0xBvkCQ37edEjWJR X-Received: by 2002:a17:906:6d95:: with SMTP id h21mr5009826ejt.260.1623438405690; Fri, 11 Jun 2021 12:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438405; cv=none; d=google.com; s=arc-20160816; b=Gew/xDHjhC0mQUhu6EEunaIgXiZRxOqk2Q+zPmFiiKqKabLT75Ib607ftSeGhF0nnG st/Lo7HAiWKoPwvjciMoyK6MgMbYU4opXkBKsoGKVH84q3nn/+XNawurUAgYTaGK3yq+ R6m+dzpjBQM6Ah3Urn94n6JRX2ty25GT8kyeI7Kvb+mX9C+7KmjM1FuuAmAvK7ZpyB0d lcHiPjiJInL1yw0ryKxpq8jbzKSk7pEYwb6zk1VDTHn4EYw35IYTS8ApPltdzzPb8BZC IHaLlnq/RTL/v3eZDS788RrJeJPBQPlmtAGmF+o7jOrmA390YIDWOsHOV3ekGB5r4sG0 D8XA== 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:date:subject:cc:to:from :dkim-signature; bh=DkdobZLTpAD7sZOMj4GkrrzOua/xsro4YIT+dik7/Ds=; b=qilPu0PMJCrFthTau2xmXcMY7yIMEtEkOahbkg7RPbQctHeBj4CvQsM5IPC6ixqtu9 F+rgb8zhejeLpbmeuDRWePOHRPCxupjCdLl+vWRKRc5v3j2ihzyIRN0ZcHjb71LQfthN ISbRni/Jon7SnyMkwuO6bhAbJv2iM7O9qUcoiQHndXr19biVIhIdDN1cE2fk1tfXGvbq hCwW6/HLA7yYO8JsNyKsfP8VLMyAGZH/us6wPyTHmV6YXwM92RBfFS16QRUC+5BGn5qN nkqGUdIHcw53Ihd2yCw+Mb/kAlm0XaDmaQ7oG6Xp1qTRDbDQTRyTxvYLlAXRmnaaSWCh 8SUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZUDQ4fWa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5229320ejc.650.2021.06.11.12.06.45; Fri, 11 Jun 2021 12:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=ZUDQ4fWa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbhFKTIm (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:42 -0400 Received: from mail-il1-f172.google.com ([209.85.166.172]:39780 "EHLO mail-il1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbhFKTIg (ORCPT ); Fri, 11 Jun 2021 15:08:36 -0400 Received: by mail-il1-f172.google.com with SMTP id j14so3304346ila.6 for ; Fri, 11 Jun 2021 12:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DkdobZLTpAD7sZOMj4GkrrzOua/xsro4YIT+dik7/Ds=; b=ZUDQ4fWalntmuoOOcLIhCQopK+ZdcXhpdPCYSNHYpAn1QF1RzoI27kDENKLMKQw91N 3B/JDELX8q8LVVeyCgYf7yxDHUQ0yDIqhXoAWoYbO5ScOSd94l3+GoVTxmGR31p1ycTI TTCrDOWOaen9tPNLONlh8X6p+pL+l+8A7NmNfOtuzaheQN6XSFs2sIrRHsbXDuiSnS0E d0L5LBZWHPJj+2qj5BlN1y1veEBULm2OPgVbcYvT9anpB804cIzhJakoErCW/PZunnEp k/LQZN4mJ1J8lKulpGRbZUFP5HFJLyCePD3gjmUZcAz0zQD/MdjvZuNe1lFW8VFQg1Wx ZuLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DkdobZLTpAD7sZOMj4GkrrzOua/xsro4YIT+dik7/Ds=; b=pO2zdIeqeEmbatnWrYF0diZwwUUKaBJ5ANkEhxThaRTT6QuJw1fq2Bcpvk+QFk0lSX aXBAfKFZjkhOh4QZ+Nid5ljtboNFzLJqHwxEM4gzTRVs50aQP9HDGVpmcDO7CoZaCZ/o e7hUgaeWon5silOy9UjMpI8MwDZOnCgyvQDhB/AiFB8WtekqPF9g3zKGuv43EhDUsjN1 7YCShyxoE4O7POUOS80eU4vL84y3W2BgZye4T6LKg4xJmuMgsZ2g7GckunczrJmkV7/y iWM2aCHb5CQt5mBO9G+eHI8jLvjtj+b0AUXvNTbp5tNRVf7q0pXunxMisvhYFQDmTiI7 Ring== X-Gm-Message-State: AOAM531rUNT7WrPiJyY+29l3k1tpWH0rOWX4dfGg/+QgAx28x74F0we8 yxm9hkCEBMsoRpdlEeCFhlWkzQ== X-Received: by 2002:a92:7312:: with SMTP id o18mr4074395ilc.289.1623438337341; Fri, 11 Jun 2021 12:05:37 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:37 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/8] net: qualcomm: rmnet: get rid of some local variables Date: Fri, 11 Jun 2021 14:05:24 -0500 Message-Id: <20210611190529.3085813-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The value passed as an argument to rmnet_map_ipv4_ul_csum_header() is always an IPv4 header. Rather than using a local variable, just have the type of the argument reflect the proper type. In rmnet_map_ipv6_ul_csum_header() things are defined a little differently, but make the same basic change there. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index b8e504ac7fb1e..ca07b87d7ed71 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -195,15 +195,14 @@ static void rmnet_map_complement_ipv4_txporthdr_csum_field(void *iphdr) } static void -rmnet_map_ipv4_ul_csum_header(void *iphdr, +rmnet_map_ipv4_ul_csum_header(struct iphdr *iphdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - struct iphdr *ip4h = iphdr; u16 val; val = MAP_CSUM_UL_ENABLED_FLAG; - if (ip4h->protocol == IPPROTO_UDP) + if (iphdr->protocol == IPPROTO_UDP) val |= MAP_CSUM_UL_UDP_FLAG; val |= skb->csum_offset & MAP_CSUM_UL_OFFSET_MASK; @@ -231,15 +230,14 @@ static void rmnet_map_complement_ipv6_txporthdr_csum_field(void *ip6hdr) } static void -rmnet_map_ipv6_ul_csum_header(void *ip6hdr, +rmnet_map_ipv6_ul_csum_header(struct ipv6hdr *ipv6hdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - struct ipv6hdr *ip6h = ip6hdr; u16 val; val = MAP_CSUM_UL_ENABLED_FLAG; - if (ip6h->nexthdr == IPPROTO_UDP) + if (ipv6hdr->nexthdr == IPPROTO_UDP) val |= MAP_CSUM_UL_UDP_FLAG; val |= skb->csum_offset & MAP_CSUM_UL_OFFSET_MASK; @@ -248,7 +246,7 @@ rmnet_map_ipv6_ul_csum_header(void *ip6hdr, skb->ip_summed = CHECKSUM_NONE; - rmnet_map_complement_ipv6_txporthdr_csum_field(ip6hdr); + rmnet_map_complement_ipv6_txporthdr_csum_field(ipv6hdr); } #endif From patchwork Fri Jun 11 19:05:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458515 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1211002jae; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw93kVXzWTaqEwAOGXJpibdjoa87e8kEVzsBy+C1dIBW/CLHaXAzZBcE1KroM4RL30RBNc5 X-Received: by 2002:a50:fd89:: with SMTP id o9mr5275937edt.336.1623438454293; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438454; cv=none; d=google.com; s=arc-20160816; b=Z/MM5uTmv+ed6FZbE1b+76Gi6xGXRVLI8nWaLVQNueowQiRccVc1Vuhj1rWkXB/2Os 8w8A0OAyQPXaKehS/iZmQ/xEN7M/3T3F1MH6nvYptqLUpFeKaWW90ZsCc+Hapd18mdOO Zs3jXYMxk7iV32yjStj1eO813a43uZqtxRK7zYOKt20krwEGLNWc0QuFhigEfrgK0lOS 7YNRoP3hjNwGxnScFyUWvDT2dlMQnPkuuKvPF2I/7Q86FHemeiA4ifRsxVXfCtfkMURr /5pz3Ko3TIgyHvbx1sCSs/hFOe3uOrCH0Q3wRLa52LERTfhEojC7gl7ZNFfVFv0eyDOS v2lg== 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:date:subject:cc:to:from :dkim-signature; bh=MUpvk546xJbxccrzYy1DJAE11qaWwvxoi2eLnJNWB58=; b=BC0XKo+DreZ9QB3X0aRH13EGkiqGSADp1DrYrEUdKQaBzcXx835yxGB1/G5xmkh9P9 NHgww+LrNYdP+S0pBJyF++wm67B4epDyTULtlH//qCYscsOyqMt9L9P2odxl1vZ/JNV2 KN3oxD32y+dFrZKx8LEWCZk01x/PWVI/WCmhr23dtEXIHGFSTU+LlVp12wSspYfU/Ta8 P2NKjmWS+5HnIaQHdLUY7PVHgclLQKT+IxWNu5DlpLgxriiGSqxgcaTGu3MGRyG+D0/j QfoCBFD3UekaNBelQT8sSwnEtyjG6g1FolbBbicEOBlps/wrnlz0sVcWSYGxIphKJDcq ANSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apDBUtta; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si5248389edh.532.2021.06.11.12.07.34; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=apDBUtta; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231582AbhFKTIx (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:53 -0400 Received: from mail-io1-f52.google.com ([209.85.166.52]:43830 "EHLO mail-io1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231416AbhFKTIr (ORCPT ); Fri, 11 Jun 2021 15:08:47 -0400 Received: by mail-io1-f52.google.com with SMTP id k16so32221277ios.10 for ; Fri, 11 Jun 2021 12:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MUpvk546xJbxccrzYy1DJAE11qaWwvxoi2eLnJNWB58=; b=apDBUttal8iaipbAO980nf/x8zRkf3UuOXodhRiWve6B/zDaSBOQcforlzF8s3aTyP kJghjhImXbxvX3Ua1WhXJeSPy+WD6MQVfRhn8oLo5xwvWk6HsW8ePBBjzMvrKKIEygr4 9PswGSNFdgp6iBWWyJU0NdKjoAD/4wlcySZ7rGKmY8zXhcVSDAU/Gt2ayZ23tQm7Lq2Q RJi04+snWlHihb6gQfXHLWnUN2o5288in0DW5h6O2f9ZSfsIhPeRJfAR/7M3D5WN+4DL P5i1B8b2E7z9c7aBhDr3w9TwW2Byx6BNvrC+JAeVyPvGvhqUjJcNl3Odc38AdVn1PVms 3BvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MUpvk546xJbxccrzYy1DJAE11qaWwvxoi2eLnJNWB58=; b=S88tp6MpPPJ6t2QQC/NC03pge8L3494YwMB1xRZyiTnU2DF02qit35uosd2COPndFf UwZbEr/hK++rkHh5qjLrTINWXkSV96n8UHUmr3VOdaFnfaklij7yydoHoBl9PBmSIHiq bc444dgXyHN7jsJ3+uJoukay1kCOspoxhkfwsSx5GkLpK6dXsJoX292vk8Qdk7t1BoxC TaQanrL/cdeoxUNVhczvdBgUNH2kLV9KNaPsv+UwqLz1Ztqosv5u/MDIdO5+RrmzEj/f pShHayQOFqBx+76FE0RK5KQLNXz3rEA0xToMwkFYZWcQd7Yy+NIHurIHSzoKZV++un/e BmPg== X-Gm-Message-State: AOAM532Gd0KxnDJXLVMoER54g+jW3bTbVSrMWrNOgo11+HIaiv2eN2Gg pUCS54SxoKnO95zLx+LGS3oazA== X-Received: by 2002:a05:6602:22ca:: with SMTP id e10mr4202393ioe.57.1623438338290; Fri, 11 Jun 2021 12:05:38 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:37 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/8] net: qualcomm: rmnet: simplify rmnet_map_get_csum_field() Date: Fri, 11 Jun 2021 14:05:25 -0500 Message-Id: <20210611190529.3085813-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The checksum fields of the TCP and UDP header structures already have type __sum16. We don't support any other protocol headers, so we can simplify rmnet_map_get_csum_field(), getting rid of the local variable entirely and just returning the appropriate address. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index ca07b87d7ed71..79f1d516b5cca 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -19,23 +19,13 @@ static __sum16 *rmnet_map_get_csum_field(unsigned char protocol, const void *txporthdr) { - __sum16 *check = NULL; + if (protocol == IPPROTO_TCP) + return &((struct tcphdr *)txporthdr)->check; - switch (protocol) { - case IPPROTO_TCP: - check = &(((struct tcphdr *)txporthdr)->check); - break; + if (protocol == IPPROTO_UDP) + return &((struct udphdr *)txporthdr)->check; - case IPPROTO_UDP: - check = &(((struct udphdr *)txporthdr)->check); - break; - - default: - check = NULL; - break; - } - - return check; + return NULL; } static int From patchwork Fri Jun 11 19:05:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458513 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1210331jae; Fri, 11 Jun 2021 12:06:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlMNcGiT9MglC7+1AGTHKaPDQ/q1MadTgvFsQBgyg3n5XAmn5sqdf8J4ogUQvTkETKjSUx X-Received: by 2002:a17:906:bc2:: with SMTP id y2mr4866101ejg.489.1623438409382; Fri, 11 Jun 2021 12:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438409; cv=none; d=google.com; s=arc-20160816; b=F16CzZYbi9T0MCioWWFNgROtPqjF4PvG4bGBUGhKo9b9to7RYU1EhhxihJNNKiQKC7 hvUg5CAmULEO7QoIZpIahmYP55OK2IBTYY/HgI3XouM+cTP/cdWtp+72bGO/CxnP7+HF blHL10vItnx9szWqEp9AFAn+gP8odKAGxQVVJuM9G9ODw1TqWBDTY3lz74S65RYOYHs9 4SV3YOY8kDr9VvoySILnU4ATFg19tcpx0t4uL9niOzwFiF075jxswV+1vZ5LlgGbFJ60 Yk/5haItrlQF7q7pnxSRhXs/JORUP6QqBhLbCZmyBVm9augc77Z/3AjJBpGwK6MelbX4 UTXA== 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:date:subject:cc:to:from :dkim-signature; bh=qBoOhTYQId0ccnEylChHcGfk116nSyfqpAW9wezghK8=; b=NbU+c91suJ/uW5Mg55BnuIVaA5PGyYTPd0XT2ufMgESUk1p2SBnmLa7cMuITbM3wt9 tB6FWXFsLzm0Eomw81IJmbzE9R6h75BHbU2ahXuSLBpOCOIPxZOC/WVAR8eQcWeg99g/ Z80/iTIY60RNTBAlHKFvsHEyVXrrwm3Z84gsi4rF92Us59fH5SLVqeehNY7aUtfggGXo H9SdlR6L+cguNhbBH0r+0fZRylG53j7ZUSFdvFTq+a+9SXlX+/JooxttRfuQvfLmfnq9 NqXygETJ46wUWTwyDXNRGGopDvBWOKXQBkp6Brg4Xad89WoXiuO4ycE3gbm9hYMbhsdb cKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fluZkObb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5229320ejc.650.2021.06.11.12.06.49; Fri, 11 Jun 2021 12:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=fluZkObb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231538AbhFKTIp (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:45 -0400 Received: from mail-io1-f54.google.com ([209.85.166.54]:39766 "EHLO mail-io1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbhFKTIh (ORCPT ); Fri, 11 Jun 2021 15:08:37 -0400 Received: by mail-io1-f54.google.com with SMTP id f10so17760795iok.6 for ; Fri, 11 Jun 2021 12:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qBoOhTYQId0ccnEylChHcGfk116nSyfqpAW9wezghK8=; b=fluZkObbAwxjzfggtAFSEfH6l9SfdNUXLwdjm3E25/LJNtHCbwMS9cm9iOeGvVuQGd q2HP3mjREoBDi7sxLcUpKK5xGbphnh1xqn+bdWJ2gYVeiqTT9Yg4xQu9uCDYept+wqqm xd19RwOKk3T2sKeoGXX0+ZHp1o9CZRXAZPULUWBgi08qTTmfPi2iBmLGODkZtmjHzMHi ymt1LLiOhKf3l8x5of51uLvUZjMwmcYXdHnjpT3an+a8JvJWSHsBYrHGyo/eMNLqUYU6 2fa2U4i41TpjEw+lJbNGRHfXUR8o6m51PN7oE9UDJrGcZXVWmoEZt0w4mDeF7mtnk3oM rAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qBoOhTYQId0ccnEylChHcGfk116nSyfqpAW9wezghK8=; b=gEziM1vl4IIM6HxRIEBuJzXBKbB7JXfVKHPbfECIWlSimWGIrqTNA+AZgZvZ3Jlc+/ cAInBYLuok9ixmefjlpMkuCp6v6eQTzbVsbAThud4chn0+DJFaCdiOFCzF247f0EuVto JyYchdlT266/K2BdLQb71pAaDDlDeGyDZmaXcwo7Z2YUdla6h3zoYYT2BSrcF/7fwORv MLu4cNQYaWwPUcad9I9quRXYbWcOtIthFvnbBFay4lqOGszKiGuWSjgJPq+cX/w2BnSQ bWCEfdo5fjdugUd4vKglISnDlXodFMAPFAKXKgrsrtMlWJLjNuyPa0P62/u31jVwyCDG 3KSw== X-Gm-Message-State: AOAM530W9Y6OUTFX/IieLPR2w+jPmFbvpy2xTa4GIJKS4/XJHZvusVhu Jq4bhQ/n64KIfUz4xCUb7NMpqQ== X-Received: by 2002:a05:6602:2143:: with SMTP id y3mr4364865ioy.89.1623438339234; Fri, 11 Jun 2021 12:05:39 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:38 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/8] net: qualcomm: rmnet: IPv4 header has zero checksum Date: Fri, 11 Jun 2021 14:05:26 -0500 Message-Id: <20210611190529.3085813-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv4_dl_csum_trailer(), an illegal checksum subtraction is done, subtracting hdr_csum (in host byte order) from csum_value (in network byte order). Despite being illegal, it generally works, because it turns out the value subtracted is (or should be) always 0, which has the same representation in either byte order. Doing illegal operations is not good form though, so fix this by verifying the IP header checksum early in that function. If its checksum is non-zero, the packet will be bad, so just return an error. This will cause the packet to passed to the IP layer where it can be dropped. Thereafter, there is no need subtract the IP header checksum from the checksum value in the trailer because we know it is zero. Add a comment explaining this. This type of packet error is different from other types, so add a new statistics counter to track this condition. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_config.h | 1 + .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 41 ++++++++++++------- .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 1 + 3 files changed, 29 insertions(+), 14 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h index 8e64ca98068d9..3d3cba56c5169 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h @@ -49,6 +49,7 @@ struct rmnet_pcpu_stats { struct rmnet_priv_stats { u64 csum_ok; + u64 csum_ip4_header_bad; u64 csum_valid_unset; u64 csum_validation_failed; u64 csum_err_bad_buffer; diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 79f1d516b5cca..40d7e0c615f9c 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -33,13 +33,21 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, struct rmnet_map_dl_csum_trailer *csum_trailer, struct rmnet_priv *priv) { - __sum16 *csum_field, csum_temp, pseudo_csum, hdr_csum, ip_payload_csum; - u16 csum_value, csum_value_final; - struct iphdr *ip4h; - void *txporthdr; + struct iphdr *ip4h = (struct iphdr *)skb->data; + void *txporthdr = skb->data + ip4h->ihl * 4; + __sum16 *csum_field, csum_temp, pseudo_csum; + __sum16 ip_payload_csum; + u16 csum_value_final; __be16 addend; - ip4h = (struct iphdr *)(skb->data); + /* Computing the checksum over just the IPv4 header--including its + * checksum field--should yield 0. If it doesn't, the IP header + * is bad, so return an error and let the IP layer drop it. + */ + if (ip_fast_csum(ip4h, ip4h->ihl)) { + priv->stats.csum_ip4_header_bad++; + return -EINVAL; + } /* We don't support checksum offload on IPv4 fragments */ if (ip_is_fragment(ip4h)) { @@ -47,25 +55,30 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, return -EOPNOTSUPP; } - txporthdr = skb->data + ip4h->ihl * 4; - + /* Checksum offload is only supported for UDP and TCP protocols */ csum_field = rmnet_map_get_csum_field(ip4h->protocol, txporthdr); - if (!csum_field) { priv->stats.csum_err_invalid_transport++; return -EPROTONOSUPPORT; } - /* RFC 768 - Skip IPv4 UDP packets where sender checksum field is 0 */ - if (*csum_field == 0 && ip4h->protocol == IPPROTO_UDP) { + /* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused */ + if (!*csum_field && ip4h->protocol == IPPROTO_UDP) { priv->stats.csum_skipped++; return 0; } - csum_value = ~ntohs(csum_trailer->csum_value); - hdr_csum = ~ip_fast_csum(ip4h, (int)ip4h->ihl); - ip_payload_csum = csum16_sub((__force __sum16)csum_value, - (__force __be16)hdr_csum); + /* The checksum value in the trailer is computed over the entire + * IP packet, including the IP header and payload. To derive the + * transport checksum from this, we first subract the contribution + * of the IP header from the trailer checksum. We then add the + * checksum computed over the pseudo header. + * + * We verified above that the IP header contributes zero to the + * trailer checksum. Therefore the checksum in the trailer is + * just the checksum computed over the IP payload. + */ + ip_payload_csum = (__force __sum16)~ntohs(csum_trailer->csum_value); pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c index fe13017e9a41e..6556b5381ce85 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c @@ -166,6 +166,7 @@ static const struct net_device_ops rmnet_vnd_ops = { static const char rmnet_gstrings_stats[][ETH_GSTRING_LEN] = { "Checksum ok", + "Bad IPv4 header checksum", "Checksum valid bit not set", "Checksum validation failed", "Checksum error bad buffer", From patchwork Fri Jun 11 19:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458516 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1211017jae; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3BL+uQJFEjcxEd/NEtVou5mlFW9BHNYurDSb1XlZ3XaUyWLAtUT2o8yjY6XjEB7l4EYSy X-Received: by 2002:a17:907:10cc:: with SMTP id rv12mr4929615ejb.533.1623438454744; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438454; cv=none; d=google.com; s=arc-20160816; b=QJZ1KXwG1KsZLxOf49JPRrE/p2rzqnaCj3Evkklmt36GyMndUP5TkTe8oOtO1sH6Ia THi9k48mAEzhNc7Di1tV0nwMK9o+PYFQpX5PrsPbh8mi6ZE6FrZpoEELbNTWREbHpzi+ +lBubTxip2YCcS+S1Jg2OaitLrN6/ELeyruTUkIQtM4HE2LEOmfugfRGPTwfsDYip/Pu sNPaTcphr83pdVXzomkRsScFR3Y1QdagTwdYFPlbwX3DMxPtr5grpeHVGo9Imdf7J88F kBBR9R/BFmdhfdlv06BBHWSXrza8Q8+zm6DXqFo34+8hwAez5HpSwkaswJC1KwxZLKE4 KX6g== 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:date:subject:cc:to:from :dkim-signature; bh=1jEKoQqd09IhMCBMusRvi4j4SzZxwB5xBIw8eYKxXpA=; b=dzrJ62vqqfsjvQhMSdXvvdYT0dLm14hHZXxr2Sxjq+BPuo2ExNy+E3KrXf5sjE9/fb 2UlQLWDhx85J82fo0Q/hjOaFgM+7RaGTY4dx0PTWhf94156NiIg9yZOsjh3LxK9yMB8v QevLDixEz1feSI+F2b54A/EV7pKhFG+ysIOX9o63KG2AJyhup14iHtPeqhRFBW5tfKcM K4DgmOHuNbn+9pT3sEE8FUsVnpWbrfnOaqDDz1Qfz9fzn9GTxtJ26LGP2nRLVx4q2ORO ZbdjNLrM0kHl3+qDHZJ2W3PnHzJjz6spbWfQlsVlAkrVzal8J2oTDkUpfLsnsjz1snLZ llcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oqo3RETa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si5248389edh.532.2021.06.11.12.07.34; Fri, 11 Jun 2021 12:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=Oqo3RETa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231672AbhFKTI5 (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:57 -0400 Received: from mail-io1-f43.google.com ([209.85.166.43]:45788 "EHLO mail-io1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbhFKTIx (ORCPT ); Fri, 11 Jun 2021 15:08:53 -0400 Received: by mail-io1-f43.google.com with SMTP id k5so22469728iow.12 for ; Fri, 11 Jun 2021 12:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1jEKoQqd09IhMCBMusRvi4j4SzZxwB5xBIw8eYKxXpA=; b=Oqo3RETafwkfkNGoPxdzW/0nahkdiMknjYHn/ccLC3m3zAyZD7FMZkg7jjr4oC0IA/ H/LtVw0T8+vkE+/DBPhIj3tB7HoNJBVjIMA9vNThbPHix151B9A7erob4v5WbDc/KX3U 3mcFtl/qwDh6KeE9akBvU8Z1DZVFvT/lCSpfohmOru9NOsBnAlagPtQPHxMMQEmlwvIo /mx0X1hAJPbze/yDfGLthjjC2MeSqBFw3zBaw++w4+Z73Q5TvoydnvKuBbogFwvqpQQE nkmFdRiI1iP3jjG69JwvNMD8fx0cqMr99h6SL4A3PngPvEjr+gA4c/wy8RgflweQ37qq Awrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1jEKoQqd09IhMCBMusRvi4j4SzZxwB5xBIw8eYKxXpA=; b=E49qR/I4T+RezUEKCB4HDqz/7vyf9/9i/ptH+/rWMA9zPViSBsymKEp+DY7/qvaQ8j iTvt2vdAkIlgA9nU/cJend2AHxVXuhhGmCO6xnnOHuyj3mjGW18LXUnABQOHUFN0KelE czeVcHx5x5v5HHlHji2IxlRkqrl62WgH8OOo/3ECjOWakOm9DbG6gY3Xx/ktT6xGJ8PL qpg9UQ81HmSKakwXmUkhIJkE4M1/z5K0wTwEyeDdAkg1cHd6PPY6dne5lEwtILaDhSfh tkapAr+4tp+CUGUcHlnv9B5EEd9jCqcThkeDa39BiXqtX1YqmoZCRjQ7dmJ0m1Vcthoa n0dw== X-Gm-Message-State: AOAM531gm5mJAeqAFV2oMPCK/iH+3UrqG8ap2WPPaj9K+ihvwjVWD9YJ fV/QeufyqoBPKaZgq76YlvTVvEf7MexHTIqq X-Received: by 2002:a05:6602:2048:: with SMTP id z8mr4292134iod.91.1623438340111; Fri, 11 Jun 2021 12:05:40 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:39 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/8] net: qualcomm: rmnet: clarify a bit of code Date: Fri, 11 Jun 2021 14:05:27 -0500 Message-Id: <20210611190529.3085813-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv6_dl_csum_trailer() there is an especially involved line of code that determines the ones' complement sum of the IPv6 packet header (in host byte order). Simplify that by storing the result of computing just the header checksum in a local variable, then using that in the original assignment. Use the size of the IPv6 header structure as the number of bytes to checksum, rather than computing the offset to the transport header. And use ip_fast_csum() rather than ipa_compute_csum(), knowing that the size of an IPv6 header (40 bytes) is a multiple of 4 bytes greater than 16. Add some comments to match rmnet_map_ipv4_dl_csum_trailer(). Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 40d7e0c615f9c..4f93355e9a93a 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -120,27 +120,33 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, struct rmnet_map_dl_csum_trailer *csum_trailer, struct rmnet_priv *priv) { - __sum16 *csum_field, ip6_payload_csum, pseudo_csum, csum_temp; + struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data; + void *txporthdr = skb->data + sizeof(*ip6h); + __sum16 *csum_field, pseudo_csum, csum_temp; u16 csum_value, csum_value_final; __be16 ip6_hdr_csum, addend; - struct ipv6hdr *ip6h; - void *txporthdr; + __sum16 ip6_payload_csum; + __be16 ip_header_csum; u32 length; - ip6h = (struct ipv6hdr *)(skb->data); - - txporthdr = skb->data + sizeof(struct ipv6hdr); + /* Checksum offload is only supported for UDP and TCP protocols; + * the packet cannot include any IPv6 extension headers + */ csum_field = rmnet_map_get_csum_field(ip6h->nexthdr, txporthdr); - if (!csum_field) { priv->stats.csum_err_invalid_transport++; return -EPROTONOSUPPORT; } + /* The checksum value in the trailer is computed over the entire + * IP packet, including the IP header and payload. To derive the + * transport checksum from this, we first subract the contribution + * of the IP header from the trailer checksum. We then add the + * checksum computed over the pseudo header. + */ csum_value = ~ntohs(csum_trailer->csum_value); - ip6_hdr_csum = (__force __be16) - ~ntohs((__force __be16)ip_compute_csum(ip6h, - (int)(txporthdr - (void *)(skb->data)))); + ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); + ip6_hdr_csum = (__force __be16)~ntohs(ip_header_csum); ip6_payload_csum = csum16_sub((__force __sum16)csum_value, ip6_hdr_csum); From patchwork Fri Jun 11 19:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458509 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1209819jae; Fri, 11 Jun 2021 12:06:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbzQE1Fp/DDSWwBFE7/BWSZlKHYW2izjzQfyBGgvVPbzJ4l+n+meusI5TkEMnPOYBEbBpz X-Received: by 2002:a17:906:c833:: with SMTP id dd19mr4821849ejb.255.1623438368861; Fri, 11 Jun 2021 12:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438368; cv=none; d=google.com; s=arc-20160816; b=fKe1ZzsCgc/YELxcVjYhkdZt3CpTTYTVZD7oHF5QNjBOK+5xG7kwDtGsG04zpp1LzH oVeAoAFCRE5DcWVLyVEqHZUDpdoSOSlrdBWJN/0LysNjtXmneCIYT9kiKzmHCWWEsyce kdu3tp1UmUt0RJzdt8/pXbWS3kvOjh0+7pYaOyooksF2h3uXDMdveijJHF1SaJNOijgB rHU6r92PIKgm6dQiRjN6bicwEFtfhv46SSCBVnZhgYm0vebH9th9xEmIv36dhfBVJkqL VEus42Mhl+93grgXtHOBg1Q3zpeT+LhcDA7HfEP5nriJhGZmFM7eOmroQyMfh2HaAK3T EefQ== 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:date:subject:cc:to:from :dkim-signature; bh=/jVit4TfeNDu88eet7u+n4Bhl+hbIMEgmGetJirKXBQ=; b=JT230NFALWYYd3dyuuIE+F4Gq4cOaGIzHSuiAddmj2bTA/vrPc9B4V6o02KxHacQig JwECsMtENtJvx8pBODZvYN+fRQQY4car9ZmQo8bg8/euwZY+Mh/WtZQd8gZqWVJU0Ebp cqEbmaZ2E+FOL3EmDIfKwfFWJg85r5MVwM6EzAOr1amkLkZymykgccU0BO/ZAkJUmOnE lAAB/epIfuHxb5tjrHaDxwGV2Y6TTITME1MpnXsxIImWtPcyJ25iqfkWcWsvT1pD3Tqq LpjN3GM2JbSjlEkqmWGslDNdTf8j07OFeEuKJHHCP/yrT6VfdOq/lyWW1p0608QFFM5N CwXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SxAmQQBI; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5229320ejc.650.2021.06.11.12.06.08; Fri, 11 Jun 2021 12:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=SxAmQQBI; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbhFKTHq (ORCPT + 8 others); Fri, 11 Jun 2021 15:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbhFKTHk (ORCPT ); Fri, 11 Jun 2021 15:07:40 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98150C0617AF for ; Fri, 11 Jun 2021 12:05:41 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id k16so32221444ios.10 for ; Fri, 11 Jun 2021 12:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/jVit4TfeNDu88eet7u+n4Bhl+hbIMEgmGetJirKXBQ=; b=SxAmQQBIRMHKhPLOsI0TqLLq2DVGGXb7zMz+g+RrSjMc//413L1V+JpSoaQ/alwqWa DrSqkgWxpMIeRHuMC4lyPxYGMe3uRp4z7MVjGml+KRKsPbSkABSKMY59UbM5rxndMsEB ZBmxDau3E4HwPVYJsOYGAlAGh04dGGHhIx9AwoZKD5/kQuoFAUU3U+ZYGq8ELsgQ2Ctc 1kdg+K/GbQBJnbQ0vy5PSCX/kKB2CsEn4hGR+qGTJcn9zqxVjLlLaSII4WVSNuh67Ue1 J4gIqJQ20udivZRb+ZrudwvAAUajgd9vAaZF961u+O3fmv71RZlzFFKW4zcuxXKTGu24 6A+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/jVit4TfeNDu88eet7u+n4Bhl+hbIMEgmGetJirKXBQ=; b=jt8QbavDDbUfePfP4LqHpodrbJj6WimqTn1XIN6yflsWCfTYO0hCAlJdHgeHgxwmvm 08L/wI91eqqOfZxsBqMfPzsBxWpgrbSl+jZJkjAyFHBpvLxMe7kFXmRYBIYKICl8CbmR +SUFLtnCW7cAFE6KZxaIb7fbSLcWcIFRMSox87rTrtgNAHfcyUPp95HXKvX0JZ4dxWUG mowIS82P082g6tfBAOkzCDdx9WN2SNh0/rdBIiKht/dl5FIrfluSOHWW7TXghLWomcql jvkg9NDV+FyIxfmDmNxos/0XpG/aHzoNjBNUJM+yqn4eIHksadkySyu59HDiOLKs15IV BI3A== X-Gm-Message-State: AOAM531hg5+XnzLzZqrMMpGPRbS2PdALAwdB5wn6sZJj4SnbuEeHZ7SO J6uii2pX1jVS2NOZ1yT7rfKXSQ== X-Received: by 2002:a6b:d115:: with SMTP id l21mr4395513iob.130.1623438341006; Fri, 11 Jun 2021 12:05:41 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:40 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/8] net: qualcomm: rmnet: avoid unnecessary byte-swapping Date: Fri, 11 Jun 2021 14:05:28 -0500 Message-Id: <20210611190529.3085813-8-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Internet checksums are used for IPv4 header checksum, as well as TCP segment and UDP datagram checksums. Such a checksum represents the negated sum of adjacent pairs of bytes, using ones' complement arithmetic. One property of the Internet checkum is byte order independence [1]. Specifically, the sum of byte-swapped pairs is equal to the result of byte swapping the sum of those same pairs when not byte-swapped. So for example if a, b, c, d, y, and z are hexadecimal digits, and PLUS represents ones' complement addition: If: ab PLUS cd = yz Then: ba PLUS dc = zy For this reason, there is no need to swap the order of bytes in the checksum value held in a message header, nor the one in the QMAPv4 trailer, in order to operate on them. In other words, we can determine whether the hardware-computed checksum matches the one in the message header without any byte swaps. (This patch leaves in place all existing type casts.) [1] https://tools.ietf.org/html/rfc1071 Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 4f93355e9a93a..39f198d7595bd 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -78,15 +78,15 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, * trailer checksum. Therefore the checksum in the trailer is * just the checksum computed over the IP payload. */ - ip_payload_csum = (__force __sum16)~ntohs(csum_trailer->csum_value); + ip_payload_csum = (__force __sum16)~csum_trailer->csum_value; pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, ip4h->protocol, 0); - addend = (__force __be16)ntohs((__force __be16)pseudo_csum); + addend = (__force __be16)pseudo_csum; pseudo_csum = csum16_add(ip_payload_csum, addend); - addend = (__force __be16)ntohs((__force __be16)*csum_field); + addend = (__force __be16)*csum_field; csum_temp = ~csum16_sub(pseudo_csum, addend); csum_value_final = (__force u16)csum_temp; @@ -105,7 +105,7 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == ntohs((__force __be16)*csum_field)) { + if (csum_value_final == (__force u16)*csum_field) { priv->stats.csum_ok++; return 0; } else { From patchwork Fri Jun 11 19:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458511 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1209857jae; Fri, 11 Jun 2021 12:06:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz02yx2Ub2CEjEWbllZChb7xw+beaxaoKa3R/qy0Dq0GQas+1DN9QwuMRCtAOh14Zn0dxcT X-Received: by 2002:a17:906:268c:: with SMTP id t12mr4860148ejc.441.1623438371537; Fri, 11 Jun 2021 12:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623438371; cv=none; d=google.com; s=arc-20160816; b=np5tO1QmT8VVhhTz+H4heiK4ODuXOGxyYvDUe5axPeSeYDnGXxHUAu+horE3zB5rwl LgsMXkUy1qXo5yS+e8b/epRN/F0vhK1gOASoBMaZOh/nMoTu6X/IPcGh6kDdtmLNTRhM 5/Oonjec99Lb/vXT30H18hNhJSf1kek1xc/+UtyuD7JPXOyqwPVElF9xdD18AOXD2ztq 2pesYxja0ItEqkmViG6CIbwzQivDZpfPyWWjTWQjiycFj7Ezi3a+Um7va1wODSTRBg/n Vig4TeeEJ5r+wKaoTka/PVfr6ZyOGp21OeOaci3qFohMZLJH5vGRvNKkqBgZbTVNDCcj vFyg== 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:date:subject:cc:to:from :dkim-signature; bh=5kMsHbtfUl/gFd/yKPF67UEpU7y0HdcT6eUdvozwYl4=; b=H45giUWDob+Qx1X73ALXN0Y3ukSDedLFzSKQyMEV5aYB60CIolL7TBHJ7gOi/NnRCo oBsxkoRpCr15LpDs3b0Z5dT03KcLMt9UtkbXG8DH1A41w8a1xV/60c7q/HQ78c8H8fVv lNBQBFUptLAKEVy11u0FeldQ4WILbtzyXLdBMBmeC936cn9icyYQtK5J+1kM4AdfccW5 azWEUev8NovVT5nc8qRz5sPz8Rgxb8cWYQENebgPRH5LQYwVTaxJB+hL17LSPlySOBF7 UxuN5YazZ3KDL7KMpyHxoZaZkphDl4548Ri6AoBOegy85ndvhTZo3UbM5imsC4KW/7c4 +nwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MR1UKLev; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si5229320ejc.650.2021.06.11.12.06.11; Fri, 11 Jun 2021 12:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@linaro.org header.s=google header.b=MR1UKLev; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbhFKTIG (ORCPT + 8 others); Fri, 11 Jun 2021 15:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbhFKTHx (ORCPT ); Fri, 11 Jun 2021 15:07:53 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F9EC0613A3 for ; Fri, 11 Jun 2021 12:05:42 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id 5so32272439ioe.1 for ; Fri, 11 Jun 2021 12:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5kMsHbtfUl/gFd/yKPF67UEpU7y0HdcT6eUdvozwYl4=; b=MR1UKLevxJ0kBzVEnTyu5RSMaakkR0f1eW2InUuTQl6S8weA9+LyD4n5klvNOOkdAk KXxZNAyQ+mSz2sLEQ0409GH41bWdynOnTn9QU+9G9dg+SkzEl8+fSAoH+j5GdG7DBBfX Q5i9tgrXWad6rzAAORb3I1/6kyHsZozQo1HfQ9ka09elIgsoFcg54LKw7AmG7b9K9rPi 0opc9w1YzM7VvfpIwvDjAa2bxTLHHi2CVtZk4OPnpX579Oobxvu8LVRGxC/sRH5jVpiJ LRUnbQ782fVYla3Y6rhj32jeXXjra1TW7uCtkkDP+38YXGaYddgcc3Ozd31Yf+0leL1K YGkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5kMsHbtfUl/gFd/yKPF67UEpU7y0HdcT6eUdvozwYl4=; b=priMQyXlZJmt7f0hKTgsvRE+qtlLK4IQIlj92VvZJ+r/G6FD8g+RFivUKfR71DDE1m FdFP0IshKC0C5/J6P6kPHqLvOBjn4tWrNG1mbBdc/9xoubvkdTbSuelR9RLOVytoREC5 7vWrhcLzxLfRYGIbEIGvhqk2igu+RDzDcs82OdRaLB/uQxVUGGIsjbMBS0ppLx7RKjFP cxISY18F12h2KjMNNG/fNL8Az3hQebdSyUJOHp93iooWbHiuuMkQq24FabXBvieVWVwe +d+Wl3Sf6EYqL9kx17w0EqQ8jF0UDBG791kyvZ/XI231kPtJ4G40GOluzKAj9zIHQ4dF YOaQ== X-Gm-Message-State: AOAM533W9aBAkXhIq2P1JRZZIlycXGg2IdqaqT7KsBu0ea032760BMLv ZKoUNqImH9oilYseZI94jdlxYg== X-Received: by 2002:a5d:8986:: with SMTP id m6mr4220177iol.87.1623438341965; Fri, 11 Jun 2021 12:05:41 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id p9sm3936566ilc.63.2021.06.11.12.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 12:05:41 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 8/8] net: qualcomm: rmnet: avoid unnecessary IPv6 byte-swapping Date: Fri, 11 Jun 2021 14:05:29 -0500 Message-Id: <20210611190529.3085813-9-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611190529.3085813-1-elder@linaro.org> References: <20210611190529.3085813-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the previous patch IPv4 download checksum offload code was updated to avoid unnecessary byte swapping, based on properties of the Internet checksum algorithm. This patch makes comparable changes to the IPv6 download checksum offload handling. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 39f198d7595bd..d4d23ab446ef5 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -123,10 +123,11 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data; void *txporthdr = skb->data + sizeof(*ip6h); __sum16 *csum_field, pseudo_csum, csum_temp; - u16 csum_value, csum_value_final; __be16 ip6_hdr_csum, addend; __sum16 ip6_payload_csum; __be16 ip_header_csum; + u16 csum_value_final; + __be16 csum_value; u32 length; /* Checksum offload is only supported for UDP and TCP protocols; @@ -144,21 +145,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * of the IP header from the trailer checksum. We then add the * checksum computed over the pseudo header. */ - csum_value = ~ntohs(csum_trailer->csum_value); + csum_value = ~csum_trailer->csum_value; ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_hdr_csum = (__force __be16)~ntohs(ip_header_csum); + ip6_hdr_csum = (__force __be16)~ip_header_csum; ip6_payload_csum = csum16_sub((__force __sum16)csum_value, ip6_hdr_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : ntohs(ip6h->payload_len); - pseudo_csum = ~(csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - length, ip6h->nexthdr, 0)); - addend = (__force __be16)ntohs((__force __be16)pseudo_csum); + pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, + length, ip6h->nexthdr, 0); + addend = (__force __be16)pseudo_csum; pseudo_csum = csum16_add(ip6_payload_csum, addend); - addend = (__force __be16)ntohs((__force __be16)*csum_field); + addend = (__force __be16)*csum_field; csum_temp = ~csum16_sub(pseudo_csum, addend); csum_value_final = (__force u16)csum_temp; @@ -179,7 +180,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == ntohs((__force __be16)*csum_field)) { + if (csum_value_final == (__force u16)*csum_field) { priv->stats.csum_ok++; return 0; } else {