From patchwork Mon Mar 15 18:49: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: 400525 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673778jai; Mon, 15 Mar 2021 11:50:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6gxpEx+aSXKa8vH/BnDzbnXncOV3a/JQeQr1zdlTxcqbEmn5LCzfesfbC9tAnmbd3Yo/l X-Received: by 2002:aa7:c7d5:: with SMTP id o21mr30784789eds.166.1615834236296; Mon, 15 Mar 2021 11:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834236; cv=none; d=google.com; s=arc-20160816; b=Xg+0eFFwB4LJHFnHamEaBNoD4cHg+eVENX4Qy8uRKQL/DBPO1noOla1aM1xyBS3IxO /nJuRqqSoZ4i88pbD6pUBD3OE4SBTq1a6eyHs5mF6gTe/y/EogV6PJniciQSgzMqxwzb MueRIj7zu4zg6AQQSnDtNjRLi7XBUDkkZ90PeUITC71BPhqAD922byidlKTIwRMR5iBy xQTZ6NuJkA12JebGZWhZ7rINCDQQeNe7IlIXs+O1mXd/OB6w57jJ14G7DSukf1mfyd2r +un5gkBS8HCS2myaCnmwDcpaXEtRYk17ghQQEyS1HwZYvraPUzjOHEnr2wCucUUbOBzX a1UA== 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=xsE0zxNABaiYDhbWIEujtOAaP2pvbVNW0ARrlyX4C/vY6xUA5jBlmWj5UERHsL8WPl K3w/8ljWpn9iev64dpxyGk0hZlzReCK36rig4I8Ozei6dMvZFHiLmGh+N5XQQ/ouuJ37 0a4Q9U0R3t2jA7OrOcAkNH5scYvwJ+iMMjqqW8B4yDqssXUvlxJjDINxolkvHkFvEH9Z 8ieCbolGX5uy5Q65Ww3bd28pU903EvSt4b6gPMR7h6CU3DZQj+a2wZT4iTXFGEMWSZdK XlDAL3C2z4SzJvGC+CzCFI4dUsni8huEFQwtse0qnvxKwV/KUewMc+jga8U9/v1pNjy2 fM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bom4lMmQ; 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 x27si11624279ejb.603.2021.03.15.11.50.36; Mon, 15 Mar 2021 11:50:36 -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=bom4lMmQ; 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 S232306AbhCOSuB (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbhCOSte (ORCPT ); Mon, 15 Mar 2021 14:49:34 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0FCC06174A for ; Mon, 15 Mar 2021 11:49:34 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id r7so10394711ilb.0 for ; Mon, 15 Mar 2021 11:49:34 -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=bom4lMmQJrp5VcTVXyEm9MMJ4NeJCRL6bqdHhGXRV8mep6rnDF0QdfZZzpn1mM50H6 qvHHmBXE2mqaHSkdqifKS546EMOYBAnUJ5FhxHltL83Pdxc5JCc4ZUiIFrxjZNQeQ5bV Okf91VbuTCBZJ6I4UYIxfXiwnzNKEfNANWfqyKPqkk1ZaDlOHyfibNOZBNFIcDjjQyTE qtTU/ERepKCjDksL8h+aY++zNqwez/tAA1gpPrf09QeUe08+i+ryBizTgRUUSBnQVqoD nkP3sOy/HYJ4nzBS01d7XTLT+SqI0ubN7ayRTRPjYdv02YaufxlII17g5KoZztlN2IHG M3Sw== 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=Fy1C1ghBjS0UIpylXNyW8xFavgHieKlTnEYrdzPMhFlWFg8G2DvdofeaiTabouWWcU ZfAvDLFxnrk9019X5oBjXIBUbCEhZVrj4wW6AJOqq54RlkRalPVhszLQyYaPwUOoGvNx DFEi2lsWHefwb9oTIqg/cXCf2m19gQxRm5vEXx+I5BNezUj94VQ4Y++Invq97aVSmesE 2Bm3u0JGrFOo9T9HBUrf0Yuw65E6l1hzTHRD1SGk5Q67Kruy4CtlGbf6YYVkiIF2PTsT NaG5gCAO3yxpiuc6ZQs9Kb6DjX9maY93uZySvBGpLiZoEZsDQq5qcglAH/tqfgvywF3r w1qA== X-Gm-Message-State: AOAM532gQs76qYB8guWslXUOZIkkVORqSj5akJLi2hvXmLQVbFuOuXMi YIIiSx79SXh4gDoAVkqa5fb4/A== X-Received: by 2002:a05:6e02:ee1:: with SMTP id j1mr765610ilk.179.1615834173956; Mon, 15 Mar 2021 11:49:33 -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 a5sm8212162ilk.14.2021.03.15.11.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:33 -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 v5 1/6] net: qualcomm: rmnet: mark trailer field endianness Date: Mon, 15 Mar 2021 13:49:23 -0500 Message-Id: <20210315184928.2913264-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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 18:49: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: 400526 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673788jai; Mon, 15 Mar 2021 11:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuVkR/JdRwiK6d5JRut6BqqgCWNTWRI7sziuOTY7o5I+5OcoKn4u85zMNsHCYsceS2PxGx X-Received: by 2002:a05:6402:1283:: with SMTP id w3mr31372658edv.340.1615834237032; Mon, 15 Mar 2021 11:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834237; cv=none; d=google.com; s=arc-20160816; b=IVQJGLuB3PpDtl3S214ssuNJNjco5hrwQjge5wo9rj0VDdArNCNmUQkHcCSrTtn97L avsMP+ypvf2FrElXqNIyNLU/YUfU0N+SSdOHkuode7ym3NkBu4nJkvdxYZfa3NHrmvRo rWEvZ3BWH0Ky3p1RjicEaS9krYrE2FdFLvqmTb4oN3rxh+ix20yUgWB867uEhAzn7/JR 7WDj5YRWJkXstjPUlJQY/m7YQKty+PPdwKA3LDt4KsJNfIaiwLTZD7Z3f4HnwbTAzFDp fjxqIDgJuO+EU00m55hIwmuE38NWRq9438fwnWfm92KQhx6Muue8HGs4Qlv0CtD8aFn+ BEJw== 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=o3oHz3tjrnBc5UWVJrza4SufsIAoiBbwM4Ix85g/asdvZXQpw8Ffy+kFzOi1ge/FXt 7TGutpm1zHlmWUjSA8CiHdql0z7FBimLwiCkRSDSH7UYBeFVejQbrVSXutC83FA/J19h yP23hq5qJDRBdRF/xbd9l0FkCfXUpuxyJHOtHLS2MhaXlcKyxCpppEaQ4LArZT296eVN yLP1hiK47tV54+MrObGyLjrFm9lcsT70+MYomlmsW5uDGWIDDCcICM7HhwSsnBNIsKF1 R0CSMzSfvk6lxwCM0WCwP9kwzmowtRRAjC+hkNQEgzdMwTr218Zunfl4Q4NSzqizihMK 6oSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GLM4k0nd; 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 x27si11624279ejb.603.2021.03.15.11.50.36; Mon, 15 Mar 2021 11:50: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=GLM4k0nd; 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 S232506AbhCOSuE (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbhCOStf (ORCPT ); Mon, 15 Mar 2021 14:49:35 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5FBC06175F for ; Mon, 15 Mar 2021 11:49:35 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id d5so10362528iln.6 for ; Mon, 15 Mar 2021 11:49:35 -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=GLM4k0nd1Bu2JQTPV+3Is3ZBwQmMUM7EL0g1eCcX6kCEdhQXfspaPcdrW33QxPxq0R JjqeSAczLiFgq/GqqoJ6h5ln4ltkVAcjlUB4MEXzsgcEGTdRcWLacL0GfVwXzWcA8+F6 1MtBnCWBA7T7CcSvNxExnyHGIdDoeAnPM7/fH68BEt/rCkb5Ov4PqqvqXQ7YZop/cIu4 MpO+nADtMdw6KXaBuHrLAPj9e/ElyDiJ7rUKza7A7wrnIDW0zH9bBBcRpMl52uKNu/nL p9eblUJUamUe88VQ7yhdd8edLin4o78kGFPSwYg7ZDki6ekXG6YiofNCC8xES0L5T2Ft gI9Q== 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=hYpoivSxQPcmQt0BzNAp6f6fBEhI5OXB5gM0Z6I1g7Y7m5/Q5DIKSbQHRYJPJ4UAPk 0AwZME3HA9VPB66EFVOVWMuzwmZWTKd0DxiPthA8pN8guopWb+6ICOXXW+hW+u6m2w/G jbgrRXnALfn7ilcHZN23XZwF33Jrt77/DaU9ZkOK/2DkHY4d9Lep2iwUE3oMN9TWD+Yi yFtUMo9QB4t90lXxzX9JjT7DD00LD05CanIqqBq4JexZZS8r5IzBGw26Qq8h8Bucrn9U 9quDBokZgo+L32Ok7KnyAhHVKLAb7gSG3kbQrazJOUo4EFFMLjHEIhx+k1sHWdKnk5dT BXHQ== X-Gm-Message-State: AOAM53252bFwh5jzU7mFZ9ijazlIKkEJnkFcxLpib2kajtdNe4iqH9YK exrNhWRwfGggZfTQcNyZZgJL5w== X-Received: by 2002:a92:c24a:: with SMTP id k10mr794970ilo.284.1615834174989; Mon, 15 Mar 2021 11:49:34 -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 a5sm8212162ilk.14.2021.03.15.11.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:34 -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 v5 2/6] net: qualcomm: rmnet: simplify some byte order logic Date: Mon, 15 Mar 2021 13:49:24 -0500 Message-Id: <20210315184928.2913264-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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 18:49: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: 400528 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673812jai; Mon, 15 Mar 2021 11:50:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAo4kWJACZLMyrBxGNDlxWP+s6k+Nl5bdwTlKLPZtLr2EKoaXhDNHIXIjznLWZ7iRdncMk X-Received: by 2002:a17:906:c24b:: with SMTP id bl11mr25782111ejb.80.1615834238914; Mon, 15 Mar 2021 11:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834238; cv=none; d=google.com; s=arc-20160816; b=LzI8u1QnRwMxX5bzgnP7+3CPu60dAJK7dHY7skJ5t+PgVOdi8bv15uvtCyoCdLL1e1 7BaZgKGPppui/afc5e0e/hhZE1YbqC7LigkNpDKheHOr0cvsr6Az3Ti4Z5fd1LkiEX9r XZ4N2ReA0y6uPA9VHhT0cQVX06QFEhfYAIB3jWCbkKUns6WxS87VU83zTcRY0fgWh7Vq qSTCXtlk1CXTM4+bkTLx7ma0MKh/Vy360ms/LcxxAbZNVH1uj8RQZhUug6v4NQzqrgQ6 QGmqBiI/J//YcvoKwD9On/9BGeBFE0vbJqvNQ/rbNaXioftv0y7BvfXw++KsSHA6T7pW XoLw== 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=ChiloiZGlA2zQXvZCRB/pktdbz1pm57UhPz4b0l9NTsA8XLTVYBifB+qn8A51638st KFBHNLFyi7I0PKL0MKECFlVUMMwRyHP8EDFrFP7W4ZrdMxNSzuCES2+IJJO6LHP5PqEW 78fC16nG6B5T+b1yEVprfNHsWBnrqOev3IcGPiu07delMse3XDxn/9NICsSxqGaDsiOL PAtVtDSXXoJklM0nXoi+m1Gv1AY+WggrupienPX8Xk0u+g0r4kJSl2YJgM4ys0b+hmy3 Yd2iQkUXe1E4D7jq0wi4LH9qG9+inxoXhhCMAdc515wo+rWmS2p5uOYoUqnWS1FFKQUV rnww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUDI23OY; 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 x27si11624279ejb.603.2021.03.15.11.50.38; Mon, 15 Mar 2021 11:50:38 -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=yUDI23OY; 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 S232577AbhCOSuG (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231891AbhCOSth (ORCPT ); Mon, 15 Mar 2021 14:49:37 -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 974A1C06174A for ; Mon, 15 Mar 2021 11:49:36 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id i18so10308060ilq.13 for ; Mon, 15 Mar 2021 11:49: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=rVEslqQM6fsvVZ7LiAEkE3ccCznmfly+zx9t6yJZNsM=; b=yUDI23OYNIhkInkPACeIRm6oTCYvArJ1DWfEBHdqn9lrVkf1BiRmV7avyO3i2MeQhk 6VbDct0tvBlipbjt1Mb+YJmVvRm/Xdc4RkQ7bYEuzFQB+Ythiwb7jPsYpeBjE64Akgwi NjPrfcZbVhbjaqKLIq1GUxQ/dzqoQZUi6/6sXBN3nPIMUTX1sjEsQ/EQsQTenN//7BEp WFXK+P6iO5qkw5GDh2nTDlXu+BRssJ3kHLLn6Rgl6t2lH5mP0e71cpHq9ElkAHJiPHa4 5pbSsL73kLDgOgZiFBBNsVW3bllt+atlZUV9Glhlfw+8gwcyqojK6/UXRGzPGjZhWPY3 S8UA== 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=PfXHs6NdRsi9jztJ2JFkeWZ3lLJIfw6Ux/jdUHXmztPy576BR1AxpPvUh+QlTaQRRk tRZExXB8kMS6gg7LQGrOvO3sAHjxNRT8XlnjiwgciZdgNtkVm6f8TWnNdS5pnJesZ8Ec cGpmhXi3JhmT2UMZNgBvVU/4UaMH8c2CXRI+bDvsav/II29EaFk/empjHC0OMm4Xm1bW QzQ/dVeZnmrYNH4/+KPn9z0XMs5MvBoA3ev7cU9CMpdT4bq+futekb+h/Se6ByliApFH gY1rE3PJ6u/JXe0/W4IWsN2LJ29lGbfxOGnQKrvDbVGjV0JfzSXXUgrtucJsZxK2KLxH +dJQ== X-Gm-Message-State: AOAM532M1KN4SsGKvsR/GHAL24U0BGhSrgmfwVoTnWFqOH9ZGDJXWWZA 5+Ffokp6zZ5LFL0r81J8x2w9Sg== X-Received: by 2002:a92:d909:: with SMTP id s9mr858869iln.120.1615834176027; Mon, 15 Mar 2021 11:49:36 -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 a5sm8212162ilk.14.2021.03.15.11.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:35 -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 v5 3/6] net: qualcomm: rmnet: kill RMNET_MAP_GET_*() accessor macros Date: Mon, 15 Mar 2021 13:49:25 -0500 Message-Id: <20210315184928.2913264-4-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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 18:49: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: 400527 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673800jai; Mon, 15 Mar 2021 11:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKll4oSOmt9Cbs5H73m2kaNmkJYdZnXT9T/oQcjYhVvOyGMQsSNaM8po7nQMNH8jk1B68D X-Received: by 2002:a05:6402:518d:: with SMTP id q13mr31735816edd.313.1615834237682; Mon, 15 Mar 2021 11:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834237; cv=none; d=google.com; s=arc-20160816; b=D00UarPEJh9tZOtBbRBXql9Br2FX/8W+TbPcNh7JHwyBJXu93Tj0VhvD8U1QIn7/bv i+WzJDJFAjyx3Ukt8hMIzmRetG+EoDcFqlPywlYpUldNdg6hgAvINnXru6wzjDx/9mQm OvzQS7cLw/ucoFQLxlwTnMfYavIGWvejd/ajt9erdhXvkwNb3HDXNsX9+yosBqRSFaZl UTpJpF5io0hbZ1+7BDZr9EceP4Q1NoNuOO8znAQYiAvOu+3hQvGnoRMsvwu7JkU+HPLq cYGEiazSAXMMRnVK8xtoistWaRpPRic5zit3Gzy0pCpX6j4qlbblEc4rxTtf4prPc0OC V85w== 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=Ji5bpOY+OpY07lWC6Epqi9uJXV7h2h3X/5vJpJZo9mfaqg3xAe0uBMTS/RkNiSVvdv 9nmcztOcfHNThfyhyplyC1y2Qa4iRVba7efoulunmJHwkexfVV/ZZwR3uurrFVu9g3lB ddoX+0q9PsXDT5vfYGxACyNGMAzu4bjOl9NXVCEJpv5K1c0u8lKtkUsAxzs3VZvzEOza uSOsQuunXumUrx70s9nNo5/bg6kAQgceJ0ciBFPMe6y7YW6k2EVIeaLe08gX8zNVP3Ct mvWh3s3viZUMYHG6FGhjNkJAqlXlWvsyzXDxAuN84jsCMGoVTOsX0V6Rbnt22jmXw8rE bbyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="siTp/EcD"; 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 x27si11624279ejb.603.2021.03.15.11.50.37; Mon, 15 Mar 2021 11:50: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="siTp/EcD"; 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 S232137AbhCOSuF (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbhCOSth (ORCPT ); Mon, 15 Mar 2021 14:49:37 -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 9BF8FC06174A for ; Mon, 15 Mar 2021 11:49:37 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id f20so34480638ioo.10 for ; Mon, 15 Mar 2021 11:49: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=Gzfg71vsx3VY2377GfG2oAcRHO8kBLm5otxChzsZJP0=; b=siTp/EcDCURtedClVwE0kYOM6IqyOaIr3aFJkBce7eWylsrNmhEKOD3/4orkrGH+KA gouAetKh8XjyZMjjGsi3NJd//K7wllrCij7gdrwhVFw/RdkUcmRPoJhQGevQ2Tyqnjb8 Uqxs+YSfV30PLd79wJuG+1LGhamiOG8GbwaRpUYZ2soEx3mPg9YgAveJ8sW9SCy9iyaX r284yDsdz1/3XTn6Mdq2B3vW6WYy/Fkj+ZFApRNcOdHXKqPprY16AqxKF8hoH2BDVb2g /ru7FuQjI63zbgzbe8ylg0qD46nIoNWcgRr07mnGLRe8Eq/uNeDykuo+czdPX/IwJ9Jn PHGQ== 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=Yn9Zhmb5aOkQ05iZDNFhV1yOBga/a+G5Ju6obAgBzKC1Or43tuZuN7IDlyHqdVPvSy wT4HIGB/Lnfl5TdH4tsuCmQzaolbh6I4qCkH0fC9U7Cyc511c0b7H0KMl9I/CAE7tCtA +YnbMW/ebuPhyeiKukpF/cI7MHz52CBj82kxGigrK+H1hzvlA8awiKBT/xin+pdn/6yR k5T8eiWLRgmXsHXzhvRL3kMlUiDVOEb6uIiURKfekb3zfqGkujlq8NhvJ2ShUWcX8iNx bvTP0yQSghlR3WTNETk+do4skDPvE+kHbfmJORaIXiQeOi5g/GR5CbhkShCqS0TwSr2H +0uw== X-Gm-Message-State: AOAM530py+CkbSSUAOkV91ENM1k4YHrBuopebym2JKsf5t7ZELoNU8Ly XMmzMMXvOqF/Z4yJFlCxrwRc0g== X-Received: by 2002:a02:94a9:: with SMTP id x38mr10824603jah.50.1615834177131; Mon, 15 Mar 2021 11:49:37 -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 a5sm8212162ilk.14.2021.03.15.11.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:36 -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 v5 4/6] net: qualcomm: rmnet: use masks instead of C bit-fields Date: Mon, 15 Mar 2021 13:49:26 -0500 Message-Id: <20210315184928.2913264-5-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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 18:49: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: 400530 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673833jai; Mon, 15 Mar 2021 11:50:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVgRx0wbeIszqatBL04NPpxmO24hUUKkBPSItbIoFfQTL7y+Ggd/2xIV37JYBJsKWv1Ua+ X-Received: by 2002:aa7:db01:: with SMTP id t1mr31736223eds.77.1615834240984; Mon, 15 Mar 2021 11:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834240; cv=none; d=google.com; s=arc-20160816; b=todsf7kREVoGPwS04JryuN7fge9CskNLxmCNZkpZ5KA9DAx6hEdeVFP0a4p99SjwfG VaY1BW7z3pjEOTHzDV2QVljYmhFqq0P1Ck0xjiCOBcx/DZ/eVSQHcmoyxJZdUA305Fcl dXB1/2Ba/+IhjMl+bRGjG487DZAtBOwF6FQM0j40wje6Y5J5NDZIczMqqGr7kGaHS7lJ oo3XoarM6tq3FTNdrSCvESaH4erQuHcRGMKn/OsAxhaw889/uUn7X+hatc5HNKOVROBk Zku836s/iK294NAIeOHfgrJUlGJbTCZnfnQ0sqS+vtE76OiXBwhbpXG6Z88jQcF5XdGQ OQwA== 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=snuCNPCxmi+TThY83/z+McyLHTxm36s7a3NUS4mYh55Wko39Nf4Akqt4rS1kGqiG9B T96dNZZJihJ/GU0ILk3UMgveMmzFmgL4+SIe5ypG3EwfgTBqt8QxGoPxjeGpG6sFA1XC kNgHlbRgHr4ZdGBBvdREeGSsHnmXz5WTVSB4HsYatZpz21loexWU9ybbEnHTH9utSbnE EYeEtBWM51wFSsA4iRW/s6LMz8HSarU1IswORghLczqLiBZ2X/lJ4kckTUMlclTwcvsP fmNZKBws+RWiyMKMS+KnfX2vYKT1Bm1pWviid8VlUr0XgX0K3g8Wm2jLlsuO0L1chPgB AJZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GshvCtSd; 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 x27si11624279ejb.603.2021.03.15.11.50.40; Mon, 15 Mar 2021 11:50: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=GshvCtSd; 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 S232621AbhCOSuH (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbhCOStj (ORCPT ); Mon, 15 Mar 2021 14:49:39 -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 AFC76C06174A for ; Mon, 15 Mar 2021 11:49:38 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id o11so34591962iob.1 for ; Mon, 15 Mar 2021 11:49: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=jKWpv2lC6idRAW4U2uy3fxWpPmNFe54usond8BqeY/A=; b=GshvCtSdibj2Ffh/vsYup4grJLYSBDrLhGFzj8q7C2rsrUWkzrGgiNA/JGfpzuREt/ +z30ti8N7gKvy/Ar8+Czba+I3X+RoeQtsJYT7GJQIKeb1MydifhTy5ZTtsAuNc7r+UoT ZkDrpwaBP0iVnYaB8JN6rZRZp+5hCBEYLbELrGnAMTcSIhvgYxU7qkqOQ1v4e0T5cY3E MatXOqMHnSaW+uDQjC8vERY5EuhIwT7ofjB1lOc2wqydqRXkViOBkc+PWS+ONVV/Mujh oHxWj0CyOhdFojKrY2dH6VbuHJFna0BSyUxyB7ul92IbWm513OMqrkoqJ2HpMrOgxA9G nTlA== 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=ZpkUh8mvw+1LIoq1ZwOF3nlVJP4r9sZtCOFimeM9RI8ZtXFNslnSAAigbMdr2B7WJd na+MahBQmoz26jfMlip9bHVd5LvNp15XnETKrxb1NSGAlBSBaGcZRgTU8EjUByPthyzw 4J4ge693RfITp66J4iiboy79PLlJFGKlqIOKYZ2xbxq53njQZuMOrSLfvpeWKjwWMEAo V8YZsZh3OsfPrwzuV8yfvh/zqHVfcSynvKfSXNOHyZbooaHGD8gkwJIr23Or+yt27Vhx xMjU/znXew6m+EeZIUYfxEXxuTP90GwAfVwx4dWlZUA5HheFDdxiLoRIl96UCT1jKLut xPbw== X-Gm-Message-State: AOAM531MU2E2O+ZYD+nF8DcRhxPRnugZXS6aSBRvG3XdkgCYYlEE5wRk hRtmdhmWNxttNPCu+iMZBj5FKg== X-Received: by 2002:a5e:cb4c:: with SMTP id h12mr668803iok.183.1615834178223; Mon, 15 Mar 2021 11:49:38 -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 a5sm8212162ilk.14.2021.03.15.11.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:37 -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 v5 5/6] net: qualcomm: rmnet: don't use C bit-fields in rmnet checksum trailer Date: Mon, 15 Mar 2021 13:49:27 -0500 Message-Id: <20210315184928.2913264-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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 18:49: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: 400529 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3673827jai; Mon, 15 Mar 2021 11:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyfI6WIgcTggRygkOx8fEBC+HK5wjFPEYyu7KZz0egvnsIHnU2mGgmrsCyRix3Xw9+IFfL X-Received: by 2002:a17:907:971a:: with SMTP id jg26mr25862107ejc.317.1615834240588; Mon, 15 Mar 2021 11:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834240; cv=none; d=google.com; s=arc-20160816; b=cS4XWM5SY4t9UwsbIszSQVmz/L2+GcliVjVV2HAc1b7K5Xvwub5pKe0DiWqTiAhZ6B rqu2KRhQXzvfJxq7rylowQ2KAokN4OFhuMXeT6q3hAyQhXo4TAwPcEvNlcsUUhZweMSv uGMMKZjpTDaHYClqZYZczvgQLX1gu7z8zq3jhHV6EGQmMtbd1w4P2303cDHsAd1RUBha iAE48MXE/leIynYKstuNPce+Lnsxh2MySIyfueSs2uOeLLUFXGv1jBJthucKjJFSO1rV eZaxIRRqg8T0Xz4FlmVIOX5LPI2jzYFMRLEAQikFkkLAeoKetT/099FWCXqKNfoFg3GN v3dA== 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=PXbxDLQ5qzFahsfuQdQd2/oh6y0N5sQbqIGCA/JCZcI=; b=LwQJjz3upLdO4RDVKeBalVrN6DBAS1K0NmAPIXkbUuneKeBnglVM2CQUG6tDWOs0ho DIo8IFM9aAXfvLNvUtS1k3RO0YofYVuelj6QJI/Sd5MOZwMaxmY0JWezTy4OiydCT1Nt 9+3UP3u72WMw9A4DyINDQE1AJTKCloMoKmL8b/bVqG1k7tfiMsFIN/H2tl6sIZmlRiJ1 XHNiQfuzaKfoxmNYog8/NV8IC4AYFACHdTcx/mF00OaC49Bq7vfGh027oaNM0lXZgYDA 8o1DB4T6Gqdidli5OMpLGHc03PYkzQF3kr7pwwVDLWcSnl0eRSqrrGeHdpj2mggD4iMf qcRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gcxva2A+; 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 x27si11624279ejb.603.2021.03.15.11.50.40; Mon, 15 Mar 2021 11:50: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=gcxva2A+; 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 S232707AbhCOSuI (ORCPT + 8 others); Mon, 15 Mar 2021 14:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbhCOStk (ORCPT ); Mon, 15 Mar 2021 14:49:40 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBB4BC061763 for ; Mon, 15 Mar 2021 11:49:39 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id 81so34501050iou.11 for ; Mon, 15 Mar 2021 11:49: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=PXbxDLQ5qzFahsfuQdQd2/oh6y0N5sQbqIGCA/JCZcI=; b=gcxva2A+i8wAZZUM0MJqS4HJtjOcnfep/osbYXHElsJUPfyLqq0LlOqZ7yxTsu/U3O X3qDUjpfYAtFVvZqW7hNgCnTx1XtIxQ2F9oqTNQQWvbRcuE92jdH9P7l1KbMMW9Mcobk 2s6+byeIDyItyjgCkC58xd0YiK8pamcDf+UI19fkAtf09oJmr14pittbE6f3rK4pqRWZ 3WkBcebWEJyAaztFyLqphCYnRzp7ww9Rt9C7KtwNbsU+gujsQkLQ84odRpnFum6cLmBD nECtX0a17koHvS55m3nsYoqDQjibk+kUMFmdjEgGXY7eDaeGq5NFdHHDvnPayOQvR7Zg dI3A== 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=PXbxDLQ5qzFahsfuQdQd2/oh6y0N5sQbqIGCA/JCZcI=; b=UEVpTEnJGv+YpAX7bthSq7u5P0qOmaVnXQCaB9dddLofnI2Lcs8cUeE/Kx7eNaE1RF CSC/48+NBevUhySJ+yS+/lYvfA1W9VY/qBNpaZyG+dRSZcI7DCYDTSg4QCX8+7+SgHxO QmUqKWiVtHmlNs7FwvfX5MOTRFihgwS/7aetIS9D78Tll+1EzfZc9Gq/e5k3NmnyRfWE Tz24BiDWHuACgiibWFLYxsLpdA7fIhbNJ/kPaqUDvvtZ1gx6+yq9DyypV2tjl5Ye6dI8 XM3b2UXKltLS1bik9Oem4KvcQDopUOinink6ZltmiXpurj8LXeQjSG0p4EeEvL3GQKpi VjWA== X-Gm-Message-State: AOAM533Dw+Tr34JKXaLpAbDEJoOwEYjPC25fQZ1I/AICj8ipWhVLkrFi jbWxq9H367nXPqPcXGq6yNtI2Q== X-Received: by 2002:a5d:9bc8:: with SMTP id d8mr680632ion.115.1615834179259; Mon, 15 Mar 2021 11:49:39 -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 a5sm8212162ilk.14.2021.03.15.11.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:49:38 -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 v5 6/6] net: qualcomm: rmnet: don't use C bit-fields in rmnet checksum header Date: Mon, 15 Mar 2021 13:49:28 -0500 Message-Id: <20210315184928.2913264-7-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210315184928.2913264-1-elder@linaro.org> References: <20210315184928.2913264-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(-) iff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c ndex 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++; } -- 2.27.0 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_) */