Skip to contentSkip to conversation

net-next: dsa: add Mediatek MT7530 support

PATCH Superseded [email protected] 5 participants 15 messages Mar 29, 2017 – May 29, 2017

Subsystems (7)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover net-next: dsa: add Mediatek MT7530 support

From: Sean Wang <[email protected]>

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.

The patch series integrated Mediatek MT7530 into DSA support which includes the most of the essential callbacks such as tag insertion for port distinguishing, port control, bridge offloading, STP setup and ethtool operations to allow DSA to model each user port into independently standalone netdevice as the other DSA driver had done.

Changes since v1:
- rebased into 4.11-rc1
- refined binding document including below five items
- changed the type of mediatek,mcm into bool
- used reset controller binding for MCM reset and removed "mediatek,ethsys" property from binding
- reused CPU port's ethernet Phandle instead of creating new one and removed "mediatek,ethernet" property from binding
- aligned naming for GPIO reset with dsa/marvell.txt
- added phy-mode as required property child nodes within ports container
- handled gpio reset with devm_gpiod_* API
- refined comment words
- removed condition for CDM setting since the setup looks both fine for all cases
- allowed of_find_net_device_by_node() working with pointing the device node into real netdev instance
- fixed Kbuild warnings

Changes since v2:
- reuse readx_poll_timeout() to poll
- add proper macro instead of hard coding
- treat inconsistent cpu port as warning
- remove the usage for regmap-debugfs
- show error message when invalid id is found
- put the logic for the setup of trgmii into adjut_link()
- refine and reuse logic between port_[disable,enable], and default port setup
- correct typo

Sean Wang (5):
dt-bindings: net: dsa: add Mediatek MT7530 binding
net-next: dsa: add Mediatek tag RX/TX handler
net-next: ethernet: mediatek: add CDM able to recognize the tag for
DSA
net-next: ethernet: mediatek: add device_node of GMAC pointing into
the netdev instance
net-next: dsa: add dsa support for Mediatek MT7530 switch

 .../devicetree/bindings/net/dsa/mt7530.txt         |   92 ++
 drivers/net/dsa/Kconfig                            |    8 +
 drivers/net/dsa/Makefile                           |    2 +-
 drivers/net/dsa/mt7530.c                           | 1126 ++++++++++++++++++++
 drivers/net/dsa/mt7530.h                           |  390 +++++++
 drivers/net/ethernet/mediatek/mtk_eth_soc.c        |    8 +
 drivers/net/ethernet/mediatek/mtk_eth_soc.h        |    4 +
 include/net/dsa.h                                  |    1 +
 net/dsa/Kconfig                                    |    2 +
 net/dsa/Makefile                                   |    1 +
 net/dsa/dsa.c                                      |    3 +
 net/dsa/dsa_priv.h                                 |    3 +
 net/dsa/tag_mtk.c                                  |  117 ++
 13 files changed, 1756 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt
 create mode 100644 drivers/net/dsa/mt7530.c
 create mode 100644 drivers/net/dsa/mt7530.h
 create mode 100644 net/dsa/tag_mtk.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/5 dt-bindings: net: dsa: add Mediatek MT7530 binding

From: Sean Wang <[email protected]>

Add device-tree binding for Mediatek MT7530 switch.

---
 .../devicetree/bindings/net/dsa/mt7530.txt         | 92 ++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt
Documentation/devicetree/bindings/net/dsa/mt7530.txt new file +92 -0
new file mode 100644
index 0000000..a9bc27b
@@ -0,0 +1,92 @@
+Mediatek MT7530 Ethernet switch
+================================
+
+Required properties:
+
+- compatible: Must be compatible = "mediatek,mt7530";
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part
+	on multi-chip module belong to MT7623A has or the remotely standalone
+	chip as the function MT7623N reference board provided for.
+- core-supply: Phandle to the regulator node necessary for the core power.
+- io-supply: Phandle to the regulator node necessary for the I/O power.
+	See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
+	for details for the regulator setup on these boards.
+
+If the property mediatek,mcm isn't defined, following property is required
+
+- reset-gpios: Should be a gpio specifier for a reset line.
+
+Else, following properties are required
+
+- resets : Phandle pointing to the system reset controller with
+	line index for the ethsys.
+- reset-names : Should be set to "mcm".
+
+Required properties for the child nodes within ports container:
+
+- reg: Port address described must be 6 for CPU port and from 0 to 5 for
+	user ports.
+- phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
+	 "cpu".
+
+See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+required, optional properties and how the integrated switch subnodes must
+be specified.
+
+Example:
+
+	&mdio0 {
+		switch@0 {
+			compatible = "mediatek,mt7530";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			core-supply = <&mt6323_vpa_reg>;
+			io-supply = <&mt6323_vemc3v3_reg>;
+			reset-gpios = <&pio 33 0>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				reg = <0>;
+				port@0 {
+					reg = <0>;
+					label = "lan0";
+				};
+
+				port@1 {
+					reg = <1>;
+					label = "lan1";
+				};
+
+				port@2 {
+					reg = <2>;
+					label = "lan2";
+				};
+
+				port@3 {
+					reg = <3>;
+					label = "lan3";
+				};
+
+				port@4 {
+					reg = <4>;
+					label = "wan";
+				};
+
+				port@6 {
+					reg = <6>;
+					label = "cpu";
+					ethernet = <&gmac0>;
+					phy-mode = "trgmii";
+					fixed-link {
+						speed = <1000>;
+						full-duplex;
+					};
+				};
+			};
+		};
+	};
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/5 net-next: dsa: add Mediatek tag RX/TX handler

In reply to [email protected]

From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>

Add the support for the 4-bytes tag for DSA port distinguishing inserted allowing receiving and transmitting the packet via the particular port. The tag is being added after the source MAC address in the ethernet header.

---
 include/net/dsa.h  |   1 +
 net/dsa/Kconfig    |   2 +
 net/dsa/Makefile   |   1 +
 net/dsa/dsa.c      |   3 ++
 net/dsa/dsa_priv.h |   3 ++
 net/dsa/tag_mtk.c  | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 127 insertions(+)
 create mode 100644 net/dsa/tag_mtk.c
include/net/dsa.h +1 -0
index 4e13e69..3276547 100644
@@ -31,6 +31,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_EDSA,
 	DSA_TAG_PROTO_BRCM,
 	DSA_TAG_PROTO_QCA,
+	DSA_TAG_PROTO_MTK,
 	DSA_TAG_LAST,		/* MUST BE LAST */
 };
 
net/dsa/Kconfig +2 -0
index 9649238..d78789b 100644
@@ -31,4 +31,6 @@ config NET_DSA_TAG_TRAILER
 config NET_DSA_TAG_QCA
 	bool
 
+config NET_DSA_TAG_MTK
+	bool
 endif
net/dsa/Makefile +1 -0
index 31d3437..9b1d478 100644
@@ -8,3 +8,4 @@ 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_TRAILER) += tag_trailer.o
 dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
+dsa_core-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
net/dsa/dsa.c +3 -0
index b6d4f6a..617f736 100644
@@ -53,6 +53,9 @@ static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb,
 #ifdef CONFIG_NET_DSA_TAG_QCA
 	[DSA_TAG_PROTO_QCA] = &qca_netdev_ops,
 #endif
+#ifdef CONFIG_NET_DSA_TAG_MTK
+	[DSA_TAG_PROTO_MTK] = &mtk_netdev_ops,
+#endif
 	[DSA_TAG_PROTO_NONE] = &none_ops,
 };
 
net/dsa/dsa_priv.h +3 -0
index 0706a51..2a31399 100644
@@ -85,4 +85,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 /* tag_qca.c */
 extern const struct dsa_device_ops qca_netdev_ops;
 
+/* tag_mtk.c */
+extern const struct dsa_device_ops mtk_netdev_ops;
+
 #endif
net/dsa/tag_mtk.c new file +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v3 3/5 net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA

In reply to [email protected]

From: Sean Wang <[email protected]>

The patch adds the setup for allowing CDM can recognize these packets with carrying port-distinguishing tag. Otherwise, these tagging packets will be handled incorrectly by CDM. The setup is also working out for general untag packets as well.

---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++
 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++++
 2 files changed, 10 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 -0
index 9e75768..c21ed99 100644
@@ -1846,6 +1846,12 @@ static int mtk_hw_init(struct mtk_eth *eth)
 	/* GE2, Force 1000M/FD, FC ON */
 	mtk_w32(eth, MAC_MCR_FIXED_LINK, MTK_MAC_MCR(1));
 
+	/* Indicates CDM to parse the MTK special tag from CPU
+	 * which also is working out for untag packets.
+	 */
+	val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
+	mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
+
 	/* Enable RX VLan Offloading */
 	mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
 
drivers/net/ethernet/mediatek/mtk_eth_soc.h +4 -0
index 99b1c8e..996024d 100644
@@ -70,6 +70,10 @@
 /* Frame Engine Interrupt Grouping Register */
 #define MTK_FE_INT_GRP		0x20
 
+/* CDMP Ingress Control Register */
+#define MTK_CDMQ_IG_CTRL	0x1400
+#define MTK_CDMQ_STAG_EN	BIT(0)
+
 /* CDMP Exgress Control Register */
 #define MTK_CDMP_EG_CTRL	0x404
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH v3 4/5 net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance

In reply to [email protected]

From: Sean Wang <[email protected]>

the patch adds the setup of the corresponding device node of GMAC into the netdev instance which could allow other modules such as DSA to find the instance through the node in dt-bindings using of_find_net_device_by_node() call.

---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +2 -0
index c21ed99..84b09a4 100644
@@ -2323,6 +2323,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 	eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops;
 
 	eth->netdev[id]->irq = eth->irq[0];
+	eth->netdev[id]->dev.of_node = np;
+
 	return 0;
 
 free_netdev:
Signature · 1 line
1.9.1
#5 lore raw

PATCH v3 5/5 net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]

From: Sean Wang <[email protected]>

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.

For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC through either the TRGMII or RGMII which could be controlled by phy-mode in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6 is being supported in this DSA driver.

The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port distinguishing, port control, bridge offloading, STP setup and ethtool operation to allow DSA to model each user port into a standalone netdevice as the other DSA driver had done.

---
 drivers/net/dsa/Kconfig  |    8 +
 drivers/net/dsa/Makefile |    2 +-
 drivers/net/dsa/mt7530.c | 1126 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/mt7530.h |  390 ++++++++++++++++
 4 files changed, 1525 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/dsa/mt7530.c
 create mode 100644 drivers/net/dsa/mt7530.h
drivers/net/dsa/Kconfig +8 -0
index 0659846..5b322b4 100644
@@ -34,4 +34,12 @@ config NET_DSA_QCA8K
 	  This enables support for the Qualcomm Atheros QCA8K Ethernet
 	  switch chips.
 
+config NET_DSA_MT7530
+	tristate "Mediatek MT7530 Ethernet switch support"
+	depends on NET_DSA
+	select NET_DSA_TAG_MTK
+	---help---
+	  This enables support for the Mediatek MT7530 Ethernet switch
+	  chip.
+
 endmenu
drivers/net/dsa/Makefile +1 -1
index a3c9416..8e629c1 100644
@@ -2,6 +2,6 @@ obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_BCM_SF2)	+= bcm-sf2.o
 bcm-sf2-objs			:= bcm_sf2.o bcm_sf2_cfp.o
 obj-$(CONFIG_NET_DSA_QCA8K)	+= qca8k.o
-
+obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o
 obj-y				+= b53/
 obj-y				+= mv88e6xxx/
drivers/net/dsa/mt7530.c new file +1126 -0

1,126 lines not on this page · raw message

drivers/net/dsa/mt7530.h new file +390 -0

390 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 1 line

+static struct mt7530_priv *lpriv;

Hi Sean

Why do you need this global variable? What if somebody has two switches connected?

drivers/net/dsa/mt7530.c line 82

Quoted 4 lines
drivers/net/dsa/mt7530.c new file +4 -0
+static void mt7530_port_disable(struct dsa_switch *ds, int port,
+				struct phy_device *phy);
+static int mt7530_cpu_port_enable(struct mt7530_priv *priv,
+				  int port);

It is better to move the functions around than have forward declarations.

Quoted 11 lines
drivers/net/dsa/mt7530.c new file +11 -0
+static u32
+_mt7530_read(u32 reg)
+{
+	struct mt7530_priv	*priv = lpriv;
+	struct mii_bus		*bus = priv->bus;
+	u32 val;
+
+	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+
+	val = mt7530_mii_read(priv, reg);
+

drivers/net/dsa/mt7530.c line 323

Quoted 10 lines
drivers/net/dsa/mt7530.c new file +10 -0
+	mutex_unlock(&bus->mdio_lock);
+
+	return val;
+}
+
+static u32
+mt7530_read(struct mt7530_priv *priv, u32 reg)
+{
+	return _mt7530_read(reg);
+}

So here you would pass priv to _mt7530_read().

drivers/net/dsa/mt7530.c line 365

Quoted 12 lines
drivers/net/dsa/mt7530.c new file +12 -0
+static int
+mt7530_fdb_cmd(struct mt7530_priv *priv, enum mt7530_fdb_cmd cmd, u32 *rsp)
+{
+	u32 val;
+	int ret;
+
+	/* Set the command operating upon the MAC address entries */
+	val = ATC_BUSY | ATC_MAT(0) | cmd;
+	mt7530_write(priv, MT7530_ATC, val);
+
+	ret = readx_poll_timeout(_mt7530_read, MT7530_ATC, val,
+				 !(val & ATC_BUSY), 20, 20000);

This is where your need for lpriv comes, you can only pass a single argument. But you can work around it. readx_poll_timeout is a #define. So there is no type check for _mt7530_read, or the arg passed to it. So pass a struct containing the address and priv.

I think you can then kill of your global lpriv.

Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/net-next-dsa-add-Mediatek-MT7530-support/20170330-135532 config: arm-allmodconfig (attached as .config) compiler…

Hi Sean,

[auto build test ERROR on net-next/master]

url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/net-next-dsa-add-Mediatek-MT7530-support/20170330-135532
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

In file included from net/dsa/tag_mtk.c:16:0:
net/dsa/dsa_priv.h:50:30: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
^~~~~~~~~~
net/dsa/dsa_priv.h:54:39: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration

    int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
                                          ^~~~~~~~~~
   net/dsa/dsa_priv.h:55:42: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
    void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
                                             ^~~~~~~~~~
   net/dsa/dsa_priv.h:59:36: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
    void dsa_slave_mii_bus_init(struct dsa_switch *ds);
                                       ^~~~~~~~~~
   net/dsa/dsa_priv.h:61:29: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
    int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
                                ^~~~~~~~~~
   net/dsa/dsa_priv.h:70:41: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
    int dsa_switch_register_notifier(struct dsa_switch *ds);
                                            ^~~~~~~~~~
   net/dsa/dsa_priv.h:71:44: warning: 'struct dsa_switch' declared inside parameter list will not be visible outside of this definition or declaration
    void dsa_switch_unregister_notifier(struct dsa_switch *ds);
                                               ^~~~~~~~~~
   net/dsa/tag_mtk.c: In function 'mtk_tag_xmit':
>> net/dsa/tag_mtk.c:38:26: error: dereferencing pointer to incomplete type 'struct dsa_port'
     mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
                             ^~
   net/dsa/tag_mtk.c: In function 'mtk_tag_rcv':
>> net/dsa/tag_mtk.c:85:10: error: dereferencing pointer to incomplete type 'struct dsa_switch_tree'
     ds = dst->ds[0];
             ^~
>> net/dsa/tag_mtk.c:91:9: error: dereferencing pointer to incomplete type 'struct dsa_switch'
     if (!ds->ports[port].netdev)
            ^~

vim +91 net/dsa/tag_mtk.c

2faad9d7 Sean Wang 2017-03-29  32  
2faad9d7 Sean Wang 2017-03-29  33  	memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN);
2faad9d7 Sean Wang 2017-03-29  34  
2faad9d7 Sean Wang 2017-03-29  35  	/* Build the tag after the MAC Source Address */
2faad9d7 Sean Wang 2017-03-29  36  	mtk_tag = skb->data + 2 * ETH_ALEN;
2faad9d7 Sean Wang 2017-03-29  37  	mtk_tag[0] = 0;
2faad9d7 Sean Wang 2017-03-29 @38  	mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
2faad9d7 Sean Wang 2017-03-29  39  	mtk_tag[2] = 0;
2faad9d7 Sean Wang 2017-03-29  40  	mtk_tag[3] = 0;
2faad9d7 Sean Wang 2017-03-29  41  
2faad9d7 Sean Wang 2017-03-29  42  	return skb;
2faad9d7 Sean Wang 2017-03-29  43  
2faad9d7 Sean Wang 2017-03-29  44  out_free:
2faad9d7 Sean Wang 2017-03-29  45  	kfree_skb(skb);
2faad9d7 Sean Wang 2017-03-29  46  	return NULL;
2faad9d7 Sean Wang 2017-03-29  47  }
2faad9d7 Sean Wang 2017-03-29  48  
2faad9d7 Sean Wang 2017-03-29  49  static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
2faad9d7 Sean Wang 2017-03-29  50  		       struct packet_type *pt, struct net_device *orig_dev)
2faad9d7 Sean Wang 2017-03-29  51  {
2faad9d7 Sean Wang 2017-03-29  52  	struct dsa_switch_tree *dst = dev->dsa_ptr;
2faad9d7 Sean Wang 2017-03-29  53  	struct dsa_switch *ds;
2faad9d7 Sean Wang 2017-03-29  54  	int port;
2faad9d7 Sean Wang 2017-03-29  55  	__be16 *phdr, hdr;
2faad9d7 Sean Wang 2017-03-29  56  
2faad9d7 Sean Wang 2017-03-29  57  	if (unlikely(!dst))
2faad9d7 Sean Wang 2017-03-29  58  		goto out_drop;
2faad9d7 Sean Wang 2017-03-29  59  
2faad9d7 Sean Wang 2017-03-29  60  	skb = skb_unshare(skb, GFP_ATOMIC);
2faad9d7 Sean Wang 2017-03-29  61  	if (!skb)
2faad9d7 Sean Wang 2017-03-29  62  		goto out;
2faad9d7 Sean Wang 2017-03-29  63  
2faad9d7 Sean Wang 2017-03-29  64  	if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
2faad9d7 Sean Wang 2017-03-29  65  		goto out_drop;
2faad9d7 Sean Wang 2017-03-29  66  
2faad9d7 Sean Wang 2017-03-29  67  	/* The MTK header is added by the switch between src addr
2faad9d7 Sean Wang 2017-03-29  68  	 * and ethertype at this point, skb->data points to 2 bytes
2faad9d7 Sean Wang 2017-03-29  69  	 * after src addr so header should be 2 bytes right before.
2faad9d7 Sean Wang 2017-03-29  70  	 */
2faad9d7 Sean Wang 2017-03-29  71  	phdr = (__be16 *)(skb->data - 2);
2faad9d7 Sean Wang 2017-03-29  72  	hdr = ntohs(*phdr);
2faad9d7 Sean Wang 2017-03-29  73  
2faad9d7 Sean Wang 2017-03-29  74  	/* Remove MTK tag and recalculate checksum. */
2faad9d7 Sean Wang 2017-03-29  75  	skb_pull_rcsum(skb, MTK_HDR_LEN);
2faad9d7 Sean Wang 2017-03-29  76  
2faad9d7 Sean Wang 2017-03-29  77  	memmove(skb->data - ETH_HLEN,
2faad9d7 Sean Wang 2017-03-29  78  		skb->data - ETH_HLEN - MTK_HDR_LEN,
2faad9d7 Sean Wang 2017-03-29  79  		2 * ETH_ALEN);
2faad9d7 Sean Wang 2017-03-29  80  
2faad9d7 Sean Wang 2017-03-29  81  	/* This protocol doesn't support cascading multiple
2faad9d7 Sean Wang 2017-03-29  82  	 * switches so it's safe to assume the switch is first
2faad9d7 Sean Wang 2017-03-29  83  	 * in the tree.
2faad9d7 Sean Wang 2017-03-29  84  	 */
2faad9d7 Sean Wang 2017-03-29 @85  	ds = dst->ds[0];
2faad9d7 Sean Wang 2017-03-29  86  	if (!ds)
2faad9d7 Sean Wang 2017-03-29  87  		goto out_drop;
2faad9d7 Sean Wang 2017-03-29  88  
2faad9d7 Sean Wang 2017-03-29  89  	/* Get source port information */
2faad9d7 Sean Wang 2017-03-29  90  	port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK);
2faad9d7 Sean Wang 2017-03-29 @91  	if (!ds->ports[port].netdev)
2faad9d7 Sean Wang 2017-03-29  92  		goto out_drop;
2faad9d7 Sean Wang 2017-03-29  93  
2faad9d7 Sean Wang 2017-03-29  94  	/* Update skb & forward the frame accordingly */

:::::: The code at line 91 was first introduced by commit
:::::: 2faad9d71e4c0544e3cf43b24439517c95df301f net-next: dsa: add Mediatek tag RX/TX handler

:::::: TO: Sean Wang <[email protected]> :::::: CC: 0day robot <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#8 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/net-next-dsa-add-Mediatek-MT7530-support/20170330-135532 config: m68k-allmodconfig (attached as .config) compiler: m68k-linux-gcc…

Hi Sean,

[auto build test ERROR on net-next/master]

url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/net-next-dsa-add-Mediatek-MT7530-support/20170330-135532
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k

All errors (new ones prefixed by >>):

In file included from net//dsa/tag_mtk.c:16:0:
net//dsa/dsa_priv.h:51:16: warning: 'struct dsa_switch' declared inside parameter list

            struct dsa_port *dport, int port);
                   ^
   net//dsa/dsa_priv.h:51:16: warning: its scope is only this definition or declaration, which is probably not what you want
   net//dsa/dsa_priv.h:54:39: warning: 'struct dsa_switch' declared inside parameter list
    int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
                                          ^
   net//dsa/dsa_priv.h:55:42: warning: 'struct dsa_switch' declared inside parameter list
    void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
                                             ^
   net//dsa/dsa_priv.h:59:36: warning: 'struct dsa_switch' declared inside parameter list
    void dsa_slave_mii_bus_init(struct dsa_switch *ds);
                                       ^
   net//dsa/dsa_priv.h:62:8: warning: 'struct dsa_switch' declared inside parameter list
           int port, const char *name);
           ^
   net//dsa/dsa_priv.h:70:41: warning: 'struct dsa_switch' declared inside parameter list
    int dsa_switch_register_notifier(struct dsa_switch *ds);
                                            ^
   net//dsa/dsa_priv.h:71:44: warning: 'struct dsa_switch' declared inside parameter list
    void dsa_switch_unregister_notifier(struct dsa_switch *ds);
                                               ^
   net//dsa/tag_mtk.c: In function 'mtk_tag_xmit':
>> net//dsa/tag_mtk.c:38:26: error: dereferencing pointer to incomplete type
     mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
                             ^
   net//dsa/tag_mtk.c: In function 'mtk_tag_rcv':
   net//dsa/tag_mtk.c:85:10: error: dereferencing pointer to incomplete type
     ds = dst->ds[0];
             ^
   net//dsa/tag_mtk.c:91:9: error: dereferencing pointer to incomplete type
     if (!ds->ports[port].netdev)
            ^
   net//dsa/tag_mtk.c:98:15: error: dereferencing pointer to incomplete type
     skb->dev = ds->ports[port].netdev;
                  ^

vim +38 net//dsa/tag_mtk.c

2faad9d7 Sean Wang 2017-03-29  22  static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
2faad9d7 Sean Wang 2017-03-29  23  				    struct net_device *dev)
2faad9d7 Sean Wang 2017-03-29  24  {
2faad9d7 Sean Wang 2017-03-29  25  	struct dsa_slave_priv *p = netdev_priv(dev);
2faad9d7 Sean Wang 2017-03-29  26  	u8 *mtk_tag;
2faad9d7 Sean Wang 2017-03-29  27  
2faad9d7 Sean Wang 2017-03-29  28  	if (skb_cow_head(skb, MTK_HDR_LEN) < 0)
2faad9d7 Sean Wang 2017-03-29  29  		goto out_free;
2faad9d7 Sean Wang 2017-03-29  30  
2faad9d7 Sean Wang 2017-03-29  31  	skb_push(skb, MTK_HDR_LEN);
2faad9d7 Sean Wang 2017-03-29  32  
2faad9d7 Sean Wang 2017-03-29  33  	memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN);
2faad9d7 Sean Wang 2017-03-29  34  
2faad9d7 Sean Wang 2017-03-29  35  	/* Build the tag after the MAC Source Address */
2faad9d7 Sean Wang 2017-03-29  36  	mtk_tag = skb->data + 2 * ETH_ALEN;
2faad9d7 Sean Wang 2017-03-29  37  	mtk_tag[0] = 0;
2faad9d7 Sean Wang 2017-03-29 @38  	mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
2faad9d7 Sean Wang 2017-03-29  39  	mtk_tag[2] = 0;
2faad9d7 Sean Wang 2017-03-29  40  	mtk_tag[3] = 0;
2faad9d7 Sean Wang 2017-03-29  41  
2faad9d7 Sean Wang 2017-03-29  42  	return skb;
2faad9d7 Sean Wang 2017-03-29  43  
2faad9d7 Sean Wang 2017-03-29  44  out_free:
2faad9d7 Sean Wang 2017-03-29  45  	kfree_skb(skb);
2faad9d7 Sean Wang 2017-03-29  46  	return NULL;

:::::: The code at line 38 was first introduced by commit
:::::: 2faad9d71e4c0544e3cf43b24439517c95df301f net-next: dsa: add Mediatek tag RX/TX handler

:::::: TO: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]> :::::: CC: 0day robot <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#9 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to [email protected]
Quoted 15 lines · In gmane.linux.kernel [email protected] wrote:

From: Sean Wang <[email protected]>

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.

For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC through either the TRGMII or RGMII which could be controlled by phy-mode in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6 is being supported in this DSA driver.

Quoted 6 lines

The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port distinguishing, port control, bridge offloading, STP setup and ethtool operation to allow DSA to model each user port into a standalone netdevice as the other DSA driver had done.

What about JUMBO frames and large MTU support? devlink support?

maintainer
#10 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 1 line

What about JUMBO frames and large MTU support? devlink support?

To get the driver merged, it is better to start small, a minimal set of features. Other features can be added later. If these features are important to you, please feel free to submit patches.

Andrew

#11 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

2017-05-24 16:20 GMT+03:00 Andrew Lunn <[email protected]>:

Quoted 5 lines
Quoted 1 line

What about JUMBO frames and large MTU support? devlink support?

To get the driver merged, it is better to start small, a minimal set of features. Other features can be added later. If these features are important to you, please feel free to submit patches.

There is no documentation from mediatek about this feature. Driver from SDK v4.x contains only switching 19'th bit in GDMA1_FWD_CFG and nothing more.
So, how to write patches? Peeking random bits in random SOC config registers? --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

In reply to Andrey Jr. Melnikov
Quoted 22 lines · Andrey Jr. Melnikov
Quoted 10 lines · In gmane.linux.kernel [email protected] wrote:

From: Sean Wang <[email protected]>

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.

For port 6, it can communicate with the CPU via Mediatek Ethernet

GMAC

Quoted 1 line

through either the TRGMII or RGMII which could be controlled by

phy-mode

Quoted 2 lines

in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6

is

Quoted 5 lines

being supported in this DSA driver.

The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port

Quoted 8 lines

distinguishing,

Quoted 1 line

port control, bridge offloading, STP setup and ethtool operation to

allow

Quoted 1 line

DSA to model each user port into a standalone netdevice as the other

DSA

Quoted 1 line

driver had done.

What about JUMBO frames and large MTU support? devlink support?

We don't have a ndo_change_mtu callback implemented for DSA network devices but that is probably how we should do it. Regarding devlink, Andrew added basic support for it but unlike mlxsw it is currently of mild interest. Do you have something specific in mind with devlink?

Signature · 5 lines
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

2017-05-26 8:54 GMT+03:00 Florian Fainelli <[email protected]>:

Quoted 26 lines · Andrey Jr. Melnikov
Quoted 25 lines
Quoted 10 lines · In gmane.linux.kernel sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected] wrote:

From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on Mediatek router platforms such as MT7623A or MT7623N platform which includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports, The port from 0 to 4 are the user ports connecting with the remote devices while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet GMAC.

For port 6, it can communicate with the CPU via Mediatek Ethernet

GMAC

Quoted 1 line

through either the TRGMII or RGMII which could be controlled by

phy-mode

Quoted 2 lines

in the dt-bindings to specify which mode is preferred to use. And for port 5, only RGMII can be specified. However, currently, only port 6

is

Quoted 5 lines

being supported in this DSA driver.

The driver is made with the reference to qca8k and other existing DSA driver. The most of the essential callbacks of the DSA are already support in the driver, including tag insert for user port

distinguishing,

Quoted 1 line

port control, bridge offloading, STP setup and ethtool operation to

allow

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

DSA to model each user port into a standalone netdevice as the other

DSA

Quoted 1 line

driver had done.

What about JUMBO frames and large MTU support? devlink support?

We don't have a ndo_change_mtu callback implemented for DSA network devices but that is probably how we should do it.
Regarding devlink, Andrew added basic support for it but unlike mlxsw it is currently of mild interest. Do you have something specific in mind with devlink?

I want to see each ports behind the bridge as independent ethernet devices. If I understand RTFM only devlink may expose this configuration.

maintainer
#14 lore raw

Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

Quoted 3 lines

I want to see each ports behind the bridge as independent ethernet devices. If I understand RTFM only devlink may expose this configuration.

DSA and switchdev in general gives you a linux interface per user switch port. So you can see each interface, get stats, ethtools, mii-tool, etc per interface. devlink is not needed for this.

Andrew

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html