Commit 39cdd349 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: bcm_sf2: Use existing shift/masks

Instead of open coding the shift for the IP protocol, IP fragment bit
etc. define and/or use existing constants to that end.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 33ad61d0
...@@ -189,7 +189,8 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port, ...@@ -189,7 +189,8 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
* Reserved [1] * Reserved [1]
* UDF_Valid[8] [0] * 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)); CORE_CFP_DATA_PORT(6));
/* UDF_Valid[7:0] [31:24] /* UDF_Valid[7:0] [31:24]
...@@ -425,8 +426,8 @@ static int bcm_sf2_cfp_rule_get(struct bcm_sf2_priv *priv, int port, ...@@ -425,8 +426,8 @@ static int bcm_sf2_cfp_rule_get(struct bcm_sf2_priv *priv, int port,
return -EINVAL; return -EINVAL;
} }
v4_spec->tos = (reg >> 16) & IPPROTO_MASK; v4_spec->tos = (reg >> IPTOS_SHIFT) & IPTOS_MASK;
nfc->fs.m_ext.data[0] = cpu_to_be32((reg >> 7) & 1); nfc->fs.m_ext.data[0] = cpu_to_be32((reg >> IP_FRAG_SHIFT) & 1);
reg = core_readl(priv, CORE_CFP_DATA_PORT(3)); reg = core_readl(priv, CORE_CFP_DATA_PORT(3));
/* src port [15:8] */ /* src port [15:8] */
......
...@@ -302,9 +302,12 @@ enum bcm_sf2_reg_offs { ...@@ -302,9 +302,12 @@ enum bcm_sf2_reg_offs {
/* UDF_DATA7 */ /* UDF_DATA7 */
#define L3_FRAMING_SHIFT 24 #define L3_FRAMING_SHIFT 24
#define L3_FRAMING_MASK (0x3 << L3_FRAMING_SHIFT) #define L3_FRAMING_MASK (0x3 << L3_FRAMING_SHIFT)
#define IPTOS_SHIFT 16
#define IPTOS_MASK 0xff
#define IPPROTO_SHIFT 8 #define IPPROTO_SHIFT 8
#define IPPROTO_MASK (0xff << IPPROTO_SHIFT) #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 */ /* UDF_DATA0 */
#define SLICE_VALID 3 #define SLICE_VALID 3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment