Lines Matching refs:mlxsw_sx

60 struct mlxsw_sx {  struct
79 struct mlxsw_sx *mlxsw_sx; argument
190 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_admin_status_set() local
196 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(paos), paos_pl); in mlxsw_sx_port_admin_status_set()
202 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_oper_status_get() local
208 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(paos), paos_pl); in mlxsw_sx_port_oper_status_get()
218 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_mtu_set() local
225 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sx_port_mtu_set()
234 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sx_port_mtu_set()
239 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_swid_set() local
243 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sx_port_swid_set()
249 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_system_port_mapping_set() local
253 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sx_port_system_port_mapping_set()
259 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_module_check() local
264 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sx_port_module_check()
295 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_xmit() local
304 if (mlxsw_core_skb_transmit_busy(mlxsw_sx, &tx_info)) in mlxsw_sx_port_xmit()
322 err = mlxsw_core_skb_transmit(mlxsw_sx, skb, &tx_info); in mlxsw_sx_port_xmit()
393 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_drvinfo() local
400 mlxsw_sx->bus_info->fw_rev.major, in mlxsw_sx_port_get_drvinfo()
401 mlxsw_sx->bus_info->fw_rev.minor, in mlxsw_sx_port_get_drvinfo()
402 mlxsw_sx->bus_info->fw_rev.subminor); in mlxsw_sx_port_get_drvinfo()
403 strlcpy(drvinfo->bus_info, mlxsw_sx->bus_info->device_name, in mlxsw_sx_port_get_drvinfo()
514 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_stats() local
520 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sx_port_get_stats()
732 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_settings() local
740 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_get_settings()
791 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_set_settings() local
807 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_set_settings()
823 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_set_settings()
866 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_attr_get() local
870 attr->u.ppid.id_len = sizeof(mlxsw_sx->hw_id); in mlxsw_sx_port_attr_get()
871 memcpy(&attr->u.ppid.id, &mlxsw_sx->hw_id, attr->u.ppid.id_len); in mlxsw_sx_port_attr_get()
884 static int mlxsw_sx_hw_id_get(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_hw_id_get() argument
889 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(spad), spad_pl); in mlxsw_sx_hw_id_get()
892 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sx->hw_id); in mlxsw_sx_hw_id_get()
898 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_dev_addr_get() local
904 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sx_port_dev_addr_get()
919 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_stp_state_set() local
928 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(spms), spms_pl); in mlxsw_sx_port_stp_state_set()
936 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_speed_set() local
940 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_speed_set()
947 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_mac_learning_mode_set() local
951 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(spmlr), spmlr_pl); in mlxsw_sx_port_mac_learning_mode_set()
954 static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port) in mlxsw_sx_port_create() argument
966 mlxsw_sx_port->mlxsw_sx = mlxsw_sx; in mlxsw_sx_port_create()
982 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Unable to get port mac address\n", in mlxsw_sx_port_create()
999 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to check module\n", in mlxsw_sx_port_create()
1005 dev_dbg(mlxsw_sx->bus_info->dev, "Port %d: Not usable, skipping initialization\n", in mlxsw_sx_port_create()
1012 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sx_port_create()
1019 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sx_port_create()
1027 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set speed\n", in mlxsw_sx_port_create()
1034 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sx_port_create()
1047 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set STP state\n", in mlxsw_sx_port_create()
1055 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set MAC learning mode\n", in mlxsw_sx_port_create()
1062 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sx_port_create()
1067 mlxsw_sx->ports[local_port] = mlxsw_sx_port; in mlxsw_sx_port_create()
1087 static void mlxsw_sx_port_remove(struct mlxsw_sx *mlxsw_sx, u8 local_port) in mlxsw_sx_port_remove() argument
1089 struct mlxsw_sx_port *mlxsw_sx_port = mlxsw_sx->ports[local_port]; in mlxsw_sx_port_remove()
1099 static void mlxsw_sx_ports_remove(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_ports_remove() argument
1104 mlxsw_sx_port_remove(mlxsw_sx, i); in mlxsw_sx_ports_remove()
1105 kfree(mlxsw_sx->ports); in mlxsw_sx_ports_remove()
1108 static int mlxsw_sx_ports_create(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_ports_create() argument
1115 mlxsw_sx->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sx_ports_create()
1116 if (!mlxsw_sx->ports) in mlxsw_sx_ports_create()
1120 err = mlxsw_sx_port_create(mlxsw_sx, i); in mlxsw_sx_ports_create()
1128 mlxsw_sx_port_remove(mlxsw_sx, i); in mlxsw_sx_ports_create()
1129 kfree(mlxsw_sx->ports); in mlxsw_sx_ports_create()
1136 struct mlxsw_sx *mlxsw_sx = priv; in mlxsw_sx_pude_event_func() local
1142 mlxsw_sx_port = mlxsw_sx->ports[local_port]; in mlxsw_sx_pude_event_func()
1144 dev_warn(mlxsw_sx->bus_info->dev, "Port %d: Link event received for non-existent port\n", in mlxsw_sx_pude_event_func()
1164 static int mlxsw_sx_event_register(struct mlxsw_sx *mlxsw_sx, in mlxsw_sx_event_register() argument
1176 err = mlxsw_core_event_listener_register(mlxsw_sx->core, el, mlxsw_sx); in mlxsw_sx_event_register()
1181 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sx_event_register()
1188 mlxsw_core_event_listener_unregister(mlxsw_sx->core, el, mlxsw_sx); in mlxsw_sx_event_register()
1192 static void mlxsw_sx_event_unregister(struct mlxsw_sx *mlxsw_sx, in mlxsw_sx_event_unregister() argument
1202 mlxsw_core_event_listener_unregister(mlxsw_sx->core, el, mlxsw_sx); in mlxsw_sx_event_unregister()
1208 struct mlxsw_sx *mlxsw_sx = priv; in mlxsw_sx_rx_listener_func() local
1209 struct mlxsw_sx_port *mlxsw_sx_port = mlxsw_sx->ports[local_port]; in mlxsw_sx_rx_listener_func()
1213 dev_warn_ratelimited(mlxsw_sx->bus_info->dev, "Port %d: skb received for non-existent port\n", in mlxsw_sx_rx_listener_func()
1304 static int mlxsw_sx_traps_init(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_traps_init() argument
1312 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sx_traps_init()
1317 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sx_traps_init()
1322 err = mlxsw_core_rx_listener_register(mlxsw_sx->core, in mlxsw_sx_traps_init()
1324 mlxsw_sx); in mlxsw_sx_traps_init()
1330 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sx_traps_init()
1337 mlxsw_core_rx_listener_unregister(mlxsw_sx->core, in mlxsw_sx_traps_init()
1339 mlxsw_sx); in mlxsw_sx_traps_init()
1344 mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sx_traps_init()
1346 mlxsw_core_rx_listener_unregister(mlxsw_sx->core, in mlxsw_sx_traps_init()
1348 mlxsw_sx); in mlxsw_sx_traps_init()
1353 static void mlxsw_sx_traps_fini(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_traps_fini() argument
1361 mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(hpkt), hpkt_pl); in mlxsw_sx_traps_fini()
1363 mlxsw_core_rx_listener_unregister(mlxsw_sx->core, in mlxsw_sx_traps_fini()
1365 mlxsw_sx); in mlxsw_sx_traps_fini()
1369 static int mlxsw_sx_flood_init(struct mlxsw_sx *mlxsw_sx) in mlxsw_sx_flood_init() argument
1382 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sftr), sftr_pl); in mlxsw_sx_flood_init()
1393 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1402 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1411 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1420 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1429 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1434 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sgcr), sgcr_pl); in mlxsw_sx_flood_init()
1440 struct mlxsw_sx *mlxsw_sx = priv; in mlxsw_sx_init() local
1443 mlxsw_sx->core = mlxsw_core; in mlxsw_sx_init()
1444 mlxsw_sx->bus_info = mlxsw_bus_info; in mlxsw_sx_init()
1446 err = mlxsw_sx_hw_id_get(mlxsw_sx); in mlxsw_sx_init()
1448 dev_err(mlxsw_sx->bus_info->dev, "Failed to get switch HW ID\n"); in mlxsw_sx_init()
1452 err = mlxsw_sx_ports_create(mlxsw_sx); in mlxsw_sx_init()
1454 dev_err(mlxsw_sx->bus_info->dev, "Failed to create ports\n"); in mlxsw_sx_init()
1458 err = mlxsw_sx_event_register(mlxsw_sx, MLXSW_TRAP_ID_PUDE); in mlxsw_sx_init()
1460 dev_err(mlxsw_sx->bus_info->dev, "Failed to register for PUDE events\n"); in mlxsw_sx_init()
1464 err = mlxsw_sx_traps_init(mlxsw_sx); in mlxsw_sx_init()
1466 dev_err(mlxsw_sx->bus_info->dev, "Failed to set traps for RX\n"); in mlxsw_sx_init()
1470 err = mlxsw_sx_flood_init(mlxsw_sx); in mlxsw_sx_init()
1472 dev_err(mlxsw_sx->bus_info->dev, "Failed to initialize flood tables\n"); in mlxsw_sx_init()
1479 mlxsw_sx_traps_fini(mlxsw_sx); in mlxsw_sx_init()
1481 mlxsw_sx_event_unregister(mlxsw_sx, MLXSW_TRAP_ID_PUDE); in mlxsw_sx_init()
1483 mlxsw_sx_ports_remove(mlxsw_sx); in mlxsw_sx_init()
1489 struct mlxsw_sx *mlxsw_sx = priv; in mlxsw_sx_fini() local
1491 mlxsw_sx_traps_fini(mlxsw_sx); in mlxsw_sx_fini()
1492 mlxsw_sx_event_unregister(mlxsw_sx, MLXSW_TRAP_ID_PUDE); in mlxsw_sx_fini()
1493 mlxsw_sx_ports_remove(mlxsw_sx); in mlxsw_sx_fini()
1533 .priv_size = sizeof(struct mlxsw_sx),