Skip to content

Commit cdb583c

Browse files
ffainellidavem330
authored andcommitted
net: dsa: b53: Have b53_hdr_setup() enable/disable tagging
Have b53_hdr_setup() check what kind of tagging protocol is configured (Broadcom or none) and apply the correct settings in both cases. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6683ed9 commit cdb583c

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎drivers/net/dsa/b53/b53_common.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ EXPORT_SYMBOL(b53_disable_port);
545545

546546
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
547547
{
548+
bool tag_en = !!(ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_BRCM);
548549
struct b53_device *dev = ds->priv;
549550
u8 hdr_ctl, val;
550551
u16 reg;
@@ -567,7 +568,10 @@ void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
567568

568569
/* Enable Broadcom tags for IMP port */
569570
b53_read8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, &hdr_ctl);
570-
hdr_ctl |= val;
571+
if (tag_en)
572+
hdr_ctl |= val;
573+
else
574+
hdr_ctl &= ~val;
571575
b53_write8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, hdr_ctl);
572576

573577
/* Registers below are only accessible on newer devices */
@@ -578,14 +582,20 @@ void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
578582
* allow us to tag outgoing frames
579583
*/
580584
b53_read16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_RX_DIS, &reg);
581-
reg &= ~BIT(port);
585+
if (tag_en)
586+
reg &= ~BIT(port);
587+
else
588+
reg |= BIT(port);
582589
b53_write16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_RX_DIS, reg);
583590

584591
/* Enable transmission of Broadcom tags from the switch (CPU RX) to
585592
* allow delivering frames to the per-port net_devices
586593
*/
587594
b53_read16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_TX_DIS, &reg);
588-
reg &= ~BIT(port);
595+
if (tag_en)
596+
reg &= ~BIT(port);
597+
else
598+
reg |= BIT(port);
589599
b53_write16(dev, B53_MGMT_PAGE, B53_BRCM_HDR_TX_DIS, reg);
590600
}
591601
EXPORT_SYMBOL(b53_brcm_hdr_setup);

0 commit comments

Comments
 (0)