From patchwork Mon Mar 15 21:51:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400554 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784283jai; Mon, 15 Mar 2021 14:52:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjO+mPGVmjJT1VYBxlNwHQxE1ZkdLg66X2303lk03WkHK9PvpQu0ocdn+eds32nFrftOjU X-Received: by 2002:a17:906:24c7:: with SMTP id f7mr25749278ejb.473.1615845157201; Mon, 15 Mar 2021 14:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845157; cv=none; d=google.com; s=arc-20160816; b=fqT4P0FmS3UYJaYC6HclnBPHwSkkJ86CTQiD3I6mF2oNiJAPH5IgkDB4L1RE8QqlGM I0MkUtEtbuvJsn7Vq5mZ114Sf4s0kS/EBz4lRyNJ4hE7dIvi/QQy+k9bvcY0oboBOGZj 62Zt8yZGpDOk1HupnqlhrR0mVFf3irZmKkFfLPTpxFV8oLZzmeCN4t8Wt/1WSYy1ElqO G6j+m7FfDNe7m/DTW0EbxMlVQUYLPmfvEQ5KCFj+Sy9HMhzX7N7qKI1YzIbf22aLs62z YSlE1OiBV0Vtw1blqu2ty4CZ92pOgM1XZdZ+zJd9VdSdMh5K/6jQpIbjwZHnGgRlJjfu BXHg== 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=tkE3LmGUj01YPH3BPs1/nEBfeLQdWBdBqpXnFwRgcR4=; b=flsyZeuUqRN7kDuVooQxSSP/UYZ32hpsqS7XTf7vKQuTCx+yZ9uA369YPvff1KEv4Y J1eRjpTHU7QUjoFCae7n4NrXgFRsN7aZjI3PcK2mdbCkUQ2n9ssf58tByBFjc6LpuiE6 ThSap0+MpWsXkLkiwikdKdcmYhA6DsHXavJyi9ZUO6lh4vc5UGkq0Zn5SYe8MctHHSwa HFLCK1oDY+IHN6V3zdb6AeHUW1vITgHpOJ0ysT5y2mbj4n7CrsmgbOK3WbI80E+Uppsb /M9cUFdS/R2Ab/u2WNmRQKbTtX9B1ovD/yl19rmdWJLk5zdu9b0gzdJpSOjbasd0IbH5 Iwxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hRSakI25; 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 c13si12173560eje.45.2021.03.15.14.52.37; Mon, 15 Mar 2021 14:52:37 -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=hRSakI25; 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 S231233AbhCOVwF (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbhCOVv4 (ORCPT ); Mon, 15 Mar 2021 17:51:56 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6CBAC06175F for ; Mon, 15 Mar 2021 14:51:56 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id f20so35009945ioo.10 for ; Mon, 15 Mar 2021 14:51:56 -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=tkE3LmGUj01YPH3BPs1/nEBfeLQdWBdBqpXnFwRgcR4=; b=hRSakI25uH/iqPFFwdYMutKVZkBqZDAiup5YEL0MEXGQQB8+ccGfQy8VEfOFnwdDUv X3GT0uWFTky5HvlgFc3ReSioSYnABS6VYnZoKDacviUuSfibMUEm5B/icGkIAnTkGIPB wH2d7OGxd0ZbUn+LFp5aGKzZje0rN77Ewhmp4f8cXL0RgML8D0eUA/bqcbfY6bFrD02f jR/hAwSTk9hadNE/elS86jdJEnZjGzQQrJffrtXYsHaltpk8W1jawXj43qD/cwxK428y Au3q2fQYRw/OpKDKQkm9nUpWFrD8oE+TusW68mH8W3dzPOPCN/pMUdB2NsgdipE6TnKG ZZvQ== 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=tkE3LmGUj01YPH3BPs1/nEBfeLQdWBdBqpXnFwRgcR4=; b=heufmJlu3tQF7baXI2IZUUBk5YMdPcJ8jLIEiMr5J07ehNrLJ60SRuC4pkY8TpHOhQ vfqiN/tOCvLyNnG1ks0MOKEJUzvWGm8cxnrcog/hpOxRO1q8Ib7pas4E35gSJOVEZBo4 ukbXSWT6efjMkiFBxCZCMaoC7NldGrBVdVVb0uzSE1yUhqW4lG7+7gT7TIIWk5INg+VW hxKX4c+XGVen7IK/pWXm9zI01q/aGG4YoNKV64p2rqfglrU6lvRMtMZpb35edtnj04lg 5SKF3U4+fBR6zx4VMfMQXYarKNq6jIJjG0Z21qVV4o5Z5BuRImiK7VWC61K4Tr8B/yWN 66rQ== X-Gm-Message-State: AOAM533JtMKN4TUG6xtDf2w8pbXkqNiti5GsLOL3rLWGCVSDmvCTH5bf Fbvy1T6KyRS6KmDViw2X3vaUAw== X-Received: by 2002:a02:9645:: with SMTP id c63mr11445641jai.84.1615845116270; Mon, 15 Mar 2021 14:51:56 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:51:55 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Duyck Subject: [PATCH net-next v6 1/6] net: qualcomm: rmnet: mark trailer field endianness Date: Mon, 15 Mar 2021 16:51:46 -0500 Message-Id: <20210315215151.3029676-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The fields in the checksum trailer structure used for QMAP protocol RX packets are all big-endian format, so define them that way. It turns out these fields are never actually used by the RMNet code. The start offset is always assumed to be zero, and the length is taken from the other packet headers. So making these fields explicitly big endian has no effect on the behavior of the code. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson Reviewed-by: Alexander Duyck --- include/linux/if_rmnet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index 9661416a9bb47..8c7845baf3837 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -32,8 +32,8 @@ struct rmnet_map_dl_csum_trailer { #else #error "Please fix " #endif - u16 csum_start_offset; - u16 csum_length; + __be16 csum_start_offset; + __be16 csum_length; __be16 csum_value; } __aligned(1); From patchwork Mon Mar 15 21:51:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400555 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784292jai; Mon, 15 Mar 2021 14:52:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVjGuSTPMYRMZjQd2nX/FnzqO0n4QNKzMxH/VBfyIxij8gesYHISecDpRiGDytltgAwdb6 X-Received: by 2002:a17:906:3b99:: with SMTP id u25mr25860674ejf.277.1615845157603; Mon, 15 Mar 2021 14:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845157; cv=none; d=google.com; s=arc-20160816; b=qIE5xWhvUNMk9mWtRUnbIiHd7R2e3Vu4EGZ+DF8pPRw8qRpOPfA6Jswv3b4mmaqUcT Wt9bfAUUgcYMoW4fRtJ9ay8/khOhU2Ht2eWz6PWKXOPkLqCa7d9tqpJCvBq+qjVDrdeE 8l62GOxC+amxoGGjs+IiqwFjVTaOe53wekU29iq1msiGM2jHMbtHzQf28qqJFBiW8e6w md0pdHWwFxAahfvdlMueD0aabt663VxSbtvlSljZK6gL0kjtmvE4oOZbOkKgw+yOzEnq OGSVKjTN7MJb4sbwK+gROmtvNbyY9PSgYtiHk3wlaQ4F3UuEhKethRfvimfenv0oOIwR nIBg== 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=dYz46nd8LxGdX7fvsu6maJR2XM9zulyZ7ppS5hOn0SA=; b=ZxKBd7WrD5+sVN8h+FMkcms9o2qZJno/Ugj2uJnLzWOjgMQJ1BbG0GXc3jOb4kvdWo WBGb6uyG+7wOQe+vNnH15Ogi+BibRBHVCzGons54t+GiYOIBtyjxDlk4DrQASB51Djaa UeFrsR0GaBUD9/zH59EDlDQk1uB2eF8bM/3rbcSZaDfrGSsvVFMOYHJvvHy5C6OuyQfc 2gXcsucIWdNYDXD0XIFwrbm8jn/L1z09avXRE+RTxp8+b9z539yU1Pqt+klprRHJmG/E ANhTsaa/wn7q5/8aj27pEZOtTwVoUNVMcw9Dd7trBUv8V5g3/9mOX384Ietsf0SQWgQT yABw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KAOd5kiI; 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 c13si12173560eje.45.2021.03.15.14.52.37; Mon, 15 Mar 2021 14:52:37 -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=KAOd5kiI; 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 S233934AbhCOVwF (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbhCOVv6 (ORCPT ); Mon, 15 Mar 2021 17:51:58 -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 C6457C061762 for ; Mon, 15 Mar 2021 14:51:57 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id a7so35024507iok.12 for ; Mon, 15 Mar 2021 14:51:57 -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=dYz46nd8LxGdX7fvsu6maJR2XM9zulyZ7ppS5hOn0SA=; b=KAOd5kiIrxkZEhIbWKaKi/NmupuaMayU7csMeknMQUxH21tpxWsbeuR9rHD77Lknm0 KN9VTxpk8jyZEPjvbtNfyHIKMZuiT+O5/UX+LiVITxIogmODtSiOozK+pdqT15bx9Y2e KbIJtY8O3/ujZ05FqvV03UYHE83jW6tH+waCtDtVxhUR/SQ8nfrPCK5Srt8TcpGx302N 6K0wH7D/qQj6kmnIPRFA88Kp9J4bBcqpjYHRr6biMS1SbCD12Ego0zaiINKtdRRjMYb8 RNYYv28ykbs6uUtVMwlZdAdkpiQwbQauMG1ssAuMuNMKtN4StHCpfo8ZB23YhASRBAKq EpGw== 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=dYz46nd8LxGdX7fvsu6maJR2XM9zulyZ7ppS5hOn0SA=; b=ISjwzMdLcFMiopJiuTzWvI/WW6xL92oa2SMuCfpVuuZxyRndQSNEBWauM68hUH0mCh MBBdoo1ffC6lGSxdttaGo6ZYRBGbMJVQFzHG1TFZSvE+c85qqCt8cCteS8bmEITRlyf7 42DfMaONmcvbRq1Nj02QoeWV4Gx0QcI8bb+HupYcLaxgv3S4Ycbwy3tG+llBCv7MGixa M/+Ef7hDuwt8ncGLGwrDY0lh7FCqZdKD19XzFpGhzuGQ1MfvLwmo9uRjISoWZJpSNSsR riI8vKOosk88roMLxdkSzMEHP/5uCOx1QcW3KDKMXDTAbTaTyN7jnyaufBBf1OgZXkEQ ZxVw== X-Gm-Message-State: AOAM530uIJ6ztak4P4R4zGK4m4jyO+JUkJkhHFplpgQoxNeIRmqy/uCf +8DCYC45pLAQjA9AMk0BCrMjNA== X-Received: by 2002:a5d:9917:: with SMTP id x23mr1204682iol.22.1615845117314; Mon, 15 Mar 2021 14:51:57 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:51:57 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 2/6] net: qualcomm: rmnet: simplify some byte order logic Date: Mon, 15 Mar 2021 16:51:47 -0500 Message-Id: <20210315215151.3029676-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In rmnet_map_ipv4_ul_csum_header() and rmnet_map_ipv6_ul_csum_header() the offset within a packet at which checksumming should commence is calculated. This calculation involves byte swapping and a forced type conversion that makes it hard to understand. Simplify this by computing the offset in host byte order, then converting the result when assigning it into the header field. Signed-off-by: Alex Elder --- v5: - Use skb_network_header_len() to decide the checksum offset. .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 16 ++++++---------- 1 file changed, 6 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 21d38167f9618..0bfe69698b278 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -197,12 +197,10 @@ rmnet_map_ipv4_ul_csum_header(void *iphdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - struct iphdr *ip4h = (struct iphdr *)iphdr; - __be16 *hdr = (__be16 *)ul_header, offset; + __be16 *hdr = (__be16 *)ul_header; + struct iphdr *ip4h = iphdr; - offset = htons((__force u16)(skb_transport_header(skb) - - (unsigned char *)iphdr)); - ul_header->csum_start_offset = offset; + ul_header->csum_start_offset = htons(skb_network_header_len(skb)); ul_header->csum_insert_offset = skb->csum_offset; ul_header->csum_enabled = 1; if (ip4h->protocol == IPPROTO_UDP) @@ -239,12 +237,10 @@ rmnet_map_ipv6_ul_csum_header(void *ip6hdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)ip6hdr; - __be16 *hdr = (__be16 *)ul_header, offset; + __be16 *hdr = (__be16 *)ul_header; + struct ipv6hdr *ip6h = ip6hdr; - offset = htons((__force u16)(skb_transport_header(skb) - - (unsigned char *)ip6hdr)); - ul_header->csum_start_offset = offset; + ul_header->csum_start_offset = htons(skb_network_header_len(skb)); ul_header->csum_insert_offset = skb->csum_offset; ul_header->csum_enabled = 1; From patchwork Mon Mar 15 21:51:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400557 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784311jai; Mon, 15 Mar 2021 14:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7jUOboawXdvgbyxW8tX2O/dRyBA5rPGzkiK5A29en3uHlz9pp4e5/vclA03xstTpR01wV X-Received: by 2002:a17:906:95d1:: with SMTP id n17mr25307559ejy.394.1615845160440; Mon, 15 Mar 2021 14:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845160; cv=none; d=google.com; s=arc-20160816; b=Ad7uwlKKPxg7wEBQbR0cpzHSbvIbW5sNv0CCYJz0uxImsPfrNP0g4q0E6z43ol0gWU rKKJ2TfowAB9G0Nmqw9/EPfWEn87w05L/B2YNar2Mv5yShhuRwozrN41eC/ZYOqUVDcs uG1j+eDSewNDIgpgQqGAMZBn5/v6z6kOFUPu3jD/q+45DtzKSyMX92FBKHnPv+AFtgKE PC0WiYA6/kw4h1ldhxB0EpSf9piDIQQiBesmcmfUJIV6fKOLd81CsRauW4U2xT74Vj/8 l0i6G1vT+z28P8uJUf1qOFjlmRFJ5uy5vooWG13qxYwssDZZG4IdYcKLEQ8ducyHL5i9 P3Cg== 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=rVEslqQM6fsvVZ7LiAEkE3ccCznmfly+zx9t6yJZNsM=; b=K8eC+4q7SBI/c6Pe0q8O8sLqef2A5v9xPbGRUF8wDhO9T3DR6hJE8sge5Y8yFSE3j9 Fd+iVOFEanuNntaZl7ihgpx5uEofYVpS/FYhArr4UTOJX+ywMoNAxw4brUs4QNWjdbPs o1uK4kZIvrwTcMYViSnEXzQ492DCUsNoVQoFSzLaDYnX6Oqs/PNZ+lE/SJM21/gXaugx n4ruU4gNprE4P4CS8Eqnb77QPuzhb8gEPSPXDLIMuC+Llzjqciy2wj1W1ejngRrAcE49 dngoQd4rGjDaVQsag1TK/+JIV2GySozQWHCYN+ee+7MDaQEgsGwBFMzP5ptA3cQzMdHb 88jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VSgVGnAq; 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 c13si12173560eje.45.2021.03.15.14.52.40; Mon, 15 Mar 2021 14:52:40 -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=VSgVGnAq; 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 S233955AbhCOVwG (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhCOVv7 (ORCPT ); Mon, 15 Mar 2021 17:51:59 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB8FC06175F for ; Mon, 15 Mar 2021 14:51:59 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id b5so10800346ilq.10 for ; Mon, 15 Mar 2021 14:51:59 -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=rVEslqQM6fsvVZ7LiAEkE3ccCznmfly+zx9t6yJZNsM=; b=VSgVGnAqHRvJFiX83rC418SJ72aIyhH7rMWLbzPgWd5zWQCUEsM3eVm+OrC7gOVT3u fowXMEwW6t+pC6bkmnvRM6b4MJ65A0PLe22QLRTp3OfDqEd1o95s1CmqwmStIFbaVdiE ctvU9I6diNPLL0BWT3OCxjQIyzWFNORZXjwXh9fwK8mMDPyRFebnAch+IZzt8J/PeHWh Yzg/7jT57sGdKZhhNU7pCM/I9qciKPQRYt8dBk8RatSDA3R8NEwinDcQwUNWJeoH8eRK SDzP7gCog5VH5dO/Xidd+MNx0YgoEY0v/Y2JU4fmUNGwD6uhFaV+Bn5UL4BKI5xKyXJc Ni8g== 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=rVEslqQM6fsvVZ7LiAEkE3ccCznmfly+zx9t6yJZNsM=; b=MY8q6Q+XqOus2VKn+bxHeWDC8+0eRoaiO9H5APaR18r4po69ztzJnTIh43/hR7UX9H Pga7GFDkWvC0lc8hmitAXfrzqinhb/+Q7BJMj4lcR9fpDzMKFdhjoPlsz6RnKlXPgOzx OMYTaLTcs7MltOkpNEHbmSY7He/mn5orAl9jgeWKlwX8NTPRfdaKhEtv777byDV76MEG tjqUzhUtO0Bg9LDOCxCAgOFt1JrdHNjpUjvZUl5CACHCClGBxi87t0JP+EJj2GtjNi6j kuGdK8QFjS7yRkmEFWXwQyRWI7PpFZZEgyTL41tcoMv8HJQRO/+bl+3uOO/wRLPJ5iSg L/Vw== X-Gm-Message-State: AOAM533YVSTjcDYeH9dcuYt1Kl/P1A9pyjM/2OUVWVrjl5yIJMGk0Jjh nb8e2le0fYzszvm8IbaRXKvkKA== X-Received: by 2002:a92:d686:: with SMTP id p6mr1287944iln.268.1615845118412; Mon, 15 Mar 2021 14:51:58 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:51:58 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Duyck Subject: [PATCH net-next v6 3/6] net: qualcomm: rmnet: kill RMNET_MAP_GET_*() accessor macros Date: Mon, 15 Mar 2021 16:51:48 -0500 Message-Id: <20210315215151.3029676-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The following macros, defined in "rmnet_map.h", assume a socket buffer is provided as an argument without any real indication this is the case. RMNET_MAP_GET_MUX_ID() RMNET_MAP_GET_CD_BIT() RMNET_MAP_GET_PAD() RMNET_MAP_GET_CMD_START() RMNET_MAP_GET_LENGTH() What they hide is pretty trivial accessing of fields in a structure, and it's much clearer to see this if we do these accesses directly. So rather than using these accessor macros, assign a local variable of the map header pointer type to the socket buffer data pointer, and derereference that pointer variable. In "rmnet_map_data.c", use sizeof(object) rather than sizeof(type) in one spot. Also, there's no need to byte swap 0; it's all zeros irrespective of endianness. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson Reviewed-by: Alexander Duyck --- drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 10 ++++++---- drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 12 ------------ .../net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 11 ++++++++--- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 4 ++-- 4 files changed, 16 insertions(+), 21 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 3d00b32323084..2a6b2a609884c 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -56,20 +56,22 @@ static void __rmnet_map_ingress_handler(struct sk_buff *skb, struct rmnet_port *port) { + struct rmnet_map_header *map_header = (void *)skb->data; struct rmnet_endpoint *ep; u16 len, pad; u8 mux_id; - if (RMNET_MAP_GET_CD_BIT(skb)) { + if (map_header->cd_bit) { + /* Packet contains a MAP command (not data) */ if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) return rmnet_map_command(skb, port); goto free_skb; } - mux_id = RMNET_MAP_GET_MUX_ID(skb); - pad = RMNET_MAP_GET_PAD(skb); - len = RMNET_MAP_GET_LENGTH(skb) - pad; + mux_id = map_header->mux_id; + pad = map_header->pad_len; + len = ntohs(map_header->pkt_len) - pad; if (mux_id >= RMNET_MAX_LOGICAL_EP) goto free_skb; diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index 576501db2a0bc..2aea153f42473 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -32,18 +32,6 @@ enum rmnet_map_commands { RMNET_MAP_COMMAND_ENUM_LENGTH }; -#define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \ - (Y)->data)->mux_id) -#define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \ - (Y)->data)->cd_bit) -#define RMNET_MAP_GET_PAD(Y) (((struct rmnet_map_header *) \ - (Y)->data)->pad_len) -#define RMNET_MAP_GET_CMD_START(Y) ((struct rmnet_map_control_command *) \ - ((Y)->data + \ - sizeof(struct rmnet_map_header))) -#define RMNET_MAP_GET_LENGTH(Y) (ntohs(((struct rmnet_map_header *) \ - (Y)->data)->pkt_len)) - #define RMNET_MAP_COMMAND_REQUEST 0 #define RMNET_MAP_COMMAND_ACK 1 #define RMNET_MAP_COMMAND_UNSUPPORTED 2 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c index beaee49621287..add0f5ade2e61 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c @@ -12,12 +12,13 @@ static u8 rmnet_map_do_flow_control(struct sk_buff *skb, struct rmnet_port *port, int enable) { + struct rmnet_map_header *map_header = (void *)skb->data; struct rmnet_endpoint *ep; struct net_device *vnd; u8 mux_id; int r; - mux_id = RMNET_MAP_GET_MUX_ID(skb); + mux_id = map_header->mux_id; if (mux_id >= RMNET_MAX_LOGICAL_EP) { kfree_skb(skb); @@ -49,6 +50,7 @@ static void rmnet_map_send_ack(struct sk_buff *skb, unsigned char type, struct rmnet_port *port) { + struct rmnet_map_header *map_header = (void *)skb->data; struct rmnet_map_control_command *cmd; struct net_device *dev = skb->dev; @@ -58,7 +60,8 @@ static void rmnet_map_send_ack(struct sk_buff *skb, skb->protocol = htons(ETH_P_MAP); - cmd = RMNET_MAP_GET_CMD_START(skb); + /* Command data immediately follows the MAP header */ + cmd = (struct rmnet_map_control_command *)(map_header + 1); cmd->cmd_type = type & 0x03; netif_tx_lock(dev); @@ -71,11 +74,13 @@ static void rmnet_map_send_ack(struct sk_buff *skb, */ void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port) { + struct rmnet_map_header *map_header = (void *)skb->data; struct rmnet_map_control_command *cmd; unsigned char command_name; unsigned char rc = 0; - cmd = RMNET_MAP_GET_CMD_START(skb); + /* Command data immediately follows the MAP header */ + cmd = (struct rmnet_map_control_command *)(map_header + 1); command_name = cmd->command_name; switch (command_name) { diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 0bfe69698b278..3af68368fc315 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -315,7 +315,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, return NULL; maph = (struct rmnet_map_header *)skb->data; - packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header); + packet_len = ntohs(maph->pkt_len) + sizeof(*maph); if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) packet_len += sizeof(struct rmnet_map_dl_csum_trailer); @@ -324,7 +324,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, return NULL; /* Some hardware can send us empty frames. Catch them */ - if (ntohs(maph->pkt_len) == 0) + if (!maph->pkt_len) return NULL; skbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, GFP_ATOMIC); From patchwork Mon Mar 15 21:51:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400556 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784306jai; Mon, 15 Mar 2021 14:52:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzyczw1Ardh34nQFoQjceYTVLrjVO/iUwY/hKYAQ4EwDtDHcGpMIa5vg86V5x/PRfjCa0V X-Received: by 2002:a17:906:358c:: with SMTP id o12mr26666120ejb.156.1615845159207; Mon, 15 Mar 2021 14:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845159; cv=none; d=google.com; s=arc-20160816; b=bxh6PKBHkrd0md/xvtkOwQLFHQeqezmm9xWonEy/UBPeVUmG/AKawjd+4Fi2XA9aDF KbyaETAYHA/MB4DiIL7jGVqRYVnwsoLRmiPlqiXpShj3mhUaBCRGCbwBpeunsVfUMyLD Fp95WVRsMJJyDzm3mzEOQsQPOJdKhiYcKDO6yGl4eqQhtS8ZFMkKuSJBWZYjqef1zeBs 7s51I4zrk/U2gQjLh9KBCS1kysd8/AHABO1lj7EU1Lv2hQvjUp3is3pRKwqofbm5FKjm nWcq28dW6RJJXAHCiwHNDvmlPnzzWbYw5XMwVCZ5pvuWIhjxZetSWiuCAttVYf7+Jy/A wMTg== 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=Gzfg71vsx3VY2377GfG2oAcRHO8kBLm5otxChzsZJP0=; b=FTwKwVUVz8iB1rTeYx/yJVD6QWydlNTDYY6BZyUSefpXDV/dYR02Y0AS9F1hr797qz 2XW38XXmso+Lu6U0CZOCXnCRMAeo0BLaSeUEc1o4uJjC5Dd+VyECVL0Zg4JlRiiDtCY/ Fg85TZNZXTwEbLG78+W8AV+7/9RIKhVjP7xv0N+rl95IQbpXsOPNDdWJZjMQ0nM/FETm 8jf9Y4dfiKEsCpgtL4EjyA++O5ijXhx1h8CIliMWOoLtW+sH3Jp8M0EnamoD8slI8d1I j1fg6BSm7NziFMitW8sTjn8oXy4Q18edPHgHCcIgqWaQlNXrz9cxSfa9Z3FSQT6J2aGc l07Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nU74m4/T"; 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 c13si12173560eje.45.2021.03.15.14.52.39; Mon, 15 Mar 2021 14:52:39 -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="nU74m4/T"; 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 S234005AbhCOVwH (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbhCOVwA (ORCPT ); Mon, 15 Mar 2021 17:52:00 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CB98C06174A for ; Mon, 15 Mar 2021 14:52:00 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id f10so10817707ilq.5 for ; Mon, 15 Mar 2021 14:52:00 -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=Gzfg71vsx3VY2377GfG2oAcRHO8kBLm5otxChzsZJP0=; b=nU74m4/TDwYTcRC/4fEWoUrB1F9S8l7PAHZcvmRg2f+JWzVfWqpnrDrdGpuyijqwKv 0VtF8OW7fWEsrbQRPQKSixSsr+JasVJfE8XHLoLRXl+S4Bksi2e6tJ6PhCepvmZYxPtQ MrHalaUfCsmWZiGWgYU9XdhCQdfKrgTQ8UB46iJoqkIrFy+X5sGOoevr2PIbZcrcbDsN Sm+GZBjEMwKnSoS16c7Im5ldPbS594ioQ2b08V25r7mB739a73pM6/lB6PXHmj7Mq8LA nYuMOH1kSyW9Y17ytEHmrv0ki/vD6YqWiITeYrlMcz063S8ctjkNa+75L4ryTwoDI3tF xYdg== 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=Gzfg71vsx3VY2377GfG2oAcRHO8kBLm5otxChzsZJP0=; b=dxYf9dl1pkKzXJJP5XbwJHrYGyaUVTaCVA+Gs5pb0Wmy/xhVI2Y3sRUAcuFbA4C7Qh YpLZgbJRfic1PpUC+Oc77PwHVZ260nkocyV7+krRGXl3hRhiWgn3hct0Z1YMHkab/uXZ bjrdpPJGvETrQHVYoYLDrYEWZszIU/c5hTuchWAisgi1WAzamHPt58N4FZQETC+qHEup fEzge/b+1cT31beaxRnOI3oK5c2ZfjnNczZlv/cP1Pr6zFVSxJwTKHZlxQbCheHw0xyR Mfbi9WCsaYKQCi92dtp98jGqMwimHYBCG8rR1q9BhOyYD1fUzs9IWKEYSFRr5OCUG5d3 F6gA== X-Gm-Message-State: AOAM532b1jbruCycy/BlE49dkfcFDwkdjELZpk0fptaXjNpvO0W4w/ys PvYI+45nX0EJoGX1f2r6P3pS/Q== X-Received: by 2002:a05:6e02:c7:: with SMTP id r7mr1319971ilq.288.1615845119526; Mon, 15 Mar 2021 14:51:59 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:51:59 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Duyck Subject: [PATCH net-next v6 4/6] net: qualcomm: rmnet: use masks instead of C bit-fields Date: Mon, 15 Mar 2021 16:51:49 -0500 Message-Id: <20210315215151.3029676-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The actual layout of bits defined in C bit-fields (e.g. int foo : 3) is implementation-defined. Structures defined in address this by specifying all bit-fields twice, to cover two possible layouts. I think this pattern is repetitive and noisy, and I find the whole notion of compiler "bitfield endianness" to be non-intuitive. Stop using C bit-fields for the command/data flag and the pad length fields in the rmnet_map structure, and define a single-byte flags field instead. Define a mask for the single-bit "command" flag, and another mask for the encoded pad length. The content of both fields can be accessed using a simple bitwise AND operation. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson Reviewed-by: Alexander Duyck --- v4: - Don't use u8_get_bits() to access the pad length - Added BUILD_BUG_ON() to ensure field width is adequate v3: - Use BIT(x) and don't use u8_get_bits() for the command flag .../ethernet/qualcomm/rmnet/rmnet_handlers.c | 4 ++-- .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 4 +++- include/linux/if_rmnet.h | 23 ++++++++----------- 3 files changed, 15 insertions(+), 16 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 2a6b2a609884c..0be5ac7ab2617 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -61,7 +61,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, u16 len, pad; u8 mux_id; - if (map_header->cd_bit) { + if (map_header->flags & MAP_CMD_FLAG) { /* Packet contains a MAP command (not data) */ if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) return rmnet_map_command(skb, port); @@ -70,7 +70,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, } mux_id = map_header->mux_id; - pad = map_header->pad_len; + pad = map_header->flags & MAP_PAD_LEN_MASK; len = ntohs(map_header->pkt_len) - pad; if (mux_id >= RMNET_MAX_LOGICAL_EP) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 3af68368fc315..e7d0394cb2979 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -280,6 +280,7 @@ struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, return map_header; } + BUILD_BUG_ON(MAP_PAD_LEN_MASK < 3); padding = ALIGN(map_datalen, 4) - map_datalen; if (padding == 0) @@ -293,7 +294,8 @@ struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, done: map_header->pkt_len = htons(map_datalen + padding); - map_header->pad_len = padding & 0x3F; + /* This is a data packet, so the CMD bit is 0 */ + map_header->flags = padding & MAP_PAD_LEN_MASK; return map_header; } diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index 8c7845baf3837..a02f0a3df1d9a 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -6,21 +6,18 @@ #define _LINUX_IF_RMNET_H_ struct rmnet_map_header { -#if defined(__LITTLE_ENDIAN_BITFIELD) - u8 pad_len:6; - u8 reserved_bit:1; - u8 cd_bit:1; -#elif defined (__BIG_ENDIAN_BITFIELD) - u8 cd_bit:1; - u8 reserved_bit:1; - u8 pad_len:6; -#else -#error "Please fix " -#endif - u8 mux_id; - __be16 pkt_len; + u8 flags; /* MAP_CMD_FLAG, MAP_PAD_LEN_MASK */ + u8 mux_id; + __be16 pkt_len; /* Length of packet, including pad */ } __aligned(1); +/* rmnet_map_header flags field: + * PAD_LEN: number of pad bytes following packet data + * CMD: 1 = packet contains a MAP command; 0 = packet contains data + */ +#define MAP_PAD_LEN_MASK GENMASK(5, 0) +#define MAP_CMD_FLAG BIT(7) + struct rmnet_map_dl_csum_trailer { u8 reserved1; #if defined(__LITTLE_ENDIAN_BITFIELD) From patchwork Mon Mar 15 21:51:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400558 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784540jai; Mon, 15 Mar 2021 14:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOjTMT8gGFGf0/2eFit0Fqk2AtZE1TkVXQQQqi0bB7+ZFTv2PT2xT5RAVM3bFom6HOcoBE X-Received: by 2002:a17:906:c301:: with SMTP id s1mr25503533ejz.382.1615845186687; Mon, 15 Mar 2021 14:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845186; cv=none; d=google.com; s=arc-20160816; b=AG/xaeUyQwvQI9t6gy4bUIrfjdpIQZ8NI2x6oM2BXx6MEyhD4AYV984EC7oO+awQ9m OAnpVHZTDXEby5iA+XnBpMc043oONh6k9au2eT5nDHosV8fHgBvLqvp57IxU5jdnudDd 8gf0/kjoTsUWG9NPIDhEBRpgM5bUHAAFDSmFPDeuycgQk+m3t0MwlVxxIfxurSxeWg6+ JJmqPLsB3N9OE1klBkOzsQwkhLzvGHmMMksEan/QpX522Xaziq3QpK7AjxvY817/aIlU EJP5xYC/3iNQQ8VdTnmXUWpHtwbKoTUrkNnEo5Z53FQZthZ/Qi4Y3W3kDfGOgNAcljWk 6XWg== 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=jKWpv2lC6idRAW4U2uy3fxWpPmNFe54usond8BqeY/A=; b=tVCZycXgxnsqlgc4NH/8FGEmaghhImAzkKUWlnf3AGbWGa9QWCZVx3qoMu24SgjBez vrY3jToKCvZfp/hfyzzeZsScWYHLfVlorfChYk4ovNiflTjoksteL/03WHO/wQfh0BmD RyqyGDMJUYtBqOKd1G5zfnFZFMZqPZX7AVQqmtHgwGc7763xla5jdSVr939SIvGxG03y Kf3NdnULJ1jJvIXOK+f+lFbWcGwzksWpB2PcTWoLPEMQKekJAB0uqaJefa1ff3CwWj/l SaZC81u9gk0kWBj/5UtLHnlbUy3Pm+HQwP44UTn9MzYseAvjsMH7gDFaaSr5+JZ5PFnP 1yIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WT2SPDCt; 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 c13si12173560eje.45.2021.03.15.14.53.06; Mon, 15 Mar 2021 14:53:06 -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=WT2SPDCt; 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 S234091AbhCOVwf (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232840AbhCOVwB (ORCPT ); Mon, 15 Mar 2021 17:52:01 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28757C06174A for ; Mon, 15 Mar 2021 14:52:01 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id k2so10849216ili.4 for ; Mon, 15 Mar 2021 14:52:01 -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=jKWpv2lC6idRAW4U2uy3fxWpPmNFe54usond8BqeY/A=; b=WT2SPDCt/BK2FqNOeKVfL1HqHZKyUA2Fk0ToapiSvU7lZKzAPSeWBRUQaqt7Z+DwxF BuTLK50vY0YWuCAubl4C5Kax6XAe+05A6XwEOTy5KG2tF8iZLUofEPyCJ2Mz8x9fUKtl KVxl44arefLIEsu/uQ8+Q2d79Rhto30uV5VYJlEV3+yIdAAKSUSMA54tIVV+OdU4c/fD Nlz6c6nHRFoFRn51lQ+o3e60TpqqfKVuujxd3iesHfvc+glT59tiyowIooaQTGvHbrjx XIc0rr/PujF9CZxruUypmthmiDFDZU19ZK9QEUyAQgaLwI6sTME4TZ2GfRatB0yxksve Z7cQ== 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=jKWpv2lC6idRAW4U2uy3fxWpPmNFe54usond8BqeY/A=; b=Yw6I0SYsQaSMwifI3ljAGk+Rp7YPLlCYr7H8TnrRmFcRkRHmQPKPDWSo/DMRmMQ1Ww 30qFAj9ugjgNsUIBRxJQ4Xhro5VHAXMlJ2i8bnqMjthL77aKIpfUmAEWXgphU1Gh2qEf ZZq4qSO5SOUHCWia9PjHYDjMxj9PCGbhiyC2KFpGdiZ7WUGrdP+3pt9xj/VwqjMohGW/ WGP9AG9z6uGBsdKrNkNzVn3qZP2eRU8Kj9+TIKQE5aoULpyaLAeeOoRRWkofHQF5oRX7 f9BKMviY0jWBlrYXYRU3oS8RRoXTaFIrl3SGNn99APhhsp2+57goLZmDaZKXtQcUv/Jx m8nw== X-Gm-Message-State: AOAM533HzFSE/PzGfflKRvDvTSBWkb3UPmtwUctWYfWRjHE7dx7fdvcO fdjHtxQig9s9y90anwdMOH0ZZw== X-Received: by 2002:a05:6e02:1044:: with SMTP id p4mr1376472ilj.238.1615845120635; Mon, 15 Mar 2021 14:52:00 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:52:00 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Duyck Subject: [PATCH net-next v6 5/6] net: qualcomm: rmnet: don't use C bit-fields in rmnet checksum trailer Date: Mon, 15 Mar 2021 16:51:50 -0500 Message-Id: <20210315215151.3029676-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace the use of C bit-fields in the rmnet_map_dl_csum_trailer structure with a single one-byte field, using constant field masks to encode or get at embedded values. Signed-off-by: Alex Elder Reviewed-by: Bjorn Andersson Reviewed-by: Alexander Duyck --- v3: - Use BIT(x) and don't use u8_get_bits() for the checksum valid flag .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 2 +- include/linux/if_rmnet.h | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 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 e7d0394cb2979..c336c17e01fe4 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -359,7 +359,7 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len) csum_trailer = (struct rmnet_map_dl_csum_trailer *)(skb->data + len); - if (!csum_trailer->valid) { + if (!(csum_trailer->flags & MAP_CSUM_DL_VALID_FLAG)) { priv->stats.csum_valid_unset++; return -EINVAL; } diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index a02f0a3df1d9a..941997df9e088 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -19,21 +19,18 @@ struct rmnet_map_header { #define MAP_CMD_FLAG BIT(7) struct rmnet_map_dl_csum_trailer { - u8 reserved1; -#if defined(__LITTLE_ENDIAN_BITFIELD) - u8 valid:1; - u8 reserved2:7; -#elif defined (__BIG_ENDIAN_BITFIELD) - u8 reserved2:7; - u8 valid:1; -#else -#error "Please fix " -#endif + u8 reserved1; + u8 flags; /* MAP_CSUM_DL_VALID_FLAG */ __be16 csum_start_offset; __be16 csum_length; __be16 csum_value; } __aligned(1); +/* rmnet_map_dl_csum_trailer flags field: + * VALID: 1 = checksum and length valid; 0 = ignore them + */ +#define MAP_CSUM_DL_VALID_FLAG BIT(0) + struct rmnet_map_ul_csum_header { __be16 csum_start_offset; #if defined(__LITTLE_ENDIAN_BITFIELD) From patchwork Mon Mar 15 21:51:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 400559 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3784555jai; Mon, 15 Mar 2021 14:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1fMcaG/HD9jrXDcu++tT85sdNSmVtG2K84la9pvTCJWQIFIvuM4l0nUWa01pjjyMXHjTO X-Received: by 2002:aa7:d813:: with SMTP id v19mr19771257edq.213.1615845187783; Mon, 15 Mar 2021 14:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615845187; cv=none; d=google.com; s=arc-20160816; b=QCEyLlC/6j/vRD9ohsgzJmPIcpxCLC1ateNXL6Foj9fSu9RL11LfPU8aTpf9x4nYOy io1q0G8BMC826lfvkh2GDZNEBcy5t9OwBzumJmXvHOhjW3ULQzq0luR1NvAnAXIQW068 S737S167WrGrNuVGAT8TULbBD6Cw0bSoAt7UAsDCJEayFo7HWmb9FA4fADBWrjrHjY7x /wHgVK2/Rg9U7wA0VkkcF6r5UIoVidZofk+38ul7MqlvCtNRo6+hizMnQs9r6Z/OMpx5 3zZXRbG2jExPsv4rju+44SUPCWhXPipBrGl5LlIcEQWDQCoZ4/ip/5ikDT+xaieoebyP S4jw== 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=v7N6p1x0BsH0iM7+7iNRHjfZcm0BfhMj037soR+6HF4=; b=aQk/j7BNMxdYBaPaMOxqE8bvBOmiiVNBlSxPIqZrpOKDo1PEYU/PCIQ8csncRzb5aV VvHJyfsFde0zdIUFlAEwmXGijRM1uSJ01wvyL2g3H/BAgb4vWAQBP2YB6jh3qc8L3jq7 vZUBThXa2LLUHc3a9SgzDk7wDjrmati3a7lzEHrDMWn/9O2E9YWOzdUhY0fE9yVbxorw 9i+kYlS3hM99LLC+iGL1YgbnSd4tgbHI8J4LhXO+H1o9Ii6n0vk4t++OxyqInqjiJ+ti 2AxZnUTAWCyU7cgYApcevPdc9IN6UgEcoeoQ4wdLMtSYLMgUa5YwCeFSMqq27iA/83Fl 8kJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=poW1YMS4; 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 c13si12173560eje.45.2021.03.15.14.53.07; Mon, 15 Mar 2021 14:53: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=poW1YMS4; 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 S234122AbhCOVwh (ORCPT + 8 others); Mon, 15 Mar 2021 17:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233186AbhCOVwC (ORCPT ); Mon, 15 Mar 2021 17:52:02 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46125C06175F for ; Mon, 15 Mar 2021 14:52:02 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id h18so10843554ils.2 for ; Mon, 15 Mar 2021 14:52:02 -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=v7N6p1x0BsH0iM7+7iNRHjfZcm0BfhMj037soR+6HF4=; b=poW1YMS4YSxaLKEiHkfDczYRpqjgHVgtW4F8oj4a78qxH0zHERoYJ65kHX3saRWU8p SpOhu/1bOxZlp+4PZxOMRBGzZ7LHESr7/QUG7FxrxE618vxSEn7G9lgXlNgJ2NsBgTKk gqjmxWmyL6Plw2ZRbUKZrpEzJ0Er7SCmELP2JN1vG1siq4wGMUPgI+yS7QIhKFyZ/Arm 42kAJUpxzU1EbUY2mtvYAX0e8IVnKLAZTshpovvj34m7gg21m0yx3Ahn0WAHj3nvIuwx us8ySMRvf33t20j7ObYagpY1Bx2qCbFq6a0rqSaVIZtl5y6J/tZjLuRaynAC5KTsy0eb yj8w== 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=v7N6p1x0BsH0iM7+7iNRHjfZcm0BfhMj037soR+6HF4=; b=dW0SiybYPukuOcKDPc6cSGLa8r/ldAwPVFRWycsCOvCnWNPBnlmf2AEZhnx0OS+CAx tqHxzki9FGPVUbf2w40bq+LwjbYOWvXj8MmPu1DwLJdiWO0UNafO93mgpkWzcPfIdtv6 Qvdnr9YbtSB0dHW2J1e0nDka5H+XC96CMuE/8TDLZTiXohkEfHYPT77EFiGqQHz1p83g VmXMctc6qhKja1nKfl3AWBf6B4PcEGJJZjYSsfpsdl3MsPzeQfi6e5IwascOTlA31I+9 /uWoqe3WFutk7RpGabd6IwX78nejqixpKKiQms8EadMhiduamg3aiXCSn0fGo1KVYzzt oI3Q== X-Gm-Message-State: AOAM530HwdW3bZex9AUB+GpHFiPNfmyvshP1a0ekcupp9Pdz/KYGP3cO UXKHBqnyZY/NABNOM3vBHcjsrg== X-Received: by 2002:a92:c690:: with SMTP id o16mr1375597ilg.256.1615845121704; Mon, 15 Mar 2021 14:52:01 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y3sm7424625iot.15.2021.03.15.14.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:52:01 -0700 (PDT) From: Alex Elder To: subashab@codeaurora.org, stranche@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: sharathv@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, David.Laight@ACULAB.COM, olteanv@gmail.com, alexander.duyck@gmail.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Duyck Subject: [PATCH net-next v6 6/6] net: qualcomm: rmnet: don't use C bit-fields in rmnet checksum header Date: Mon, 15 Mar 2021 16:51:51 -0500 Message-Id: <20210315215151.3029676-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315215151.3029676-1-elder@linaro.org> References: <20210315215151.3029676-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace the use of C bit-fields in the rmnet_map_ul_csum_header structure with a single two-byte (big endian) structure member, and use masks to encode or get values within it. The content of these fields can be accessed using simple bitwise AND and OR operations on the (host byte order) value of the new structure member. Previously rmnet_map_ipv4_ul_csum_header() would update C bit-field values in host byte order, then forcibly fix their byte order using a combination of byte swap operations and types. Instead, just compute the value that needs to go into the new structure member and save it with a simple byte-order conversion. Make similar simplifications in rmnet_map_ipv6_ul_csum_header(). Finally, in rmnet_map_checksum_uplink_packet() a set of assignments zeroes every field in the upload checksum header. Replace that with a single memset() operation. Signed-off-by: Alex Elder Reviewed-by: Alexander Duyck --- v5: - Assign checksum start offset a little later (with csum_info) v4: - Don't use u16_get_bits() to access the checksum field offset v3: - Use BIT(x) and don't use u16_get_bits() for single-bit flags v2: - Fixed to use u16_encode_bits() instead of be16_encode_bits() .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 38 +++++++------------ include/linux/if_rmnet.h | 21 +++++----- 2 files changed, 23 insertions(+), 36 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 c336c17e01fe4..0ac2ff828320c 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -197,20 +197,16 @@ rmnet_map_ipv4_ul_csum_header(void *iphdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - __be16 *hdr = (__be16 *)ul_header; struct iphdr *ip4h = iphdr; + u16 val; - ul_header->csum_start_offset = htons(skb_network_header_len(skb)); - ul_header->csum_insert_offset = skb->csum_offset; - ul_header->csum_enabled = 1; + val = MAP_CSUM_UL_ENABLED_FLAG; if (ip4h->protocol == IPPROTO_UDP) - ul_header->udp_ind = 1; - else - ul_header->udp_ind = 0; + val |= MAP_CSUM_UL_UDP_FLAG; + val |= skb->csum_offset & MAP_CSUM_UL_OFFSET_MASK; - /* Changing remaining fields to network order */ - hdr++; - *hdr = htons((__force u16)*hdr); + ul_header->csum_start_offset = htons(skb_network_header_len(skb)); + ul_header->csum_info = htons(val); skb->ip_summed = CHECKSUM_NONE; @@ -237,21 +233,16 @@ rmnet_map_ipv6_ul_csum_header(void *ip6hdr, struct rmnet_map_ul_csum_header *ul_header, struct sk_buff *skb) { - __be16 *hdr = (__be16 *)ul_header; struct ipv6hdr *ip6h = ip6hdr; + u16 val; - ul_header->csum_start_offset = htons(skb_network_header_len(skb)); - ul_header->csum_insert_offset = skb->csum_offset; - ul_header->csum_enabled = 1; - + val = MAP_CSUM_UL_ENABLED_FLAG; if (ip6h->nexthdr == IPPROTO_UDP) - ul_header->udp_ind = 1; - else - ul_header->udp_ind = 0; + val |= MAP_CSUM_UL_UDP_FLAG; + val |= skb->csum_offset & MAP_CSUM_UL_OFFSET_MASK; - /* Changing remaining fields to network order */ - hdr++; - *hdr = htons((__force u16)*hdr); + ul_header->csum_start_offset = htons(skb_network_header_len(skb)); + ul_header->csum_info = htons(val); skb->ip_summed = CHECKSUM_NONE; @@ -419,10 +410,7 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb, } sw_csum: - ul_header->csum_start_offset = 0; - ul_header->csum_insert_offset = 0; - ul_header->csum_enabled = 0; - ul_header->udp_ind = 0; + memset(ul_header, 0, sizeof(*ul_header)); priv->stats.csum_sw++; } diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h index 941997df9e088..4efb537f57f31 100644 --- a/include/linux/if_rmnet.h +++ b/include/linux/if_rmnet.h @@ -33,17 +33,16 @@ struct rmnet_map_dl_csum_trailer { struct rmnet_map_ul_csum_header { __be16 csum_start_offset; -#if defined(__LITTLE_ENDIAN_BITFIELD) - u16 csum_insert_offset:14; - u16 udp_ind:1; - u16 csum_enabled:1; -#elif defined (__BIG_ENDIAN_BITFIELD) - u16 csum_enabled:1; - u16 udp_ind:1; - u16 csum_insert_offset:14; -#else -#error "Please fix " -#endif + __be16 csum_info; /* MAP_CSUM_UL_* */ } __aligned(1); +/* csum_info field: + * OFFSET: where (offset in bytes) to insert computed checksum + * UDP: 1 = UDP checksum (zero checkum means no checksum) + * ENABLED: 1 = checksum computation requested + */ +#define MAP_CSUM_UL_OFFSET_MASK GENMASK(13, 0) +#define MAP_CSUM_UL_UDP_FLAG BIT(14) +#define MAP_CSUM_UL_ENABLED_FLAG BIT(15) + #endif /* !(_LINUX_IF_RMNET_H_) */