From: Mathieu Olivari <mathieu@codeaurora.org>
To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
davem@davemloft.net, mathieu@codeaurora.org, andrew@lunn.ch,
f.fainelli@gmail.com, linux@roeck-us.net,
gang.chen.5i5j@gmail.com, jiri@resnulli.us, leitec@staticky.com,
fabf@skynet.be, alexander.h.duyck@intel.com,
pavel.nakonechny@skitlab.ru, joe@perches.com, sfeldma@gmail.com,
nbd@openwrt.org, juhosg@openwrt.org
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH 5/7] net: dsa: ar8xxx: enable QCA header support on AR8xxx
Date: Thu, 28 May 2015 18:42:20 -0700 [thread overview]
Message-ID: <1432863742-18427-6-git-send-email-mathieu@codeaurora.org> (raw)
In-Reply-To: <1432863742-18427-1-git-send-email-mathieu@codeaurora.org>
This change enable support for the QCA headers in QCA83337 driver.
A 2 bytes header will be added by the switch on every incoming packet
to identify the ingress port, and the DSA tagging code will add a
similar 2 bytes header to control which port is used to send a
particular packet.
Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
---
drivers/net/dsa/Kconfig | 1 +
drivers/net/dsa/ar8xxx.c | 28 ++++++++++++++++++++++++++--
drivers/net/dsa/ar8xxx.h | 22 ++++++++++++++++++++++
3 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 17fb296..fa8b484 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -68,6 +68,7 @@ config NET_DSA_BCM_SF2
config NET_DSA_AR8XXX
tristate "Qualcomm Atheros AR8XXX Ethernet switch family support"
depends on NET_DSA
+ select NET_DSA_TAG_QCA
select REGMAP
---help---
This enables support for the Qualcomm Atheros AR8XXX Ethernet
diff --git a/drivers/net/dsa/ar8xxx.c b/drivers/net/dsa/ar8xxx.c
index 327abd4..4044614 100644
--- a/drivers/net/dsa/ar8xxx.c
+++ b/drivers/net/dsa/ar8xxx.c
@@ -292,15 +292,31 @@ static int ar8xxx_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
+ /* Enable CPU Port */
+ ar8xxx_reg_set(ds, AR8327_REG_GLOBAL_FW_CTRL0,
+ AR8327_GLOBAL_FW_CTRL0_CPU_PORT_EN);
+
/* Enable MIB counters */
ar8xxx_reg_set(ds, AR8327_REG_MIB, AR8327_MIB_CPU_KEEP);
ar8xxx_write(ds, AR8327_REG_MODULE_EN, AR8327_MODULE_EN_MIB);
+ /* Enable QCA header mode on Port 0 */
+ ar8xxx_write(ds, AR8327_REG_PORT_HDR_CTRL(0),
+ AR8327_PORT_HDR_CTRL_ALL << AR8327_PORT_HDR_CTRL_TX_S |
+ AR8327_PORT_HDR_CTRL_ALL << AR8327_PORT_HDR_CTRL_RX_S);
+
/* Disable forwarding by default on all ports */
for (i = 0; i < AR8327_NUM_PORTS; i++)
ar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(i),
AR8327_PORT_LOOKUP_MEMBER, 0);
+ /* Forward all unknown frames to CPU port for Linux processing */
+ ar8xxx_write(ds, AR8327_REG_GLOBAL_FW_CTRL1,
+ BIT(0) << AR8327_GLOBAL_FW_CTRL1_IGMP_DP_S |
+ BIT(0) << AR8327_GLOBAL_FW_CTRL1_BC_DP_S |
+ BIT(0) << AR8327_GLOBAL_FW_CTRL1_MC_DP_S |
+ BIT(0) << AR8327_GLOBAL_FW_CTRL1_UC_DP_S);
+
/* Setup connection between CPU ports & PHYs */
for (i = 0; i < DSA_MAX_PORTS; i++) {
/* CPU port gets connected to all PHYs in the switch */
@@ -312,8 +328,16 @@ static int ar8xxx_setup(struct dsa_switch *ds)
/* Invividual PHYs gets connected to CPU port only */
if (ds->phys_port_mask & BIT(i)) {
- ar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(phy_to_port(i)),
+ int phy = phy_to_port(i);
+
+ ar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(phy),
AR8327_PORT_LOOKUP_MEMBER, BIT(0));
+
+ /* Disable Auto-learning by default so the switch
+ * doesn't try to forward the frame to another port
+ */
+ ar8xxx_reg_clear(ds, AR8327_PORT_LOOKUP_CTRL(phy),
+ AR8327_PORT_LOOKUP_LEARN);
}
}
@@ -423,7 +447,7 @@ static void ar8xxx_poll_link(struct dsa_switch *ds)
}
static struct dsa_switch_driver ar8xxx_switch_driver = {
- .tag_protocol = DSA_TAG_PROTO_NONE,
+ .tag_protocol = DSA_TAG_PROTO_QCA,
.priv_size = sizeof(struct ar8xxx_priv),
.probe = ar8xxx_probe,
.setup = ar8xxx_setup,
diff --git a/drivers/net/dsa/ar8xxx.h b/drivers/net/dsa/ar8xxx.h
index 98cc7ed..e68b92a 100644
--- a/drivers/net/dsa/ar8xxx.h
+++ b/drivers/net/dsa/ar8xxx.h
@@ -62,6 +62,28 @@ struct ar8xxx_mib_desc {
#define AR8XXX_PORT_STATUS_LINK_AUTO BIT(9)
#define AR8XXX_PORT_STATUS_LINK_PAUSE BIT(10)
+#define AR8327_REG_PORT_HDR_CTRL(_i) (0x9c + (_i * 4))
+#define AR8327_PORT_HDR_CTRL_RX_MASK GENMASK(3, 2)
+#define AR8327_PORT_HDR_CTRL_RX_S 2
+#define AR8327_PORT_HDR_CTRL_TX_MASK GENMASK(1, 0)
+#define AR8327_PORT_HDR_CTRL_TX_S 0
+#define AR8327_PORT_HDR_CTRL_ALL 2
+#define AR8327_PORT_HDR_CTRL_MGMT 1
+#define AR8327_PORT_HDR_CTRL_NONE 0
+
+#define AR8327_REG_GLOBAL_FW_CTRL0 0x620
+#define AR8327_GLOBAL_FW_CTRL0_CPU_PORT_EN BIT(10)
+
+#define AR8327_REG_GLOBAL_FW_CTRL1 0x624
+#define AR8327_GLOBAL_FW_CTRL1_IGMP_DP_MASK GENMASK(30, 24)
+#define AR8327_GLOBAL_FW_CTRL1_IGMP_DP_S 24
+#define AR8327_GLOBAL_FW_CTRL1_BC_DP_MASK GENMASK(22, 16)
+#define AR8327_GLOBAL_FW_CTRL1_BC_DP_S 16
+#define AR8327_GLOBAL_FW_CTRL1_MC_DP_MASK GENMASK(14, 8)
+#define AR8327_GLOBAL_FW_CTRL1_MC_DP_S 8
+#define AR8327_GLOBAL_FW_CTRL1_UC_DP_MASK GENMASK(6, 0)
+#define AR8327_GLOBAL_FW_CTRL1_UC_DP_S 0
+
#define AR8327_PORT_LOOKUP_CTRL(_i) (0x660 + (_i) * 0xc)
#define AR8327_PORT_LOOKUP_MEMBER GENMASK(6, 0)
#define AR8327_PORT_LOOKUP_IN_MODE GENMASK(9, 8)
--
2.1.4
next prev parent reply other threads:[~2015-05-29 1:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 1:42 [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support Mathieu Olivari
2015-05-29 1:42 ` [PATCH 1/7] net: dsa: add new driver for ar8xxx family Mathieu Olivari
2015-05-29 2:08 ` Andrew Lunn
2015-06-01 8:14 ` Paul Bolle
2015-05-29 1:42 ` [PATCH 2/7] net: dsa: ar8xxx: add ethtool hw statistics support Mathieu Olivari
2015-05-29 1:42 ` [PATCH 3/7] net: dsa: ar8xxx: add regmap support Mathieu Olivari
2015-05-29 1:58 ` Florian Fainelli
2015-05-29 2:23 ` Andrew Lunn
2015-05-29 2:36 ` Florian Fainelli
2015-05-29 2:44 ` Andrew Lunn
2015-05-29 17:36 ` Mathieu Olivari
2015-05-29 17:59 ` Andrew Lunn
2015-05-30 22:38 ` Sergey Ryazanov
2015-05-29 1:42 ` [PATCH 4/7] net: dsa: add QCA tag support Mathieu Olivari
2015-05-29 1:42 ` Mathieu Olivari [this message]
2015-05-29 1:42 ` [PATCH 6/7] net: dsa: ar8xxx: add support for second xMII interfaces through DT Mathieu Olivari
2015-05-29 1:42 ` [PATCH 7/7] Documentation: devicetree: add ar8xxx binding Mathieu Olivari
2015-05-29 2:04 ` Florian Fainelli
2015-05-29 2:00 ` [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support Andrew Lunn
2015-05-29 18:49 ` [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support\ Mathieu Olivari
2015-05-29 18:59 ` Andrew Lunn
2015-05-29 19:58 ` Florian Fainelli
2015-05-29 19:59 ` Mathieu Olivari
2015-05-29 20:01 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432863742-18427-6-git-send-email-mathieu@codeaurora.org \
--to=mathieu@codeaurora.org \
--cc=alexander.h.duyck@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=fabf@skynet.be \
--cc=galak@codeaurora.org \
--cc=gang.chen.5i5j@gmail.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jiri@resnulli.us \
--cc=joe@perches.com \
--cc=juhosg@openwrt.org \
--cc=leitec@staticky.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=pavel.nakonechny@skitlab.ru \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sfeldma@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).