From patchwork Mon May 20 13:53:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 164644 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp281310oca; Mon, 20 May 2019 06:54:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2P2o1pTs8fYqvXcCv0RMw7414sSb+iTS9CMp6m7eL2gFvcqsx7qIkiqBQR1tKJWdTsvva X-Received: by 2002:a63:144e:: with SMTP id 14mr58151996pgu.304.1558360447656; Mon, 20 May 2019 06:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558360447; cv=none; d=google.com; s=arc-20160816; b=AVQRUA7tfGhMipTCy0Vt795QxwJnGAHYOxy1MAeH5QEowGWtw9s/nzHT05YPLFF1HV ncn+ewSFZTlHVzkIPmunYE/IQtZNbpV6HO1aVQqc1Pm8RMcD37Jstr5sZOxhcnetLIvK 83qs9mSs6rLp4vuEV2PnhF+CEHbiAwUneVlG08T/MbF2YA14BCsosxN5ZBbL/IfkL6R0 xSV8+K5s2VhIh46uuCp4lJ1IC6XOWPdRQpVNnqdP9pOGHiICDor/ovDDATzoG95G4NX+ oo/XB0910htQ8DRBzZrypt/swJL/3eyYWynaXbzkDatH39lmnFnurvUW5pG8eDZRwHAY yTSA== 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=4j5LbYhgEMKnY68snBvOCpO79qdUQ+grRP4+9IrOwhs=; b=0eOc3HGl6es3hA+GEl0Fr630NihSBaBAXuQ+QV1NRNZYcPbhlASflYPT15BjaMkl8x 8RkC4XOx2PA2+9EEFpX9uG3JMNcG/ZhYvI6vHyg9T+KIFrVMjbw8neq8HiF489VmV7LH UJSqdLhpFBiAkTMPLWAgfLBbgd5cQcFftTjLu3ltR+HjhdIS3hMVrCwQbeSt6UKeUsEE m2UyM0ANb9eHuxotIaWyhDqw0Gy2wk+eiAqNXLoCAeThWDeksuOf6ISrxDpoJAYDcJDJ +hB/SoBJzBU8co9Dy6OYRuPKV0KFNidTO6NxtC6jeRrSuhxy+xVYkpHv0hP9mJEHQcSJ D0Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p86wF9vs; 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 j1si1105703pfn.53.2019.05.20.06.54.07; Mon, 20 May 2019 06:54:07 -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=p86wF9vs; 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 S2390231AbfETNyG (ORCPT + 30 others); Mon, 20 May 2019 09:54:06 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:53809 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732373AbfETNyE (ORCPT ); Mon, 20 May 2019 09:54:04 -0400 Received: by mail-it1-f195.google.com with SMTP id m141so22997465ita.3 for ; Mon, 20 May 2019 06:54:03 -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=4j5LbYhgEMKnY68snBvOCpO79qdUQ+grRP4+9IrOwhs=; b=p86wF9vsShGKGUgixYkUTORMJxa4rHW8U2B8qe/L6lGwMHVSshSA9L2RRaEQBaHvZi ejV3/fM3HNBKSSWv+Ki6tTqzJrnhofs6FhgExBGRcZo3BD+SXMcVI+WgNHqS/ARLUPpY hnO5czpCXSRF+n0UhF3HpujxNSyWSsBh7GMgty+rt/DhYaKhr1+7BdvQpvxt4aq+Ugzz qmlxC+BZx7MF38y12539vx3VgvKw4akmUQbOuLNVJdFoCQZqZSL07hCyqGaqiNtJugED ChsacW8CFWky8cw8nlUE6wTa83sINciLuwhiHQdc9+eqwQ486sljn2APog+b4xx8DmID Dkfg== 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=4j5LbYhgEMKnY68snBvOCpO79qdUQ+grRP4+9IrOwhs=; b=Lv4O45APrVfIybK1zQe/NItlFJGzeQDq1yZQYeafwk+h2BVkxhbjvmY8ihu5dVuZ8G h7sTPmIHyZPKY7QNxtTRSRm1HfsYThxwZn3zyDooryRve0eBQO0gseJw7dvZ9vKLsTam Q4D9EEIv2toPwDEIZjdcBAp6QWNY/tYmGjhfLSAtS7QEoa5tZaDm+lWMRbyerJuyGYy9 5EaL8KwhBIF7o1vPwIfymWEixKy8mSzxt8U3IDu7EUERivecVy9ATn1vWI1gUdj6XBPK O15nqcQomdfQjENgnPhGQOEMDMGFlp60jDOAewTYGg87HPgHVUb8R6az1LXq63pdsA1M 7nUA== X-Gm-Message-State: APjAAAWQy9cd1VdwrN8Rsp5j1dx77tXN/bMO451YBgFa3oKS50AehM8S tZYtq0gF6gmBi/gL+R3kdECvgA== X-Received: by 2002:a24:218a:: with SMTP id e132mr1015517ita.77.1558360443143; Mon, 20 May 2019 06:54:03 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:02 -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 2/8] net: qualcomm: rmnet: kill RMNET_MAP_GET_*() accessor macros Date: Mon, 20 May 2019 08:53:48 -0500 Message-Id: <20190520135354.18628-3-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 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. Use the network byte order macros (e.g., ntohs()), not the Linux byte order functions (e.g. be_to_cpu16()) to convert the big-endian packet length field, to match the convention used elswhere in the driver. There's no need to byte swap 0; it's all zeros irrespective of endianness. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 9 +++++---- 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, 15 insertions(+), 21 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 11167abe5934..4c1b62b72504 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -65,20 +65,21 @@ 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) { 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 b1ae9499c0b2..a30a7b405a11 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -63,18 +63,6 @@ struct rmnet_map_ul_csum_header { u16 csum_enabled:1; } __aligned(1); -#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 f6cf59aee212..f675f47c3495 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c @@ -20,12 +20,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); @@ -57,6 +58,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; @@ -66,7 +68,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 header */ + cmd = (struct rmnet_map_control_command *)(map_header + 1); cmd->cmd_type = type & 0x03; netif_tx_lock(dev); @@ -79,11 +82,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 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 57a9c314a665..498f20ba1826 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -323,7 +323,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); @@ -332,7 +332,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 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; } From patchwork Mon May 20 13:53:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 164645 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp281370oca; Mon, 20 May 2019 06:54:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0yOAV3lN6BRKm5/pdNBsXYCjpLdSksbegSv++AE3zWqyQ9frAV5o9jCoCuUHSQUeWkRS6 X-Received: by 2002:a17:902:b58a:: with SMTP id a10mr46242940pls.83.1558360451622; Mon, 20 May 2019 06:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558360451; cv=none; d=google.com; s=arc-20160816; b=iviOLzSsTTX5cSVBxpsVGyk7dtxFWJWcVO7dcS4XlgHERIV78njZr+ngjePQC+9DvO pMv0TRvlv+zTopeUJuh7ayQRGEhdDWdk6R+ylspK413yzxKtDPtJ3RLyzcu3jU4iNdID 7v/0MjNGF6fYJdciYq6OispGhqL42cTDa4P15iNFPog+eIUSNV35jSctN3ilw0mc8FJ4 zLuD4ak3/o1hGnkKeaQqSb0KwoVoYRGc20zzclb18+H8Mr6v5xi5XADklML0bL3p+4fI H4W0qCcHzpH3RpyofE/EHhw09gAw3oCR0FabLbB/J6Cox1fnTNyNbWVesYmTpWRJLosU 0jvg== 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=R+Jpk+XthHVG0qFI+gAyJW+786CYrgpLqGw1dG639sc=; b=cHVNvmI+dACVzt4by250nD6pyWNlTErt5hXaRUmn2XgWooxOO/+2VGir4WjE2z8YJy K6nC5lYAZ8duP059zexTQPO/27WlE9+cOrW+pqElBL7hBYKrz/MYVcF1XsQTeRR2HFwW /xA//xMKc4zZJpqSVHBpIFeWkhJm125n1j/en1AVDMv/VP42k6erQeaPCcryiGFZ3sfR yWXpsjr4PhAQ1ul0ldYCz9sdNTaHqXBvuJ3yF5lAddknXFWcQ2PSRiVUM3tk7Svpm3S3 V3+fSqLwSbeVmGxppRbhcuoRxTbI2Ro9cmguN0aqT94O6Q12iMd+HtdMak+7BzNlSndi QfnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUlwrKA6; 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 ay3si16687640plb.298.2019.05.20.06.54.11; Mon, 20 May 2019 06:54:11 -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=kUlwrKA6; 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 S2390393AbfETNyK (ORCPT + 30 others); Mon, 20 May 2019 09:54:10 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:44800 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390239AbfETNyH (ORCPT ); Mon, 20 May 2019 09:54:07 -0400 Received: by mail-io1-f65.google.com with SMTP id f22so11033133iol.11 for ; Mon, 20 May 2019 06:54:06 -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=R+Jpk+XthHVG0qFI+gAyJW+786CYrgpLqGw1dG639sc=; b=kUlwrKA6Jg9T6clWLPJgeGUuaE9PZk89mqOd9MnvQdrLTvEBvGPK+iniaIoOUfuyIn QXoEpsQP3UrMYBN3jNm4JMiGQwiLHjLiNqoSubqfzcWS9J3nMo+Hq8ev5PXyG69DjXHV fcIxJ3nHRXB+WfFuhNsCaJL9aSPf0Y5+wQgDHH6x1REzX40cC8jtntFcuHXQBst6HXIF VDgfxkjCCr4/AKfVplJelzBYtiIe0RoYpR9mfu99YYKNYe5yJMuUIkEaZC6dft8Z3as9 urvLde/3DeJRDV2EZz67QkJ6chBk0YkJGVMrr0UIEB3gNKwPmIuzAloPUTyWXsOgD/2k U3qg== 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=R+Jpk+XthHVG0qFI+gAyJW+786CYrgpLqGw1dG639sc=; b=UUnUqOg0vhUu/cnZmaRtacYnaZhPfSTTURJa7F5fw55JVLS25cMaAu45z5w7EIs02x EPNBUoO4dp/HFU6aAvf0dJArMlep2Mta9cJI7lFu8Kweqef6ONbz2IHW2d61LU+p8wTH xSyemC45jQPufqfVzdI4dbT4eJfRKbGjiVzTmBm016uCO00W32MrnFkkR32abkQZN8HO o+qfEip5K1Z88/ArBFMLs9zf2alCaVYje3dhvRsFe2lbtwALIsmdiL4qtGQl2KXGosur A12L1HV2Nn8K1dQlLBmlZPMTvgE9c7ecJbwP4PJ+7jk4WStrd+c50b8EzQ4mvSqLKkj+ W6OA== X-Gm-Message-State: APjAAAWDfbvOPFojqS2qcRcgCEh3Yu/BxCwv3rkGHOMukFtOayvhWJr4 MhaYfyNOf94KQUDw++f3Eqlxfg== X-Received: by 2002:a5e:a71a:: with SMTP id b26mr12962200iod.95.1558360446575; Mon, 20 May 2019 06:54:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:06 -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 5/8] net: qualcomm: rmnet: don't use C bit-fields in rmnet checksum trailer Date: Mon, 20 May 2019 08:53:51 -0500 Message-Id: <20190520135354.18628-6-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 Replace the use of C bit-fields in the rmnet_map_dl_csum_trailer structure with a single integral field, using field masks to encode or get at sub-field values. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 6 ++++-- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index f3231c26badd..fb1cdb4ec41f 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -51,13 +51,15 @@ struct rmnet_map_header { struct rmnet_map_dl_csum_trailer { u8 reserved1; - u8 valid:1; - u8 reserved2:7; + u8 flags; /* RMNET_MAP_DL_* */ u16 csum_start_offset; u16 csum_length; __be16 csum_value; } __aligned(1); +#define RMNET_MAP_DL_CSUM_VALID_FMASK GENMASK(0, 0) +#define RMNET_MAP_DL_RESERVED_FMASK GENMASK(7, 1) + struct rmnet_map_ul_csum_header { __be16 csum_start_offset; __be16 csum_info; /* RMNET_MAP_UL_* */ diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 72b64114505a..a95111cdcd29 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -362,7 +362,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 (!u8_get_bits(csum_trailer->flags, RMNET_MAP_DL_CSUM_VALID_FMASK)) { priv->stats.csum_valid_unset++; return -EINVAL; } From patchwork Mon May 20 13:53:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 164646 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp281402oca; Mon, 20 May 2019 06:54:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYSREyY7/iIFUb9d4HBmqht4lI8neh9hPudrGr1NRUnsYSP9LHZnvVwhK+rveyVhkRc++9 X-Received: by 2002:a62:5581:: with SMTP id j123mr81106492pfb.102.1558360452856; Mon, 20 May 2019 06:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558360452; cv=none; d=google.com; s=arc-20160816; b=ET+Bzp7XGdhu9GAqXWjiUPNRY7/Q+Y2oHH4imc8lioc+7ksEc58D8t+i1UvewjSVaw C2jBid9LVJ8Jvkb2sQ5AEPSW7LSEWPrAiJWyVGpSMecnEozVhn0y/tW80yYjATxjpLHF GGnFfQFLCbwc03mh9nISB+k5MIDHbImSsVlGmThFxfFNxgq+1Z6v1oAcLgkWbSF2fBzi eRJX1U6CP6qz/sXVYesv9d+/7jPQu4fcqCehLLwaBnUgnRyhSRhMEmwB4LnwM03FmS1v /zzcvu7zOUWehXFkpLx3x4UVeiWKUlqpF1ohOn6NbeBpVcaQ1OgCOgsNkRwSd7bDzVha Fbfw== 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=KapGiunwwx5p5z/8cIELmJy7chJVMEDGUUi3pAZirR8=; b=u681La0DKur8VknwwjlaGjwFIsSTW29edbEyDUcJpPPsx4zao3n0Duom/XD/SpPe7N l5YFcTF0ePCPamRDGn0NWmhnrMUkYYi2y0APTnI7IO1thGTlEuLrlP630JRkUqAwBAVU OOhELAxvkVjx6PKxqsMqgTCqaHpzffD3OgojfEVeaFiH5kJEsLNnxztE39n9/zMAs7wZ 4fcmCQkCOr/jVPJdJGkoCJcWOnSf3SyMXIOLTVY2IPzHIfKomPAIsl2UmzG0G5v+EoSt b601t9kRNUAXjeummnLP1fVfoDecskIA6+MBj89oZuwzl1flnxjpIrF1/ZYhAdvjQ0zX XETQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yzkpmxk6; 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 ay3si16687640plb.298.2019.05.20.06.54.12; Mon, 20 May 2019 06:54:12 -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=yzkpmxk6; 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 S2390466AbfETNyM (ORCPT + 30 others); Mon, 20 May 2019 09:54:12 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:33969 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390358AbfETNyJ (ORCPT ); Mon, 20 May 2019 09:54:09 -0400 Received: by mail-io1-f65.google.com with SMTP id g84so11097473ioa.1 for ; Mon, 20 May 2019 06:54:09 -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=KapGiunwwx5p5z/8cIELmJy7chJVMEDGUUi3pAZirR8=; b=yzkpmxk6Ixt7Vl80qvoHTPb21ID7tx7gUl5mLADJHRIA+mwJh+3RgoLGGk3FLTk54T YiScf7OxLAxGZZO9LC3+c8gtM0a7Ny2oW1diBfNo/KFgJgeeoC6QMtMvwqVezCPM64Mp Vqa2IRutPqE8aDKy5pSCg0SoCU7x3XEmR9EhpHbWBcQfO0t7f0HIZTkPOFFny9fs2ft/ SubZ6bAz3fd+WTZssKs0U/8XN4Bvy28hyjoIYHIsrx1TFdoJk2enr7kbvfSS3KDsuUkm SnglFiYSqw9p+9YZ7rokP3YXlNVR+BjVzrA4BlMeUzKXro+jzAtArTeK6j2I5+Cf7jRR miAg== 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=KapGiunwwx5p5z/8cIELmJy7chJVMEDGUUi3pAZirR8=; b=Bo46zEf1H1ypuJyjm8zTj5c497GVd1gAA96BeJYAjf42R/k1JfAhNnU6+0CQMFjZ2c Ug3TTJ8YkW8HEezzBeAlap1XXTCUdO1oupIW99k4Knx+3UrItjwJ6cbb6Dx9SgJTD03a 0pbgoHvTWQCpKPULL9+nojz2Se/f4SOFDFaxv4NMRhCnerQKyo3mtq/a/WPQVKFPiU2p 1plosAoc7/LlVZuqlq2mve3DoYx+gUM/BJwBtWNKXzFQT/OxylH1lqHNlIbnXmby3AyO yvzesilUeo2LlN+DB8eW70/TDVCofvf7VAJ3st2F5dKx1uG7fjY5B04SRoNoKdEXuwwK fm8g== X-Gm-Message-State: APjAAAXnJ1bjr8hwXxbqt7qRstl8akmSgsuiQZyz33YSAfIuVxnjwM6t C2W4qhbmqjs7Gk+UFt0zpYnYqw== X-Received: by 2002:a6b:f404:: with SMTP id i4mr7597663iog.251.1558360449000; Mon, 20 May 2019 06:54:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:08 -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 7/8] net: qualcomm: rmnet: mark endianness of struct rmnet_map_dl_csum_trailer fields Date: Mon, 20 May 2019 08:53:53 -0500 Message-Id: <20190520135354.18628-8-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 Two 16-bit fields (csum_start_offset and csum_length) in the rmnet_map_dl_csum_trailer structure are currently defined to have type u16. But they are in fact big endian values, so should be properly represented as __be16 values. No existing code actually references these fields (they're ignored by rmnet_map_ipv4_dl_csum_trailer() and rmnet_map_ipv6_dl_csum_trailer()). Changing their type therefore causes no harm, so just fix them. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Bjorn Andersson diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index fb1cdb4ec41f..775b98d34e94 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -52,8 +52,8 @@ struct rmnet_map_header { struct rmnet_map_dl_csum_trailer { u8 reserved1; u8 flags; /* RMNET_MAP_DL_* */ - u16 csum_start_offset; - u16 csum_length; + __be16 csum_start_offset; + __be16 csum_length; __be16 csum_value; } __aligned(1); From patchwork Mon May 20 13:53:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 164647 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp281481oca; Mon, 20 May 2019 06:54:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEeWEg6gyfMeWYrrNTfb+UZ+T66IrIoQRXcODAFUXdbAKBgWAK0dyxlAUas2BIQam8Oh8c X-Received: by 2002:a17:902:a415:: with SMTP id p21mr62444280plq.286.1558360456632; Mon, 20 May 2019 06:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558360456; cv=none; d=google.com; s=arc-20160816; b=vA/9ucup9Q9uJgQoO+7uNjUDvkBOz5A82s69pZt6aAIjKDbob7UnkFqcGU9XXUZ6hG gNHAVcHxg28Gz9zRiIR4QymGyBTXFuG6PNG7+BE8cT/jxjqSp47OHBJGcabgBZzI8grd MbMw0nGs8JyzP9cHatUNCQrRrc2eazQwCyUv0KBieEy7D8s9mtxvKB3rzEnoS3gEeMKD JbX0KqZWXN38LHudvDwmfG0eVWNanX1DimdswKR0Xtpstkw8wZP4neGiOzXMXdnmDtYd lW0+k/pFdOTy4AS+vxtO5JzcfznPa1DtlWwOGbZ44kGSRbosp6J/FSMQ80bDs7UY9zox 894g== 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=qTfgXH2ZXOT0rZW+kdJ3acNhah3zg+9vblvPOMdBQ14=; b=rkJFDDZkvYwPgmaZaUMI47EsWcjV0kduEbhosTRsXmK0WgpyXqzxhyilpyO4GSLWGG RRpiCQbgBJwQfuqyWtcN4ekNcIE1cVUzhOCQImRWMtKS+I3r0MIFVWYX0Pw9kCPAaIwj rED2zzcLpZ5oNp/Y71cjwr72uU1k/StQxL5fMgkA0bIl54gFvcztETePPs0YYUK/4hM4 2VYHrtTHhANLquPrSbW/6XYwmUDLnxB7dFXNi3YXPzSMvu9z7QGEj/Jfv9lN2I7SIy3z DlAUUhquWUSjvanbxcv8hubmsn3c6lZOcwtX5tPWg6rE7LeSno/Ep2Xr6sSKVD/9Qf8m xW6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v3cHBs+J; 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.16; Mon, 20 May 2019 06:54:16 -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=v3cHBs+J; 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 S2390517AbfETNyO (ORCPT + 30 others); Mon, 20 May 2019 09:54:14 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:35422 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390399AbfETNyL (ORCPT ); Mon, 20 May 2019 09:54:11 -0400 Received: by mail-io1-f67.google.com with SMTP id p2so11101574iol.2 for ; Mon, 20 May 2019 06:54:10 -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=qTfgXH2ZXOT0rZW+kdJ3acNhah3zg+9vblvPOMdBQ14=; b=v3cHBs+JVLGbaW7f+X68Q7SNESSu2ea1qt0XE5rwqRRjB1H+pvrtWDxfUH0AEFsQJq +l0yHFwkErTYtnhtH/d87kocoecxvwNEuzEn3ZgwG54OEKQbv0vupQIsVRPhY7yvwsrg Wepwos5OEehfTrvI6BJ3/HL98x9ItLBsiW4ABMW4s6cvh29x/nQal4rB5atykq3D+fXq o2pcQA2VJz1bqrOD16+M33W2hVMyjFGHKcFIAqkJWBAVwu8iMyTEbfFoqlPUfckbLVWB VNrr2RSoVbQp421gKP4231PwDa78wGcYfQJlvT3qi89msxZU19CRvpv0TxKB6B20v7/K HE1A== 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=qTfgXH2ZXOT0rZW+kdJ3acNhah3zg+9vblvPOMdBQ14=; b=ZhCTdDgPfWm3LwQg8rHrFK1I7XS+Un0uWKyDX0AHgm2V7p1mblFxEmjoaJDUdrqERu grCBsRJ71s3DJlB6MsgTTy5ME0Vujbz4V6CKu/3ZhRl3qjVWtz/cRrVUlVuggPGRrRwO icoukVfiFhmOdXJ0BhsJeeZz4I1GE2TBmOgEwnmbd+dYdcGqjQR00kYiamShfiRukMum t/Y2n6gh/BTIVNazOjyC4lTmgTRiiIF+ZxFRPocrPNQ8xedYBvN+/emJIaXS4L9xZF8H OhHvUR3OE6o57Wt5VvPmHj/wTV9vN3eMXTLcUbS9MpDgQb3/aH4xIgYImPs/44Nfq2KX Rhhw== X-Gm-Message-State: APjAAAXooAOXwTiSvuv/bKD6ZJZOmb/tfEIJcV9UW6BloBIVQaSRQ+tM f/9SHzFe57kEpZJ2kV8jbDWBDA== X-Received: by 2002:a05:6602:2049:: with SMTP id z9mr14847619iod.46.1558360450147; Mon, 20 May 2019 06:54:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:09 -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 8/8] net: introduce "include/linux/if_rmnet.h" Date: Mon, 20 May 2019 08:53:54 -0500 Message-Id: <20190520135354.18628-9-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 The IPA driver requires some (but not all) symbols defined in "drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h". Create a new public header file "include/linux/if_rmnet.h" and move the needed definitions there. Signed-off-by: Alex Elder --- .../ethernet/qualcomm/rmnet/rmnet_handlers.c | 1 + .../net/ethernet/qualcomm/rmnet/rmnet_map.h | 31 ------------- .../qualcomm/rmnet/rmnet_map_command.c | 1 + .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 1 + .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 1 + include/linux/if_rmnet.h | 45 +++++++++++++++++++ 6 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 include/linux/if_rmnet.h -- 2.20.1 diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 5fff6c78ecd5..8e00e14f4ac9 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "rmnet_private.h" #include "rmnet_config.h" #include "rmnet_vnd.h" diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index 775b98d34e94..d101cabb04c3 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -39,37 +39,6 @@ enum rmnet_map_commands { RMNET_MAP_COMMAND_ENUM_LENGTH }; -struct rmnet_map_header { - 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 flags; /* RMNET_MAP_DL_* */ - __be16 csum_start_offset; - __be16 csum_length; - __be16 csum_value; -} __aligned(1); - -#define RMNET_MAP_DL_CSUM_VALID_FMASK GENMASK(0, 0) -#define RMNET_MAP_DL_RESERVED_FMASK GENMASK(7, 1) - -struct rmnet_map_ul_csum_header { - __be16 csum_start_offset; - __be16 csum_info; /* RMNET_MAP_UL_* */ -} __aligned(1); - -/* NOTE: These field masks are defined in CPU byte order */ -#define RMNET_MAP_UL_CSUM_INSERT_FMASK GENMASK(13, 0) -#define RMNET_MAP_UL_CSUM_UDP_FMASK GENMASK(14, 14) /* 0: IP; 1: UDP */ -#define RMNET_MAP_UL_CSUM_ENABLED_FMASK GENMASK(15, 15) - #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 f675f47c3495..6832c5939cae 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c @@ -11,6 +11,7 @@ */ #include +#include #include "rmnet_config.h" #include "rmnet_map.h" #include "rmnet_private.h" diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 61b7dbab2056..370aee7402e0 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "rmnet_config.h" #include "rmnet_map.h" #include "rmnet_private.h" diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c index d11c16aeb19a..6b39d4d8e523 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "rmnet_config.h" #include "rmnet_handlers.h" #include "rmnet_private.h" diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h new file mode 100644 index 000000000000..ae60472ecc79 --- /dev/null +++ b/include/linux/if_rmnet.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. + * Copyright (C) 2019 Linaro Ltd. + */ +#ifndef _LINUX_IF_RMNET_H_ +#define _LINUX_IF_RMNET_H_ + +#include + +/* Header structure that precedes packets in ETH_P_MAP protocol */ +struct rmnet_map_header { + 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) + +/* Checksum offload metadata header for outbound packets*/ +struct rmnet_map_ul_csum_header { + __be16 csum_start_offset; + __be16 csum_info; /* RMNET_MAP_UL_* */ +} __aligned(1); + +/* NOTE: These field masks are defined in CPU byte order */ +#define RMNET_MAP_UL_CSUM_INSERT_FMASK GENMASK(13, 0) +#define RMNET_MAP_UL_CSUM_UDP_FMASK GENMASK(14, 14) /* 0: IP; 1: UDP */ +#define RMNET_MAP_UL_CSUM_ENABLED_FMASK GENMASK(15, 15) + +/* Checksum offload metadata trailer for inbound packets */ +struct rmnet_map_dl_csum_trailer { + u8 reserved1; + u8 flags; /* RMNET_MAP_DL_* */ + __be16 csum_start_offset; + __be16 csum_length; + __be16 csum_value; +} __aligned(1); + +#define RMNET_MAP_DL_CSUM_VALID_FMASK GENMASK(0, 0) +#define RMNET_MAP_DL_RESERVED_FMASK GENMASK(7, 1) + +#endif /* _LINUX_IF_RMNET_H_ */