DSA support for Micrel KSZ8895
Hi!
I've got hardware with KSZ8895, and I'd like to use switch ports as separate ethernet cards. I believe that means DSA support.
And there are even patches available from microchip... unfortunately they are in strange form and for v3.18.
http://www.microchip.com/SWLibraryWeb/product.aspx?product=KSZ8895%20Software%20Linux%203.18
Is there newer version of the driver available somewhere? Is the driver good starting point, or should I start with something else?
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 5 lines · Pavel Machek
Hi!
I've got hardware with KSZ8895, and I'd like to use switch ports as separate ethernet cards. I believe that means DSA support.
Quoted 7 lines
And there are even patches available from microchip... unfortunately they are in strange form and for v3.18.
http://www.microchip.com/SWLibraryWeb/product.aspx?product=KSZ8895%20Software%20Linux%203.18
Is there newer version of the driver available somewhere? Is the driver good starting point, or should I start with something else?
Hi Pavel
Woojung is the expert here. His DSA driver for the 9477 is a nice clean driver.
Have you compared the 8895 to the 9477. Are they similar? Could the existing 9477 be extended to support the 8895?
Andrew
[email protected]
maintainerQuoted 17 lines
Quoted 9 lines
Hi!
I've got hardware with KSZ8895, and I'd like to use switch ports as separate ethernet cards. I believe that means DSA support.
And there are even patches available from microchip... unfortunately they are in strange form and for v3.18.
http://www.microchip.com/SWLibraryWeb/product.aspx?product=KSZ8895
%20Software%20Linux%203.18Quoted 3 lines
Is there newer version of the driver available somewhere? Is the driver good starting point, or should I start with something else?
Hi Pavel
Quoted 7 lines
Woojung is the expert here. His DSA driver for the 9477 is a nice clean driver.
Have you compared the 8895 to the 9477. Are they similar? Could the existing 9477 be extended to support the 8895?
Andrew
Hi Pavel,
I'll forward your email to our support.
AFAIK, KSZ8895 has different register mapping from KSZ9477, it will be more than ID changes in current driver.
Thanks.
Woojung
Hi!
Quoted 6 lines
Quoted 6 lines
Woojung is the expert here. His DSA driver for the 9477 is a nice clean driver.
Have you compared the 8895 to the 9477. Are they similar? Could the existing 9477 be extended to support the 8895?
Quoted 7 lines
Quoted 1 line
Andrew
Hi Pavel,
I'll forward your email to our support.
AFAIK, KSZ8895 has different register mapping from KSZ9477, it will be more than ID changes in current driver.
More than ID changes, indeed. As layout is completely different, it looks like different source file will be needed for support.
I'm not nearly there; but I can ifconfig lanX up, already, and perform some pings.
Any ideas how to do the work in a way to minimize code duplication are welcome...
Best regards,
Pavel
drivers/net/dsa/microchip/ksz_8895_reg.h new file +41 -0
@@ -0,0 +1,41 @@ +/* +* Microchip KSZ9477 register definitions +* +* Copyright (C) 2017 +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef __KSZ9477_REGS_H +#define __KSZ9477_REGS_H + +#define KS_PRIO_M 0x3 +#define KS_PRIO_S 2 + +/* 0 - Operation */ +#define REG_CHIP_ID0__1 0x0000 + +#define REG_CHIP_ID1__1 0x0001 + +#define FAMILY_ID 0x95 +#define FAMILY_ID_94 0x94 +#define FAMILY_ID_95 0x95 +#define FAMILY_ID_85 0x85 +#define FAMILY_ID_98 0x98 +#define FAMILY_ID_88 0x88 + +#define TOTAL_SWITCH_COUNTER_NUM 0x24/* FIXME */ +#define PORT_CTRL_ADDR (port, addr) ((addr) | (((port) + 1) << 4)) + + +#endif /* KSZ9477_REGS_H */
drivers/net/dsa/microchip/ksz_9477_reg.h +1 -0
@@ -16,6 +16,7 @@* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#error This is not switch we have#ifndef __KSZ9477_REGS_H#define __KSZ9477_REGS_H
drivers/net/dsa/microchip/ksz_common.c +225 -15
629 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +373 -0
373 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_priv.h +2 -1
@@ -25,7 +25,7 @@#include <linux/etherdevice.h> #include <net/dsa.h> -#include "ksz_9477_reg.h" +#include "ksz_8895_reg.h" struct ksz_io_ops ;
@@ -174,6 +174,7 @@ static inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value)static inline void ksz_pread8 (struct ksz_device *dev,int port,int offset,u8 *data) { +//printk("pread8 %d %d -> %d\n", port, offset, PORT_CTRL_ADDR(port, offset)); ksz_read8 (dev,PORT_CTRL_ADDR (port, offset), data); }
drivers/net/dsa/microchip/ksz_spi.c +34 -3
@@ -29,22 +29,38 @@#define KS_SPIOP_RD 3#define KS_SPIOP_WR 2 +#ifdef KSOLD #define SPI_ADDR_SHIFT 24 -#define SPI_ADDR_MASK (BIT(SPI_ADDR_SHIFT) - 1)#define SPI_TURNAROUND_SHIFT 5 +#else +/* FIXME?! */ +#define SPI_ADDR_SHIFT 12 +#define SPI_TURNAROUND_SHIFT 1 +#endif +#define SPI_ADDR_MASK (BIT(SPI_ADDR_SHIFT) - 1)static int ksz_spi_read_reg (struct spi_device *spi,u32 reg,u8 *val,unsigned int len) { -u32 txbuf;int ret; +#ifdef KSOLD +u32 txbuf; txbuf = reg &SPI_ADDR_MASK ; txbuf |=KS_SPIOP_RD <<SPI_ADDR_SHIFT ; txbuf <<=SPI_TURNAROUND_SHIFT ; txbuf =cpu_to_be32 (txbuf); ret =spi_write_then_read (spi, &txbuf,4 , val, len); +#else +u8 buf[2 ]; + + buf[0 ] =KS_SPIOP_RD ; + buf[1 ] = reg; + + ret =spi_write_then_read (spi, buf,2 , val, len); +#endif +return ret; }
@@ -99,8 +115,10 @@ static int ksz_spi_read32(struct ksz_device *dev, u32 reg, u32 *val)static int ksz_spi_write_reg (struct spi_device *spi,u32 reg,u8 *val,unsigned int len) { -u32 txbuf;u8 data[12 ]; + +#ifdef KSOLD +u32 txbuf;int i; txbuf = reg &SPI_ADDR_MASK ;
@@ -116,6 +134,16 @@ static int ksz_spi_write_reg(struct spi_device *spi, u32 reg, u8 *val, data[i +4 ] = val[i];return spi_write (spi, &data,4 + len); +#else +int i; + + data[0 ] =KS_SPIOP_WR ; + data[1 ] = reg; +for (i =0 ; i < len; i++) + data[i +2 ] = val[i]; + +return spi_write (spi, &data,2 + len); +#endif }static int ksz_spi_write8 (struct ksz_device *dev,u32 reg,u8 value)
@@ -174,6 +202,8 @@ static int ksz_spi_probe(struct spi_device *spi)if (spi->dev.platform_data) dev->pdata = spi->dev.platform_data; +//printk("Chip variant is %lx\n", spi_get_device_id(spi)->driver_data + ret =ksz_switch_register (dev);if (ret)return ret;
@@ -195,6 +225,7 @@ static int ksz_spi_remove(struct spi_device *spi)static const struct of_device_id ksz_dt_ids[] = { { .compatible ="microchip,ksz9477" }, + { .compatible ="microchip,ksz8895" }, {}, };MODULE_DEVICE_TABLE (of, ksz_dt_ids);
drivers/net/dsa/microchip/ksz_sw_phy.h new file +754 -0
754 lines not on this page · raw message
net/dsa/tag_ksz.c +6 -3
@@ -29,7 +29,7 @@* (eg, 0x00=port1, 0x02=port3, 0x06=port7) */ -#define KSZ_INGRESS_TAG_LEN 2 +#define KSZ_INGRESS_TAG_LEN 1#define KSZ_EGRESS_TAG_LEN 1static struct sk_buff *ksz_xmit (struct sk_buff *skb,struct net_device *dev)
@@ -40,6 +40,7 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)u8 *tag; padlen = (skb->len >=ETH_ZLEN ) ?0 :ETH_ZLEN - skb->len; +printk ("ksz_xmit...\n" );if (skb_tailroom (skb) >= padlen +KSZ_INGRESS_TAG_LEN ) {if (skb_put_padto (skb, skb->len + padlen))
@@ -69,8 +70,9 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) } tag =skb_put (nskb,KSZ_INGRESS_TAG_LEN ); - tag[0 ] =0 ; - tag[1 ] =1 << p->dp->index;/* destination port */ + tag[0 ] =1 << p->dp->index;/* destination port */ + +printk ("ksz_xmit: tagging with %lx\n" ,1 << p->dp->index);return nskb; }
@@ -88,6 +90,7 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev, tag =skb_tail_pointer (skb) -KSZ_EGRESS_TAG_LEN ; source_port = tag[0 ] &7 ; +printk ("ksz_rcv: got source port %d\n" , source_port);if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)return NULL ;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 2 lines
Any ideas how to do the work in a way to minimize code duplication are welcome...
A lot depends on how much duplication there is. mv88e6xxx uses a set of function points per chip variant. Another option is to put the common code into a library, and have two drivers. Or if it is the same registers, but at different locations, you can add a translation function, which is what i think the b53 driver does.
Andrew
[email protected]
maintainerPavel,
Quoted 4 lines
Quoted 3 lines
I'll forward your email to our support.
AFAIK, KSZ8895 has different register mapping from KSZ9477, it will be more than ID changes in current driver.
Quoted 8 lines
More than ID changes, indeed. As layout is completely different, it looks like different source file will be needed for support.
I'm not nearly there; but I can ifconfig lanX up, already, and perform some pings.
Any ideas how to do the work in a way to minimize code duplication are welcome...
Which version do you use to create patch? Getting error when applying patch to the latest net-next.
- Woojung
Hi!
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I'll forward your email to our support.
AFAIK, KSZ8895 has different register mapping from KSZ9477, it will be more than ID changes in current driver.More than ID changes, indeed. As layout is completely different, it looks like different source file will be needed for support.
Quoted 8 lines
Quoted 5 lines
I'm not nearly there; but I can ifconfig lanX up, already, and perform some pings.
Any ideas how to do the work in a way to minimize code duplication are welcome...
Which version do you use to create patch? Getting error when applying patch to the latest net-next.
I'm working at 4.13-rc.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 1 line
I'm working at 4.13-rc.
For network code, it is a good idea to use net-next. That is what you need to target in order to get patches with new features merged.
Andrew
PATCH 1/1 DSA support for Micrel KSZ8895
In reply to [email protected]Hi!
So I fought with the driver a bit more, and now I have something that kind-of-works.
"great great hack" belows worries me.
Yeah, disabled code needs to be removed before merge.
No, tag_ksz part probably is not acceptable. Do you see solution better than just copying it into tag_ksz1 file?
Any more comments, etc?
Help would be welcome.
Best regards,
Pavel
drivers/net/dsa/microchip/Kconfig +15 -2
@@ -1,12 +1,25 @@ menuconfig MICROCHIP_KSZ - tristate "Microchip KSZ series switch support" + tristate "Microchip KSZ 9477 series switch support" + depends on NET_DSA + select NET_DSA_TAG_KSZ + help + This driver adds support for Microchip KSZ switch chips. + +menuconfig MICROCHIP_KSZ_8895 + tristate "Microchip KSZ 8895 series switch support" depends on NET_DSA select NET_DSA_TAG_KSZ help This driver adds support for Microchip KSZ switch chips. config MICROCHIP_KSZ_SPI_DRIVER - tristate "KSZ series SPI connected switch driver" + tristate "KSZ 9477 series SPI connected switch driver" depends on MICROCHIP_KSZ && SPI help Select to enable support for registering switches configured through SPI. + +config MICROCHIP_KSZ_8895_SPI_DRIVER + tristate "KSZ 8895 series SPI connected switch driver" + depends on MICROCHIP_KSZ_8895 && SPI + help + Select to enable support for registering switches configured through SPI.
drivers/net/dsa/microchip/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-$(CONFIG_MICROCHIP_KSZ) += ksz_common.o +obj-$(CONFIG_MICROCHIP_KSZ_8895) += ksz_8895.o obj-$(CONFIG_MICROCHIP_KSZ_SPI_DRIVER) += ksz_spi.o +obj-$(CONFIG_MICROCHIP_KSZ_8895_SPI_DRIVER) += ksz_8895_spi.o
drivers/net/dsa/microchip/ksz_8895.c new file +721 -0
721 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_8895_reg.h new file +769 -0
769 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_8895_spi.c new file +275 -0
275 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_9477_reg.h +1 -0
@@ -16,6 +16,7 @@* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#error This is not switch we have#ifndef __KSZ9477_REGS_H#define __KSZ9477_REGS_H
drivers/net/dsa/microchip/ksz_common.c +1 -0
@@ -28,6 +28,7 @@#include <net/dsa.h> #include <net/switchdev.h> +#include "ksz_9477_reg.h" #include "ksz_priv.h" static const struct {
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +286 -0
286 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_priv.h +3 -2
@@ -25,8 +25,6 @@#include <linux/etherdevice.h> #include <net/dsa.h> -#include "ksz_9477_reg.h" -struct ksz_io_ops ;struct vlan_table {
@@ -60,6 +58,8 @@ struct ksz_device {struct vlan_table *vlan_cache;u64 mib_value[TOTAL_SWITCH_COUNTER_NUM ]; + +struct bin_attribute regs_attr; };struct ksz_io_ops {
@@ -174,6 +174,7 @@ static inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value)static inline void ksz_pread8 (struct ksz_device *dev,int port,int offset,u8 *data) { +//printk("pread8 %d %d -> %d\n", port, offset, PORT_CTRL_ADDR(port, offset)); ksz_read8 (dev,PORT_CTRL_ADDR (port, offset), data); }
drivers/net/dsa/microchip/ksz_spi.c +1 -0
@@ -23,6 +23,7 @@#include <linux/module.h> #include <linux/spi/spi.h> +#include "ksz_9477_reg.h" #include "ksz_priv.h" /* SPI frame opcodes */
net/dsa/tag_ksz.c +2 -3
@@ -29,7 +29,7 @@* (eg, 0x00=port1, 0x02=port3, 0x06=port7) */ -#define KSZ_INGRESS_TAG_LEN 2 +#define KSZ_INGRESS_TAG_LEN 1#define KSZ_EGRESS_TAG_LEN 1static struct sk_buff *ksz_xmit (struct sk_buff *skb,struct net_device *dev)
@@ -69,8 +69,7 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) } tag =skb_put (nskb,KSZ_INGRESS_TAG_LEN ); - tag[0 ] =0 ; - tag[1 ] =1 << p->dp->index;/* destination port */ + tag[0 ] =1 << p->dp->index;/* destination port */ return nskb; }
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 4 lines · Pavel Machek
Hi!
So I fought with the driver a bit more, and now I have something that kind-of-works.
Thanks for keeping on working on this.
Quoted 8 lines
"great great hack" belows worries me.
Yeah, disabled code needs to be removed before merge.
No,
tag_kszpart probably is not acceptable. Do you see solution better than just copying it intotag_ksz1file?Any more comments, etc?
It would help with review if you split this up into multiple patches. The change to the tagger should be one patch. The mdio emulation would make a reasonable standalone patch etc.
I will do a more detailed review later.
Andrew
Andrew Lunn
maintainerQuoted 57 lines
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +57
-0+/** +* sw_r_phy - read data from PHY register +* @sw: The switch instance. +* @phy: PHY address to read. +* @reg: PHY register to read. +* @val: Buffer to store the read data. +* +* This routine reads data from the PHY register. +*/ +static void sw_r_phy (struct ksz_device *sw,u16 phy,u16 reg,u16 *val) +{ +u8 ctrl; +u8 restart; +u8 link; +u8 speed; +u8 force; +u8 p = phy; +u16 data =0 ; + +switch (reg) { +case PHY_REG_CTRL : +ksz_pread8 (sw, p,P_LOCAL_CTRL , &ctrl); +ksz_pread8 (sw, p,P_NEG_RESTART_CTRL , &restart); +ksz_pread8 (sw, p,P_SPEED_STATUS , &speed); +ksz_pread8 (sw, p,P_FORCE_CTRL , &force); +if (restart &PORT_PHY_LOOPBACK ) + data |=PHY_LOOPBACK ; +if (force &PORT_FORCE_100_MBIT ) + data |=PHY_SPEED_100MBIT ; +if (!(force &PORT_AUTO_NEG_DISABLE )) + data |=PHY_AUTO_NEG_ENABLE ; +if (restart &PORT_POWER_DOWN ) + data |=PHY_POWER_DOWN ; +if (restart &PORT_AUTO_NEG_RESTART ) + data |=PHY_AUTO_NEG_RESTART ; +if (force &PORT_FORCE_FULL_DUPLEX ) + data |=PHY_FULL_DUPLEX ; +if (speed &PORT_HP_MDIX ) + data |=PHY_HP_MDIX ; +if (restart &PORT_FORCE_MDIX ) + data |=PHY_FORCE_MDIX ; +if (restart &PORT_AUTO_MDIX_DISABLE ) + data |=PHY_AUTO_MDIX_DISABLE ; +if (restart &PORT_TX_DISABLE ) + data |=PHY_TRANSMIT_DISABLE ; +if (restart &PORT_LED_OFF ) + data |=PHY_LED_DISABLE ; +break ; +case PHY_REG_STATUS : +ksz_pread8 (sw, p,P_LINK_STATUS , &link); +ksz_pread8 (sw, p,P_SPEED_STATUS , &speed); + data =PHY_100BTX_FD_CAPABLE | +PHY_100BTX_CAPABLE | +PHY_10BT_FD_CAPABLE | +PHY_10BT_CAPABLE | +PHY_AUTO_NEG_CAPABLE ; +if (link &PORT_AUTO_NEG_COMPLETE )
drivers/net/dsa/microchip/ksz_mdio_emulation.c line 77
Quoted 10 lines
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +10
-0+ data |=PHY_AUTO_NEG_ACKNOWLEDGE ; +if (link &PORT_STAT_LINK_GOOD ) + data |=PHY_LINK_STATUS ; +break ; +case PHY_REG_ID_1 : + data =KSZ8895_ID_HI ; +break ; +case PHY_REG_ID_2 : + data =KSZ8895_ID_LO ; +break ;
According to the datasheet, the PHY has the normal ID registers, which have the value 0x0022, 0x1450. So it should be possible to have a standard PHY driver in drivers/net/phy.
In fact, the IDs suggest it is a micrel phy, and 1430, 1435 are already supported. So it could be you only need minor modifications to the micrel.c.
Andrew
Hi!
Thanks for review.
Quoted 24 lines
Quoted 9 lines
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +9
-0+case PHY_REG_STATUS : +ksz_pread8 (sw, p,P_LINK_STATUS , &link); +ksz_pread8 (sw, p,P_SPEED_STATUS , &speed); + data =PHY_100BTX_FD_CAPABLE | +PHY_100BTX_CAPABLE | +PHY_10BT_FD_CAPABLE | +PHY_10BT_CAPABLE | +PHY_AUTO_NEG_CAPABLE ; +if (link &PORT_AUTO_NEG_COMPLETE )drivers/net/dsa/microchip/ksz_mdio_emulation.c line 77
Quoted 10 lines
drivers/net/dsa/microchip/ksz_mdio_emulation.c new file +10
-0+ data |=PHY_AUTO_NEG_ACKNOWLEDGE ; +if (link &PORT_STAT_LINK_GOOD ) + data |=PHY_LINK_STATUS ; +break ; +case PHY_REG_ID_1 : + data =KSZ8895_ID_HI ; +break ; +case PHY_REG_ID_2 : + data =KSZ8895_ID_LO ; +break ;According to the datasheet, the PHY has the normal ID registers, which have the value
0x0022,0x1450. So it should be possible to have a standard PHY driver indrivers/net/phy.
Quoted 3 lines
In fact, the IDs suggest it is a micrel phy, and 1430, 1435 are already supported. So it could be you only need minor modifications to the
micrel.c.
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO. But then there's no access to the bridging functionality, and MDIO access may not be available. [I was told not to use it for this design, so I did not].
2) drivers/net/phy/spi_ks8995.c can be trivially modified to work with this chip.. but then you don't get the bridge functionality. (And I'm not sure how it works / who translates layouts in this case.)
I'd like to get rid of this code, or use some existing code instead, but I don't think it is possible while keeping the SPI accesss. Let me know if I'm wrong.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
Andrew
Micrel has some drivers on their web site to support some chips. For that chips they do virtual mdio over spi.
And driver is available on download page:
http://www.microchip.com/wwwproducts/en/KSZ8895
Documentation->Software library.
Both driver and DSA driver. Driver has to work with some minor fixups related to your kernel version. But I think they are don't care about up-streaming that code.
So you can take their code as a reference.
2017-08-28 17:09 GMT+03:00 Andrew Lunn <[email protected]>:
Quoted 7 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Section 4.8 of the datasheet says:
Quoted 8 lines
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
Andrew
Micrel has some drivers on their web site to support some chips. For that chips they do virtual mdio over spi.
And driver is available on download page:
http://www.microchip.com/wwwproducts/en/KSZ8895
Documentation->Software library.
Both driver and DSA driver. Driver has to work with some minor fixups related to your kernel version. But I think they are don't care about up-streaming that code.
So you can take their code as a reference.
Signature · 2 lines
Best regards, Maxim Uvarov
Hi!
Quoted 11 lines
Micrel has some drivers on their web site to support some chips. For that chips they do virtual mdio over spi.
And driver is available on download page:
http://www.microchip.com/wwwproducts/en/KSZ8895
Documentation->Softwarelibrary.Both driver and DSA driver. Driver has to work with some minor fixups related to your kernel version. But I think they are don't care about up-streaming that code.
So you can take their code as a reference.
"Minor fixups". Take a look at the driver.. I wanted to do a "minor fixups". It turned out it was easier to start from scratch.
But the MDIO emaulation code is from their driver, after lots of deletions.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerQuoted 2 lines
But the MDIO emaulation code is from their driver, after lots of deletions.
Is this driver supposed to run on lots of different OSs? That would explain why they ignored the Linux MDIO and PHY layers.
If possible, please make use of the Linux infrastructure.
Andrew
Quoted 5 lines · Andrew Lunn
Quoted 2 lines
But the MDIO emaulation code is from their driver, after lots of deletions.
Is this driver supposed to run on lots of different OSs? That would explain why they ignored the Linux MDIO and PHY layers.
It did not look particulary portable.
Quoted 1 line
If possible, please make use of the Linux infrastructure.
I did not find any infrastructure I could use instead ksz_mdio_emulation.
Now, drivers/net/phy/spi_ks8995.c can access the PHY registers, and I can not see any translation there, so there may be something I'm missing.
Pointers would be welcome at this point.
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 8 lines · Pavel Machek
Quoted 5 lines · Andrew Lunn
Quoted 2 lines
But the MDIO emaulation code is from their driver, after lots of deletions.
Is this driver supposed to run on lots of different OSs? That would explain why they ignored the Linux MDIO and PHY layers.
It did not look particulary portable.
Part of the problem is that they need to duplicate the standard MII definitions, whereas we could re-use those from include/linux/mii.h and/or mdio.h.
Quoted 5 lines
Quoted 2 lines
If possible, please make use of the Linux infrastructure.
I did not find any infrastructure I could use instead
ksz_mdio_emulation.
fixed PHY/swphy.c is as close as it could get, but it is a highly simplified version of this.
Quoted 4 lines
Now,
drivers/net/phy/spi_ks8995.ccan access the PHY registers, and I can not see any translation there, so there may be something I'm missing.
I don't see anything in that driver that seems to access PHY registers what makes you think it does?
There's got to be a way to perform indirect accesses through SPI, Woojung, do you know?
Quoted 6 lines
Pointers would be welcome at this point.
Thanks,
Pavel
Signature · 1 line
Florian
2017-08-30 0:23 GMT+03:00 Florian Fainelli <[email protected]>:
Quoted 28 lines · Pavel Machek
Quoted 8 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
But the MDIO emaulation code is from their driver, after lots of deletions.
Is this driver supposed to run on lots of different OSs? That would explain why they ignored the Linux MDIO and PHY layers.
It did not look particulary portable.
Part of the problem is that they need to duplicate the standard MII definitions, whereas we could re-use those from
include/linux/mii.hand/ormdio.h.Quoted 5 lines
Quoted 2 lines
If possible, please make use of the Linux infrastructure.
I did not find any infrastructure I could use instead
ksz_mdio_emulation.fixed
PHY/swphy.cis as close as it could get, but it is a highly simplified version of this.Quoted 4 lines
Now,
drivers/net/phy/spi_ks8995.ccan access the PHY registers, and I can not see any translation there, so there may be something I'm missing.
Quoted 6 lines
I don't see anything in that driver that seems to access PHY registers what makes you think it does?
There's got to be a way to perform indirect accesses through SPI, Woojung, do you know?
As I understand they just attach phy on spi bus with generic driver:
phy_addr = 0;
phy_mode = PHY_INTERFACE_MODE_MII;
snprintf(bus_id, MII_BUS_ID_SIZE, "sw.%d", sw_device_present);
snprintf(phy_id, MII_BUS_ID_SIZE, PHY_ID_FMT, bus_id, phy_addr);
phydev = phy_attach(netdev, phy_id, 0, phy_mode);
if (!IS_ERR(phydev)) {
phydev->adjust_link = sw_adjust_link;
return phydev;
}Where is bus is:
bus = mdiobus_alloc();bus->read = ksz_mii_read; (spi read function)bus->write = ksz_mii_write;
Then just generic reads:
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
Maxim.
Quoted 10 lines
Quoted 6 lines
Pointers would be welcome at this point.
Thanks,
Pavel--
Florian
Signature · 2 lines
Best regards, Maxim Uvarov
Quoted 5 lines · Andrew Lunn
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 15 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
Quoted 8 lines
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Best regards,
Pavel
Can you hold on your developing work on KSZ8895 driver? I am afraid your effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
The driver files all follow the structures of the current KSZ9477 DSA driver, and the file tag_ksz.c will be updated to handle the tail tag of different chips, which requires including the ksz_priv.h header. That is required nevertheless to support using the offload_fwd_mark indication.
The KSZ8795 driver will be submitted after Labor Day (9/4) if testing reveals no problem. The KSZ8895 driver will be submitted right after that. You should have no problem using the driver right away.
Tristram Ha
Principal Software Engineer
Microchip Technology Inc.
Andrew Lunn
maintainerQuoted 4 lines
The KSZ8795 driver will be submitted after Labor Day (9/4) if testing reveals no problem. The KSZ8895 driver will be submitted right after that. You should have no problem using the driver right away.
Hi Tristram
Release early, release often. It stops people wasting time....
Also, we are likely to give you feedback, asking you to make changes. Testing is important, but you are probably going to have to do it a number of times. So it is not everything passes now, don't worry, you will have time to fix things up as you go through review cycles.
Andrew
Hi!
Quoted 15 lines · On Wed 2017-08-30 21:32:07, [email protected] wrote:
Quoted 15 lines · Andrew Lunn
Quoted 13 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
Quoted 9 lines
Quoted 6 lines
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Best regards,
Can you hold on your developing work on KSZ8895 driver? I am afraid your effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
Well, thanks for heads up... but its too late to stop now. I already have working code, without the advanced features.
I don't know how far away you are with the development. You may want to start from my driver (but its probably too late now).
Quoted 6 lines
The driver files all follow the structures of the current KSZ9477 DSA driver, and the file
tag_ksz.cwill be updated to handle the tail tag of different chips, which requires including theksz_priv.hheader. That is required nevertheless to support using theoffload_fwd_markindication.The KSZ8795 driver will be submitted after Labor Day (9/4) if testing reveals no problem. The KSZ8895 driver will be submitted right after that. You should have no problem using the driver right away.
Well, normally world can help with the testing, too. It would be nice to see the code, as [RFC]. There's great chance that you'll have to modify the code to adress review feedback, which is why seeing code soon is useful.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 23 lines · Pavel Machek
Hi!
Quoted 20 lines · On Wed 2017-08-30 21:32:07, [email protected] wrote:
Quoted 20 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Best regards,
Can you hold on your developing work on KSZ8895 driver? I am afraid your effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
Well, thanks for heads up... but its too late to stop now. I already have working code, without the advanced features.
No driver has landed yet nor has any driver been posted in a proper form or shape, so at this point neither of you are able to make any claims as to which one should be chosen.
Quoted 3 lines
I don't know how far away you are with the development. You may want to start from my driver (but its probably too late now).
I would tend to favor Tristram's submission when we see it because he claims support for more devices and it is likely to be backed and maintained by Microchip in the future.
I am sure there will be opportunity for you to contribute a lot to this driver. Of course, this all depends on the code quality and timing, but having two people work on the same things in parallel is just a complete waste of each other's time so we might as well wait for Tristram to post the said driver and define a plan of action from there?
Signature · 1 line
Florian
Hi!
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
Quoted 6 lines
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Best regards,
Can you hold on your developing work on KSZ8895 driver? I am afraid your effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
Quoted 6 lines
Quoted 2 lines
Well, thanks for heads up... but its too late to stop now. I already have working code, without the advanced features.
No driver has landed yet nor has any driver been posted in a proper form or shape, so at this point neither of you are able to make any claims as to which one should be chosen.
I certainly do not want to make any claims. Tristram's driver is likely to support all (most?) features of the chip, which is not my goal.
Quoted 6 lines
Quoted 2 lines
I don't know how far away you are with the development. You may want to start from my driver (but its probably too late now).
I would tend to favor Tristram's submission when we see it because he claims support for more devices and it is likely to be backed and maintained by Microchip in the future.
Well, I guess we decide when we see the code, that's how it works, right?
Quoted 5 lines
I am sure there will be opportunity for you to contribute a lot to this driver. Of course, this all depends on the code quality and timing, but having two people work on the same things in parallel is just a complete waste of each other's time so we might as well wait for Tristram to post the said driver and define a plan of action from there?
Well, it would be good to see the code, so we can judge the quality. Normally, code is posted before testing, so this kind of problems does not arise.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
2017-08-31 0:32 GMT+03:00 <[email protected]>:
Quoted 22 lines
Quoted 22 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Best regards,
Quoted 8 lines
Quoted 1 line
Pavel
Can you hold on your developing work on KSZ8895 driver? I am afraid your effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
The driver files all follow the structures of the current KSZ9477 DSA driver, and the file
tag_ksz.cwill be updated to handle the tail tag of different chips, which requires including theksz_priv.hheader. That is required nevertheless to support using theoffload_fwd_markindication.The KSZ8795 driver will be submitted after Labor Day (9/4) if testing reveals no problem. The KSZ8895 driver will be submitted right after that. You should have no problem using the driver right away.
Hello Tristram, is there any update for that driver?
Maxim.
Quoted 4 lines
Tristram Ha
Principal Software Engineer
Microchip Technology Inc.
Signature · 2 lines
Best regards, Maxim Uvarov
Quoted 43 lines
-----Original Message-----
From: Maxim Uvarov [mailto:[email protected]]
Sent: Wednesday, September 06, 2017 2:15 AM
To: Tristram Ha - C24268
Cc: Pavel Machek; Woojung Huh - C21699; Nathan Conrad; Vivien Didelot; Florian Fainelli; netdev; [email protected]; Andrew Lunn
Subject: Re: [PATCH] DSA support for Micrel KSZ88952017-08-31 0:32 GMT+03:00 <[email protected]>:
Quoted 20 lines
Quoted 20 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
I may be confused here, but AFAICT:
1) Yes, it has standard layout when accessed over MDIO.
Quoted 8 lines
Section 4.8 of the datasheet says:
All the registers defined in this section can be also accessed via the SPI interface.
Meaning all PHY registers can be access via the SPI interface. So you should be able to make a standard Linux MDIO bus driver which performs SPI reads.
As far as I can tell (and their driver confirms) -- yes, all those registers can be accessed over the SPI, they are just shuffled around... hence MDIO emulation code. I copied it from their code (see the copyrights) so no, I don't believe there's nicer solution.
Quoted 6 lines
Quoted 4 lines
Best regards,
Pavel
Can you hold on your developing work on KSZ8895 driver? I am afraid your
effort may be in vain. We at Microchip are planning to release DSA drivers for all KSZ switches, starting at KSZ8795, then KSZ8895, and KSZ8863.
Quoted 2 lines
The driver files all follow the structures of the current KSZ9477 DSA driver,
and the file
tag_ksz.cwill be updated to handle the tail tag of different chips, which requires including theksz_priv.hheader. That is required nevertheless to support using theoffload_fwd_markindication.Quoted 1 line
Quoted 9 lines
Quoted 1 line
The KSZ8795 driver will be submitted after Labor Day (9/4) if testing reveals
no problem. The KSZ8895 driver will be submitted right after that. You should have no problem using the driver right away.
Quoted 1 line
Hello Tristram, is there any update for that driver?
Maxim.
The patches are under review internally and will need to be updated and approved by Woojung before formal submission. Problem is although KSZ8795 and KSZ8895 drivers are new code and will be submitted as RFC, they depend on the change of KSZ9477 driver currently in the kernel, which require more rigorous review.
Andrew Lunn
maintainerQuoted 5 lines
The patches are under review internally and will need to be updated and approved by Woojung before formal submission. Problem is although KSZ8795 and KSZ8895 drivers are new code and will be submitted as RFC, they depend on the change of KSZ9477 driver currently in the kernel, which require more rigorous review.
Please be aware that they will also go though review when you post them. This can be anything from great, nice job, to throw them away and start again. Since you are submitting RFCs we understand it is early code, issues still to be solved, and we can make suggestions how to solve those issues.
Post early, post often...
Andrew
Andrew Lunn
maintainerQuoted 2 lines
No,
tag_kszpart probably is not acceptable. Do you see solution better than just copying it intotag_ksz1file?
How about something like this, which needs further work to actually compile, but should give you the idea.
Andrew
index 99e38af85fc5..843e77b7c270 100644
net/dsa/dsa.c +5 -2
@@ -49,8 +49,11 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = { #ifdef CONFIG_NET_DSA_TAG_EDSA [DSA_TAG_PROTO_EDSA ] = &edsa_netdev_ops, #endif -#ifdef CONFIG_NET_DSA_TAG_KSZ - [DSA_TAG_PROTO_KSZ ] = &ksz_netdev_ops, +#ifdef CONFIG_NET_DSA_TAG_KSZ_8K + [DSA_TAG_PROTO_KSZ8K ] = &ksz8k_netdev_ops, +#endif +#ifdef CONFIG_NET_DSA_TAG_KSZ_9K + [DSA_TAG_PROTO_KSZ9K ] = &ksz9k_netdev_ops, #endif #ifdef CONFIG_NET_DSA_TAG_LAN9303 [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,
net/dsa/tag_ksz.c +17 -3
@@ -35,6 +35,9 @@static struct sk_buff *ksz_xmit (struct sk_buff *skb,struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev); +struct dsa_port *dp = p->dp; +struct dsa_switch *ds = dp->ds; +struct dsa_switch_tree *dst = ds->dst;struct sk_buff *nskb;int padlen;u8 *tag;
@@ -69,8 +72,14 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) } tag =skb_put (nskb,KSZ_INGRESS_TAG_LEN ); - tag[0 ] =0 ; - tag[1 ] =1 << p->dp->index;/* destination port */ +if (dst->tag_ops == ksz8k_netdev_ops) { + tag[0 ] =1 << p->dp->index;/* destination port */ 0 ; + tag[1 ] =0 ; + } + +if (dst->tag_ops == ksz9k_netdev_ops) { + tag[0 ] =0 ; + tag[1 ] =1 << p->dp->index;/* destination port */ return nskb; }
@@ -98,7 +107,12 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,return skb; } -const struct dsa_device_ops ksz_netdev_ops = { +const struct dsa_device_ops ksz8k_netdev_ops = { + .xmit = ksz_xmit, + .rcv = ksz_rcv, +}; + +const struct dsa_device_ops ksz9k_netdev_ops = { .xmit = ksz_xmit, .rcv = ksz_rcv, };
Hi!
Quoted 5 lines
Quoted 2 lines
No,
tag_kszpart probably is not acceptable. Do you see solution better than just copying it intotag_ksz1file?How about something like this, which needs further work to actually compile, but should give you the idea.
If that's acceptable, yes, I can do something similar. I don't think CONFIG_NET_DSA_TAG_KSZ_8K / CONFIG_NET_DSA_TAG_KSZ_9K is suitable naming (these will probably differ according to number of ports), what about keeping CONFIG_NET_DSA_TAG_KSZ and adding CONFIG_NET_DSA_TAG_KSZ_1B (for one byte)?
Thanks,
Pavel
Quoted 64 lines
Andrew
index
99e38af85fc5..843e77b7c270100644net/dsa/dsa.c +5
-2@@ -49,8 +49,11 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = { #ifdef CONFIG_NET_DSA_TAG_EDSA [DSA_TAG_PROTO_EDSA ] = &edsa_netdev_ops, #endif -#ifdef CONFIG_NET_DSA_TAG_KSZ - [DSA_TAG_PROTO_KSZ ] = &ksz_netdev_ops, +#ifdef CONFIG_NET_DSA_TAG_KSZ_8K + [DSA_TAG_PROTO_KSZ8K ] = &ksz8k_netdev_ops, +#endif +#ifdef CONFIG_NET_DSA_TAG_KSZ_9K + [DSA_TAG_PROTO_KSZ9K ] = &ksz9k_netdev_ops, #endif #ifdef CONFIG_NET_DSA_TAG_LAN9303 [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,net/dsa/tag_ksz.c +17
-3@@ -35,6 +35,9 @@static struct sk_buff *ksz_xmit (struct sk_buff *skb,struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev); +struct dsa_port *dp = p->dp; +struct dsa_switch *ds = dp->ds; +struct dsa_switch_tree *dst = ds->dst;struct sk_buff *nskb;int padlen;u8 *tag;@@ -69,8 +72,14 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) } tag =skb_put (nskb,KSZ_INGRESS_TAG_LEN ); - tag[0 ] =0 ; - tag[1 ] =1 << p->dp->index;/* destination port */ +if (dst->tag_ops == ksz8k_netdev_ops) { + tag[0 ] =1 << p->dp->index;/* destination port */ 0 ; + tag[1 ] =0 ; + } + +if (dst->tag_ops == ksz9k_netdev_ops) { + tag[0 ] =0 ; + tag[1 ] =1 << p->dp->index;/* destination port */ return nskb; }@@ -98,7 +107,12 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,return skb; } -const struct dsa_device_ops ksz_netdev_ops = { +const struct dsa_device_ops ksz8k_netdev_ops = { + .xmit = ksz_xmit, + .rcv = ksz_rcv, +}; + +const struct dsa_device_ops ksz9k_netdev_ops = { .xmit = ksz_xmit, .rcv = ksz_rcv, };
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Hi!
So I fought with the driver a bit more, and now I have something that kind-of-works.
"great great hack" belows worries me.
Yeah, disabled code needs to be removed before merge.
No,
tag_kszpart probably is not acceptable. Do you see solution better than just copying it intotag_ksz1file?
You could have all Micrel tag implementations live under net/dsa/tag_ksz.c and have e.g: DSA_TAG_PROTO_KSZ for the current (newer) switches and DSA_TAG_PROTO_KSZ_LEGACY (or any other name) for the older switches and you would provide two sets of function pointers depending on which protocol is requested by the switch.
Considering the minor difference needed in tagging here, it might be acceptable to actually keep the current functions and just have the xmit() call check what get_tag_protocol returns and use word 1 or 0 based on that. Even though that's a fast path it shouldn't hurt performance too much. If it does, we can always copy the tagging protocol into dsa_slave_priv so you have a fast access to it.
Quoted 2 lines
Any more comments, etc?
The MII emulation bits are interesting, was it not sufficient if you implemented phy_read and phy_write operations that perform the necessary internal PHY accesses or maybe you don't get access to standard MII registers? b53 does such a thing and we merely just need to do a simple shift to access the MII register number, thus avoiding the translation.
Quoted 2 lines
Help would be welcome.
I concur with Andrew, try to get a patch series, even an RFC one together so we can review things individually.
How functional is your driver so far? I'd say the basic stuff to get working: counters (debugging), link management (auto-negotiation, forced, etc.) and basic bridging: all ports separate by default and working port to port switching when brought together in a bridge. VLAN, FDB, MDB, other ethtool goodies can be added later on.
Signature · 1 line
Florian
Hi!
Quoted 7 lines
Quoted 2 lines
No,
tag_kszpart probably is not acceptable. Do you see solution better than just copying it intotag_ksz1file?You could have all Micrel tag implementations live under
net/dsa/tag_ksz.cand have e.g:DSA_TAG_PROTO_KSZfor the current (newer) switches andDSA_TAG_PROTO_KSZ_LEGACY(or any other name) for the older switches and you would provide two sets of function pointers depending on which protocol is requested by the switch.Considering the minor difference needed in tagging here, it might be acceptable to actually keep the current functions and just have the
xmit()call check whatget_tag_protocolreturns and use word 1 or 0 based on that. Even though that's a fast path it shouldn't hurt performance too much. If it does, we can always copy the tagging protocol intodsa_slave_privso you have a fast access to it.
Actually I believe I can do optimizer tricks to keep this zero-cost with clean code, if needed.
Quoted 5 lines
Quoted 2 lines
Any more comments, etc?
The MII emulation bits are interesting, was it not sufficient if you implemented
phy_readandphy_writeoperations that perform the necessary internal PHY accesses or maybe you don't get access to standard MII registers? b53 does such a thing and we merely just need to do a simple shift to access the MII register number, thus avoiding the translation.
We don't get standard MII registers over SPI bus.
Quoted 6 lines
Quoted 1 line
Help would be welcome.
I concur with Andrew, try to get a patch series, even an RFC one together so we can review things individually.
How functional is your driver so far? I'd say the basic stuff to get working: counters (debugging), link management (auto-negotiation, forced, etc.) and basic bridging: all ports separate by default and working port to port switching when brought together in a bridge. VLAN, FDB, MDB, other ethtool goodies can be added later on.
Which counters are essential? Link management and basic bridging should work, not sure if I'll have time to do more than that.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[email protected]
maintainerPavel,
Thanks for update and sorry about email format (due to web-access version) I'll do review when getting back to office later this week.
- Woojung
________________________________________
From: Pavel Machek [[email protected]]
Sent: Sunday, August 27, 2017 8:36 AM
To: Woojung Huh - C21699; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] DSA support for Micrel KSZ8895
Hi!
So I fought with the driver a bit more, and now I have something that kind-of-works.
"great great hack" belows worries me.
Yeah, disabled code needs to be removed before merge.
No, tag_ksz part probably is not acceptable. Do you see solution better than just copying it into tag_ksz1 file?
Any more comments, etc?
Help would be welcome.
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Pavel-Machek/DSA-support-for-Micrel-KSZ8895/20170829-220156 config: xtensa-allmodconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 4.9.0…
Hi Pavel,
[auto build test ERROR on net-next/master]
[also build test ERROR on v4.13-rc7 next-20170829]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Pavel-Machek/DSA-support-for-Micrel-KSZ8895/20170829-220156
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-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=xtensa
All error/warnings (new ones prefixed by >>):
In file included from drivers/net/dsa/microchip/ksz_common.c:31:0:
>> drivers/net/dsa/microchip/ksz_9477_reg.h:19:2: error: #error This is not switch we have
#error This is not switch we have
^
--
drivers/net/dsa/microchip/ksz_8895.c: In function 'ksz_reset_switch':
drivers/net/dsa/microchip/ksz_8895.c:109:21: warning: unused variable 'dev' [-Wunused-variable]
struct ksz_device *dev = ds->priv;
^
drivers/net/dsa/microchip/ksz_8895.c: In function 'ksz_br_join':
drivers/net/dsa/microchip/ksz_8895.c:262:21: warning: unused variable 'dev' [-Wunused-variable]
struct ksz_device *dev = ds->priv;
^
drivers/net/dsa/microchip/ksz_8895.c: In function 'ksz_br_leave':
drivers/net/dsa/microchip/ksz_8895.c:270:21: warning: unused variable 'dev' [-Wunused-variable]
struct ksz_device *dev = ds->priv;
^
drivers/net/dsa/microchip/ksz_8895.c: At top level:
>> drivers/net/dsa/microchip/ksz_8895.c:469:12: warning: 'struct switchdev_obj_port_fdb' declared inside parameter list
struct switchdev_trans *trans)
^
>> drivers/net/dsa/microchip/ksz_8895.c:469:12: warning: its scope is only this definition or declaration, which is probably not what you want
drivers/net/dsa/microchip/ksz_8895.c:497:16: warning: 'struct switchdev_obj_port_fdb' declared inside parameter list
struct switchdev_trans *trans)
^
drivers/net/dsa/microchip/ksz_8895.c:503:21: warning: 'struct switchdev_obj_port_fdb' declared inside parameter list
const struct switchdev_obj_port_fdb *fdb)
^
drivers/net/dsa/microchip/ksz_8895.c:510:9: warning: 'struct switchdev_obj_port_fdb' declared inside parameter list
switchdev_obj_dump_cb_t *cb)
^
>> drivers/net/dsa/microchip/ksz_8895.c:576:2: error: unknown field 'port_vlan_dump' specified in initializer
.port_vlan_dump = ksz_port_vlan_dump,
^
>> drivers/net/dsa/microchip/ksz_8895.c:576:2: warning: initialization from incompatible pointer type
drivers/net/dsa/microchip/ksz_8895.c:576:2: warning: (near initialization for 'ksz_switch_ops.port_fdb_add')
>> drivers/net/dsa/microchip/ksz_8895.c:577:2: error: unknown field 'port_fdb_prepare' specified in initializer
.port_fdb_prepare = ksz_port_fdb_prepare,
^
drivers/net/dsa/microchip/ksz_8895.c:577:2: warning: initialization from incompatible pointer type
drivers/net/dsa/microchip/ksz_8895.c:577:2: warning: (near initialization for 'ksz_switch_ops.port_fdb_del')
drivers/net/dsa/microchip/ksz_8895.c:578:2: warning: initialization from incompatible pointer type
.port_fdb_dump = ksz_port_fdb_dump,
^
drivers/net/dsa/microchip/ksz_8895.c:578:2: warning: (near initialization for 'ksz_switch_ops.port_fdb_dump')
drivers/net/dsa/microchip/ksz_8895.c:579:2: warning: initialization from incompatible pointer type
.port_fdb_add = ksz_port_fdb_add,
^
drivers/net/dsa/microchip/ksz_8895.c:579:2: warning: (near initialization for 'ksz_switch_ops.port_fdb_add')
drivers/net/dsa/microchip/ksz_8895.c:580:2: warning: initialization from incompatible pointer type
.port_fdb_del = ksz_port_fdb_del,
^
drivers/net/dsa/microchip/ksz_8895.c:580:2: warning: (near initialization for 'ksz_switch_ops.port_fdb_del')
>> drivers/net/dsa/microchip/ksz_8895.c:584:2: error: unknown field 'port_mdb_dump' specified in initializer .port_mdb_dump = ksz_port_mdb_dump,
^
drivers/net/dsa/microchip/ksz_8895.c:584:2: warning: initialization from incompatible pointer type drivers/net/dsa/microchip/ksz_8895.c:584:2: warning: (near initialization for 'ksz_switch_ops.get_rxnfc')
vim +19 drivers/net/dsa/microchip/ksz_9477_reg.h
> 19 #error This is not switch we have
20 #ifndef __KSZ9477_REGS_H
21 #define __KSZ9477_REGS_H
22 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi!
Quoted 8 lines
Quoted 8 lines
I've got hardware with KSZ8895, and I'd like to use switch ports as separate ethernet cards. I believe that means DSA support.
And there are even patches available from microchip... unfortunately they are in strange form and for v3.18.
http://www.microchip.com/SWLibraryWeb/product.aspx?product=KSZ8895%20Software%20Linux%203.18
Quoted 7 lines
Quoted 2 lines
Is there newer version of the driver available somewhere? Is the driver good starting point, or should I start with something else?
Hi Pavel
Woojung is the expert here. His DSA driver for the 9477 is a nice clean driver.
Good.
Quoted 2 lines
Have you compared the 8895 to the 9477. Are they similar? Could the existing 9477 be extended to support the 8895?
Register layouts are completely different, at the very least. I'm not sure if functionality maps 1:1, that was not exactly easy to check.
I've ported the v3.18 driver to v4.4; it looks like v4.5 port will not be easy. Plus question is if it works at all... time will tell.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html