OSDN Git Service

net: dsa: Remove prepare phase for FDB
[uclinux-h8/linux.git] / drivers / net / dsa / microchip / ksz_common.c
index b313ecd..b55f364 100644 (file)
@@ -678,15 +678,6 @@ static int ksz_port_vlan_dump(struct dsa_switch *ds, int port,
        return err;
 }
 
-static int ksz_port_fdb_prepare(struct dsa_switch *ds, int port,
-                               const struct switchdev_obj_port_fdb *fdb,
-                               struct switchdev_trans *trans)
-{
-       /* nothing needed */
-
-       return 0;
-}
-
 struct alu_struct {
        /* entry 1 */
        u8      is_static:1;
@@ -706,30 +697,31 @@ struct alu_struct {
        u8      mac[ETH_ALEN];
 };
 
-static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
-                            const struct switchdev_obj_port_fdb *fdb,
-                            struct switchdev_trans *trans)
+static int ksz_port_fdb_add(struct dsa_switch *ds, int port,
+                           const unsigned char *addr, u16 vid)
 {
        struct ksz_device *dev = ds->priv;
        u32 alu_table[4];
        u32 data;
+       int ret = 0;
 
        mutex_lock(&dev->alu_mutex);
 
        /* find any entry with mac & vid */
-       data = fdb->vid << ALU_FID_INDEX_S;
-       data |= ((fdb->addr[0] << 8) | fdb->addr[1]);
+       data = vid << ALU_FID_INDEX_S;
+       data |= ((addr[0] << 8) | addr[1]);
        ksz_write32(dev, REG_SW_ALU_INDEX_0, data);
 
-       data = ((fdb->addr[2] << 24) | (fdb->addr[3] << 16));
-       data |= ((fdb->addr[4] << 8) | fdb->addr[5]);
+       data = ((addr[2] << 24) | (addr[3] << 16));
+       data |= ((addr[4] << 8) | addr[5]);
        ksz_write32(dev, REG_SW_ALU_INDEX_1, data);
 
        /* start read operation */
        ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
 
        /* wait to be finished */
-       if (wait_alu_ready(dev, ALU_START, 1000) < 0) {
+       ret = wait_alu_ready(dev, ALU_START, 1000);
+       if (ret < 0) {
                dev_dbg(dev->dev, "Failed to read ALU\n");
                goto exit;
        }
@@ -740,27 +732,30 @@ static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
        /* update ALU entry */
        alu_table[0] = ALU_V_STATIC_VALID;
        alu_table[1] |= BIT(port);
-       if (fdb->vid)
+       if (vid)
                alu_table[1] |= ALU_V_USE_FID;
-       alu_table[2] = (fdb->vid << ALU_V_FID_S);
-       alu_table[2] |= ((fdb->addr[0] << 8) | fdb->addr[1]);
-       alu_table[3] = ((fdb->addr[2] << 24) | (fdb->addr[3] << 16));
-       alu_table[3] |= ((fdb->addr[4] << 8) | fdb->addr[5]);
+       alu_table[2] = (vid << ALU_V_FID_S);
+       alu_table[2] |= ((addr[0] << 8) | addr[1]);
+       alu_table[3] = ((addr[2] << 24) | (addr[3] << 16));
+       alu_table[3] |= ((addr[4] << 8) | addr[5]);
 
        write_table(ds, alu_table);
 
        ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
 
        /* wait to be finished */
-       if (wait_alu_ready(dev, ALU_START, 1000) < 0)
-               dev_dbg(dev->dev, "Failed to read ALU\n");
+       ret = wait_alu_ready(dev, ALU_START, 1000);
+       if (ret < 0)
+               dev_dbg(dev->dev, "Failed to write ALU\n");
 
 exit:
        mutex_unlock(&dev->alu_mutex);
+
+       return ret;
 }
 
 static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
-                           const struct switchdev_obj_port_fdb *fdb)
+                           const unsigned char *addr, u16 vid)
 {
        struct ksz_device *dev = ds->priv;
        u32 alu_table[4];
@@ -770,12 +765,12 @@ static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
        mutex_lock(&dev->alu_mutex);
 
        /* read any entry with mac & vid */
-       data = fdb->vid << ALU_FID_INDEX_S;
-       data |= ((fdb->addr[0] << 8) | fdb->addr[1]);
+       data = vid << ALU_FID_INDEX_S;
+       data |= ((addr[0] << 8) | addr[1]);
        ksz_write32(dev, REG_SW_ALU_INDEX_0, data);
 
-       data = ((fdb->addr[2] << 24) | (fdb->addr[3] << 16));
-       data |= ((fdb->addr[4] << 8) | fdb->addr[5]);
+       data = ((addr[2] << 24) | (addr[3] << 16));
+       data |= ((addr[4] << 8) | addr[5]);
        ksz_write32(dev, REG_SW_ALU_INDEX_1, data);
 
        /* start read operation */
@@ -1130,7 +1125,6 @@ static const struct dsa_switch_ops ksz_switch_ops = {
        .port_vlan_add          = ksz_port_vlan_add,
        .port_vlan_del          = ksz_port_vlan_del,
        .port_vlan_dump         = ksz_port_vlan_dump,
-       .port_fdb_prepare       = ksz_port_fdb_prepare,
        .port_fdb_dump          = ksz_port_fdb_dump,
        .port_fdb_add           = ksz_port_fdb_add,
        .port_fdb_del           = ksz_port_fdb_del,