From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com,
davem@davemloft.net,
Florian Fainelli <florian.fainelli@broadcom.com>
Subject: [PATCH net-next 1/7] net: dsa: bcm_sf2: Use existing shift/masks
Date: Fri, 20 Oct 2017 14:34:48 -0700 [thread overview]
Message-ID: <20171020213454.14848-2-f.fainelli@gmail.com> (raw)
In-Reply-To: <20171020213454.14848-1-f.fainelli@gmail.com>
From: Florian Fainelli <florian.fainelli@broadcom.com>
Instead of open coding the shift for the IP protocol, IP fragment bit
etc. define and/or use existing constants to that end.
refs #SWLINUX-4608
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/dsa/bcm_sf2_cfp.c | 7 ++++---
drivers/net/dsa/bcm_sf2_regs.h | 5 ++++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
index 94649e1481ec..cef4b3d4df36 100644
--- a/drivers/net/dsa/bcm_sf2_cfp.c
+++ b/drivers/net/dsa/bcm_sf2_cfp.c
@@ -189,7 +189,8 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
* Reserved [1]
* UDF_Valid[8] [0]
*/
- core_writel(priv, v4_spec->tos << 16 | ip_proto << 8 | ip_frag << 7,
+ core_writel(priv, v4_spec->tos << IPTOS_SHIFT |
+ ip_proto << IPPROTO_SHIFT | ip_frag << IP_FRAG_SHIFT,
CORE_CFP_DATA_PORT(6));
/* UDF_Valid[7:0] [31:24]
@@ -425,8 +426,8 @@ static int bcm_sf2_cfp_rule_get(struct bcm_sf2_priv *priv, int port,
return -EINVAL;
}
- v4_spec->tos = (reg >> 16) & IPPROTO_MASK;
- nfc->fs.m_ext.data[0] = cpu_to_be32((reg >> 7) & 1);
+ v4_spec->tos = (reg >> IPTOS_SHIFT) & IPTOS_MASK;
+ nfc->fs.m_ext.data[0] = cpu_to_be32((reg >> IP_FRAG_SHIFT) & 1);
reg = core_readl(priv, CORE_CFP_DATA_PORT(3));
/* src port [15:8] */
diff --git a/drivers/net/dsa/bcm_sf2_regs.h b/drivers/net/dsa/bcm_sf2_regs.h
index d1596dfca323..61bc9729383f 100644
--- a/drivers/net/dsa/bcm_sf2_regs.h
+++ b/drivers/net/dsa/bcm_sf2_regs.h
@@ -302,9 +302,12 @@ enum bcm_sf2_reg_offs {
/* UDF_DATA7 */
#define L3_FRAMING_SHIFT 24
#define L3_FRAMING_MASK (0x3 << L3_FRAMING_SHIFT)
+#define IPTOS_SHIFT 16
+#define IPTOS_MASK 0xff
#define IPPROTO_SHIFT 8
#define IPPROTO_MASK (0xff << IPPROTO_SHIFT)
-#define IP_FRAG (1 << 7)
+#define IP_FRAG_SHIFT 7
+#define IP_FRAG (1 << IP_FRAG_SHIFT)
/* UDF_DATA0 */
#define SLICE_VALID 3
--
2.14.1
next prev parent reply other threads:[~2017-10-20 21:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 21:34 [PATCH net-next 0/7] net: dsa: bcm_sf2: Add support for IPv6 CFP rules Florian Fainelli
2017-10-20 21:34 ` Florian Fainelli [this message]
2017-10-20 21:34 ` [PATCH net-next 2/7] net: dsa: bcm_sf2: Move IPv4 CFP processing to specific functions Florian Fainelli
2017-10-20 21:34 ` [PATCH net-next 3/7] net: dsa: bcm_sf2: Make UDF slices more configurable Florian Fainelli
2017-10-20 21:34 ` [PATCH net-next 4/7] net: dsa: bcm_sf2: Simplify bcm_sf2_cfp_rule_get_all() Florian Fainelli
2017-10-20 21:34 ` [PATCH net-next 5/7] net: dsa: bcm_sf2: Add support for IPv6 CFP rules Florian Fainelli
2017-10-20 21:34 ` [PATCH net-next 6/7] net: dsa: bcm_sf2: Allow matching arbitrary IPv4 mask lengths Florian Fainelli
2017-10-20 21:34 ` [PATCH net-next 7/7] net: dsa: bcm_sf2: Allow matching arbitrary IPv6 masks/lengths Florian Fainelli
2017-10-20 21:35 ` [PATCH net-next 0/7] net: dsa: bcm_sf2: Add support for IPv6 CFP rules Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171020213454.14848-2-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=florian.fainelli@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).