RE: [PATCH v5 4/6] net: dsa: microchip: ksz8795: add support for ksz88xx chips

2020-12-16 Thread Tristram.Ha
> static void ksz8_r_vlan_table(struct ksz_device *dev, u16 vid, u32 *vlan) > { > - int index; > - u16 *data; > - u16 addr; > + u16 addr = vid / dev->phy_port_cnt; > u64 buf; > > - data = (u16 *)&buf; > - addr = vid / dev->phy_port_cnt; > - index

RE: [PATCH v5 3/6] net: dsa: microchip: ksz8795: move register offsets and shifts to separate struct

2020-12-07 Thread Tristram.Ha
> In order to get this driver used with other switches the functions need > to use different offsets and register shifts. This patch changes the > direct use of the register defines to register description structures, > which can be set depending on the chips register layout. > > Signed-off-by: Mi

RE: [PATCH net-next v3 00/12] net: dsa: microchip: PTP support for KSZ956x

2020-11-30 Thread Tristram.Ha
> Hi Microchip, > > as ACL based blocking of PTP traffic seems not to work, I tried to install MAC > based static lookup rules on the switch I successfully managed to block other > non-PTP traffic, but for PTP the lookup table entry (see below) seems not to > work. Incoming SYNC messages on port a

RE: [PATCH net-next v3 00/12] net: dsa: microchip: PTP support for KSZ956x

2020-11-19 Thread Tristram.Ha
> On Thursday, 19 November 2020, 00:40:18 CET, Vladimir Oltean wrote: > > On Wed, Nov 18, 2020 at 09:30:01PM +0100, Christian Eggers wrote: > > > This series adds support for PTP to the KSZ956x and KSZ9477 devices. > > > > > > There is only little documentation for PTP available on the data sheet >

RE: [PATCH 08/11] net: dsa: microchip: ksz8795: align port_cnt usage with other microchip drivers

2020-11-19 Thread Tristram.Ha
> On Wed, Nov 18, 2020 at 11:03:54PM +0100, Michael Grzeschik wrote: > > The ksz8795 driver is using port_cnt differently to the other microchip > > DSA drivers. It sets it to the external physical port count, than the > > whole port count (including the cpu port). This patch is aligning the > > va

RE: [PATCH v1 net-next 3/3] net: dsa: microchip: add KSZ9893 switch support

2019-03-04 Thread Tristram.Ha
> > static int ksz9477_phy_read16(struct dsa_switch *ds, int addr, int reg) > > @@ -389,6 +399,10 @@ static int ksz9477_phy_write16(struct dsa_switch > *ds, int addr, int reg, > > /* No real PHY after this. */ > > if (addr >= dev->phy_port_cnt) > > return 0; > > + > > + /* No

[PATCH v1 net-next 0/3] net: dsa: microchip: add KSZ9893 switch support

2019-02-28 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to support running KSZ9893 switch. The KSZ9893 switch is similar to KSZ9477 except the ingress tail tag has 1 byte instead of 2 bytes. The XMII register that governs the MAC communication also has different register de

[PATCH v1 net-next 3/3] net: dsa: microchip: add KSZ9893 switch support

2019-02-28 Thread Tristram.Ha
From: Tristram Ha Add KSZ9893 switch support in KSZ9477 driver. This switch is similar to KSZ9477 except the ingress tail tag has 1 byte instead of 2 bytes, so KSZ9893 tagging will be used. The XMII register that governs how the host port communicates with the MAC also has different register de

[PATCH v1 net-next 2/3] net: dsa: add KSZ9893 switch tagging support

2019-02-28 Thread Tristram.Ha
From: Tristram Ha KSZ9893 switch is similar to KSZ9477 switch except the ingress tail tag has 1 byte instead of 2 bytes. The size of the portmap is smaller and so the override and lookup bits are also moved. Signed-off-by: Tristram Ha --- include/net/dsa.h | 1 + net/dsa/dsa.c | 2 ++

[PATCH v1 net-next 1/3] dt-bindings: net: dsa: document additional Microchip KSZ9477 family switches

2019-02-28 Thread Tristram.Ha
From: Tristram Ha Document additional Microchip KSZ9477 family switches. Show how KSZ8565 switch should be configured as the host port is port 7 instead of port 5. Signed-off-by: Tristram Ha --- Documentation/devicetree/bindings/net/dsa/ksz.txt | 43 +++ 1 file changed, 43

[PATCH net-next 1/3] dt-bindings: net: dsa: document additional Microchip KSZ9477 family switches

2019-02-26 Thread Tristram.Ha
From: Tristram Ha Document additional Microchip KSZ9477 family switches. Show how KSZ8565 switch should be configured as the host port is port 7 instead of port 5. Signed-off-by: Tristram Ha --- Documentation/devicetree/bindings/net/dsa/ksz.txt | 43 +++ 1 file changed, 43

[PATCH net-next 2/3] net: dsa: microchip: add KSZ9893 switch support

2019-02-26 Thread Tristram.Ha
From: Tristram Ha Add KSZ9893 switch support in KSZ9477 driver. This switch is similar to KSZ9477 except the ingress tail tag has 1 byte instead of 2 bytes. The XMII register that governs how the host port communicates with the MAC also has different register definitions. Signed-off-by: Tristr

[PATCH net-next 3/3] net: dsa: microchip: add other KSZ9477 switch variants

2019-02-26 Thread Tristram.Ha
From: Tristram Ha Add other switches in KSZ9477 family. KSZ9896 is a switch with 6 ports; the last one is typically used to connect to MAC. KSZ9567 is same as KSZ9897 but with 1588 PTP capability. KSZ8567 is same as KSZ9567 but without gigabit capability. KSZ9563 is same as KSZ9893 but with 1588

[PATCH net-next 0/3] net: dsa: microchip: add KSZ9893 switch support

2019-02-26 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to support running KSZ9893 and other switches in the KSZ9477 family. The KSZ9893 switch is similar to KSZ9477 except the ingress tail tag has 1 byte instead of 2 bytes. The XMII register that governs the MAC communicat

[PATCH v4 net-next 0/4] net: dsa: microchip: add MIB counters support

2019-02-22 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to read MIB counters periodically to avoid overflow. The MIB counters should be read only when there is link. Otherwise it is a waste of time as hardware never increases the counters. Functions are added to check the

[PATCH v4 net-next 5/5] net: dsa: microchip: add port_cleanup function

2019-02-22 Thread Tristram.Ha
From: Tristram Ha Add port_cleanup function to reset some device variables when the port is disabled. Add a mutex to make sure changing those variables is thread-safe. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 6 ++ drivers/net/dsa/microchip/ksz_common.c | 2

[PATCH v4 net-next 1/5] net: dsa: microchip: prepare PHY for proper advertisement

2019-02-22 Thread Tristram.Ha
From: Tristram Ha Prepare PHY for proper advertisement as sometimes the PHY in the switch has its own problems even though it may share the PHY id from regular PHY but the fixes in the PHY driver do not apply. Signed-off-by: Tristram Ha Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli -

[PATCH v4 net-next 4/5] net: dsa: microchip: remove unnecessary include headers

2019-02-22 Thread Tristram.Ha
From: Tristram Ha Remove unnecessary header include. Signed-off-by: Tristram Ha Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz9477.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 1b8267c..b1b

[PATCH v4 net-next 3/5] net: dsa: microchip: get port link status

2019-02-22 Thread Tristram.Ha
From: Tristram Ha Get port link status to know whether to read MIB counters when the link is going down. Signed-off-by: Tristram Ha Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz9477.c| 1 + drivers/net/dsa/microchip/ksz_common.c | 14 ++ drivers/net/dsa/microchip

[PATCH v4 net-next 2/5] net: dsa: microchip: add MIB counter reading support

2019-02-22 Thread Tristram.Ha
From: Tristram Ha Add background MIB counter reading support. Port MIB counters should only be read when there is link. Otherwise it is a waste of time as hardware never increases those counters. There are exceptions as some switches keep track of dropped counts no matter what. Signed-off-by:

[PATCH v3 net-next 3/4] net: dsa: microchip: get port link status

2019-02-21 Thread Tristram.Ha
From: Tristram Ha Get port link status to know whether to read MIB counters when the link is going down. Add port_cleanup function to read MIB counters the last time as when the port is disabled the PHY is also powered down. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c

[PATCH v3 net-next 1/4] net: dsa: microchip: prepare PHY for proper advertisement

2019-02-21 Thread Tristram.Ha
From: Tristram Ha Prepare PHY for proper advertisement as sometimes the PHY in the switch has its own problems even though it may share the PHY id from regular PHY but the fixes in the PHY driver do not apply. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 13 +

[PATCH v3 net-next 0/4] net: dsa: microchip: add MIB counters support

2019-02-21 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to read MIB counters periodically to avoid overflow. The MIB counters should be read only when there is link. Otherwise it is a waste of time as hardware never increases the counters. Functions are added to check the

[PATCH v3 net-next 4/4] net: dsa: microchip: remove unnecessary include headers

2019-02-21 Thread Tristram.Ha
From: Tristram Ha Remove unnecessary header include. Signed-off-by: Tristram Ha Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz9477.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 6ad28e2..a94

[PATCH v3 net-next 2/4] net: dsa: microchip: add MIB counter reading support

2019-02-21 Thread Tristram.Ha
From: Tristram Ha Add background MIB counter reading support. Port MIB counters should only be read when there is link. Otherwise it is a waste of time as hardware never increases those counters. There are exceptions as some switches keep track of dropped counts no matter what. Signed-off-by:

[PATCH v2 net-next 2/4] net: dsa: microchip: add MIB counter reading support

2019-02-19 Thread Tristram.Ha
From: Tristram Ha Add background MIB counter reading support. Port MIB counters should only be read when there is link. Otherwise it is a waste of time as hardware never increases those counters. There are exceptions as some switches keep track of dropped counts no matter waht. Signed-off-by:

[PATCH v2 net-next 3/4] net: dsa: microchip: get port link status

2019-02-19 Thread Tristram.Ha
From: Tristram Ha Get port link status to know whether to read MIB counters when the link is going down. Add port_cleanup function to read MIB counters the last time as after the port is disabled the PHY is also powered down. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c

[PATCH v2 net-next 1/4] net: dsa: microchip: prepare PHY for proper advertisement

2019-02-19 Thread Tristram.Ha
From: Tristram Ha Prepare PHY for proper advertisement as sometimes the PHY in the switch has its own problems even though it may share the PHY id from regular PHY but the fixes in the PHY driver do not apply. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 13 +

[PATCH v2 net-next 4/4] net: dsa: microchip: remove unnecessary include headers

2019-02-19 Thread Tristram.Ha
From: Tristram Ha Remove unnecessary header include. Signed-off-by: Tristram Ha Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz9477.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 6ad28e2..a94

[PATCH v2 net-next 0/4] net: dsa: microchip: add MIB counters support

2019-02-19 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to read MIB counters periodically to avoid overflow. The MIB counters should be read only when there is link. Otherwise it is a waste of time as hardware never increases the counters. Functions are added to check the

RE: [PATCH v1 net-next 2/4] net: dsa: microchip: add MIB counter reading support

2019-02-14 Thread Tristram.Ha
> >> > +/* read only dropped counters when link is not up */ > >> > +if (p->link_just_down) > >> > +p->link_just_down = 0; > >> > +else if (!p->phydev.link) > >> > +mib->cnt_ptr = dev->reg_mib_cnt; > >>

RE: [PATCH v1 net-next 3/4] net: dsa: microchip: use readx_poll_time for polling

2019-02-12 Thread Tristram.Ha
> > -static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev, u32 > waiton, > > - int timeout) > > -{ > > - u8 data; > > - > > - do { > > - ksz_read8(dev, REG_SW_VLAN_CTRL, &data); > > - if (!(data & waiton)) > > - b

RE: [PATCH v1 net-next 2/4] net: dsa: microchip: add MIB counter reading support

2019-02-12 Thread Tristram.Ha
> > +static void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool > freeze) > > +{ > > + struct ksz_port *p = &dev->ports[port]; > > + u32 val = freeze ? MIB_COUNTER_FLUSH_FREEZE : 0; > > Reverse Christmas tree. There was a checkpatch.pl patch in 2016 that tried to check this, but it

[PATCH v1 net-next 4/4] net: dsa: microchip: remove unnecessary include headers

2019-02-07 Thread Tristram.Ha
From: Tristram Ha Remove unnecessary header include lines. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 8391b9e..7c51edd 100644 --- a/dr

[PATCH v1 net-next 3/4] net: dsa: microchip: use readx_poll_time for polling

2019-02-07 Thread Tristram.Ha
From: Tristram Ha Replace register polling functions using timeout with readx_poll_time call. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 91 +++-- 1 file changed, 27 insertions(+), 64 deletions(-) diff --git a/drivers/net/dsa/microchip

[PATCH v1 net-next 0/4] net: dsa: microchip: add MIB counters support

2019-02-07 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to read MIB counters periodically to avoid overflow. v1 - Use readx_poll_time - Do not clear MIB counters when port is enabled - Do not advertise 1000 half-duplex mode when port is enabled - Do not use freeze function a

[PATCH v1 net-next 2/4] net: dsa: microchip: add MIB counter reading support

2019-02-07 Thread Tristram.Ha
From: Tristram Ha Add MIB counter reading support. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 139 +++-- drivers/net/dsa/microchip/ksz_common.c | 96 +++ drivers/net/dsa/microchip/ksz_common.h | 2 + drivers/net/ds

[PATCH v1 net-next 1/4] net: dsa: microchip: prepare PHY for proper advertisement

2019-02-07 Thread Tristram.Ha
From: Tristram Ha Prepare PHY for proper advertisement and get link status for the port. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 17 - drivers/net/dsa/microchip/ksz_common.c | 19 ++- drivers/net/dsa/microchip/ksz_common.h | 4 ++

[PATCH net] net: dsa: microchip: add switch offload forwarding support

2019-02-07 Thread Tristram.Ha
From: Tristram Ha The flag offload_fwd_mark is set as the switch can forward frames by itself. This can be considered a fix to a problem introduced in commit c2e866911e254067 where the port membership are not set in sync. The flag offload_fwd_mark just needs to be set in tag_ksz.c to prevent th

RE: [PATCH RFC 1/4] net: dsa: microchip: convert KSZ9477 SPI driver to use regmap

2019-01-18 Thread Tristram.Ha
> > These extremely patches look similar to what I posted here before: > > > > https://patchwork.ozlabs.org/cover/1017222/ > > > > But the authorship has changed. Why ? > > There seems to be explanation in 0/4. > > Tristram: if you started from Marek's patches as you describe in 0/4, > you should

RE: [PATCH RFC v1] net: dsa: microchip: add KSZ9477 I2C driver

2019-01-18 Thread Tristram.Ha
> > +#define REG_SIZE 0x8000 > > + > > +#define I2C_REGMAP_VAL 8 > > +#define I2C_REGMAP_REG 16 > > + > > +#define KSZ_REGMAP_COMMON(n, width) > \ > > +{ \ > > +

[PATCH RFC v1] net: dsa: microchip: add KSZ9477 I2C driver

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Add KSZ9477 I2C driver support. The code ksz9477.c and ksz_common.c are used together to generate the I2C driver. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/Kconfig | 7 ++ drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz94

[PATCH RFC v1] net: dsa: microchip: add KSZ9477 I2C driver

2019-01-16 Thread Tristram.Ha
From: Tristram Ha This patch adds KSZ9477 I2C driver support using regmap mechanism. Previous patches converting KSZ9477 SPI driver to regmap have to be applied first. v1 - Regmap mechanism is used to simplify access code. Tristram Ha (1): net: dsa: microchip: add KSZ9477 I2C driver drivers

[PATCH RFC 0/4] Convert KSZ9477 SPI driver to use regmap

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Convert KSZ9477 SPI driver to use regmap mechanism so that an I2C driver can be easily added. Original regmap implementation was submitted by Marek Vasut. Modified and verified the implementation on real hardware. Tristram Ha (4): net: dsa: microchip: convert KSZ9477 SPI dr

[PATCH RFC 1/4] net: dsa: microchip: convert KSZ9477 SPI driver to use regmap

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Convert KSZ9477 SPI driver to use regmap mechanism so that an I2C driver can be easily added. KSZ9477 SPI driver uses a 32-bit SPI command containing a 24-bit address to access registers in 8-bit. The address is automatically increased to next register. In theory all register

[PATCH RFC 2/4] net: dsa: microchip: Use regmap_update_bits

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Use regmap_update_bits function for bit manipulation in 32-bit access. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 23 +++ 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/driver

[PATCH RFC 3/4] net: dsa: microchip: remove ksz9477_get_port_addr

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Remove ksz9477_get_port_addr as it is considered too slow and the macro PORT_CTRL_ADDR can be used directly. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 11 +-- drivers/net/dsa/microchip/ksz_priv.h | 1 - 2 files changed, 1 insertion(+), 11

[PATCH RFC 4/4] net: dsa: microchip: remove ksz_spi.h

2019-01-16 Thread Tristram.Ha
From: Tristram Ha Remove ksz_spi.h as it is not used anymore. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz_spi.h | 69 - 1 file changed, 69 deletions(-) delete mode 100644 drivers/net/dsa/microchip/ksz_spi.h diff --git a/drivers/net/dsa/mic

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2019-01-11 Thread Tristram.Ha
> OK, so there are clearly restrictions to what can be written and how. > It is hardware bug. You need to read those high PHY registers in 32-bit and modify them and write them back even though they are 16-bit. The regular low PHY registers are not affected. Another hardware bug with I2C acce

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2019-01-10 Thread Tristram.Ha
> On 1/10/19 3:10 AM, tristram...@microchip.com wrote: > >>> I just looked at your regmap code and you use 3 regmap pointers for > >> specific 8-bit, 16-bit, and 32-bit accesses. The switch access is always > >> 8-bit. > It > >> has automatic register increment so that you can access arbitrary le

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2019-01-09 Thread Tristram.Ha
> > I just looked at your regmap code and you use 3 regmap pointers for > specific 8-bit, 16-bit, and 32-bit accesses. The switch access is always > 8-bit. It > has automatic register increment so that you can access arbitrary length of > registers. The use of 16-bit and 32-bit accesses makes a

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2019-01-09 Thread Tristram.Ha
> This is the regmap_config I used in Linux 4.9: > > .reg_bits = SPI_REGMAP_REG, > .val_bits = SPI_REGMAP_VAL, > .pad_bits = SPI_REGMAP_PAD, > .read_flag_mask = KS_SPIOP_RD << SPI_REGMAP_MASK_S, > .write_flag_mask= KS_

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2019-01-09 Thread Tristram.Ha
> >>> + { \ > >>> + .val_bits = (width),\ > >>> + .reg_stride = (width) / 8, \ > >>> + .reg_bits = (regbits) + (regalign), \ > >

RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap config generation into common header

2018-12-20 Thread Tristram.Ha
> + { \ > + .val_bits = (width),\ > + .reg_stride = (width) / 8, \ > + .reg_bits = (regbits) + (regalign), \ > +

RE: [RFT][PATCH 6/7] net: dsa: microchip: Initial SPI regmap support

2018-12-20 Thread Tristram.Ha
> +static const struct regmap_config ksz9477_regmap_config = { > + .reg_bits = 32, > + .val_bits = 8, > + .max_register = 0x100, > + .cache_type = REGCACHE_RBTREE, > + .read_flag_mask = KS_SPIOP_RD << SPI_ADDR_SHIFT, > + .write_flag_mask = KS_SPIOP_WR << SPI_ADDR_SHIFT, > +

RE: [RFT][PATCH 4/7] net: dsa: microchip: Remove dev->txbuf

2018-12-20 Thread Tristram.Ha
> On 12/20/2018 10:41 AM, Andrew Lunn wrote: > > On Wed, Dec 19, 2018 at 05:20:33PM -0800, Florian Fainelli wrote: > >> On 12/19/18 5:06 PM, Marek Vasut wrote: > >>> Previous patches unconver that ksz_spi_write() is always ever called > >>> with len = 1, 2 or 4. We can thus drop the if (len > SPI_T

RE: [PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-20 Thread Tristram.Ha
> >> Well, I just did 'git grep regmap_i2c drivers' and 'git grep regmap_spi > >> drivers/' and found eg. > >> drivers/iio/pressure/zpa2326_i2c.c > >> drivers/iio/pressure/zpa2326_spi.c > >> > >> There's plenty of drivers using regmap in drivers/ to demonstrate how to > >> use it. And there's alway

[PATCH v1 net] net: dsa: microchip: fix unicast frame leak

2018-12-19 Thread Tristram.Ha
From: Tristram Ha Port partitioning is done by enabling UNICAST_VLAN_BOUNDARY and changing the default port membership of 0x7f to other values such that there is no communication between ports. In KSZ9477 the member for port 1 is 0x41; port 2, 0x42; port 3, 0x44; port 4, 0x48; port 5, 0x50; and

RE: [PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-19 Thread Tristram.Ha
> Is there any specific reason that ksz_i2c_read24 & ksz_i2c_write24 in > ksz9477_i2c.c > but, other functions are in ksz_i2c.h? > There are specific registers in KSZ9477 such that using 24-bit is more efficient than reading 32-bit first and writing 32-bit. The other older switches mostly use

RE: [PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-19 Thread Tristram.Ha
> This header file makes no sense. Please move the functions into .c > >>> > >>> No, that would make code bigger & slower. > >>> > >>> It makes sense to me. But I'd add "inline" keyword to make the goal > >>> explicit. > >> > >> 1) It makes no sense to have header files for things like this. T

RE: [PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-19 Thread Tristram.Ha
> Can this use regmap instead ? > To tell the truth I do not know how. Some customers, like Sergio, seem to be using KSZ9897 with I2C in their projects and so cannot wait further.

[PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-18 Thread Tristram.Ha
From: Tristram Ha Add KSZ9477 I2C driver support. The code ksz9477.c and ksz_common.c are used together to generate the I2C driver. Signed-off-by: Tristram Ha --- v1 - Return error code from i2c_transfer - Change GPL license - Change author drivers/net/dsa/microchip/Kconfig | 6 + dr

RE: [PATCH RFC net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-17 Thread Tristram.Ha
Sorry about the patch. I know you were using the code from the new SPI and old I2C drivers to come up with your patch. You can incorporate the changes and test the driver and re-submit the patch if you want. Your i2c_probe function displays an error message when ksz9477_switch_register is not

[PATCH net-next] net: dsa: microchip: fix VLAN filtering operation

2018-12-17 Thread Tristram.Ha
From: Tristram Ha Fix VLAN filtering operation in kernel 4.15 and later. Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 44 ++--- 1 file changed, 36 insertions(+),

[PATCH RFC net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-17 Thread Tristram.Ha
From: Tristram Ha Add KSZ9477 I2C driver support. The code ksz9477.c and ksz_common.c are used together to generate the I2C driver. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/Kconfig | 6 + drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz947

[PATCH RFC net-next] net: dsa: microchip: add KSZ9477 I2C driver

2018-12-17 Thread Tristram.Ha
From: Tristram Ha This patch adds KSZ9477 I2C driver support. I know a patch for KSZ9477 I2C driver was already submitted. There is a minor problem though. The structure and code of the I2C driver should match those in the SPI driver. The only difference is the register access. Accordingly t

RE: [PATCH RFC 5/6] net: dsa: microchip: Update tag_ksz.c to access switch driver

2018-12-11 Thread Tristram.Ha
> I'd be careful about locking. Seems like dsa was designed with "tag > format is static", and you want to change it dynamically... I see there is now a new overhead parameter in the dsa_device_ops structure and dev_set_mtu is called in master.c. It does not prevent the tag size to change dynamic

RE: [PATCH] net: dsa: ksz: Increase the tag alignment

2018-12-10 Thread Tristram.Ha
> I am not looking for a hack-around, I am looking for a proper solution. > As you have the hardware you can try something to correct the problem. The change was introduced in commit 9421c9015047 on Nov 15. In the net-next tree it is about -42 commits. git log -42 cpsw.c git diff f5b589488ea5

RE: [PATCH 3/5] net: dsa: ksz: Factor out common tag code

2018-12-10 Thread Tristram.Ha
> On Fri, Dec 07, 2018 at 07:18:43PM +0100, Marek Vasut wrote: > > From: Tristram Ha > > > > Factor out common code from the tag_ksz , so that the code can be used > > with other KSZ family switches which use differenly sized tags. > > I prefer this implementation over what Tristram recently subm

RE: [PATCH] net: dsa: ksz: Increase the tag alignment

2018-12-10 Thread Tristram.Ha
> -padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; > +padlen = (skb->len >= VLAN_ETH_ZLEN) ? 0 : VLAN_ETH_ZLEN - skb- > > len; > > Oh so they add the internal VLAN at the end of the frame, not the > > beginning? That is quite surprising but that would not be

RE: [PATCH] net: dsa: ksz: Increase the tag alignment

2018-12-07 Thread Tristram.Ha
> - padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; > + padlen = (skb->len >= VLAN_ETH_ZLEN) ? 0 : VLAN_ETH_ZLEN - skb- > >len; The requirement is the tail tag should be at the end of frame before FCS. When the length is less than 60 the MAC controller will pad the frame to lega

RE: [PATCH] net: dsa: ksz: Fix port membership

2018-12-07 Thread Tristram.Ha
> Do you have a git tree with all the KSZ patches based on -next > somewhere, so I don't have to look for them in random MLs ? I just sent it this Monday and the subject for that patch is "[PATCH RFC 6/6] net: dsa: microchip: Add switch offload forwarding support."

RE: [PATCH] net: dsa: ksz: Fix port membership

2018-12-07 Thread Tristram.Ha
> > I think if you do this without setting offload_fwd_mark you will > > receive duplicate frame. > > I don't think it will, at least not in the normal case. The hardware > should know the egress port, so there is no need to forward a copy to > the CPU. The only time it should forward to the CPU i

RE: [PATCH] net: dsa: ksz: Fix port membership

2018-12-07 Thread Tristram.Ha
> >> If two ports are in the same bridge and in forwarding state, the packets > >> must be able to pass between them in both directions. The current code > >> only configures this bridge membership for a port newly added to the > >> bridge, but does not update all the other ports. Thus, ingress pac

RE: [PATCH] net: dsa: ksz: Fix port membership

2018-12-07 Thread Tristram.Ha
> If two ports are in the same bridge and in forwarding state, the packets > must be able to pass between them in both directions. The current code > only configures this bridge membership for a port newly added to the > bridge, but does not update all the other ports. Thus, ingress packets > on th

RE: [PATCH RFC 1/6] net: dsa: microchip: Prepare PHY for proper advertisement

2018-12-06 Thread Tristram.Ha
> > +static void ksz9477_phy_setup(struct ksz_device *dev, int port, > > + struct phy_device *phy) > > +{ > > + if (port < dev->phy_port_cnt) { > > + /* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be > removed to > > +* disable flow control when rate

RE: [PATCH RFC 2/6] net: dsa: microchip: Add MIB counter reading support

2018-12-06 Thread Tristram.Ha
> > +static void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, > > + u64 *cnt) > > +{ > > + u32 data; > > + int timeout; > > + struct ksz_port *p = &dev->ports[port]; > > + > > + /* retain the flush/freeze bit */ > > + data = p->freeze ? MIB_COUNTER

RE: [PATCH RFC 5/6] net: dsa: microchip: Update tag_ksz.c to access switch driver

2018-12-06 Thread Tristram.Ha
> >>> Update tag_ksz.c to access switch driver's tail tagging operations. > >> > >> Hi Tristram > >> > >> Humm, i'm not sure we want this, the tagging spit into two places. I > >> need to take a closer look at the previous patch, to see why it cannot > >> be done here. > > > > O.K, i think i get w

[PATCH RFC 2/6] net: dsa: microchip: Add MIB counter reading support

2018-12-03 Thread Tristram.Ha
From: Tristram Ha Add MIB counter reading support. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh --- drivers/net/dsa/microchip/ksz9477.c| 121 ++--- drivers/net/dsa/microchip/ksz_common.c | 101 +++ drivers/net/dsa/microchip/ksz_co

[PATCH RFC 5/6] net: dsa: microchip: Update tag_ksz.c to access switch driver

2018-12-03 Thread Tristram.Ha
From: Tristram Ha Update tag_ksz.c to access switch driver's tail tagging operations. Signed-off-by: Tristram Ha --- net/dsa/tag_ksz.c | 44 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index

[PATCH RFC 6/6] net: dsa: microchip: Add switch offload forwarding support

2018-12-03 Thread Tristram.Ha
From: Tristram Ha The flag offload_fwd_mark is set as the switch can forward frames by itself. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c | 7 --- net/dsa/tag_ksz.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/

[PATCH RFC 3/6] net: dsa: microchip: Break ksz_priv.h into two files

2018-12-03 Thread Tristram.Ha
From: Tristram Ha Break ksz_priv.h into two files: private and public. The public one is put in include/linux/dsa/ksz_dsa.h. This allows the tail tagging code tag_ksz.c to access the switch driver as the tail tag format can be different when certain switch functions are enabled. Signed-off-by:

[PATCH RFC 4/6] net: dsa: microchip: Each switch driver has its own tail tagging operations

2018-12-03 Thread Tristram.Ha
From: Tristram Ha The tail tagging operations are implemented in each switch driver so that the main tail tagging code tag_ksz.c does not need to be changed after modification to support that mechanism is made. Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz9477.c| 78

[PATCH RFC 0/6] net: dsa: microchip: Modify KSZ9477 DSA driver to support different tail tag formats

2018-12-03 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the KSZ9477 DSA driver to support different tail tag formats such that other new KSZ switch drivers can be added without changing the base tail tagging code. Tristram Ha (6): net: dsa: microchip: Prepare PHY for proper advertisement net:

[PATCH RFC 1/6] net: dsa: microchip: Prepare PHY for proper advertisement

2018-12-03 Thread Tristram.Ha
From: Tristram Ha Prepare PHY for proper advertisement and get link status for the port. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh --- drivers/net/dsa/microchip/ksz9477.c| 12 drivers/net/dsa/microchip/ksz_common.c | 17 + drivers/net/dsa/microchip/k

RE: [PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA driver into two files

2018-12-03 Thread Tristram.Ha
> From: Sørensen, Stefan > Sent: Monday, December 03, 2018 5:50 AM > To: da...@davemloft.net; Tristram Ha - C24268 > > Cc: netdev@vger.kernel.org; pa...@ucw.cz; f.faine...@gmail.com; > UNGLinuxDriver ; and...@lunn.ch > Subject: Re: [PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA >

RE: [PATCH v1 net] lan743x: fix return value for lan743x_tx_napi_poll

2018-11-20 Thread Tristram.Ha
Slightly out of topic I am not sure why NAPI is used on the transmit side. Originally NAPI was designed to fix the receive interrupt happening on each receive frame problem, so on transmit side it is to avoid the transmit done interrupt on each transmit frame? Typically hardware has a way to trigg

[PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA driver into two files

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Break KSZ9477 DSA driver into two files in preparation to add more KSZ switch drivers. Add common functions in ksz_common.h so that other KSZ switch drivers can access code in ksz_common.c. Add ksz_spi.h for common functions used by KSZ switch SPI drivers. Signed-off-by: Tristr

[PATCH v4 net-next 2/6] net: dsa: microchip: clean up code

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Clean up code according to patch check suggestions. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh Reviewed-by: Pavel Machek Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz_common.c | 8 1 file changed, 4 insertions(+

[PATCH v4 net-next 3/6] net: dsa: microchip: rename some functions with ksz9477 prefix

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Rename some functions with ksz9477 prefix to separate chip specific code from common code. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh Reviewed-by: Pavel Machek Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz_common.c | 116

[PATCH v4 net-next 0/6] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers

2018-11-20 Thread Tristram.Ha
From: Tristram Ha This series of patches is to modify the original KSZ9477 DSA driver so that other KSZ switch drivers can be added and use the common code. There are several steps to accomplish this achievement. First is to rename some function names with a prefix to indicate chip specific fun

[PATCH v4 net-next 4/6] net: dsa: microchip: rename ksz_spi.c to ksz9477_spi.c

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Rename ksz_spi.c to ksz9477_spi.c and update Kconfig in preparation to add more KSZ switch drivers. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh Reviewed-by: Pavel Machek Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/Kconfig

[PATCH v4 net-next 6/6] net: dsa: microchip: rename ksz_9477_reg.h to ksz9477_reg.h

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product name is always KSZ. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz9477.c | 2 +- drivers/net/dsa/microchip/{ksz_

[PATCH v4 net-next 1/6] net: dsa: microchip: replace license with GPL

2018-11-20 Thread Tristram.Ha
From: Tristram Ha Replace license with GPL. Signed-off-by: Tristram Ha Reviewed-by: Woojung Huh Reviewed-by: Andrew Lunn Acked-by: Pavel Machek --- drivers/net/dsa/microchip/ksz_9477_reg.h | 17 +++-- drivers/net/dsa/microchip/ksz_common.c | 15 ++- drivers/net/dsa

[PATCH v2 net] net: dsa: microchip: initialize mutex before use

2018-11-02 Thread Tristram.Ha
From: Tristram Ha Initialize mutex before use. Avoid kernel complaint when CONFIG_DEBUG_LOCK_ALLOC is enabled. Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Tristram Ha Reviewed-by: Pavel Machek Reviewed-by: Andrew Lunn Reviewed-by: Florian Faine

[PATCH v2 net] net: dsa: microchip: initialize mutex before use

2018-11-01 Thread Tristram.Ha
From: Tristram Ha Initialize mutex before use. Avoid kernel complaint when CONFIG_DEBUG_LOCK_ALLOC is enabled. Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Tristram Ha Reviewed-by: Pavel Machek Reviewed-by: Andrew Lunn --- v2 - Add endorsements

[PATCH v1 net] net: dsa: microchip: initialize mutex before use

2018-10-31 Thread Tristram.Ha
From: Tristram Ha Initialize mutex before use. Avoid kernel complaint when CONFIG_DEBUG_LOCK_ALLOC is enabled. Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Tristram Ha --- v1 - Remove comment drivers/net/dsa/microchip/ksz_common.c | 10 +

[PATCH net] net: dsa: microchip: initialize mutex before use

2018-10-30 Thread Tristram.Ha
From: Tristram Ha Initialize mutex before use. Avoid kernel complaint when CONFIG_DEBUG_LOCK_ALLOC is enabled. Fixes: b987e98e50ab90e5 ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Tristram Ha --- drivers/net/dsa/microchip/ksz_common.c | 11 ++- 1 file changed, 6

RE: [PATCH net] net: ethernet: cadence: fix socket buffer corruption problem

2018-10-30 Thread Tristram.Ha
> Could you check on your side that applying this on top of your patch, your > scenario is still working? > > diff --git a/drivers/net/ethernet/cadence/macb_main.c > b/drivers/net/ethernet/cadence/macb_main.c > index 1d86b4d5645a..e1347d6d1b50 100644 > --- a/drivers/net/ethernet/cadence/macb_main.

RE: [PATCH net] net: ethernet: cadence: fix socket buffer corruption problem

2018-10-29 Thread Tristram.Ha
> Could you, please, tell me if the above variable was false in your case? > > bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb); > > If yes, then, the proper fix would be as follows: > > diff --git a/drivers/net/ethernet/cadence/macb_main.c > b/drivers/net/ethernet/cadence/macb_main.c >

  1   2   3   >