Lines Matching refs:mlxsw_sp

172 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,  in mlxsw_sp_flow_counter_get()  argument
181 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_get()
191 static int mlxsw_sp_flow_counter_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_clear() argument
198 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_clear()
201 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_alloc() argument
206 err = mlxsw_sp_counter_alloc(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_alloc()
210 err = mlxsw_sp_flow_counter_clear(mlxsw_sp, *p_counter_index); in mlxsw_sp_flow_counter_alloc()
216 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_alloc()
221 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_free() argument
224 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_free()
264 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_stp_set() local
274 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_vid_stp_set()
279 static int mlxsw_sp_base_mac_get(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_base_mac_get() argument
284 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(spad), spad_pl); in mlxsw_sp_base_mac_get()
287 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sp->base_mac); in mlxsw_sp_base_mac_get()
294 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set() local
300 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_admin_status_set()
306 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set() local
311 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sp_port_dev_addr_set()
316 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init() local
319 ether_addr_copy(addr, mlxsw_sp->base_mac); in mlxsw_sp_port_dev_addr_init()
326 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_max_mtu_get() local
331 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_max_mtu_get()
341 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set() local
349 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
354 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_swid_set() local
358 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sp_port_swid_set()
363 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set() local
367 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svpe), svpe_pl); in mlxsw_sp_port_vp_mode_set()
373 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set() local
382 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvmlr), spvmlr_pl); in mlxsw_sp_port_vid_learning_set()
390 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_pvid_set() local
394 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl); in __mlxsw_sp_port_pvid_set()
400 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_allow_untagged_set() local
404 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl); in mlxsw_sp_port_allow_untagged_set()
435 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set() local
439 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sp_port_system_port_mapping_set()
443 mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp, u8 local_port, in mlxsw_sp_port_module_info_get() argument
454 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_info_get()
462 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: width value is not power of … in mlxsw_sp_port_module_info_get()
469 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple modules\n", in mlxsw_sp_port_module_info_get()
476 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: TX and RX lane numbers are d… in mlxsw_sp_port_module_info_get()
481 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: TX and RX lane numbers are n… in mlxsw_sp_port_module_info_get()
496 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_map() local
507 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_map()
512 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_unmap() local
517 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_unmap()
544 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit() local
561 if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &tx_info)) in mlxsw_sp_port_xmit()
578 err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &tx_info); in mlxsw_sp_port_xmit()
700 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats_raw() local
703 return mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sp_port_get_stats_raw()
825 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_vlan_set() local
835 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvm), spvm_pl); in __mlxsw_sp_port_vlan_set()
1027 err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr), in mlxsw_sp_feature_loopback()
1087 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_devlink_port() local
1089 return mlxsw_core_port_devlink_port_get(mlxsw_sp->core, in mlxsw_sp_port_get_devlink_port()
1102 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set()
1119 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_get(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get()
1134 mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, &config); in mlxsw_sp_port_ptp_clear()
1173 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_by_width_set() local
1180 ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_by_width_set()
1185 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1187 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1191 ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, &eth_proto_cap, in mlxsw_sp_port_speed_by_width_set()
1194 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1197 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1203 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_get() local
1208 port_type_speed_ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_get()
1209 port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, in mlxsw_sp_port_speed_get()
1212 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_get()
1215 port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL, in mlxsw_sp_port_speed_get()
1217 *speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper); in mlxsw_sp_port_speed_get()
1225 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_set() local
1233 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_set()
1240 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_maxrate_set() local
1248 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_maxrate_set()
1255 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_min_bw_set() local
1263 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_min_bw_set()
1269 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_prio_tc_set() local
1274 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtct), qtct_pl); in mlxsw_sp_port_prio_tc_set()
1366 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_tc_mc_mode_set() local
1370 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtctm), qtctm_pl); in mlxsw_sp_port_tc_mc_mode_set()
1375 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_overheat_init_val_set() local
1380 err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, module, in mlxsw_sp_port_overheat_init_val_set()
1389 static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, in mlxsw_sp_port_create() argument
1402 err = mlxsw_core_port_init(mlxsw_sp->core, local_port, in mlxsw_sp_port_create()
1406 mlxsw_sp->base_mac, in mlxsw_sp_port_create()
1407 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_port_create()
1409 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n", in mlxsw_sp_port_create()
1419 SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); in mlxsw_sp_port_create()
1420 dev_net_set(dev, mlxsw_sp_net(mlxsw_sp)); in mlxsw_sp_port_create()
1423 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1447 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to map module\n", in mlxsw_sp_port_create()
1454 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sp_port_create()
1461 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", in mlxsw_sp_port_create()
1482 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sp_port_create()
1489 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", in mlxsw_sp_port_create()
1494 err = mlxsw_sp->port_type_speed_ops->ptys_max_speed(mlxsw_sp_port, in mlxsw_sp_port_create()
1497 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum speed\n", in mlxsw_sp_port_create()
1504 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum MTU\n", in mlxsw_sp_port_create()
1511 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sp_port_create()
1522 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize buffers\n", in mlxsw_sp_port_create()
1529 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize ETS\n", in mlxsw_sp_port_create()
1536 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC MC mode\n", in mlxsw_sp_port_create()
1544 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize DCB\n", in mlxsw_sp_port_create()
1551 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize FIDs\n", in mlxsw_sp_port_create()
1558 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC qdiscs\n", in mlxsw_sp_port_create()
1566 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to clear VLAN filter\n", in mlxsw_sp_port_create()
1573 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize NVE\n", in mlxsw_sp_port_create()
1580 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set PVID\n", in mlxsw_sp_port_create()
1588 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n", in mlxsw_sp_port_create()
1596 mlxsw_sp->ptp_ops->shaper_work); in mlxsw_sp_port_create()
1598 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1602 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set overheat initial value\n", in mlxsw_sp_port_create()
1609 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sp_port_create()
1614 mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port, in mlxsw_sp_port_create()
1621 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_create()
1654 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_create()
1658 static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) in mlxsw_sp_port_remove() argument
1660 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove()
1665 mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp); in mlxsw_sp_port_remove()
1667 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_remove()
1680 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_remove()
1683 static int mlxsw_sp_cpu_port_create(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_cpu_port_create() argument
1692 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_cpu_port_create()
1695 err = mlxsw_core_cpu_port_init(mlxsw_sp->core, in mlxsw_sp_cpu_port_create()
1697 mlxsw_sp->base_mac, in mlxsw_sp_cpu_port_create()
1698 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_cpu_port_create()
1700 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize core CPU port\n"); in mlxsw_sp_cpu_port_create()
1704 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = mlxsw_sp_port; in mlxsw_sp_cpu_port_create()
1712 static void mlxsw_sp_cpu_port_remove(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_cpu_port_remove() argument
1715 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp_cpu_port_remove()
1717 mlxsw_core_cpu_port_fini(mlxsw_sp->core); in mlxsw_sp_cpu_port_remove()
1718 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = NULL; in mlxsw_sp_cpu_port_remove()
1722 static bool mlxsw_sp_port_created(struct mlxsw_sp *mlxsw_sp, u8 local_port) in mlxsw_sp_port_created() argument
1724 return mlxsw_sp->ports[local_port] != NULL; in mlxsw_sp_port_created()
1727 static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_remove() argument
1731 for (i = 1; i < mlxsw_core_max_ports(mlxsw_sp->core); i++) in mlxsw_sp_ports_remove()
1732 if (mlxsw_sp_port_created(mlxsw_sp, i)) in mlxsw_sp_ports_remove()
1733 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_remove()
1734 mlxsw_sp_cpu_port_remove(mlxsw_sp); in mlxsw_sp_ports_remove()
1735 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_remove()
1736 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_remove()
1739 static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_create() argument
1741 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_create()
1748 mlxsw_sp->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_ports_create()
1749 if (!mlxsw_sp->ports) in mlxsw_sp_ports_create()
1752 err = mlxsw_sp_cpu_port_create(mlxsw_sp); in mlxsw_sp_ports_create()
1757 port_mapping = mlxsw_sp->port_mapping[i]; in mlxsw_sp_ports_create()
1760 err = mlxsw_sp_port_create(mlxsw_sp, i, 0, port_mapping); in mlxsw_sp_ports_create()
1768 if (mlxsw_sp_port_created(mlxsw_sp, i)) in mlxsw_sp_ports_create()
1769 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_create()
1770 mlxsw_sp_cpu_port_remove(mlxsw_sp); in mlxsw_sp_ports_create()
1772 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_create()
1773 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_create()
1777 static int mlxsw_sp_port_module_info_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_port_module_info_init() argument
1779 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_port_module_info_init()
1784 mlxsw_sp->port_mapping = kcalloc(max_ports, in mlxsw_sp_port_module_info_init()
1787 if (!mlxsw_sp->port_mapping) in mlxsw_sp_port_module_info_init()
1791 err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, &port_mapping); in mlxsw_sp_port_module_info_init()
1797 mlxsw_sp->port_mapping[i] = kmemdup(&port_mapping, in mlxsw_sp_port_module_info_init()
1800 if (!mlxsw_sp->port_mapping[i]) { in mlxsw_sp_port_module_info_init()
1810 kfree(mlxsw_sp->port_mapping[i]); in mlxsw_sp_port_module_info_init()
1811 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_init()
1815 static void mlxsw_sp_port_module_info_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_port_module_info_fini() argument
1819 for (i = 1; i < mlxsw_core_max_ports(mlxsw_sp->core); i++) in mlxsw_sp_port_module_info_fini()
1820 kfree(mlxsw_sp->port_mapping[i]); in mlxsw_sp_port_module_info_fini()
1821 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_fini()
1832 mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port, in mlxsw_sp_port_split_create() argument
1842 err = mlxsw_sp_port_create(mlxsw_sp, base_port + i * offset, in mlxsw_sp_port_split_create()
1853 if (mlxsw_sp_port_created(mlxsw_sp, base_port + i * offset)) in mlxsw_sp_port_split_create()
1854 mlxsw_sp_port_remove(mlxsw_sp, base_port + i * offset); in mlxsw_sp_port_split_create()
1858 static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_unsplit_create() argument
1867 port_mapping = mlxsw_sp->port_mapping[base_port + i]; in mlxsw_sp_port_unsplit_create()
1870 mlxsw_sp_port_create(mlxsw_sp, base_port + i, 0, port_mapping); in mlxsw_sp_port_unsplit_create()
1896 mlxsw_sp_port_get_by_local_port(struct mlxsw_sp *mlxsw_sp, u8 local_port) in mlxsw_sp_port_get_by_local_port() argument
1898 if (mlxsw_sp->ports && mlxsw_sp->ports[local_port]) in mlxsw_sp_port_get_by_local_port()
1899 return mlxsw_sp->ports[local_port]; in mlxsw_sp_port_get_by_local_port()
1907 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_port_split() local
1916 mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port); in mlxsw_sp_port_split()
1918 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_split()
1960 if (mlxsw_sp_port_created(mlxsw_sp, base_port + i)) { in mlxsw_sp_port_split()
1970 if (mlxsw_sp_port_created(mlxsw_sp, base_port + i * offset)) in mlxsw_sp_port_split()
1971 mlxsw_sp_port_remove(mlxsw_sp, base_port + i * offset); in mlxsw_sp_port_split()
1973 err = mlxsw_sp_port_split_create(mlxsw_sp, base_port, &port_mapping, in mlxsw_sp_port_split()
1976 dev_err(mlxsw_sp->bus_info->dev, "Failed to create split ports\n"); in mlxsw_sp_port_split()
1983 mlxsw_sp_port_unsplit_create(mlxsw_sp, base_port, count, offset); in mlxsw_sp_port_split()
1990 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_port_unsplit() local
1998 mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port); in mlxsw_sp_port_unsplit()
2000 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_unsplit()
2032 if (mlxsw_sp_port_created(mlxsw_sp, base_port + i * offset)) in mlxsw_sp_port_unsplit()
2033 mlxsw_sp_port_remove(mlxsw_sp, base_port + i * offset); in mlxsw_sp_port_unsplit()
2035 mlxsw_sp_port_unsplit_create(mlxsw_sp, base_port, count, offset); in mlxsw_sp_port_unsplit()
2052 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_pude_event_func() local
2058 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
2074 static void mlxsw_sp1_ptp_fifo_event_func(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp1_ptp_fifo_event_func() argument
2092 mlxsw_sp1_ptp_got_timestamp(mlxsw_sp, ingress, local_port, in mlxsw_sp1_ptp_fifo_event_func()
2101 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp1_ptp_ing_fifo_event_func() local
2103 mlxsw_sp1_ptp_fifo_event_func(mlxsw_sp, mtpptr_pl, true); in mlxsw_sp1_ptp_ing_fifo_event_func()
2109 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp1_ptp_egr_fifo_event_func() local
2111 mlxsw_sp1_ptp_fifo_event_func(mlxsw_sp, mtpptr_pl, false); in mlxsw_sp1_ptp_egr_fifo_event_func()
2117 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_rx_listener_no_mark_func() local
2118 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_no_mark_func()
2122 dev_warn_ratelimited(mlxsw_sp->bus_info->dev, "Port %d: skb received for non-existent port\n", in mlxsw_sp_rx_listener_no_mark_func()
2154 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, in mlxsw_sp_ptp_receive() argument
2157 mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_receive()
2160 void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, in mlxsw_sp_sample_receive() argument
2163 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_sample_receive()
2168 …dev_warn_ratelimited(mlxsw_sp->bus_info->dev, "Port %d: sample skb received for non-existent port\… in mlxsw_sp_sample_receive()
2235 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_cpu_policers_set() local
2263 __set_bit(i, mlxsw_sp->trap->policers_usage); in mlxsw_sp_cpu_policers_set()
2321 static int mlxsw_sp_traps_register(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_traps_register() argument
2329 err = mlxsw_core_trap_register(mlxsw_sp->core, in mlxsw_sp_traps_register()
2331 mlxsw_sp); in mlxsw_sp_traps_register()
2340 mlxsw_core_trap_unregister(mlxsw_sp->core, in mlxsw_sp_traps_register()
2342 mlxsw_sp); in mlxsw_sp_traps_register()
2347 static void mlxsw_sp_traps_unregister(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_traps_unregister() argument
2354 mlxsw_core_trap_unregister(mlxsw_sp->core, in mlxsw_sp_traps_unregister()
2356 mlxsw_sp); in mlxsw_sp_traps_unregister()
2360 static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_init() argument
2366 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_CPU_POLICERS)) in mlxsw_sp_traps_init()
2368 max_policers = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_CPU_POLICERS); in mlxsw_sp_traps_init()
2374 mlxsw_sp->trap = trap; in mlxsw_sp_traps_init()
2376 err = mlxsw_sp_cpu_policers_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2380 err = mlxsw_sp_trap_groups_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2384 err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2389 err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp->listeners, in mlxsw_sp_traps_init()
2390 mlxsw_sp->listeners_count); in mlxsw_sp_traps_init()
2397 mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2406 static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_fini() argument
2408 mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp->listeners, in mlxsw_sp_traps_fini()
2409 mlxsw_sp->listeners_count); in mlxsw_sp_traps_fini()
2410 mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener, in mlxsw_sp_traps_fini()
2412 kfree(mlxsw_sp->trap); in mlxsw_sp_traps_fini()
2417 static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lag_init() argument
2423 seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), in mlxsw_sp_lag_init()
2434 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcr), slcr_pl); in mlxsw_sp_lag_init()
2438 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG) || in mlxsw_sp_lag_init()
2439 !MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS)) in mlxsw_sp_lag_init()
2442 mlxsw_sp->lags = kcalloc(MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_LAG), in mlxsw_sp_lag_init()
2445 if (!mlxsw_sp->lags) in mlxsw_sp_lag_init()
2451 static void mlxsw_sp_lag_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lag_fini() argument
2453 kfree(mlxsw_sp->lags); in mlxsw_sp_lag_fini()
2531 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_init() local
2534 mlxsw_sp->core = mlxsw_core; in mlxsw_sp_init()
2535 mlxsw_sp->bus_info = mlxsw_bus_info; in mlxsw_sp_init()
2539 err = mlxsw_sp_base_mac_get(mlxsw_sp); in mlxsw_sp_init()
2541 dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); in mlxsw_sp_init()
2545 err = mlxsw_sp_kvdl_init(mlxsw_sp); in mlxsw_sp_init()
2547 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize KVDL\n"); in mlxsw_sp_init()
2551 err = mlxsw_sp_fids_init(mlxsw_sp); in mlxsw_sp_init()
2553 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize FIDs\n"); in mlxsw_sp_init()
2557 err = mlxsw_sp_policers_init(mlxsw_sp); in mlxsw_sp_init()
2559 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize policers\n"); in mlxsw_sp_init()
2563 err = mlxsw_sp_traps_init(mlxsw_sp); in mlxsw_sp_init()
2565 dev_err(mlxsw_sp->bus_info->dev, "Failed to set traps\n"); in mlxsw_sp_init()
2569 err = mlxsw_sp_devlink_traps_init(mlxsw_sp); in mlxsw_sp_init()
2571 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize devlink traps\n"); in mlxsw_sp_init()
2575 err = mlxsw_sp_buffers_init(mlxsw_sp); in mlxsw_sp_init()
2577 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize buffers\n"); in mlxsw_sp_init()
2581 err = mlxsw_sp_lag_init(mlxsw_sp); in mlxsw_sp_init()
2583 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize LAG\n"); in mlxsw_sp_init()
2590 err = mlxsw_sp_span_init(mlxsw_sp); in mlxsw_sp_init()
2592 dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n"); in mlxsw_sp_init()
2596 err = mlxsw_sp_switchdev_init(mlxsw_sp); in mlxsw_sp_init()
2598 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); in mlxsw_sp_init()
2602 err = mlxsw_sp_counter_pool_init(mlxsw_sp); in mlxsw_sp_init()
2604 dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter pool\n"); in mlxsw_sp_init()
2608 err = mlxsw_sp_afa_init(mlxsw_sp); in mlxsw_sp_init()
2610 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL actions\n"); in mlxsw_sp_init()
2614 err = mlxsw_sp_nve_init(mlxsw_sp); in mlxsw_sp_init()
2616 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize NVE\n"); in mlxsw_sp_init()
2620 err = mlxsw_sp_acl_init(mlxsw_sp); in mlxsw_sp_init()
2622 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL\n"); in mlxsw_sp_init()
2626 err = mlxsw_sp_router_init(mlxsw_sp, extack); in mlxsw_sp_init()
2628 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize router\n"); in mlxsw_sp_init()
2632 if (mlxsw_sp->bus_info->read_frc_capable) { in mlxsw_sp_init()
2634 mlxsw_sp->clock = in mlxsw_sp_init()
2635 mlxsw_sp->ptp_ops->clock_init(mlxsw_sp, in mlxsw_sp_init()
2636 mlxsw_sp->bus_info->dev); in mlxsw_sp_init()
2637 if (IS_ERR(mlxsw_sp->clock)) { in mlxsw_sp_init()
2638 err = PTR_ERR(mlxsw_sp->clock); in mlxsw_sp_init()
2639 dev_err(mlxsw_sp->bus_info->dev, "Failed to init ptp clock\n"); in mlxsw_sp_init()
2644 if (mlxsw_sp->clock) { in mlxsw_sp_init()
2646 mlxsw_sp->ptp_state = mlxsw_sp->ptp_ops->init(mlxsw_sp); in mlxsw_sp_init()
2647 if (IS_ERR(mlxsw_sp->ptp_state)) { in mlxsw_sp_init()
2648 err = PTR_ERR(mlxsw_sp->ptp_state); in mlxsw_sp_init()
2649 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PTP\n"); in mlxsw_sp_init()
2658 mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event; in mlxsw_sp_init()
2659 err = register_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_init()
2660 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
2662 dev_err(mlxsw_sp->bus_info->dev, "Failed to register netdev notifier\n"); in mlxsw_sp_init()
2666 err = mlxsw_sp_dpipe_init(mlxsw_sp); in mlxsw_sp_init()
2668 dev_err(mlxsw_sp->bus_info->dev, "Failed to init pipeline debug\n"); in mlxsw_sp_init()
2672 err = mlxsw_sp_port_module_info_init(mlxsw_sp); in mlxsw_sp_init()
2674 dev_err(mlxsw_sp->bus_info->dev, "Failed to init port module info\n"); in mlxsw_sp_init()
2678 err = mlxsw_sp_ports_create(mlxsw_sp); in mlxsw_sp_init()
2680 dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n"); in mlxsw_sp_init()
2687 mlxsw_sp_port_module_info_fini(mlxsw_sp); in mlxsw_sp_init()
2689 mlxsw_sp_dpipe_fini(mlxsw_sp); in mlxsw_sp_init()
2691 unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_init()
2692 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
2694 if (mlxsw_sp->clock) in mlxsw_sp_init()
2695 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_init()
2697 if (mlxsw_sp->clock) in mlxsw_sp_init()
2698 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_init()
2700 mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_init()
2702 mlxsw_sp_acl_fini(mlxsw_sp); in mlxsw_sp_init()
2704 mlxsw_sp_nve_fini(mlxsw_sp); in mlxsw_sp_init()
2706 mlxsw_sp_afa_fini(mlxsw_sp); in mlxsw_sp_init()
2708 mlxsw_sp_counter_pool_fini(mlxsw_sp); in mlxsw_sp_init()
2710 mlxsw_sp_switchdev_fini(mlxsw_sp); in mlxsw_sp_init()
2712 mlxsw_sp_span_fini(mlxsw_sp); in mlxsw_sp_init()
2714 mlxsw_sp_lag_fini(mlxsw_sp); in mlxsw_sp_init()
2716 mlxsw_sp_buffers_fini(mlxsw_sp); in mlxsw_sp_init()
2718 mlxsw_sp_devlink_traps_fini(mlxsw_sp); in mlxsw_sp_init()
2720 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_init()
2722 mlxsw_sp_policers_fini(mlxsw_sp); in mlxsw_sp_init()
2724 mlxsw_sp_fids_fini(mlxsw_sp); in mlxsw_sp_init()
2726 mlxsw_sp_kvdl_fini(mlxsw_sp); in mlxsw_sp_init()
2734 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp1_init() local
2736 mlxsw_sp->kvdl_ops = &mlxsw_sp1_kvdl_ops; in mlxsw_sp1_init()
2737 mlxsw_sp->afa_ops = &mlxsw_sp1_act_afa_ops; in mlxsw_sp1_init()
2738 mlxsw_sp->afk_ops = &mlxsw_sp1_afk_ops; in mlxsw_sp1_init()
2739 mlxsw_sp->mr_tcam_ops = &mlxsw_sp1_mr_tcam_ops; in mlxsw_sp1_init()
2740 mlxsw_sp->acl_rulei_ops = &mlxsw_sp1_acl_rulei_ops; in mlxsw_sp1_init()
2741 mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops; in mlxsw_sp1_init()
2742 mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr; in mlxsw_sp1_init()
2743 mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask; in mlxsw_sp1_init()
2744 mlxsw_sp->rif_ops_arr = mlxsw_sp1_rif_ops_arr; in mlxsw_sp1_init()
2745 mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals; in mlxsw_sp1_init()
2746 mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops; in mlxsw_sp1_init()
2747 mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops; in mlxsw_sp1_init()
2748 mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops; in mlxsw_sp1_init()
2749 mlxsw_sp->span_ops = &mlxsw_sp1_span_ops; in mlxsw_sp1_init()
2750 mlxsw_sp->policer_core_ops = &mlxsw_sp1_policer_core_ops; in mlxsw_sp1_init()
2751 mlxsw_sp->trap_ops = &mlxsw_sp1_trap_ops; in mlxsw_sp1_init()
2752 mlxsw_sp->listeners = mlxsw_sp1_listener; in mlxsw_sp1_init()
2753 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener); in mlxsw_sp1_init()
2754 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1; in mlxsw_sp1_init()
2763 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp2_init() local
2765 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp2_init()
2766 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp2_init()
2767 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp2_init()
2768 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp2_init()
2769 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp2_init()
2770 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp2_init()
2771 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp2_init()
2772 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp2_init()
2773 mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr; in mlxsw_sp2_init()
2774 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp2_init()
2775 mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops; in mlxsw_sp2_init()
2776 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp2_init()
2777 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp2_init()
2778 mlxsw_sp->span_ops = &mlxsw_sp2_span_ops; in mlxsw_sp2_init()
2779 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp2_init()
2780 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp2_init()
2781 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2; in mlxsw_sp2_init()
2790 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp3_init() local
2792 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp3_init()
2793 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp3_init()
2794 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp3_init()
2795 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp3_init()
2796 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp3_init()
2797 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp3_init()
2798 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp3_init()
2799 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp3_init()
2800 mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr; in mlxsw_sp3_init()
2801 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp3_init()
2802 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp3_init()
2803 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp3_init()
2804 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp3_init()
2805 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp3_init()
2806 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp3_init()
2807 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp3_init()
2808 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; in mlxsw_sp3_init()
2815 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_fini() local
2817 mlxsw_sp_ports_remove(mlxsw_sp); in mlxsw_sp_fini()
2818 mlxsw_sp_port_module_info_fini(mlxsw_sp); in mlxsw_sp_fini()
2819 mlxsw_sp_dpipe_fini(mlxsw_sp); in mlxsw_sp_fini()
2820 unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_fini()
2821 &mlxsw_sp->netdevice_nb); in mlxsw_sp_fini()
2822 if (mlxsw_sp->clock) { in mlxsw_sp_fini()
2823 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_fini()
2824 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_fini()
2826 mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_fini()
2827 mlxsw_sp_acl_fini(mlxsw_sp); in mlxsw_sp_fini()
2828 mlxsw_sp_nve_fini(mlxsw_sp); in mlxsw_sp_fini()
2829 mlxsw_sp_afa_fini(mlxsw_sp); in mlxsw_sp_fini()
2830 mlxsw_sp_counter_pool_fini(mlxsw_sp); in mlxsw_sp_fini()
2831 mlxsw_sp_switchdev_fini(mlxsw_sp); in mlxsw_sp_fini()
2832 mlxsw_sp_span_fini(mlxsw_sp); in mlxsw_sp_fini()
2833 mlxsw_sp_lag_fini(mlxsw_sp); in mlxsw_sp_fini()
2834 mlxsw_sp_buffers_fini(mlxsw_sp); in mlxsw_sp_fini()
2835 mlxsw_sp_devlink_traps_fini(mlxsw_sp); in mlxsw_sp_fini()
2836 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_fini()
2837 mlxsw_sp_policers_fini(mlxsw_sp); in mlxsw_sp_fini()
2838 mlxsw_sp_fids_fini(mlxsw_sp); in mlxsw_sp_fini()
2839 mlxsw_sp_kvdl_fini(mlxsw_sp); in mlxsw_sp_fini()
3149 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_params_acl_region_rehash_intrvl_get() local
3151 ctx->val.vu32 = mlxsw_sp_acl_region_rehash_intrvl_get(mlxsw_sp); in mlxsw_sp_params_acl_region_rehash_intrvl_get()
3160 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_params_acl_region_rehash_intrvl_set() local
3162 return mlxsw_sp_acl_region_rehash_intrvl_set(mlxsw_sp, ctx->val.vu32); in mlxsw_sp_params_acl_region_rehash_intrvl_set()
3203 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_ptp_transmitted() local
3206 mlxsw_sp->ptp_ops->transmitted(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_transmitted()
3211 .priv_size = sizeof(struct mlxsw_sp),
3251 .priv_size = sizeof(struct mlxsw_sp),
3292 .priv_size = sizeof(struct mlxsw_sp),
3363 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev) in mlxsw_sp_lower_get()
3368 return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp : NULL; in mlxsw_sp_lower_get()
3422 static int mlxsw_sp_lag_create(struct mlxsw_sp *mlxsw_sp, u16 lag_id) in mlxsw_sp_lag_create() argument
3427 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_create()
3430 static int mlxsw_sp_lag_destroy(struct mlxsw_sp *mlxsw_sp, u16 lag_id) in mlxsw_sp_lag_destroy() argument
3435 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_destroy()
3441 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_add() local
3446 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_add()
3452 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_remove() local
3457 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_remove()
3463 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_enable() local
3468 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_enable()
3474 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_disable() local
3479 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_disable()
3482 static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lag_index_get() argument
3491 max_lag = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_LAG); in mlxsw_sp_lag_index_get()
3493 lag = mlxsw_sp_lag_get(mlxsw_sp, i); in mlxsw_sp_lag_index_get()
3510 mlxsw_sp_master_lag_check(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_master_lag_check() argument
3517 if (mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id) != 0) { in mlxsw_sp_master_lag_check()
3528 static int mlxsw_sp_port_lag_index_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_lag_index_get() argument
3534 max_lag_members = MLXSW_CORE_RES_GET(mlxsw_sp->core, in mlxsw_sp_port_lag_index_get()
3537 if (!mlxsw_sp_port_lagged_get(mlxsw_sp, lag_id, i)) { in mlxsw_sp_port_lag_index_get()
3548 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_join() local
3554 err = mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id); in mlxsw_sp_port_lag_join()
3557 lag = mlxsw_sp_lag_get(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
3559 err = mlxsw_sp_lag_create(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
3565 err = mlxsw_sp_port_lag_index_get(mlxsw_sp, lag_id, &port_index); in mlxsw_sp_port_lag_join()
3572 mlxsw_core_lag_mapping_set(mlxsw_sp->core, lag_id, port_index, in mlxsw_sp_port_lag_join()
3586 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
3593 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_leave() local
3599 lag = mlxsw_sp_lag_get(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_leave()
3613 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_leave()
3615 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_leave()
3627 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_add() local
3632 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_add()
3638 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_remove() local
3643 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_remove()
3701 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_set() local
3718 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_stp_set()
3841 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event() local
3845 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event()
3863 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev) && in mlxsw_sp_netdevice_port_upper_event()
3869 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, in mlxsw_sp_netdevice_port_upper_event()
3875 !mlxsw_sp_master_lag_check(mlxsw_sp, upper_dev, in mlxsw_sp_netdevice_port_upper_event()
3888 !mlxsw_sp_rif_exists(mlxsw_sp, lower_dev)) { in mlxsw_sp_netdevice_port_upper_event()
3929 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_port_upper_event()
4013 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_vlan_event() local
4032 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev) && in mlxsw_sp_netdevice_port_vlan_event()
4038 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, in mlxsw_sp_netdevice_port_vlan_event()
4044 !mlxsw_sp_rif_exists(mlxsw_sp, vlan_dev)) { in mlxsw_sp_netdevice_port_vlan_event()
4063 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_port_vlan_event()
4101 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(vlan_dev); in mlxsw_sp_netdevice_bridge_vlan_event() local
4106 if (!mlxsw_sp) in mlxsw_sp_netdevice_bridge_vlan_event()
4121 !mlxsw_sp_rif_exists(mlxsw_sp, vlan_dev)) { in mlxsw_sp_netdevice_bridge_vlan_event()
4131 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_vlan_event()
4161 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(br_dev); in mlxsw_sp_netdevice_bridge_event() local
4166 if (!mlxsw_sp) in mlxsw_sp_netdevice_bridge_event()
4181 !mlxsw_sp_rif_exists(mlxsw_sp, br_dev)) { in mlxsw_sp_netdevice_bridge_event()
4191 mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_event()
4193 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_event()
4203 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(macvlan_dev); in mlxsw_sp_netdevice_macvlan_event() local
4207 if (!mlxsw_sp || event != NETDEV_PRECHANGEUPPER) in mlxsw_sp_netdevice_macvlan_event()
4227 static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_vxlan_event() argument
4259 return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev, in mlxsw_sp_netdevice_vxlan_event()
4267 mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev); in mlxsw_sp_netdevice_vxlan_event()
4278 return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev, dev, 0, in mlxsw_sp_netdevice_vxlan_event()
4288 mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev); in mlxsw_sp_netdevice_vxlan_event()
4300 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_event() local
4303 mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); in mlxsw_sp_netdevice_event()
4305 span_entry = mlxsw_sp_span_entry_find_by_port(mlxsw_sp, dev); in mlxsw_sp_netdevice_event()
4307 mlxsw_sp_span_entry_invalidate(mlxsw_sp, span_entry); in mlxsw_sp_netdevice_event()
4309 mlxsw_sp_span_respin(mlxsw_sp); in mlxsw_sp_netdevice_event()
4312 err = mlxsw_sp_netdevice_vxlan_event(mlxsw_sp, dev, event, ptr); in mlxsw_sp_netdevice_event()
4313 if (mlxsw_sp_netdev_is_ipip_ol(mlxsw_sp, dev)) in mlxsw_sp_netdevice_event()
4314 err = mlxsw_sp_netdevice_ipip_ol_event(mlxsw_sp, dev, in mlxsw_sp_netdevice_event()
4316 else if (mlxsw_sp_netdev_is_ipip_ul(mlxsw_sp, dev)) in mlxsw_sp_netdevice_event()
4317 err = mlxsw_sp_netdevice_ipip_ul_event(mlxsw_sp, dev, in mlxsw_sp_netdevice_event()