aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/microchip/ksz_common.c
diff options
context:
space:
mode:
authorArkadi Sharshevsky <arkadis@mellanox.com>2017-08-06 09:15:40 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-07 17:48:47 -0400
commit1b6dd556c3045ca5fa31cc1e98a4a43afa680e1e (patch)
tree157769b86c0cba693eddb32f7a98c64f7e5c806d /drivers/net/dsa/microchip/ksz_common.c
parent6c2c1dcb185f1e44e1c895781dbaba40195234f9 (diff)
net: dsa: Remove prepare phase for FDB
The prepare phase for FDB add is unneeded because most of DSA devices can have failures during bus transactions (SPI, I2C, etc.), thus, the prepare phase cannot guarantee success of the commit stage. The support for learning FDB through notification chain, which will be introduced in the following patches, will provide the ability to notify back the bridge about successful offload. Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/microchip/ksz_common.c')
-rw-r--r--drivers/net/dsa/microchip/ksz_common.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index db828080ee93..b55f3649ff93 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -678,14 +678,6 @@ static int ksz_port_vlan_dump(struct dsa_switch *ds, int port,
678 return err; 678 return err;
679} 679}
680 680
681static int ksz_port_fdb_prepare(struct dsa_switch *ds, int port,
682 const unsigned char *addr, u16 vid)
683{
684 /* nothing needed */
685
686 return 0;
687}
688
689struct alu_struct { 681struct alu_struct {
690 /* entry 1 */ 682 /* entry 1 */
691 u8 is_static:1; 683 u8 is_static:1;
@@ -705,12 +697,13 @@ struct alu_struct {
705 u8 mac[ETH_ALEN]; 697 u8 mac[ETH_ALEN];
706}; 698};
707 699
708static void ksz_port_fdb_add(struct dsa_switch *ds, int port, 700static int ksz_port_fdb_add(struct dsa_switch *ds, int port,
709 const unsigned char *addr, u16 vid) 701 const unsigned char *addr, u16 vid)
710{ 702{
711 struct ksz_device *dev = ds->priv; 703 struct ksz_device *dev = ds->priv;
712 u32 alu_table[4]; 704 u32 alu_table[4];
713 u32 data; 705 u32 data;
706 int ret = 0;
714 707
715 mutex_lock(&dev->alu_mutex); 708 mutex_lock(&dev->alu_mutex);
716 709
@@ -727,7 +720,8 @@ static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
727 ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START); 720 ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
728 721
729 /* wait to be finished */ 722 /* wait to be finished */
730 if (wait_alu_ready(dev, ALU_START, 1000) < 0) { 723 ret = wait_alu_ready(dev, ALU_START, 1000);
724 if (ret < 0) {
731 dev_dbg(dev->dev, "Failed to read ALU\n"); 725 dev_dbg(dev->dev, "Failed to read ALU\n");
732 goto exit; 726 goto exit;
733 } 727 }
@@ -750,11 +744,14 @@ static void ksz_port_fdb_add(struct dsa_switch *ds, int port,
750 ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START); 744 ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
751 745
752 /* wait to be finished */ 746 /* wait to be finished */
753 if (wait_alu_ready(dev, ALU_START, 1000) < 0) 747 ret = wait_alu_ready(dev, ALU_START, 1000);
754 dev_dbg(dev->dev, "Failed to read ALU\n"); 748 if (ret < 0)
749 dev_dbg(dev->dev, "Failed to write ALU\n");
755 750
756exit: 751exit:
757 mutex_unlock(&dev->alu_mutex); 752 mutex_unlock(&dev->alu_mutex);
753
754 return ret;
758} 755}
759 756
760static int ksz_port_fdb_del(struct dsa_switch *ds, int port, 757static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
@@ -1128,7 +1125,6 @@ static const struct dsa_switch_ops ksz_switch_ops = {
1128 .port_vlan_add = ksz_port_vlan_add, 1125 .port_vlan_add = ksz_port_vlan_add,
1129 .port_vlan_del = ksz_port_vlan_del, 1126 .port_vlan_del = ksz_port_vlan_del,
1130 .port_vlan_dump = ksz_port_vlan_dump, 1127 .port_vlan_dump = ksz_port_vlan_dump,
1131 .port_fdb_prepare = ksz_port_fdb_prepare,
1132 .port_fdb_dump = ksz_port_fdb_dump, 1128 .port_fdb_dump = ksz_port_fdb_dump,
1133 .port_fdb_add = ksz_port_fdb_add, 1129 .port_fdb_add = ksz_port_fdb_add,
1134 .port_fdb_del = ksz_port_fdb_del, 1130 .port_fdb_del = ksz_port_fdb_del,