summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/microchip/ksz8795.c
diff options
context:
space:
mode:
authorArun Ramadoss <arun.ramadoss@microchip.com>2022-06-17 14:12:54 +0530
committerPaolo Abeni <pabeni@redhat.com>2022-06-21 15:26:45 +0200
commite587be759e6e4f5a257d1f2bd7f2883a6397a6e8 (patch)
tree1706bcada6a8e1948ff2508e7d97deb2a0027562 /drivers/net/dsa/microchip/ksz8795.c
parent980c7d171d3a6e777715ca968f97090448d6ff1d (diff)
net: dsa: microchip: update fdb add/del/dump in ksz_common
This patch makes the dsa_switch_hook for fdbs to use ksz_common.c file. And from ksz_common, individual switches fdb functions are called using the dev->dev_ops. And removed the r_dyn_mac_table, r_sta_mac_table and w_sta_mac_table from ksz_dev_ops as it is used only in ksz8795.c Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/dsa/microchip/ksz8795.c')
-rw-r--r--drivers/net/dsa/microchip/ksz8795.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 7ebed00777b9..2f93b921b45e 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -953,6 +953,34 @@ static void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)
}
}
+static int ksz8_fdb_dump(struct ksz_device *dev, int port,
+ dsa_fdb_dump_cb_t *cb, void *data)
+{
+ int ret = 0;
+ u16 i = 0;
+ u16 entries = 0;
+ u8 timestamp = 0;
+ u8 fid;
+ u8 member;
+ struct alu_struct alu;
+
+ do {
+ alu.is_static = false;
+ ret = ksz8_r_dyn_mac_table(dev, i, alu.mac, &fid, &member,
+ &timestamp, &entries);
+ if (!ret && (member & BIT(port))) {
+ ret = cb(alu.mac, alu.fid, alu.is_static, data);
+ if (ret)
+ break;
+ }
+ i++;
+ } while (i < entries);
+ if (i >= entries)
+ ret = 0;
+
+ return ret;
+}
+
static int ksz8_mdb_add(struct ksz_device *dev, int port,
const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db)
@@ -963,7 +991,7 @@ static int ksz8_mdb_add(struct ksz_device *dev, int port,
alu.port_forward = 0;
for (index = 0; index < dev->info->num_statics; index++) {
- if (!dev->dev_ops->r_sta_mac_table(dev, index, &alu)) {
+ if (!ksz8_r_sta_mac_table(dev, index, &alu)) {
/* Found one already in static MAC table. */
if (!memcmp(alu.mac, mdb->addr, ETH_ALEN) &&
alu.fid == mdb->vid)
@@ -992,7 +1020,7 @@ static int ksz8_mdb_add(struct ksz_device *dev, int port,
/* Need a way to map VID to FID. */
alu.fid = mdb->vid;
}
- dev->dev_ops->w_sta_mac_table(dev, index, &alu);
+ ksz8_w_sta_mac_table(dev, index, &alu);
return 0;
}
@@ -1005,7 +1033,7 @@ static int ksz8_mdb_del(struct ksz_device *dev, int port,
int index;
for (index = 0; index < dev->info->num_statics; index++) {
- if (!dev->dev_ops->r_sta_mac_table(dev, index, &alu)) {
+ if (!ksz8_r_sta_mac_table(dev, index, &alu)) {
/* Found one already in static MAC table. */
if (!memcmp(alu.mac, mdb->addr, ETH_ALEN) &&
alu.fid == mdb->vid)
@@ -1021,7 +1049,7 @@ static int ksz8_mdb_del(struct ksz_device *dev, int port,
alu.port_forward &= ~BIT(port);
if (!alu.port_forward)
alu.is_static = false;
- dev->dev_ops->w_sta_mac_table(dev, index, &alu);
+ ksz8_w_sta_mac_table(dev, index, &alu);
exit:
return 0;
@@ -1516,13 +1544,11 @@ static const struct ksz_dev_ops ksz8_dev_ops = {
.port_setup = ksz8_port_setup,
.r_phy = ksz8_r_phy,
.w_phy = ksz8_w_phy,
- .r_dyn_mac_table = ksz8_r_dyn_mac_table,
- .r_sta_mac_table = ksz8_r_sta_mac_table,
- .w_sta_mac_table = ksz8_w_sta_mac_table,
.r_mib_cnt = ksz8_r_mib_cnt,
.r_mib_pkt = ksz8_r_mib_pkt,
.freeze_mib = ksz8_freeze_mib,
.port_init_cnt = ksz8_port_init_cnt,
+ .fdb_dump = ksz8_fdb_dump,
.mdb_add = ksz8_mdb_add,
.mdb_del = ksz8_mdb_del,
.vlan_filtering = ksz8_port_vlan_filtering,