From patchwork Mon May 20 13:53:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 164649 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp281639oca; Mon, 20 May 2019 06:54:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvo8XtkjHoEsXwM66AqWloIAGIMpAjMQN8v0WXzZQmTEhI7GWpl0cgtUIoi59I5jbHpqEZ X-Received: by 2002:a17:902:8609:: with SMTP id f9mr19436790plo.252.1558360466867; Mon, 20 May 2019 06:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558360466; cv=none; d=google.com; s=arc-20160816; b=x1q7BSEcqApY22ZXplF7/IJI/W/mQlEg0tnr7LZK1LhbXV6rt9r/elPhAKREeM8rfH OVvDVFaN2Dx+xvVLQSQcpX4j1+jvWqSqvidzY3/815s/Do2ivaaWQFRQZl7XlQ1V/s/H gkGuP0bxPh2TTEGhZQssn70a5rJQsBsmxwbvq0EQ4IPwg6lITJO7h9RiSMvMkgjxYi7M ytNZirsdUUtpdWF7JtA23M4ULPeh6g2LzauCf3j0vhHbDltL7WmkPTOnK6dz/lBkii1w aDgyD76v83h/O/WnW4uBPDxb6Bsr2H6Geor6G/vT0mUJHcbjAWq53Np3CfDvfN9RJtLF /VRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=njKYp+14ITtVWnHaTIS/znCm9EIrcpgkV5g8TLL3fv0=; b=aHUn4CdTjQPF1ffkGNyOWO+kIguAXb5vvYgU2Q5BMEcRAKyLHUpz6YcUrA7STAhNxK nwKmHXqWtcUB7Qxuoq7tZeA8uzf9EqBllXoOVozrfQToLhjweZXnbUhc1Ko/AzMPH+Oh e8IC1yGBrBJxOJLq96cc4FkluUGVJVvJRtn+65ivUkEfHd1Ff1DQoIzVwKvr6dOVaft4 twBTMhZs0CWl8diHtxZgqv/0Cya5J+vYonuxNop5FtKxIb05aVfaDnWQL4o39h15/NKX wzdrO0LYU6QvkBkW2gTkP2tHA6yzD0MNbadcJWrrgpLMUy81UjQx3fiZ3fROCiARf+Fy vIzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P0r2Nz9M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id t25si3336589pgk.442.2019.05.20.06.54.26; Mon, 20 May 2019 06:54:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P0r2Nz9M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2390332AbfETNyI (ORCPT + 30 others); Mon, 20 May 2019 09:54:08 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:36366 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732409AbfETNyF (ORCPT ); Mon, 20 May 2019 09:54:05 -0400 Received: by mail-io1-f68.google.com with SMTP id e19so11097987iob.3 for ; Mon, 20 May 2019 06:54:04 -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=njKYp+14ITtVWnHaTIS/znCm9EIrcpgkV5g8TLL3fv0=; b=P0r2Nz9M5k5sdUMKG8tZN6/xXI3z2RMasXRwJ6C6IeCz245s8PRpWOVSujb7b9MgyZ J9/23EYY+ddUAUrMZfay1vIRvXEYHtG0hgkeSCVzvMevIlhSks1nyvB39qMm5SDJ1eGA BNG5V3yHIpt/nBHeGeT2bHxz/w8RAvaWxH4Tocn/u83KGX2u/CAyCKsAlG4UfjmeL0UE ebkV8fpgkCucrce5oUMX+XrHRZHReuOACoOcTTPouoyUp0MvZHd70Sxxhy9Hrocqf59x mYBWhTiIugfAAZMLNxxUDAJxJh3D0s0zOqlJNAX883i+rNwOr+FuGKKyonpz2Hu5Al+6 uJ8g== 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=njKYp+14ITtVWnHaTIS/znCm9EIrcpgkV5g8TLL3fv0=; b=L2/SVcJByH3E9TUApg7EKaHudiQ7FqwGciIO3QswaIcM5A17AsFTj4JJFbqcxEAQRP mlsGzYMbeq8gcGHHc5g11U/PHJPxd0t12qTxlvUsJJsVPOpYhevv+gHTDjPMIb/qg7qa 26ex+couPfstCr1xn2x654RhWS+3MDpLh2ve4Hekp3uyPnz8d5ug+nbS8krVCAUZwM3X 8NTKFcjzNXJI+t6j3WAW17sobxxTdX75U5qAwrptcO1RN0bq/s9S0XSEQo9QEji+90P4 zKvokjr7eqRcEjd0QrU13vFWdBsacdXNSTO9dSGlN2Wqt5WeHDC0cGBR4OwP2iPNX0zg 5hgQ== X-Gm-Message-State: APjAAAXRGVsWtURYZXikaFOhPF56x22VLkQGhg9AxQ6rC190t2Ebqg9A 9mBNxmENQ/DyrMlQI23Mg6/0dg== X-Received: by 2002:a5d:9687:: with SMTP id m7mr6337627ion.229.1558360444278; Mon, 20 May 2019 06:54:04 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id n17sm6581185ioa.0.2019.05.20.06.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:03 -0700 (PDT) From: Alex Elder To: arnd@arndb.de, subashab@codeaurora.org, david.brown@linaro.org, agross@kernel.org, davem@davemloft.net Cc: bjorn.andersson@linaro.org, ilias.apalodimas@linaro.org, cpratapa@codeaurora.org, syadagir@codeaurora.org, evgreen@chromium.org, benchan@google.com, ejcaruso@google.com, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] net: qualcomm: rmnet: use field masks instead of C bit-fields Date: Mon, 20 May 2019 08:53:49 -0500 Message-Id: <20190520135354.18628-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520135354.18628-1-elder@linaro.org> References: <20190520135354.18628-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using C bitfields (e.g. int foo : 3) is not portable. So stop using them for the command/data flag and the pad length fields in the rmnet_map structure. Instead, use the functions defined in along with field mask constants to extract or assign values within an integral structure member of a known size. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +++-- drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 8 +++++--- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Bjorn Andersson diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 4c1b62b72504..5fff6c78ecd5 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include @@ -70,7 +71,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, u16 len, pad; u8 mux_id; - if (map_header->cd_bit) { + if (u8_get_bits(map_header->cmd_pad_len, RMNET_MAP_CMD_FMASK)) { if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) return rmnet_map_command(skb, port); @@ -78,7 +79,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, } mux_id = map_header->mux_id; - pad = map_header->pad_len; + pad = u8_get_bits(map_header->cmd_pad_len, RMNET_MAP_PAD_LEN_FMASK); len = ntohs(map_header->pkt_len) - pad; if (mux_id >= RMNET_MAX_LOGICAL_EP) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index a30a7b405a11..a56209645c81 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -40,13 +40,15 @@ enum rmnet_map_commands { }; struct rmnet_map_header { - u8 cd_bit:1; - u8 reserved_bit:1; - u8 pad_len:6; + u8 cmd_pad_len; /* RMNET_MAP_* */ u8 mux_id; __be16 pkt_len; } __aligned(1); +#define RMNET_MAP_CMD_FMASK GENMASK(0, 0) /* 0: data; 1: cmd */ +#define RMNET_MAP_RESERVED_FMASK GENMASK(1, 1) +#define RMNET_MAP_PAD_LEN_FMASK GENMASK(7, 2) + struct rmnet_map_dl_csum_trailer { u8 reserved1; u8 valid:1; diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 498f20ba1826..10d2d582a9ce 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include @@ -301,7 +302,9 @@ 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 cmd field is 0 */ + map_header->cmd_pad_len = + u8_encode_bits(padding, RMNET_MAP_PAD_LEN_FMASK); return map_header; }