Lines Matching refs:mlxsw_sp

178 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,  in mlxsw_sp_flow_counter_get()  argument
187 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_get()
197 static int mlxsw_sp_flow_counter_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_clear() argument
204 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_clear()
207 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_alloc() argument
212 err = mlxsw_sp_counter_alloc(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_alloc()
216 err = mlxsw_sp_flow_counter_clear(mlxsw_sp, *p_counter_index); in mlxsw_sp_flow_counter_alloc()
222 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_alloc()
227 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_flow_counter_free() argument
230 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_FLOW, in mlxsw_sp_flow_counter_free()
305 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_txhdr_handle() local
312 return mlxsw_sp->ptp_ops->txhdr_construct(mlxsw_core, in mlxsw_sp_txhdr_handle()
346 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_stp_set() local
356 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_vid_stp_set()
361 static int mlxsw_sp_base_mac_get(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_base_mac_get() argument
366 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(spad), spad_pl); in mlxsw_sp_base_mac_get()
369 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sp->base_mac); in mlxsw_sp_base_mac_get()
376 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set() local
382 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_admin_status_set()
388 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set() local
393 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sp_port_dev_addr_set()
398 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init() local
400 eth_hw_addr_gen(mlxsw_sp_port->dev, mlxsw_sp->base_mac, in mlxsw_sp_port_dev_addr_init()
408 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_max_mtu_get() local
413 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_max_mtu_get()
423 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set() local
431 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
434 static int mlxsw_sp_port_swid_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_swid_set() argument
440 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sp_port_swid_set()
445 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set() local
449 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svpe), svpe_pl); in mlxsw_sp_port_vp_mode_set()
455 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set() local
464 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvmlr), spvmlr_pl); in mlxsw_sp_port_vid_learning_set()
471 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_security_set() local
479 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spfsr), spfsr_pl); in mlxsw_sp_port_security_set()
506 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_egress_ethtype_set() local
516 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spevet), spevet_pl); in mlxsw_sp_port_egress_ethtype_set()
522 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_pvid_set() local
534 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl); in __mlxsw_sp_port_pvid_set()
540 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_allow_untagged_set() local
544 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl); in mlxsw_sp_port_allow_untagged_set()
576 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set() local
580 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sp_port_system_port_mapping_set()
584 mlxsw_sp_port_module_info_parse(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_module_info_parse() argument
602 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: width value is not power of … in mlxsw_sp_port_module_info_parse()
609 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple modules\n", in mlxsw_sp_port_module_info_parse()
614 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple slot index… in mlxsw_sp_port_module_info_parse()
621 …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_parse()
626 …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_parse()
641 mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp, u16 local_port, in mlxsw_sp_port_module_info_get() argument
648 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_info_get()
651 return mlxsw_sp_port_module_info_parse(mlxsw_sp, local_port, in mlxsw_sp_port_module_info_get()
656 mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u16 local_port, in mlxsw_sp_port_module_map() argument
662 mlxsw_env_module_port_map(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
674 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_map()
680 mlxsw_env_module_port_unmap(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
685 static void mlxsw_sp_port_module_unmap(struct mlxsw_sp *mlxsw_sp, u16 local_port, in mlxsw_sp_port_module_unmap() argument
692 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_unmap()
693 mlxsw_env_module_port_unmap(mlxsw_sp->core, slot_index, module); in mlxsw_sp_port_module_unmap()
699 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_open() local
702 err = mlxsw_env_module_port_up(mlxsw_sp->core, in mlxsw_sp_port_open()
714 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_open()
723 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stop() local
727 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_stop()
737 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit() local
748 if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &tx_info)) in mlxsw_sp_port_xmit()
756 err = mlxsw_sp_txhdr_handle(mlxsw_sp->core, mlxsw_sp_port, skb, in mlxsw_sp_port_xmit()
769 err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &tx_info); in mlxsw_sp_port_xmit()
891 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats_raw() local
894 return mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sp_port_get_stats_raw()
1020 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_vlan_set() local
1030 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvm), spvm_pl); in __mlxsw_sp_port_vlan_set()
1224 err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr), in mlxsw_sp_feature_loopback()
1289 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set()
1306 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_get(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get()
1321 mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, &config); in mlxsw_sp_port_ptp_clear()
1359 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_by_width_set() local
1366 ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_by_width_set()
1371 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1373 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1377 ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, &eth_proto_cap, in mlxsw_sp_port_speed_by_width_set()
1380 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1383 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1389 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_get() local
1394 port_type_speed_ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_get()
1395 port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, in mlxsw_sp_port_speed_get()
1398 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_get()
1401 port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL, in mlxsw_sp_port_speed_get()
1403 *speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper); in mlxsw_sp_port_speed_get()
1411 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_set() local
1419 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_set()
1426 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_maxrate_set() local
1434 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_maxrate_set()
1441 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_min_bw_set() local
1449 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_min_bw_set()
1455 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_prio_tc_set() local
1460 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtct), qtct_pl); in mlxsw_sp_port_prio_tc_set()
1552 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_tc_mc_mode_set() local
1556 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtctm), qtctm_pl); in mlxsw_sp_port_tc_mc_mode_set()
1561 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_overheat_init_val_set() local
1567 err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, slot_index, in mlxsw_sp_port_overheat_init_val_set()
1581 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_classification_set() local
1586 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvc), spvc_pl); in mlxsw_sp_port_vlan_classification_set()
1589 static int mlxsw_sp_port_label_info_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_label_info_get() argument
1598 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pllp), pllp_pl); in mlxsw_sp_port_label_info_get()
1606 static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u16 local_port, in mlxsw_sp_port_create() argument
1620 err = mlxsw_sp_port_module_map(mlxsw_sp, local_port, port_mapping); in mlxsw_sp_port_create()
1622 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to map module\n", in mlxsw_sp_port_create()
1627 err = mlxsw_sp_port_swid_set(mlxsw_sp, local_port, 0); in mlxsw_sp_port_create()
1629 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sp_port_create()
1634 err = mlxsw_sp_port_label_info_get(mlxsw_sp, local_port, &port_number, in mlxsw_sp_port_create()
1637 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get port label information\n", in mlxsw_sp_port_create()
1643 err = mlxsw_core_port_init(mlxsw_sp->core, local_port, slot_index, in mlxsw_sp_port_create()
1645 splittable, lanes, mlxsw_sp->base_mac, in mlxsw_sp_port_create()
1646 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_port_create()
1648 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n", in mlxsw_sp_port_create()
1658 SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); in mlxsw_sp_port_create()
1659 dev_net_set(dev, mlxsw_sp_net(mlxsw_sp)); in mlxsw_sp_port_create()
1661 mlxsw_core_port_netdev_link(mlxsw_sp->core, local_port, in mlxsw_sp_port_create()
1664 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1687 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", in mlxsw_sp_port_create()
1708 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sp_port_create()
1715 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", in mlxsw_sp_port_create()
1720 err = mlxsw_sp->port_type_speed_ops->ptys_max_speed(mlxsw_sp_port, in mlxsw_sp_port_create()
1723 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum speed\n", in mlxsw_sp_port_create()
1730 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum MTU\n", in mlxsw_sp_port_create()
1737 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sp_port_create()
1748 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize buffers\n", in mlxsw_sp_port_create()
1755 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize ETS\n", in mlxsw_sp_port_create()
1762 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC MC mode\n", in mlxsw_sp_port_create()
1770 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize DCB\n", in mlxsw_sp_port_create()
1777 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize FIDs\n", in mlxsw_sp_port_create()
1784 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC qdiscs\n", in mlxsw_sp_port_create()
1792 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to clear VLAN filter\n", in mlxsw_sp_port_create()
1799 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize NVE\n", in mlxsw_sp_port_create()
1807 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set PVID\n", in mlxsw_sp_port_create()
1815 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n", in mlxsw_sp_port_create()
1827 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set default VLAN classification\n", in mlxsw_sp_port_create()
1833 mlxsw_sp->ptp_ops->shaper_work); in mlxsw_sp_port_create()
1835 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1839 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set overheat initial value\n", in mlxsw_sp_port_create()
1846 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sp_port_create()
1858 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_create()
1887 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_create()
1890 mlxsw_sp_port_swid_set(mlxsw_sp, local_port, in mlxsw_sp_port_create()
1893 mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, in mlxsw_sp_port_create()
1899 static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u16 local_port) in mlxsw_sp_port_remove() argument
1901 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove()
1910 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_remove()
1921 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_remove()
1922 mlxsw_sp_port_swid_set(mlxsw_sp, local_port, in mlxsw_sp_port_remove()
1924 mlxsw_sp_port_module_unmap(mlxsw_sp, local_port, slot_index, module); in mlxsw_sp_port_remove()
1927 static int mlxsw_sp_cpu_port_create(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_cpu_port_create() argument
1936 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_cpu_port_create()
1939 err = mlxsw_core_cpu_port_init(mlxsw_sp->core, in mlxsw_sp_cpu_port_create()
1941 mlxsw_sp->base_mac, in mlxsw_sp_cpu_port_create()
1942 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_cpu_port_create()
1944 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize core CPU port\n"); in mlxsw_sp_cpu_port_create()
1948 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = mlxsw_sp_port; in mlxsw_sp_cpu_port_create()
1956 static void mlxsw_sp_cpu_port_remove(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_cpu_port_remove() argument
1959 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp_cpu_port_remove()
1961 mlxsw_core_cpu_port_fini(mlxsw_sp->core); in mlxsw_sp_cpu_port_remove()
1962 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = NULL; in mlxsw_sp_cpu_port_remove()
1971 static bool mlxsw_sp_port_created(struct mlxsw_sp *mlxsw_sp, u16 local_port) in mlxsw_sp_port_created() argument
1975 return mlxsw_sp->ports[local_port] != NULL; in mlxsw_sp_port_created()
1978 static int mlxsw_sp_port_mapping_event_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_mapping_event_set() argument
1986 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmecr), pmecr_pl); in mlxsw_sp_port_mapping_event_set()
1999 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_port_mapping_events_work() local
2006 mlxsw_sp = container_of(events, struct mlxsw_sp, port_mapping_events); in mlxsw_sp_port_mapping_events_work()
2007 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_port_mapping_events_work()
2015 err = mlxsw_sp_port_module_info_parse(mlxsw_sp, local_port, in mlxsw_sp_port_mapping_events_work()
2025 if (!mlxsw_sp_port_created(mlxsw_sp, local_port)) in mlxsw_sp_port_mapping_events_work()
2026 mlxsw_sp_port_create(mlxsw_sp, local_port, in mlxsw_sp_port_mapping_events_work()
2033 mlxsw_sp->port_mapping[local_port] = port_mapping; in mlxsw_sp_port_mapping_events_work()
2046 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_port_mapping_listener_func() local
2050 if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) in mlxsw_sp_port_mapping_listener_func()
2053 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_port_mapping_listener_func()
2065 __mlxsw_sp_port_mapping_events_cancel(struct mlxsw_sp *mlxsw_sp) in __mlxsw_sp_port_mapping_events_cancel() argument
2070 events = &mlxsw_sp->port_mapping_events; in __mlxsw_sp_port_mapping_events_cancel()
2080 static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_remove() argument
2082 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_remove()
2086 mlxsw_sp_port_mapping_event_set(mlxsw_sp, i, false); in mlxsw_sp_ports_remove()
2088 __mlxsw_sp_port_mapping_events_cancel(mlxsw_sp); in mlxsw_sp_ports_remove()
2091 if (mlxsw_sp_port_created(mlxsw_sp, i)) in mlxsw_sp_ports_remove()
2092 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_remove()
2093 mlxsw_sp_cpu_port_remove(mlxsw_sp); in mlxsw_sp_ports_remove()
2094 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_remove()
2095 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_remove()
2103 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_ports_remove_selected() local
2108 if (mlxsw_sp_port_created(mlxsw_sp, i) && selector(priv, i)) in mlxsw_sp_ports_remove_selected()
2109 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_remove_selected()
2112 static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ports_create() argument
2114 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_create()
2122 mlxsw_sp->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_ports_create()
2123 if (!mlxsw_sp->ports) in mlxsw_sp_ports_create()
2126 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_ports_create()
2132 err = mlxsw_sp_port_mapping_event_set(mlxsw_sp, i, true); in mlxsw_sp_ports_create()
2137 err = mlxsw_sp_cpu_port_create(mlxsw_sp); in mlxsw_sp_ports_create()
2142 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_ports_create()
2145 err = mlxsw_sp_port_create(mlxsw_sp, i, false, port_mapping); in mlxsw_sp_ports_create()
2153 if (mlxsw_sp_port_created(mlxsw_sp, i)) in mlxsw_sp_ports_create()
2154 mlxsw_sp_port_remove(mlxsw_sp, i); in mlxsw_sp_ports_create()
2156 mlxsw_sp_cpu_port_remove(mlxsw_sp); in mlxsw_sp_ports_create()
2160 mlxsw_sp_port_mapping_event_set(mlxsw_sp, i, false); in mlxsw_sp_ports_create()
2162 __mlxsw_sp_port_mapping_events_cancel(mlxsw_sp); in mlxsw_sp_ports_create()
2163 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_create()
2164 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_create()
2168 static int mlxsw_sp_port_module_info_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_port_module_info_init() argument
2170 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_port_module_info_init()
2175 mlxsw_sp->port_mapping = kcalloc(max_ports, in mlxsw_sp_port_module_info_init()
2178 if (!mlxsw_sp->port_mapping) in mlxsw_sp_port_module_info_init()
2182 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_port_module_info_init()
2183 err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, port_mapping); in mlxsw_sp_port_module_info_init()
2190 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_init()
2194 static void mlxsw_sp_port_module_info_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_port_module_info_fini() argument
2196 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_fini()
2200 mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_split_create() argument
2215 err = mlxsw_sp_port_create(mlxsw_sp, s_local_port, in mlxsw_sp_port_split_create()
2228 if (mlxsw_sp_port_created(mlxsw_sp, s_local_port)) in mlxsw_sp_port_split_create()
2229 mlxsw_sp_port_remove(mlxsw_sp, s_local_port); in mlxsw_sp_port_split_create()
2234 static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_unsplit_create() argument
2245 port_mapping = &mlxsw_sp->port_mapping[local_port]; in mlxsw_sp_port_unsplit_create()
2248 mlxsw_sp_port_create(mlxsw_sp, local_port, in mlxsw_sp_port_unsplit_create()
2254 mlxsw_sp_port_get_by_local_port(struct mlxsw_sp *mlxsw_sp, u16 local_port) in mlxsw_sp_port_get_by_local_port() argument
2256 if (mlxsw_sp->ports && mlxsw_sp->ports[local_port]) in mlxsw_sp_port_get_by_local_port()
2257 return mlxsw_sp->ports[local_port]; in mlxsw_sp_port_get_by_local_port()
2265 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_port_split() local
2273 mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port); in mlxsw_sp_port_split()
2275 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_split()
2307 if (mlxsw_sp_port_created(mlxsw_sp, s_local_port)) in mlxsw_sp_port_split()
2308 mlxsw_sp_port_remove(mlxsw_sp, s_local_port); in mlxsw_sp_port_split()
2311 err = mlxsw_sp_port_split_create(mlxsw_sp, &port_mapping, in mlxsw_sp_port_split()
2314 dev_err(mlxsw_sp->bus_info->dev, "Failed to create split ports\n"); in mlxsw_sp_port_split()
2321 mlxsw_sp_port_unsplit_create(mlxsw_sp, count, pmtdb_pl); in mlxsw_sp_port_split()
2329 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_port_unsplit() local
2336 mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port); in mlxsw_sp_port_unsplit()
2338 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_unsplit()
2365 if (mlxsw_sp_port_created(mlxsw_sp, s_local_port)) in mlxsw_sp_port_unsplit()
2366 mlxsw_sp_port_remove(mlxsw_sp, s_local_port); in mlxsw_sp_port_unsplit()
2369 mlxsw_sp_port_unsplit_create(mlxsw_sp, count, pmtdb_pl); in mlxsw_sp_port_unsplit()
2386 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_pude_event_func() local
2393 if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) in mlxsw_sp_pude_event_func()
2395 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
2411 static void mlxsw_sp1_ptp_fifo_event_func(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp1_ptp_fifo_event_func() argument
2429 mlxsw_sp1_ptp_got_timestamp(mlxsw_sp, ingress, local_port, in mlxsw_sp1_ptp_fifo_event_func()
2438 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp1_ptp_ing_fifo_event_func() local
2440 mlxsw_sp1_ptp_fifo_event_func(mlxsw_sp, mtpptr_pl, true); in mlxsw_sp1_ptp_ing_fifo_event_func()
2446 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp1_ptp_egr_fifo_event_func() local
2448 mlxsw_sp1_ptp_fifo_event_func(mlxsw_sp, mtpptr_pl, false); in mlxsw_sp1_ptp_egr_fifo_event_func()
2454 struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_rx_listener_no_mark_func() local
2455 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_no_mark_func()
2459 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()
2491 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, in mlxsw_sp_ptp_receive() argument
2494 mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_receive()
2551 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_cpu_policers_set() local
2579 __set_bit(i, mlxsw_sp->trap->policers_usage); in mlxsw_sp_cpu_policers_set()
2637 static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_init() argument
2643 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_CPU_POLICERS)) in mlxsw_sp_traps_init()
2645 max_policers = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_CPU_POLICERS); in mlxsw_sp_traps_init()
2651 mlxsw_sp->trap = trap; in mlxsw_sp_traps_init()
2653 err = mlxsw_sp_cpu_policers_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2657 err = mlxsw_sp_trap_groups_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2661 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2663 mlxsw_sp); in mlxsw_sp_traps_init()
2667 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_init()
2668 mlxsw_sp->listeners_count, mlxsw_sp); in mlxsw_sp_traps_init()
2675 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2677 mlxsw_sp); in mlxsw_sp_traps_init()
2685 static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_traps_fini() argument
2687 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_fini()
2688 mlxsw_sp->listeners_count, in mlxsw_sp_traps_fini()
2689 mlxsw_sp); in mlxsw_sp_traps_fini()
2690 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_fini()
2691 ARRAY_SIZE(mlxsw_sp_listener), mlxsw_sp); in mlxsw_sp_traps_fini()
2692 kfree(mlxsw_sp->trap); in mlxsw_sp_traps_fini()
2697 static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lag_init() argument
2704 seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), in mlxsw_sp_lag_init()
2715 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcr), slcr_pl); in mlxsw_sp_lag_init()
2719 err = mlxsw_core_max_lag(mlxsw_sp->core, &max_lag); in mlxsw_sp_lag_init()
2723 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS)) in mlxsw_sp_lag_init()
2726 mlxsw_sp->lags = kcalloc(max_lag, sizeof(struct mlxsw_sp_upper), in mlxsw_sp_lag_init()
2728 if (!mlxsw_sp->lags) in mlxsw_sp_lag_init()
2734 static void mlxsw_sp_lag_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lag_fini() argument
2736 kfree(mlxsw_sp->lags); in mlxsw_sp_lag_fini()
2816 mlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_sample_trigger_params_lookup() argument
2823 trigger_node = rhashtable_lookup(&mlxsw_sp->sample_trigger_ht, &key, in mlxsw_sp_sample_trigger_params_lookup()
2832 mlxsw_sp_sample_trigger_node_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_sample_trigger_node_init() argument
2847 err = rhashtable_insert_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_init()
2861 mlxsw_sp_sample_trigger_node_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_sample_trigger_node_fini() argument
2864 rhashtable_remove_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_fini()
2871 mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_sample_trigger_params_set() argument
2883 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_set()
2887 return mlxsw_sp_sample_trigger_node_init(mlxsw_sp, &key, in mlxsw_sp_sample_trigger_params_set()
2909 mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_sample_trigger_params_unset() argument
2919 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_unset()
2928 mlxsw_sp_sample_trigger_node_fini(mlxsw_sp, trigger_node); in mlxsw_sp_sample_trigger_params_unset()
2938 static void mlxsw_sp_parsing_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_parsing_init() argument
2940 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 0); in mlxsw_sp_parsing_init()
2941 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_init()
2942 mlxsw_sp->parsing.vxlan_udp_dport = MLXSW_SP_DEFAULT_VXLAN_UDP_DPORT; in mlxsw_sp_parsing_init()
2943 mutex_init(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_init()
2946 static void mlxsw_sp_parsing_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_parsing_fini() argument
2948 mutex_destroy(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_fini()
2949 WARN_ON_ONCE(refcount_read(&mlxsw_sp->parsing.parsing_depth_ref)); in mlxsw_sp_parsing_fini()
2967 mlxsw_sp_ipv6_addr_init(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6, in mlxsw_sp_ipv6_addr_init() argument
2974 err = mlxsw_sp_kvdl_alloc(mlxsw_sp, in mlxsw_sp_ipv6_addr_init()
2981 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rips), rips_pl); in mlxsw_sp_ipv6_addr_init()
2995 err = rhashtable_insert_fast(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_init()
3007 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, in mlxsw_sp_ipv6_addr_init()
3012 static void mlxsw_sp_ipv6_addr_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipv6_addr_fini() argument
3017 rhashtable_remove_fast(&mlxsw_sp->ipv6_addr_ht, &node->ht_node, in mlxsw_sp_ipv6_addr_fini()
3020 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 1, in mlxsw_sp_ipv6_addr_fini()
3024 int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipv6_addr_kvdl_index_get() argument
3031 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3032 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_kvdl_index_get()
3040 err = mlxsw_sp_ipv6_addr_init(mlxsw_sp, addr6, p_kvdl_index); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3043 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3048 mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6) in mlxsw_sp_ipv6_addr_put() argument
3052 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
3053 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_put()
3061 mlxsw_sp_ipv6_addr_fini(mlxsw_sp, node); in mlxsw_sp_ipv6_addr_put()
3064 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
3067 static int mlxsw_sp_ipv6_addr_ht_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ipv6_addr_ht_init() argument
3071 err = rhashtable_init(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_ht_init()
3076 mutex_init(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_init()
3080 static void mlxsw_sp_ipv6_addr_ht_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ipv6_addr_ht_fini() argument
3082 mutex_destroy(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_fini()
3083 rhashtable_destroy(&mlxsw_sp->ipv6_addr_ht); in mlxsw_sp_ipv6_addr_ht_fini()
3090 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_init() local
3093 mlxsw_sp->core = mlxsw_core; in mlxsw_sp_init()
3094 mlxsw_sp->bus_info = mlxsw_bus_info; in mlxsw_sp_init()
3096 mlxsw_sp_parsing_init(mlxsw_sp); in mlxsw_sp_init()
3098 err = mlxsw_sp_base_mac_get(mlxsw_sp); in mlxsw_sp_init()
3100 dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); in mlxsw_sp_init()
3104 err = mlxsw_sp_kvdl_init(mlxsw_sp); in mlxsw_sp_init()
3106 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize KVDL\n"); in mlxsw_sp_init()
3110 err = mlxsw_sp_pgt_init(mlxsw_sp); in mlxsw_sp_init()
3112 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PGT\n"); in mlxsw_sp_init()
3116 err = mlxsw_sp_fids_init(mlxsw_sp); in mlxsw_sp_init()
3118 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize FIDs\n"); in mlxsw_sp_init()
3122 err = mlxsw_sp_policers_init(mlxsw_sp); in mlxsw_sp_init()
3124 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize policers\n"); in mlxsw_sp_init()
3128 err = mlxsw_sp_traps_init(mlxsw_sp); in mlxsw_sp_init()
3130 dev_err(mlxsw_sp->bus_info->dev, "Failed to set traps\n"); in mlxsw_sp_init()
3134 err = mlxsw_sp_devlink_traps_init(mlxsw_sp); in mlxsw_sp_init()
3136 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize devlink traps\n"); in mlxsw_sp_init()
3140 err = mlxsw_sp_buffers_init(mlxsw_sp); in mlxsw_sp_init()
3142 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize buffers\n"); in mlxsw_sp_init()
3146 err = mlxsw_sp_lag_init(mlxsw_sp); in mlxsw_sp_init()
3148 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize LAG\n"); in mlxsw_sp_init()
3155 err = mlxsw_sp_span_init(mlxsw_sp); in mlxsw_sp_init()
3157 dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n"); in mlxsw_sp_init()
3161 err = mlxsw_sp_switchdev_init(mlxsw_sp); in mlxsw_sp_init()
3163 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); in mlxsw_sp_init()
3167 err = mlxsw_sp_counter_pool_init(mlxsw_sp); in mlxsw_sp_init()
3169 dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter pool\n"); in mlxsw_sp_init()
3173 err = mlxsw_sp_afa_init(mlxsw_sp); in mlxsw_sp_init()
3175 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL actions\n"); in mlxsw_sp_init()
3179 err = mlxsw_sp_ipv6_addr_ht_init(mlxsw_sp); in mlxsw_sp_init()
3181 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize hash table for IPv6 addresses\n"); in mlxsw_sp_init()
3185 err = mlxsw_sp_nve_init(mlxsw_sp); in mlxsw_sp_init()
3187 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize NVE\n"); in mlxsw_sp_init()
3191 err = mlxsw_sp_port_range_init(mlxsw_sp); in mlxsw_sp_init()
3193 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize port ranges\n"); in mlxsw_sp_init()
3197 err = mlxsw_sp_acl_init(mlxsw_sp); in mlxsw_sp_init()
3199 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL\n"); in mlxsw_sp_init()
3203 err = mlxsw_sp_router_init(mlxsw_sp, extack); in mlxsw_sp_init()
3205 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize router\n"); in mlxsw_sp_init()
3209 if (mlxsw_sp->bus_info->read_clock_capable) { in mlxsw_sp_init()
3211 mlxsw_sp->clock = in mlxsw_sp_init()
3212 mlxsw_sp->ptp_ops->clock_init(mlxsw_sp, in mlxsw_sp_init()
3213 mlxsw_sp->bus_info->dev); in mlxsw_sp_init()
3214 if (IS_ERR(mlxsw_sp->clock)) { in mlxsw_sp_init()
3215 err = PTR_ERR(mlxsw_sp->clock); in mlxsw_sp_init()
3216 dev_err(mlxsw_sp->bus_info->dev, "Failed to init ptp clock\n"); in mlxsw_sp_init()
3221 if (mlxsw_sp->clock) { in mlxsw_sp_init()
3223 mlxsw_sp->ptp_state = mlxsw_sp->ptp_ops->init(mlxsw_sp); in mlxsw_sp_init()
3224 if (IS_ERR(mlxsw_sp->ptp_state)) { in mlxsw_sp_init()
3225 err = PTR_ERR(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3226 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PTP\n"); in mlxsw_sp_init()
3234 mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event; in mlxsw_sp_init()
3235 err = register_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_init()
3236 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3238 dev_err(mlxsw_sp->bus_info->dev, "Failed to register netdev notifier\n"); in mlxsw_sp_init()
3242 err = mlxsw_sp_dpipe_init(mlxsw_sp); in mlxsw_sp_init()
3244 dev_err(mlxsw_sp->bus_info->dev, "Failed to init pipeline debug\n"); in mlxsw_sp_init()
3248 err = mlxsw_sp_port_module_info_init(mlxsw_sp); in mlxsw_sp_init()
3250 dev_err(mlxsw_sp->bus_info->dev, "Failed to init port module info\n"); in mlxsw_sp_init()
3254 err = rhashtable_init(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_init()
3257 dev_err(mlxsw_sp->bus_info->dev, "Failed to init sampling trigger hashtable\n"); in mlxsw_sp_init()
3261 err = mlxsw_sp_ports_create(mlxsw_sp); in mlxsw_sp_init()
3263 dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n"); in mlxsw_sp_init()
3270 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_init()
3272 mlxsw_sp_port_module_info_fini(mlxsw_sp); in mlxsw_sp_init()
3274 mlxsw_sp_dpipe_fini(mlxsw_sp); in mlxsw_sp_init()
3276 unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_init()
3277 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3279 if (mlxsw_sp->clock) in mlxsw_sp_init()
3280 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3282 if (mlxsw_sp->clock) in mlxsw_sp_init()
3283 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_init()
3285 mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_init()
3287 mlxsw_sp_acl_fini(mlxsw_sp); in mlxsw_sp_init()
3289 mlxsw_sp_port_range_fini(mlxsw_sp); in mlxsw_sp_init()
3291 mlxsw_sp_nve_fini(mlxsw_sp); in mlxsw_sp_init()
3293 mlxsw_sp_ipv6_addr_ht_fini(mlxsw_sp); in mlxsw_sp_init()
3295 mlxsw_sp_afa_fini(mlxsw_sp); in mlxsw_sp_init()
3297 mlxsw_sp_counter_pool_fini(mlxsw_sp); in mlxsw_sp_init()
3299 mlxsw_sp_switchdev_fini(mlxsw_sp); in mlxsw_sp_init()
3301 mlxsw_sp_span_fini(mlxsw_sp); in mlxsw_sp_init()
3303 mlxsw_sp_lag_fini(mlxsw_sp); in mlxsw_sp_init()
3305 mlxsw_sp_buffers_fini(mlxsw_sp); in mlxsw_sp_init()
3307 mlxsw_sp_devlink_traps_fini(mlxsw_sp); in mlxsw_sp_init()
3309 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_init()
3311 mlxsw_sp_policers_fini(mlxsw_sp); in mlxsw_sp_init()
3313 mlxsw_sp_fids_fini(mlxsw_sp); in mlxsw_sp_init()
3315 mlxsw_sp_pgt_fini(mlxsw_sp); in mlxsw_sp_init()
3317 mlxsw_sp_kvdl_fini(mlxsw_sp); in mlxsw_sp_init()
3318 mlxsw_sp_parsing_fini(mlxsw_sp); in mlxsw_sp_init()
3326 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp1_init() local
3328 mlxsw_sp->switchdev_ops = &mlxsw_sp1_switchdev_ops; in mlxsw_sp1_init()
3329 mlxsw_sp->kvdl_ops = &mlxsw_sp1_kvdl_ops; in mlxsw_sp1_init()
3330 mlxsw_sp->afa_ops = &mlxsw_sp1_act_afa_ops; in mlxsw_sp1_init()
3331 mlxsw_sp->afk_ops = &mlxsw_sp1_afk_ops; in mlxsw_sp1_init()
3332 mlxsw_sp->mr_tcam_ops = &mlxsw_sp1_mr_tcam_ops; in mlxsw_sp1_init()
3333 mlxsw_sp->acl_rulei_ops = &mlxsw_sp1_acl_rulei_ops; in mlxsw_sp1_init()
3334 mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops; in mlxsw_sp1_init()
3335 mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr; in mlxsw_sp1_init()
3336 mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask; in mlxsw_sp1_init()
3337 mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals; in mlxsw_sp1_init()
3338 mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops; in mlxsw_sp1_init()
3339 mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops; in mlxsw_sp1_init()
3340 mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops; in mlxsw_sp1_init()
3341 mlxsw_sp->span_ops = &mlxsw_sp1_span_ops; in mlxsw_sp1_init()
3342 mlxsw_sp->policer_core_ops = &mlxsw_sp1_policer_core_ops; in mlxsw_sp1_init()
3343 mlxsw_sp->trap_ops = &mlxsw_sp1_trap_ops; in mlxsw_sp1_init()
3344 mlxsw_sp->mall_ops = &mlxsw_sp1_mall_ops; in mlxsw_sp1_init()
3345 mlxsw_sp->router_ops = &mlxsw_sp1_router_ops; in mlxsw_sp1_init()
3346 mlxsw_sp->listeners = mlxsw_sp1_listener; in mlxsw_sp1_init()
3347 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener); in mlxsw_sp1_init()
3348 mlxsw_sp->fid_family_arr = mlxsw_sp1_fid_family_arr; in mlxsw_sp1_init()
3349 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1; in mlxsw_sp1_init()
3350 mlxsw_sp->pgt_smpe_index_valid = true; in mlxsw_sp1_init()
3359 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp2_init() local
3361 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp2_init()
3362 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp2_init()
3363 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp2_init()
3364 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp2_init()
3365 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp2_init()
3366 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp2_init()
3367 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp2_init()
3368 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp2_init()
3369 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp2_init()
3370 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp2_init()
3371 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp2_init()
3372 mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops; in mlxsw_sp2_init()
3373 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp2_init()
3374 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp2_init()
3375 mlxsw_sp->span_ops = &mlxsw_sp2_span_ops; in mlxsw_sp2_init()
3376 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp2_init()
3377 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp2_init()
3378 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp2_init()
3379 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp2_init()
3380 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp2_init()
3381 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp2_init()
3382 mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr; in mlxsw_sp2_init()
3383 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2; in mlxsw_sp2_init()
3384 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp2_init()
3393 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp3_init() local
3395 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp3_init()
3396 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp3_init()
3397 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp3_init()
3398 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp3_init()
3399 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp3_init()
3400 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp3_init()
3401 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp3_init()
3402 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp3_init()
3403 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp3_init()
3404 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp3_init()
3405 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp3_init()
3406 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp3_init()
3407 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp3_init()
3408 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp3_init()
3409 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp3_init()
3410 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp3_init()
3411 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp3_init()
3412 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp3_init()
3413 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp3_init()
3414 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp3_init()
3415 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp3_init()
3416 mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr; in mlxsw_sp3_init()
3417 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; in mlxsw_sp3_init()
3418 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp3_init()
3427 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp4_init() local
3429 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp4_init()
3430 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp4_init()
3431 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp4_init()
3432 mlxsw_sp->afk_ops = &mlxsw_sp4_afk_ops; in mlxsw_sp4_init()
3433 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp4_init()
3434 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp4_init()
3435 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp4_init()
3436 mlxsw_sp->acl_bf_ops = &mlxsw_sp4_acl_bf_ops; in mlxsw_sp4_init()
3437 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp4_init()
3438 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp4_init()
3439 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp4_init()
3440 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp4_init()
3441 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp4_init()
3442 mlxsw_sp->ptp_ops = &mlxsw_sp4_ptp_ops; in mlxsw_sp4_init()
3443 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp4_init()
3444 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp4_init()
3445 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp4_init()
3446 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp4_init()
3447 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp4_init()
3448 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp4_init()
3449 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp4_init()
3450 mlxsw_sp->fid_family_arr = mlxsw_sp2_fid_family_arr; in mlxsw_sp4_init()
3451 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4; in mlxsw_sp4_init()
3452 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp4_init()
3459 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_fini() local
3461 mlxsw_sp_ports_remove(mlxsw_sp); in mlxsw_sp_fini()
3462 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_fini()
3463 mlxsw_sp_port_module_info_fini(mlxsw_sp); in mlxsw_sp_fini()
3464 mlxsw_sp_dpipe_fini(mlxsw_sp); in mlxsw_sp_fini()
3465 unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_fini()
3466 &mlxsw_sp->netdevice_nb); in mlxsw_sp_fini()
3467 if (mlxsw_sp->clock) { in mlxsw_sp_fini()
3468 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_fini()
3469 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_fini()
3471 mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_fini()
3472 mlxsw_sp_acl_fini(mlxsw_sp); in mlxsw_sp_fini()
3473 mlxsw_sp_port_range_fini(mlxsw_sp); in mlxsw_sp_fini()
3474 mlxsw_sp_nve_fini(mlxsw_sp); in mlxsw_sp_fini()
3475 mlxsw_sp_ipv6_addr_ht_fini(mlxsw_sp); in mlxsw_sp_fini()
3476 mlxsw_sp_afa_fini(mlxsw_sp); in mlxsw_sp_fini()
3477 mlxsw_sp_counter_pool_fini(mlxsw_sp); in mlxsw_sp_fini()
3478 mlxsw_sp_switchdev_fini(mlxsw_sp); in mlxsw_sp_fini()
3479 mlxsw_sp_span_fini(mlxsw_sp); in mlxsw_sp_fini()
3480 mlxsw_sp_lag_fini(mlxsw_sp); in mlxsw_sp_fini()
3481 mlxsw_sp_buffers_fini(mlxsw_sp); in mlxsw_sp_fini()
3482 mlxsw_sp_devlink_traps_fini(mlxsw_sp); in mlxsw_sp_fini()
3483 mlxsw_sp_traps_fini(mlxsw_sp); in mlxsw_sp_fini()
3484 mlxsw_sp_policers_fini(mlxsw_sp); in mlxsw_sp_fini()
3485 mlxsw_sp_fids_fini(mlxsw_sp); in mlxsw_sp_fini()
3486 mlxsw_sp_pgt_fini(mlxsw_sp); in mlxsw_sp_fini()
3487 mlxsw_sp_kvdl_fini(mlxsw_sp); in mlxsw_sp_fini()
3488 mlxsw_sp_parsing_fini(mlxsw_sp); in mlxsw_sp_fini()
3908 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); in mlxsw_sp_ptp_transmitted() local
3911 mlxsw_sp->ptp_ops->transmitted(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_transmitted()
3916 .priv_size = sizeof(struct mlxsw_sp),
3953 .priv_size = sizeof(struct mlxsw_sp),
3990 .priv_size = sizeof(struct mlxsw_sp),
4027 .priv_size = sizeof(struct mlxsw_sp),
4092 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev) in mlxsw_sp_lower_get()
4097 return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp : NULL; in mlxsw_sp_lower_get()
4115 int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_parsing_depth_inc() argument
4120 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4122 if (refcount_inc_not_zero(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_inc()
4126 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_inc()
4127 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_inc()
4131 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_INCREASED_PARSING_DEPTH; in mlxsw_sp_parsing_depth_inc()
4132 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 1); in mlxsw_sp_parsing_depth_inc()
4135 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4139 void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_parsing_depth_dec() argument
4143 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4145 if (!refcount_dec_and_test(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_dec()
4149 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_dec()
4150 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_dec()
4151 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_depth_dec()
4154 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4157 int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_parsing_vxlan_udp_dport_set() argument
4163 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4165 mlxsw_reg_mprs_pack(mprs_pl, mlxsw_sp->parsing.parsing_depth, in mlxsw_sp_parsing_vxlan_udp_dport_set()
4167 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4171 mlxsw_sp->parsing.vxlan_udp_dport = be16_to_cpu(udp_dport); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4174 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4197 static int mlxsw_sp_lag_create(struct mlxsw_sp *mlxsw_sp, u16 lag_id) in mlxsw_sp_lag_create() argument
4202 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_create()
4205 static int mlxsw_sp_lag_destroy(struct mlxsw_sp *mlxsw_sp, u16 lag_id) in mlxsw_sp_lag_destroy() argument
4210 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_destroy()
4216 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_add() local
4221 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_add()
4227 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_remove() local
4232 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_remove()
4238 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_enable() local
4243 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_enable()
4249 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_disable() local
4254 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_disable()
4257 static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lag_index_get() argument
4266 err = mlxsw_core_max_lag(mlxsw_sp->core, &max_lag); in mlxsw_sp_lag_index_get()
4271 lag = mlxsw_sp_lag_get(mlxsw_sp, i); in mlxsw_sp_lag_index_get()
4288 mlxsw_sp_master_lag_check(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_master_lag_check() argument
4295 if (mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id) != 0) { in mlxsw_sp_master_lag_check()
4306 static int mlxsw_sp_port_lag_index_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_lag_index_get() argument
4312 max_lag_members = MLXSW_CORE_RES_GET(mlxsw_sp->core, in mlxsw_sp_port_lag_index_get()
4315 if (!mlxsw_sp_port_lagged_get(mlxsw_sp, lag_id, i)) { in mlxsw_sp_port_lag_index_get()
4409 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_join() local
4415 err = mlxsw_sp_lag_index_get(mlxsw_sp, lag_dev, &lag_id); in mlxsw_sp_port_lag_join()
4418 lag = mlxsw_sp_lag_get(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
4420 err = mlxsw_sp_lag_create(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
4426 err = mlxsw_sp_port_lag_index_get(mlxsw_sp, lag_id, &port_index); in mlxsw_sp_port_lag_join()
4439 mlxsw_core_lag_mapping_set(mlxsw_sp->core, lag_id, port_index, in mlxsw_sp_port_lag_join()
4455 err = mlxsw_sp_netdevice_enslavement_replay(mlxsw_sp, lag_dev, extack); in mlxsw_sp_port_lag_join()
4466 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_join()
4473 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_join()
4480 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_leave() local
4486 lag = mlxsw_sp_lag_get(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_leave()
4500 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); in mlxsw_sp_port_lag_leave()
4502 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_leave()
4515 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_add() local
4520 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_add()
4526 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_remove() local
4531 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_remove()
4589 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_set() local
4606 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_stp_set()
4727 static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp,
4731 static int mlxsw_sp_netdevice_validate_uppers(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_validate_uppers() argument
4758 err = __mlxsw_sp_netdevice_event(mlxsw_sp, in mlxsw_sp_netdevice_validate_uppers()
4764 err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, upper_dev, in mlxsw_sp_netdevice_validate_uppers()
4782 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event() local
4787 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event()
4806 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev) && in mlxsw_sp_netdevice_port_upper_event()
4812 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, in mlxsw_sp_netdevice_port_upper_event()
4814 err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, in mlxsw_sp_netdevice_port_upper_event()
4821 !mlxsw_sp_master_lag_check(mlxsw_sp, upper_dev, in mlxsw_sp_netdevice_port_upper_event()
4890 mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, in mlxsw_sp_netdevice_port_upper_event()
4901 mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, in mlxsw_sp_netdevice_port_upper_event()
4911 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_port_upper_event()
4979 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(dev); in mlxsw_sp_netdevice_post_lag_event() local
4982 if (!mlxsw_sp) in mlxsw_sp_netdevice_post_lag_event()
4990 mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, dev); in mlxsw_sp_netdevice_post_lag_event()
5021 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_vlan_event() local
5041 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev) && in mlxsw_sp_netdevice_port_vlan_event()
5047 !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, in mlxsw_sp_netdevice_port_vlan_event()
5049 err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, in mlxsw_sp_netdevice_port_vlan_event()
5070 mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, in mlxsw_sp_netdevice_port_vlan_event()
5075 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_port_vlan_event()
5105 static int mlxsw_sp_netdevice_bridge_vlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_bridge_vlan_event() argument
5134 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_vlan_event()
5141 static int mlxsw_sp_netdevice_vlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_vlan_event() argument
5158 return mlxsw_sp_netdevice_bridge_vlan_event(mlxsw_sp, vlan_dev, in mlxsw_sp_netdevice_vlan_event()
5166 static int mlxsw_sp_netdevice_bridge_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_bridge_event() argument
5210 mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_event()
5212 mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); in mlxsw_sp_netdevice_bridge_event()
5222 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(macvlan_dev); in mlxsw_sp_netdevice_macvlan_event() local
5227 if (!mlxsw_sp || event != NETDEV_PRECHANGEUPPER) in mlxsw_sp_netdevice_macvlan_event()
5241 static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_vxlan_event() argument
5273 return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev, in mlxsw_sp_netdevice_vxlan_event()
5281 mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev); in mlxsw_sp_netdevice_vxlan_event()
5292 return mlxsw_sp_bridge_vxlan_join(mlxsw_sp, upper_dev, dev, 0, in mlxsw_sp_netdevice_vxlan_event()
5302 mlxsw_sp_bridge_vxlan_leave(mlxsw_sp, dev); in mlxsw_sp_netdevice_vxlan_event()
5309 static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_netdevice_event() argument
5318 span_entry = mlxsw_sp_span_entry_find_by_port(mlxsw_sp, dev); in __mlxsw_sp_netdevice_event()
5320 mlxsw_sp_span_entry_invalidate(mlxsw_sp, span_entry); in __mlxsw_sp_netdevice_event()
5324 err = mlxsw_sp_netdevice_vxlan_event(mlxsw_sp, dev, event, ptr); in __mlxsw_sp_netdevice_event()
5330 err = mlxsw_sp_netdevice_vlan_event(mlxsw_sp, dev, event, ptr, in __mlxsw_sp_netdevice_event()
5333 err = mlxsw_sp_netdevice_bridge_event(mlxsw_sp, dev, event, ptr, in __mlxsw_sp_netdevice_event()
5344 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_event() local
5347 mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); in mlxsw_sp_netdevice_event()
5348 mlxsw_sp_span_respin(mlxsw_sp); in mlxsw_sp_netdevice_event()
5349 err = __mlxsw_sp_netdevice_event(mlxsw_sp, event, ptr, false); in mlxsw_sp_netdevice_event()