Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: b53: Move Broadcom header setup to b53

The code to enable Broadcom tags/headers is largely switch independent,
and in preparation for enabling it for multiple devices with b53, move
the code we have in bcm_sf2.c to b53_common.c

Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Fainelli and committed by
David S. Miller
b409a9ef 5345862e

+57 -49
+47
drivers/net/dsa/b53/b53_common.c
··· 538 538 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), reg); 539 539 } 540 540 541 + void b53_brcm_hdr_setup(struct dsa_switch *ds, int port) 542 + { 543 + struct b53_device *dev = ds->priv; 544 + u8 hdr_ctl, val; 545 + u16 reg; 546 + 547 + /* Resolve which bit controls the Broadcom tag */ 548 + switch (port) { 549 + case 8: 550 + val = BRCM_HDR_P8_EN; 551 + break; 552 + case 7: 553 + val = BRCM_HDR_P7_EN; 554 + break; 555 + case 5: 556 + val = BRCM_HDR_P5_EN; 557 + break; 558 + default: 559 + val = 0; 560 + break; 561 + } 562 + 563 + /* Enable Broadcom tags for IMP port */ 564 + b53_read8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, &hdr_ctl); 565 + hdr_ctl |= val; 566 + b53_write8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, hdr_ctl); 567 + 568 + /* Registers below are only accessible on newer devices */ 569 + if (!is58xx(dev)) 570 + return; 571 + 572 + /* Enable reception Broadcom tag for CPU TX (switch RX) to 573 + * allow us to tag outgoing frames 574 + */ 575 + b53_read16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_RX_DIS, &reg); 576 + reg &= ~BIT(port); 577 + b53_write16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_RX_DIS, reg); 578 + 579 + /* Enable transmission of Broadcom tags from the switch (CPU RX) to 580 + * allow delivering frames to the per-port net_devices 581 + */ 582 + b53_read16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_TX_DIS, &reg); 583 + reg &= ~BIT(port); 584 + b53_write16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_TX_DIS, reg); 585 + } 586 + EXPORT_SYMBOL(b53_brcm_hdr_setup); 587 + 541 588 static void b53_enable_cpu_port(struct b53_device *dev, int port) 542 589 { 543 590 u8 port_ctrl;
+1
drivers/net/dsa/b53/b53_priv.h
··· 309 309 struct dsa_mall_mirror_tc_entry *mirror, bool ingress); 310 310 void b53_mirror_del(struct dsa_switch *ds, int port, 311 311 struct dsa_mall_mirror_tc_entry *mirror); 312 + void b53_brcm_hdr_setup(struct dsa_switch *ds, int port); 312 313 313 314 #endif
+7
drivers/net/dsa/b53/b53_regs.h
··· 210 210 #define B53_BRCM_HDR 0x03 211 211 #define BRCM_HDR_P8_EN BIT(0) /* Enable tagging on port 8 */ 212 212 #define BRCM_HDR_P5_EN BIT(1) /* Enable tagging on port 5 */ 213 + #define BRCM_HDR_P7_EN BIT(2) /* Enable tagging on port 7 */ 213 214 214 215 /* Mirror capture control register (16 bit) */ 215 216 #define B53_MIR_CAP_CTL 0x10 ··· 249 248 250 249 /* Revision ID register (8 bit) */ 251 250 #define B53_REV_ID 0x40 251 + 252 + /* Broadcom header RX control (16 bit) */ 253 + #define B53_BRCM_HDR_RX_DIS 0x60 254 + 255 + /* Broadcom header TX control (16 bit) */ 256 + #define B53_BRCM_HDR_TX_DIS 0x62 252 257 253 258 /************************************************************************* 254 259 * ARL Access Page Registers
+2 -41
drivers/net/dsa/bcm_sf2.c
··· 60 60 } 61 61 } 62 62 63 - static void bcm_sf2_brcm_hdr_setup(struct bcm_sf2_priv *priv, int port) 64 - { 65 - u32 reg, val; 66 - 67 - /* Resolve which bit controls the Broadcom tag */ 68 - switch (port) { 69 - case 8: 70 - val = BRCM_HDR_EN_P8; 71 - break; 72 - case 7: 73 - val = BRCM_HDR_EN_P7; 74 - break; 75 - case 5: 76 - val = BRCM_HDR_EN_P5; 77 - break; 78 - default: 79 - val = 0; 80 - break; 81 - } 82 - 83 - /* Enable Broadcom tags for IMP port */ 84 - reg = core_readl(priv, CORE_BRCM_HDR_CTRL); 85 - reg |= val; 86 - core_writel(priv, reg, CORE_BRCM_HDR_CTRL); 87 - 88 - /* Enable reception Broadcom tag for CPU TX (switch RX) to 89 - * allow us to tag outgoing frames 90 - */ 91 - reg = core_readl(priv, CORE_BRCM_HDR_RX_DIS); 92 - reg &= ~(1 << port); 93 - core_writel(priv, reg, CORE_BRCM_HDR_RX_DIS); 94 - 95 - /* Enable transmission of Broadcom tags from the switch (CPU RX) to 96 - * allow delivering frames to the per-port net_devices 97 - */ 98 - reg = core_readl(priv, CORE_BRCM_HDR_TX_DIS); 99 - reg &= ~(1 << port); 100 - core_writel(priv, reg, CORE_BRCM_HDR_TX_DIS); 101 - } 102 63 103 64 static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) 104 65 { ··· 99 138 reg |= i << (PRT_TO_QID_SHIFT * i); 100 139 core_writel(priv, reg, CORE_PORT_TC2_QOS_MAP_PORT(port)); 101 140 102 - bcm_sf2_brcm_hdr_setup(priv, port); 141 + b53_brcm_hdr_setup(ds, port); 103 142 104 143 /* Force link status for IMP port */ 105 144 reg = core_readl(priv, offset); ··· 208 247 209 248 /* Enable Broadcom tags for that port if requested */ 210 249 if (priv->brcm_tag_mask & BIT(port)) 211 - bcm_sf2_brcm_hdr_setup(priv, port); 250 + b53_brcm_hdr_setup(ds, port); 212 251 213 252 /* Configure Traffic Class to QoS mapping, allow each priority to map 214 253 * to a different queue number
-8
drivers/net/dsa/bcm_sf2_regs.h
··· 205 205 206 206 #define CORE_IMP0_PRT_ID 0x0804 207 207 208 - #define CORE_BRCM_HDR_CTRL 0x0080c 209 - #define BRCM_HDR_EN_P8 (1 << 0) 210 - #define BRCM_HDR_EN_P5 (1 << 1) 211 - #define BRCM_HDR_EN_P7 (1 << 2) 212 - 213 208 #define CORE_RST_MIB_CNT_EN 0x0950 214 - 215 - #define CORE_BRCM_HDR_RX_DIS 0x0980 216 - #define CORE_BRCM_HDR_TX_DIS 0x0988 217 209 218 210 #define CORE_ARLA_VTBL_RWCTRL 0x1600 219 211 #define ARLA_VTBL_CMD_WRITE 0