2022-08-30 11:15:23

by Arun Ramadoss

[permalink] [raw]
Subject: [RFC Patch net-next v3 2/3] net: dsa: microchip: add reference to ksz_device inside the ksz_port

struct ksz_port doesn't have reference to ksz_device as of now. In order
to find out from which port interrupt has triggered, we need to pass the
struct ksz_port as a host data. When the interrupt is triggered, we can
get the port from which interrupt triggered, but to identify it is phy
interrupt we have to read status register. The regmap structure for
accessing the device register is present in the ksz_device struct. To
access the ksz_device from the ksz_port, the reference is added to it
with port number as well.

Signed-off-by: Arun Ramadoss <[email protected]>
---
drivers/net/dsa/microchip/ksz_common.c | 3 +++
drivers/net/dsa/microchip/ksz_common.h | 4 ++++
2 files changed, 7 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index da9bdf753f7a..8714a20da0e7 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1917,6 +1917,9 @@ int ksz_switch_register(struct ksz_device *dev)
GFP_KERNEL);
if (!dev->ports[i].mib.counters)
return -ENOMEM;
+
+ dev->ports[i].ksz_dev = dev;
+ dev->ports[i].num = i;
}

/* set the real number of ports */
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 0d9520dc6d2d..c675a58ef298 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -16,6 +16,8 @@

#define KSZ_MAX_NUM_PORTS 8

+struct ksz_device;
+
struct vlan_table {
u32 table[3];
};
@@ -82,6 +84,8 @@ struct ksz_port {
u16 max_frame;
u32 rgmii_tx_val;
u32 rgmii_rx_val;
+ struct ksz_device *ksz_dev;
+ u8 num;
};

struct ksz_device {
--
2.36.1


2022-08-30 12:55:30

by Andrew Lunn

[permalink] [raw]
Subject: Re: [RFC Patch net-next v3 2/3] net: dsa: microchip: add reference to ksz_device inside the ksz_port

On Tue, Aug 30, 2022 at 04:23:02PM +0530, Arun Ramadoss wrote:
> struct ksz_port doesn't have reference to ksz_device as of now. In order
> to find out from which port interrupt has triggered, we need to pass the
> struct ksz_port as a host data. When the interrupt is triggered, we can
> get the port from which interrupt triggered, but to identify it is phy
> interrupt we have to read status register. The regmap structure for
> accessing the device register is present in the ksz_device struct. To
> access the ksz_device from the ksz_port, the reference is added to it
> with port number as well.
>
> Signed-off-by: Arun Ramadoss <[email protected]>

Reviewed-by: Andrew Lunn <[email protected]>

Andrew