Skip to content

Commit

Permalink
net: dsa: Support prepended Broadcom tag
Browse files Browse the repository at this point in the history
Add a new type: DSA_TAG_PROTO_PREPEND which allows us to support for the
4-bytes Broadcom tag that we already support, but in a format where it
is pre-pended to the packet instead of located between the MAC SA and
the Ethertyper (DSA_TAG_PROTO_BRCM).

Signed-off-by: Florian Fainelli <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ffainelli authored and davem330 committed Nov 13, 2017
1 parent f7c39e3 commit b74b70c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/net/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct fixed_phy_status;
enum dsa_tag_protocol {
DSA_TAG_PROTO_NONE = 0,
DSA_TAG_PROTO_BRCM,
DSA_TAG_PROTO_BRCM_PREPEND,
DSA_TAG_PROTO_DSA,
DSA_TAG_PROTO_EDSA,
DSA_TAG_PROTO_KSZ,
Expand Down
3 changes: 3 additions & 0 deletions net/dsa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if NET_DSA
config NET_DSA_TAG_BRCM
bool

config NET_DSA_TAG_BRCM_PREPEND
bool

config NET_DSA_TAG_DSA
bool

Expand Down
1 change: 1 addition & 0 deletions net/dsa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o

# tagging formats
dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
dsa_core-$(CONFIG_NET_DSA_TAG_BRCM_PREPEND) += tag_brcm.o
dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
dsa_core-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
Expand Down
3 changes: 3 additions & 0 deletions net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
#ifdef CONFIG_NET_DSA_TAG_BRCM
[DSA_TAG_PROTO_BRCM] = &brcm_netdev_ops,
#endif
#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
[DSA_TAG_PROTO_BRCM_PREPEND] = &brcm_prepend_netdev_ops,
#endif
#ifdef CONFIG_NET_DSA_TAG_DSA
[DSA_TAG_PROTO_DSA] = &dsa_netdev_ops,
#endif
Expand Down
1 change: 1 addition & 0 deletions net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void dsa_switch_unregister_notifier(struct dsa_switch *ds);

/* tag_brcm.c */
extern const struct dsa_device_ops brcm_netdev_ops;
extern const struct dsa_device_ops brcm_prepend_netdev_ops;

/* tag_dsa.c */
extern const struct dsa_device_ops dsa_netdev_ops;
Expand Down
39 changes: 32 additions & 7 deletions net/dsa/tag_brcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
return skb;
}

static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
struct net_device *dev)
{
/* Build the tag after the MAC Source Address */
return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
}

static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt,
Expand Down Expand Up @@ -139,6 +132,15 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
return skb;
}

#ifdef CONFIG_NET_DSA_TAG_BRCM
static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
struct net_device *dev)
{
/* Build the tag after the MAC Source Address */
return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
}


static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
Expand All @@ -161,3 +163,26 @@ const struct dsa_device_ops brcm_netdev_ops = {
.xmit = brcm_tag_xmit,
.rcv = brcm_tag_rcv,
};
#endif

#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb,
struct net_device *dev)
{
/* tag is prepended to the packet */
return brcm_tag_xmit_ll(skb, dev, 0);
}

static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt)
{
/* tag is prepended to the packet */
return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN);
}

const struct dsa_device_ops brcm_prepend_netdev_ops = {
.xmit = brcm_tag_xmit_prepend,
.rcv = brcm_tag_rcv_prepend,
};
#endif

0 comments on commit b74b70c

Please sign in to comment.