net: dsa: microchip: Add Microchip KSZ8795 DSA driver
v3 cover net: dsa: microchip: Add Microchip KSZ8795 DSA driver
From: Tristram Ha <[email protected]>
This patch requires the previous patches for Microchip KSZ9477 DSA driver.
v3
- For latest KSZ9477 v2 patch
v2
- No new feature is introduced in tag_ksz.c
v1
- Return error codes instead of numbers
- Add more comments to clarify operation
- Use ksz8795 prefix to indicate KSZ8795 specific code
- Simplify MIB counter reading code
- Switch driver code is not accessed from tag_ksz.c
Tristram Ha (1):
Add Microchip KSZ8795 DSA driver.
drivers/net/dsa/microchip/Kconfig | 17 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1363 +++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1016 +++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 166 ++++ drivers/net/dsa/microchip/ksz_priv.h | 1 + include/net/dsa.h | 1 + net/dsa/Kconfig | 4 + net/dsa/dsa.c | 3 + net/dsa/dsa_priv.h | 1 + net/dsa/tag_ksz.c | 32 + 11 files changed, 2606 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz8795.c create mode 100644 drivers/net/dsa/microchip/ksz8795_reg.h create mode 100644 drivers/net/dsa/microchip/ksz8795_spi.c
Signature · 1 line
1.9.1
PATCH v3 1/1 net: dsa: microchip: Add Microchip KSZ8795 DSA driver
From: Tristram Ha <[email protected]>
Add Microchip KSZ8795 DSA driver.
--- drivers/net/dsa/microchip/Kconfig | 17 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1363 +++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1016 +++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 166 ++++ drivers/net/dsa/microchip/ksz_priv.h | 1 + include/net/dsa.h | 1 + net/dsa/Kconfig | 4 + net/dsa/dsa.c | 3 + net/dsa/dsa_priv.h | 1 + net/dsa/tag_ksz.c | 32 + 11 files changed, 2606 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz8795.c create mode 100644 drivers/net/dsa/microchip/ksz8795_reg.h create mode 100644 drivers/net/dsa/microchip/ksz8795_spi.c
drivers/net/dsa/microchip/Kconfig +17 -0
@@ -10,3 +10,20 @@ config MICROCHIP_KSZ9477_SPI_DRIVER depends on MICROCHIP_KSZ9477 && SPI help Select to enable support for registering switches configured through SPI. + +menuconfig MICROCHIP_KSZ8795 + tristate "Microchip KSZ8795 series switch support" + depends on NET_DSA + select NET_DSA_TAG_KSZ8795 + help + This driver adds support for Microchip KSZ8795 switch chips. + +config MICROCHIP_KSZ8795_SPI_DRIVER + tristate "KSZ8795 series SPI connected switch driver" + depends on MICROCHIP_KSZ8795 && SPI + default y + help + This driver accesses KSZ8795 chip through SPI. + + It is required to use the KSZ8795 switch driver as the only access + is through SPI.
drivers/net/dsa/microchip/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-$(CONFIG_MICROCHIP_KSZ9477) += ksz9477.o ksz_common.o obj-$(CONFIG_MICROCHIP_KSZ9477_SPI_DRIVER) += ksz9477_spi.o +obj-$(CONFIG_MICROCHIP_KSZ8795) += ksz8795.o ksz_common.o +obj-$(CONFIG_MICROCHIP_KSZ8795_SPI_DRIVER) += ksz8795_spi.o
drivers/net/dsa/microchip/ksz8795.c new file +1363 -0
1,363 lines not on this page · raw message
drivers/net/dsa/microchip/ksz8795_reg.h new file +1016 -0
1,016 lines not on this page · raw message
drivers/net/dsa/microchip/ksz8795_spi.c new file +166 -0
166 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_priv.h +1 -0
@@ -178,6 +178,7 @@ int ksz_switch_register(struct ksz_device *dev, const struct ksz_dev_ops *ops);void ksz_switch_remove (struct ksz_device *dev); +int ksz8795_switch_register (struct ksz_device *dev);int ksz9477_switch_register (struct ksz_device *dev);#endif
include/net/dsa.h +1 -0
@@ -32,6 +32,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_BRCM_PREPEND ,DSA_TAG_PROTO_DSA ,DSA_TAG_PROTO_EDSA , +DSA_TAG_PROTO_KSZ8795 ,DSA_TAG_PROTO_KSZ9477 ,DSA_TAG_PROTO_LAN9303 , DSA_TAG_PROTO_MTK,
net/dsa/Kconfig +4 -0
@@ -32,6 +32,10 @@ config NET_DSA_TAG_EDSA config NET_DSA_TAG_KSZ bool +config NET_DSA_TAG_KSZ8795 + bool + select NET_DSA_TAG_KSZ + config NET_DSA_TAG_KSZ9477 bool select NET_DSA_TAG_KSZ
net/dsa/dsa.c +3 -0
@@ -53,6 +53,9 @@ static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, #ifdef CONFIG_NET_DSA_TAG_EDSA [DSA_TAG_PROTO_EDSA ] = &edsa_netdev_ops, #endif +#ifdef CONFIG_NET_DSA_TAG_KSZ8795 + [DSA_TAG_PROTO_KSZ8795 ] = &ksz8795_netdev_ops, +#endif #ifdef CONFIG_NET_DSA_TAG_KSZ9477 [DSA_TAG_PROTO_KSZ9477] = &ksz9477_netdev_ops, #endif
net/dsa/dsa_priv.h +1 -0
@@ -200,6 +200,7 @@ static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)extern const struct dsa_device_ops edsa_netdev_ops;/* tag_ksz.c */ +extern const struct dsa_device_ops ksz8795_netdev_ops;extern const struct dsa_device_ops ksz9477_netdev_ops;/* tag_lan9303.c */
net/dsa/tag_ksz.c +32 -0
@@ -83,6 +83,36 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,return skb; } +static int ksz_get_tag (u8 *tag,int *port) +{ + *port = tag[0 ] &7 ; +return KSZ_EGRESS_TAG_LEN ; +} + +static void ksz8795_set_tag (void *ptr,u8 *addr,int p) +{ +u8 *tag = (u8 *)ptr; + + *tag =1 << p; +} + +static struct sk_buff *ksz8795_xmit (struct sk_buff *skb, +struct net_device *dev) +{ +return ksz_xmit (skb, dev,KSZ_INGRESS_TAG_LEN , ksz8795_set_tag); +} + +static struct sk_buff *ksz_sw_rcv (struct sk_buff *skb,struct net_device *dev, +struct packet_type *pt) +{ +return ksz_rcv (skb, dev, pt, ksz_get_tag); +} + +const struct dsa_device_ops ksz8795_netdev_ops = { + .xmit = ksz8795_xmit, + .rcv = ksz_sw_rcv, +}; +/* For Ingress (Host -> KSZ9477), 2 bytes are added before FCS. * --------------------------------------------------------------------------- * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|tag1(1byte)|FCS(4bytes)
@@ -103,6 +133,8 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,static int ksz9477_get_tag (u8 *tag,int *port) { *port = tag[0 ] &7 ; + +/* length can be longer for PTP timestamp */ return KSZ_EGRESS_TAG_LEN ; }
Signature · 1 line
1.9.1
Andrew Lunn
maintainerQuoted 3 lines · On Tue, Dec 05, 2017 at 05:47:30PM -0800, [email protected] wrote:
From: Tristram Ha <[email protected]>
This patch requires the previous patches for Microchip KSZ9477 DSA driver.
Please don't submit so many patch sets, which all depend on the previous one. Wait until they get accepted.
I'm not going to review this or the following patchsets, until the previous ones are accepted.
Andrew
Quoted 10 lines · Andrew Lunn
Quoted 3 lines · On Tue, Dec 05, 2017 at 05:47:30PM -0800, [email protected] wrote:
From: Tristram Ha <[email protected]>
This patch requires the previous patches for Microchip KSZ9477 DSA driver.
Please don't submit so many patch sets, which all depend on the previous one. Wait until they get accepted.
I'm not going to review this or the following patchsets, until the previous ones are accepted.
+1