Lines Matching refs:mlxsw_sp
148 static int mlxsw_sp_base_mac_get(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_base_mac_get() argument
153 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(spad), spad_pl); in mlxsw_sp_base_mac_get()
156 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sp->base_mac); in mlxsw_sp_base_mac_get()
163 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set() local
169 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_admin_status_set()
175 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_oper_status_get() local
181 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_oper_status_get()
189 static int mlxsw_sp_vfid_create(struct mlxsw_sp *mlxsw_sp, u16 vfid) in mlxsw_sp_vfid_create() argument
196 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfmr), sfmr_pl); in mlxsw_sp_vfid_create()
201 set_bit(vfid, mlxsw_sp->active_vfids); in mlxsw_sp_vfid_create()
205 static void mlxsw_sp_vfid_destroy(struct mlxsw_sp *mlxsw_sp, u16 vfid) in mlxsw_sp_vfid_destroy() argument
209 clear_bit(vfid, mlxsw_sp->active_vfids); in mlxsw_sp_vfid_destroy()
213 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfmr), sfmr_pl); in mlxsw_sp_vfid_destroy()
219 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set() local
224 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sp_port_dev_addr_set()
229 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init() local
232 ether_addr_copy(addr, mlxsw_sp->base_mac); in mlxsw_sp_port_dev_addr_init()
240 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_state_set() local
249 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_stp_state_set()
256 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set() local
263 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
272 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
277 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_swid_set() local
281 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sp_port_swid_set()
287 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set() local
291 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svpe), svpe_pl); in mlxsw_sp_port_vp_mode_set()
298 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_to_fid_set() local
303 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svfa), svfa_pl); in mlxsw_sp_port_vid_to_fid_set()
309 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set() local
318 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvmlr), spvmlr_pl); in mlxsw_sp_port_vid_learning_set()
326 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set() local
330 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sp_port_system_port_mapping_set()
336 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_check() local
341 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_check()
372 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit() local
381 if (mlxsw_core_skb_transmit_busy(mlxsw_sp, &tx_info)) in mlxsw_sp_port_xmit()
405 err = mlxsw_core_skb_transmit(mlxsw_sp, skb, &tx_info); in mlxsw_sp_port_xmit()
483 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_set() local
493 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvm), spvm_pl); in mlxsw_sp_port_vlan_set()
552 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_add_vid() local
567 if (!test_bit(vid, mlxsw_sp->active_vfids)) { in mlxsw_sp_port_add_vid()
568 err = mlxsw_sp_vfid_create(mlxsw_sp, vid); in mlxsw_sp_port_add_vid()
583 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); in mlxsw_sp_port_add_vid()
643 mlxsw_sp_vfid_destroy(mlxsw_sp, vid); in mlxsw_sp_port_add_vid()
745 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_drvinfo() local
752 mlxsw_sp->bus_info->fw_rev.major, in mlxsw_sp_port_get_drvinfo()
753 mlxsw_sp->bus_info->fw_rev.minor, in mlxsw_sp_port_get_drvinfo()
754 mlxsw_sp->bus_info->fw_rev.subminor); in mlxsw_sp_port_get_drvinfo()
755 strlcpy(drvinfo->bus_info, mlxsw_sp->bus_info->device_name, in mlxsw_sp_port_get_drvinfo()
866 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats() local
872 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sp_port_get_stats()
1084 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_settings() local
1092 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_get_settings()
1143 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_set_settings() local
1159 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_set_settings()
1175 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_set_settings()
1214 static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port) in mlxsw_sp_port_create() argument
1226 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1245 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", in mlxsw_sp_port_create()
1262 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to check module\n", in mlxsw_sp_port_create()
1268 dev_dbg(mlxsw_sp->bus_info->dev, "Port %d: Not usable, skipping initialization\n", in mlxsw_sp_port_create()
1275 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sp_port_create()
1282 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sp_port_create()
1289 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sp_port_create()
1300 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize buffers\n", in mlxsw_sp_port_create()
1308 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sp_port_create()
1317 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1337 static void mlxsw_sp_vfids_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_vfids_fini() argument
1341 for_each_set_bit(vfid, mlxsw_sp->active_vfids, VLAN_N_VID) in mlxsw_sp_vfids_fini()
1342 mlxsw_sp_vfid_destroy(mlxsw_sp, vfid); in mlxsw_sp_vfids_fini()
1345 static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) in mlxsw_sp_port_remove() argument
1347 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove()
1358 static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_remove() argument
1363 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_remove()
1364 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_remove()
1367 static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_create() argument
1374 mlxsw_sp->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_ports_create()
1375 if (!mlxsw_sp->ports) in mlxsw_sp_ports_create()
1379 err = mlxsw_sp_port_create(mlxsw_sp, i); in mlxsw_sp_ports_create()
1387 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_create()
1388 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_create()
1395 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_pude_event_func() local
1401 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
1403 dev_warn(mlxsw_sp->bus_info->dev, "Port %d: Link event received for non-existent port\n", in mlxsw_sp_pude_event_func()
1423 static int mlxsw_sp_event_register(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_event_register() argument
1435 err = mlxsw_core_event_listener_register(mlxsw_sp->core, el, mlxsw_sp); in mlxsw_sp_event_register()
1440 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sp_event_register()
1447 mlxsw_core_event_listener_unregister(mlxsw_sp->core, el, mlxsw_sp); in mlxsw_sp_event_register()
1451 static void mlxsw_sp_event_unregister(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_event_unregister() argument
1461 mlxsw_core_event_listener_unregister(mlxsw_sp->core, el, mlxsw_sp); in mlxsw_sp_event_unregister()
1467 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_rx_listener_func() local
1468 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_func()
1472 dev_warn_ratelimited(mlxsw_sp->bus_info->dev, "Port %d: skb received for non-existent port\n", in mlxsw_sp_rx_listener_func()
1563 static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_init() argument
1571 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sp_traps_init()
1576 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sp_traps_init()
1581 err = mlxsw_core_rx_listener_register(mlxsw_sp->core, in mlxsw_sp_traps_init()
1583 mlxsw_sp); in mlxsw_sp_traps_init()
1589 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sp_traps_init()
1596 mlxsw_core_rx_listener_unregister(mlxsw_sp->core, in mlxsw_sp_traps_init()
1598 mlxsw_sp); in mlxsw_sp_traps_init()
1603 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sp_traps_init()
1605 mlxsw_core_rx_listener_unregister(mlxsw_sp->core, in mlxsw_sp_traps_init()
1607 mlxsw_sp); in mlxsw_sp_traps_init()
1612 static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_fini() argument
1620 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sp_traps_fini()
1622 mlxsw_core_rx_listener_unregister(mlxsw_sp->core, in mlxsw_sp_traps_fini()
1624 mlxsw_sp); in mlxsw_sp_traps_fini()
1652 static int mlxsw_sp_flood_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_flood_init() argument
1663 err = __mlxsw_sp_flood_init(mlxsw_sp->core, type, in mlxsw_sp_flood_init()
1677 err = __mlxsw_sp_flood_init(mlxsw_sp->core, type, in mlxsw_sp_flood_init()
1689 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_init() local
1692 mlxsw_sp->core = mlxsw_core; in mlxsw_sp_init()
1693 mlxsw_sp->bus_info = mlxsw_bus_info; in mlxsw_sp_init()
1695 err = mlxsw_sp_base_mac_get(mlxsw_sp); in mlxsw_sp_init()
1697 dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); in mlxsw_sp_init()
1701 err = mlxsw_sp_ports_create(mlxsw_sp); in mlxsw_sp_init()
1703 dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n"); in mlxsw_sp_init()
1707 err = mlxsw_sp_event_register(mlxsw_sp, MLXSW_TRAP_ID_PUDE); in mlxsw_sp_init()
1709 dev_err(mlxsw_sp->bus_info->dev, "Failed to register for PUDE events\n"); in mlxsw_sp_init()
1713 err = mlxsw_sp_traps_init(mlxsw_sp); in mlxsw_sp_init()
1715 dev_err(mlxsw_sp->bus_info->dev, "Failed to set traps for RX\n"); in mlxsw_sp_init()
1719 err = mlxsw_sp_flood_init(mlxsw_sp); in mlxsw_sp_init()
1721 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize flood tables\n"); in mlxsw_sp_init()
1725 err = mlxsw_sp_buffers_init(mlxsw_sp); in mlxsw_sp_init()
1727 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize buffers\n"); in mlxsw_sp_init()
1731 err = mlxsw_sp_switchdev_init(mlxsw_sp); in mlxsw_sp_init()
1733 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); in mlxsw_sp_init()
1742 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_init()
1744 mlxsw_sp_event_unregister(mlxsw_sp, MLXSW_TRAP_ID_PUDE); in mlxsw_sp_init()
1746 mlxsw_sp_ports_remove(mlxsw_sp); in mlxsw_sp_init()
1748 mlxsw_sp_vfids_fini(mlxsw_sp); in mlxsw_sp_init()
1754 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_fini() local
1756 mlxsw_sp_switchdev_fini(mlxsw_sp); in mlxsw_sp_fini()
1757 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_fini()
1758 mlxsw_sp_event_unregister(mlxsw_sp, MLXSW_TRAP_ID_PUDE); in mlxsw_sp_fini()
1759 mlxsw_sp_ports_remove(mlxsw_sp); in mlxsw_sp_fini()
1760 mlxsw_sp_vfids_fini(mlxsw_sp); in mlxsw_sp_fini()
1802 .priv_size = sizeof(struct mlxsw_sp),
1847 static bool mlxsw_sp_master_bridge_check(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_master_bridge_check() argument
1850 return !mlxsw_sp->master_bridge.dev || in mlxsw_sp_master_bridge_check()
1851 mlxsw_sp->master_bridge.dev == br_dev; in mlxsw_sp_master_bridge_check()
1854 static void mlxsw_sp_master_bridge_inc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_master_bridge_inc() argument
1857 mlxsw_sp->master_bridge.dev = br_dev; in mlxsw_sp_master_bridge_inc()
1858 mlxsw_sp->master_bridge.ref_count++; in mlxsw_sp_master_bridge_inc()
1861 static void mlxsw_sp_master_bridge_dec(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_master_bridge_dec() argument
1864 if (--mlxsw_sp->master_bridge.ref_count == 0) in mlxsw_sp_master_bridge_dec()
1865 mlxsw_sp->master_bridge.dev = NULL; in mlxsw_sp_master_bridge_dec()
1875 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_event() local
1882 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_event()
1891 !mlxsw_sp_master_bridge_check(mlxsw_sp, upper_dev)) in mlxsw_sp_netdevice_event()
1902 mlxsw_sp_master_bridge_inc(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_event()
1909 mlxsw_sp_master_bridge_dec(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_event()