Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac7a04c3 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller
Browse files

net: dsa: change tag_protocol to an enum



Now that we introduced an additional multiplexing/demultiplexing layer
with commit 3e8a72d1 ("net: dsa: reduce number of protocol hooks")
that lives within the DSA code, we no longer need to have a given switch
driver tag_protocol be an actual ethertype value, instead, we can
replace it with an enum: dsa_tag_protocol.

Do this replacement in the drivers, which allows us to get rid of the
cpu_to_be16()/htons() dance, and remove ETH_P_BRCMTAG since we do not
need it anymore.

Suggested-by: default avatarAlexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5554298
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -592,7 +592,7 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
}

static struct dsa_switch_driver bcm_sf2_switch_driver = {
	.tag_protocol		= htons(ETH_P_BRCMTAG),
	.tag_protocol		= DSA_TAG_PROTO_BRCM,
	.priv_size		= sizeof(struct bcm_sf2_priv),
	.probe			= bcm_sf2_sw_probe,
	.setup			= bcm_sf2_sw_setup,
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ static void mv88e6060_poll_link(struct dsa_switch *ds)
}

static struct dsa_switch_driver mv88e6060_switch_driver = {
	.tag_protocol	= htons(ETH_P_TRAILER),
	.tag_protocol	= DSA_TAG_PROTO_TRAILER,
	.probe		= mv88e6060_probe,
	.setup		= mv88e6060_setup,
	.set_addr	= mv88e6060_set_addr,
+2 −2
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ static int mv88e6123_61_65_setup_port(struct dsa_switch *ds, int p)
	 */
	val = 0x0433;
	if (dsa_is_cpu_port(ds, p)) {
		if (ds->dst->tag_protocol == htons(ETH_P_EDSA))
		if (ds->dst->tag_protocol == DSA_TAG_PROTO_EDSA)
			val |= 0x3300;
		else
			val |= 0x0100;
@@ -391,7 +391,7 @@ static int mv88e6123_61_65_get_sset_count(struct dsa_switch *ds)
}

struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
	.tag_protocol		= cpu_to_be16(ETH_P_EDSA),
	.tag_protocol		= DSA_TAG_PROTO_EDSA,
	.priv_size		= sizeof(struct mv88e6xxx_priv_state),
	.probe			= mv88e6123_61_65_probe,
	.setup			= mv88e6123_61_65_setup,
+1 −1
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ static int mv88e6131_get_sset_count(struct dsa_switch *ds)
}

struct dsa_switch_driver mv88e6131_switch_driver = {
	.tag_protocol		= cpu_to_be16(ETH_P_DSA),
	.tag_protocol		= DSA_TAG_PROTO_DSA,
	.priv_size		= sizeof(struct mv88e6xxx_priv_state),
	.probe			= mv88e6131_probe,
	.setup			= mv88e6131_setup,
+10 −7
Original line number Diff line number Diff line
@@ -19,10 +19,13 @@
#include <linux/phy.h>
#include <linux/phy_fixed.h>

/* Not an official ethertype value, used only internally for DSA
 * demultiplexing
 */
#define ETH_P_BRCMTAG		(ETH_P_XDSA + 1)
enum dsa_tag_protocol {
	DSA_TAG_PROTO_NONE = 0,
	DSA_TAG_PROTO_DSA,
	DSA_TAG_PROTO_TRAILER,
	DSA_TAG_PROTO_EDSA,
	DSA_TAG_PROTO_BRCM,
};

#define DSA_MAX_SWITCHES	4
#define DSA_MAX_PORTS		12
@@ -89,7 +92,7 @@ struct dsa_switch_tree {
	 */
	struct net_device	*master_netdev;
	const struct dsa_device_ops	*ops;
	__be16			tag_protocol;
	enum dsa_tag_protocol	tag_protocol;

	/*
	 * The switch and port to which the CPU is attached.
@@ -166,7 +169,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
struct dsa_switch_driver {
	struct list_head	list;

	__be16			tag_protocol;
	enum dsa_tag_protocol	tag_protocol;
	int			priv_size;

	/*
@@ -215,7 +218,7 @@ static inline void *ds_to_priv(struct dsa_switch *ds)

static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
{
	return dst->tag_protocol != 0;
	return dst->tag_protocol != DSA_TAG_PROTO_NONE;
}

#endif
Loading