Lines Matching +full:core +full:- +full:module

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
5 #include <linux/module.h>
16 #include "core.h"
30 struct mlxsw_core *core; member
50 u8 module; member
62 * 0 - Ethernet control (e.g. EMADs, LACP)
63 * 1 - Ethernet data
75 * Range is 0-15, where 15 is the highest priority.
126 * 0 - Data packets
127 * 6 - Control packets
135 bool is_emad = tx_info->is_emad; in mlxsw_sx_txhdr_construct()
146 mlxsw_tx_hdr_port_mid_set(txhdr, tx_info->local_port); in mlxsw_sx_txhdr_construct()
161 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_admin_status_set()
164 mlxsw_reg_paos_pack(paos_pl, mlxsw_sx_port->local_port, in mlxsw_sx_port_admin_status_set()
167 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(paos), paos_pl); in mlxsw_sx_port_admin_status_set()
173 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_oper_status_get()
178 mlxsw_reg_paos_pack(paos_pl, mlxsw_sx_port->local_port, 0); in mlxsw_sx_port_oper_status_get()
179 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(paos), paos_pl); in mlxsw_sx_port_oper_status_get()
190 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in __mlxsw_sx_port_mtu_set()
195 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sx_port->local_port, 0); in __mlxsw_sx_port_mtu_set()
196 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(pmtu), pmtu_pl); in __mlxsw_sx_port_mtu_set()
202 return -EINVAL; in __mlxsw_sx_port_mtu_set()
204 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sx_port->local_port, mtu); in __mlxsw_sx_port_mtu_set()
205 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(pmtu), pmtu_pl); in __mlxsw_sx_port_mtu_set()
224 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_ib_port_set()
228 mlxsw_reg_plib_local_port_set(plib_pl, mlxsw_sx_port->local_port); in mlxsw_sx_port_ib_port_set()
230 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(plib), plib_pl); in mlxsw_sx_port_ib_port_set()
236 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_swid_set()
239 mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sx_port->local_port); in mlxsw_sx_port_swid_set()
240 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sx_port_swid_set()
246 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_system_port_mapping_set()
249 mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sx_port->local_port); in mlxsw_sx_port_system_port_mapping_set()
250 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sx_port_system_port_mapping_set()
261 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sx_port_module_info_get()
293 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_xmit()
296 .local_port = mlxsw_sx_port->local_port, in mlxsw_sx_port_xmit()
303 this_cpu_inc(mlxsw_sx_port->pcpu_stats->tx_dropped); in mlxsw_sx_port_xmit()
308 memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb)); in mlxsw_sx_port_xmit()
310 if (mlxsw_core_skb_transmit_busy(mlxsw_sx->core, &tx_info)) in mlxsw_sx_port_xmit()
317 len = skb->len - MLXSW_TXHDR_LEN; in mlxsw_sx_port_xmit()
321 err = mlxsw_core_skb_transmit(mlxsw_sx->core, skb, &tx_info); in mlxsw_sx_port_xmit()
324 pcpu_stats = this_cpu_ptr(mlxsw_sx_port->pcpu_stats); in mlxsw_sx_port_xmit()
325 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sx_port_xmit()
326 pcpu_stats->tx_packets++; in mlxsw_sx_port_xmit()
327 pcpu_stats->tx_bytes += len; in mlxsw_sx_port_xmit()
328 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sx_port_xmit()
330 this_cpu_inc(mlxsw_sx_port->pcpu_stats->tx_dropped); in mlxsw_sx_port_xmit()
344 dev->mtu = mtu; in mlxsw_sx_port_change_mtu()
360 p = per_cpu_ptr(mlxsw_sx_port->pcpu_stats, i); in mlxsw_sx_port_get_stats64()
362 start = u64_stats_fetch_begin_irq(&p->syncp); in mlxsw_sx_port_get_stats64()
363 rx_packets = p->rx_packets; in mlxsw_sx_port_get_stats64()
364 rx_bytes = p->rx_bytes; in mlxsw_sx_port_get_stats64()
365 tx_packets = p->tx_packets; in mlxsw_sx_port_get_stats64()
366 tx_bytes = p->tx_bytes; in mlxsw_sx_port_get_stats64()
367 } while (u64_stats_fetch_retry_irq(&p->syncp, start)); in mlxsw_sx_port_get_stats64()
369 stats->rx_packets += rx_packets; in mlxsw_sx_port_get_stats64()
370 stats->rx_bytes += rx_bytes; in mlxsw_sx_port_get_stats64()
371 stats->tx_packets += tx_packets; in mlxsw_sx_port_get_stats64()
372 stats->tx_bytes += tx_bytes; in mlxsw_sx_port_get_stats64()
374 tx_dropped += p->tx_dropped; in mlxsw_sx_port_get_stats64()
376 stats->tx_dropped = tx_dropped; in mlxsw_sx_port_get_stats64()
383 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_devlink_port()
385 return mlxsw_core_port_devlink_port_get(mlxsw_sx->core, in mlxsw_sx_port_get_devlink_port()
386 mlxsw_sx_port->local_port); in mlxsw_sx_port_get_devlink_port()
402 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_drvinfo()
404 strlcpy(drvinfo->driver, mlxsw_sx_driver_name, sizeof(drvinfo->driver)); in mlxsw_sx_port_get_drvinfo()
405 strlcpy(drvinfo->version, mlxsw_sx_driver_version, in mlxsw_sx_port_get_drvinfo()
406 sizeof(drvinfo->version)); in mlxsw_sx_port_get_drvinfo()
407 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), in mlxsw_sx_port_get_drvinfo()
409 mlxsw_sx->bus_info->fw_rev.major, in mlxsw_sx_port_get_drvinfo()
410 mlxsw_sx->bus_info->fw_rev.minor, in mlxsw_sx_port_get_drvinfo()
411 mlxsw_sx->bus_info->fw_rev.subminor); in mlxsw_sx_port_get_drvinfo()
412 strlcpy(drvinfo->bus_info, mlxsw_sx->bus_info->device_name, in mlxsw_sx_port_get_drvinfo()
413 sizeof(drvinfo->bus_info)); in mlxsw_sx_port_get_drvinfo()
523 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_stats()
528 mlxsw_reg_ppcnt_pack(ppcnt_pl, mlxsw_sx_port->local_port, in mlxsw_sx_port_get_stats()
530 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sx_port_get_stats()
541 return -EOPNOTSUPP; in mlxsw_sx_port_get_sset_count()
684 cmd->base.speed = speed; in mlxsw_sx_from_ptys_speed_duplex()
685 cmd->base.duplex = duplex; in mlxsw_sx_from_ptys_speed_duplex()
715 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_get_link_ksettings()
723 mlxsw_reg_ptys_eth_pack(ptys_pl, mlxsw_sx_port->local_port, 0, false); in mlxsw_sx_port_get_link_ksettings()
724 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_get_link_ksettings()
740 cmd->base.port = mlxsw_sx_port_connector_port(eth_proto_oper); in mlxsw_sx_port_get_link_ksettings()
743 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in mlxsw_sx_port_get_link_ksettings()
745 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in mlxsw_sx_port_get_link_ksettings()
747 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising, in mlxsw_sx_port_get_link_ksettings()
794 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_set_link_ksettings()
804 speed = cmd->base.speed; in mlxsw_sx_port_set_link_ksettings()
807 cmd->link_modes.advertising); in mlxsw_sx_port_set_link_ksettings()
809 eth_proto_new = cmd->base.autoneg == AUTONEG_ENABLE ? in mlxsw_sx_port_set_link_ksettings()
813 mlxsw_reg_ptys_eth_pack(ptys_pl, mlxsw_sx_port->local_port, 0, false); in mlxsw_sx_port_set_link_ksettings()
814 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_set_link_ksettings()
825 return -EINVAL; in mlxsw_sx_port_set_link_ksettings()
830 mlxsw_reg_ptys_eth_pack(ptys_pl, mlxsw_sx_port->local_port, in mlxsw_sx_port_set_link_ksettings()
832 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_set_link_ksettings()
876 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(spad), spad_pl); in mlxsw_sx_hw_id_get()
879 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sx->hw_id); in mlxsw_sx_hw_id_get()
885 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_dev_addr_get()
886 struct net_device *dev = mlxsw_sx_port->dev; in mlxsw_sx_port_dev_addr_get()
891 err = mlxsw_reg_query(mlxsw_sx->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sx_port_dev_addr_get()
894 mlxsw_reg_ppad_mac_memcpy_from(ppad_pl, dev->dev_addr); in mlxsw_sx_port_dev_addr_get()
899 dev->dev_addr[ETH_ALEN - 1] += mlxsw_sx_port->local_port; in mlxsw_sx_port_dev_addr_get()
906 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_stp_state_set()
912 return -ENOMEM; in mlxsw_sx_port_stp_state_set()
913 mlxsw_reg_spms_pack(spms_pl, mlxsw_sx_port->local_port); in mlxsw_sx_port_stp_state_set()
915 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(spms), spms_pl); in mlxsw_sx_port_stp_state_set()
923 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_ib_speed_set()
926 mlxsw_reg_ptys_ib_pack(ptys_pl, mlxsw_sx_port->local_port, speed, in mlxsw_sx_port_ib_speed_set()
928 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_ib_speed_set()
934 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_speed_by_width_set()
940 mlxsw_reg_ptys_eth_pack(ptys_pl, mlxsw_sx_port->local_port, in mlxsw_sx_port_speed_by_width_set()
942 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sx_port_speed_by_width_set()
949 struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; in mlxsw_sx_port_mac_learning_mode_set()
952 mlxsw_reg_spmlr_pack(spmlr_pl, mlxsw_sx_port->local_port, mode); in mlxsw_sx_port_mac_learning_mode_set()
953 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(spmlr), spmlr_pl); in mlxsw_sx_port_mac_learning_mode_set()
957 u8 module, u8 width) in __mlxsw_sx_port_eth_create() argument
965 return -ENOMEM; in __mlxsw_sx_port_eth_create()
966 SET_NETDEV_DEV(dev, mlxsw_sx->bus_info->dev); in __mlxsw_sx_port_eth_create()
967 dev_net_set(dev, mlxsw_core_net(mlxsw_sx->core)); in __mlxsw_sx_port_eth_create()
969 mlxsw_sx_port->dev = dev; in __mlxsw_sx_port_eth_create()
970 mlxsw_sx_port->mlxsw_sx = mlxsw_sx; in __mlxsw_sx_port_eth_create()
971 mlxsw_sx_port->local_port = local_port; in __mlxsw_sx_port_eth_create()
972 mlxsw_sx_port->mapping.module = module; in __mlxsw_sx_port_eth_create()
974 mlxsw_sx_port->pcpu_stats = in __mlxsw_sx_port_eth_create()
976 if (!mlxsw_sx_port->pcpu_stats) { in __mlxsw_sx_port_eth_create()
977 err = -ENOMEM; in __mlxsw_sx_port_eth_create()
981 dev->netdev_ops = &mlxsw_sx_port_netdev_ops; in __mlxsw_sx_port_eth_create()
982 dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops; in __mlxsw_sx_port_eth_create()
986 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Unable to get port mac address\n", in __mlxsw_sx_port_eth_create()
987 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
993 dev->features |= NETIF_F_NETNS_LOCAL | NETIF_F_LLTX | NETIF_F_SG | in __mlxsw_sx_port_eth_create()
996 dev->min_mtu = 0; in __mlxsw_sx_port_eth_create()
997 dev->max_mtu = ETH_MAX_MTU; in __mlxsw_sx_port_eth_create()
1002 dev->needed_headroom = MLXSW_TXHDR_LEN; in __mlxsw_sx_port_eth_create()
1006 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set system port mapping\n", in __mlxsw_sx_port_eth_create()
1007 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1013 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set SWID\n", in __mlxsw_sx_port_eth_create()
1014 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1020 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set speed\n", in __mlxsw_sx_port_eth_create()
1021 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1027 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set MTU\n", in __mlxsw_sx_port_eth_create()
1028 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1040 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set STP state\n", in __mlxsw_sx_port_eth_create()
1041 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1048 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set MAC learning mode\n", in __mlxsw_sx_port_eth_create()
1049 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1055 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to register netdev\n", in __mlxsw_sx_port_eth_create()
1056 mlxsw_sx_port->local_port); in __mlxsw_sx_port_eth_create()
1060 mlxsw_core_port_eth_set(mlxsw_sx->core, mlxsw_sx_port->local_port, in __mlxsw_sx_port_eth_create()
1062 mlxsw_sx->ports[local_port] = mlxsw_sx_port; in __mlxsw_sx_port_eth_create()
1075 free_percpu(mlxsw_sx_port->pcpu_stats); in __mlxsw_sx_port_eth_create()
1082 u8 module, u8 width) in mlxsw_sx_port_eth_create() argument
1086 err = mlxsw_core_port_init(mlxsw_sx->core, local_port, in mlxsw_sx_port_eth_create()
1087 module + 1, false, 0, false, 0, in mlxsw_sx_port_eth_create()
1088 mlxsw_sx->hw_id, sizeof(mlxsw_sx->hw_id)); in mlxsw_sx_port_eth_create()
1090 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to init core port\n", in mlxsw_sx_port_eth_create()
1094 err = __mlxsw_sx_port_eth_create(mlxsw_sx, local_port, module, width); in mlxsw_sx_port_eth_create()
1101 mlxsw_core_port_fini(mlxsw_sx->core, local_port); in mlxsw_sx_port_eth_create()
1107 struct mlxsw_sx_port *mlxsw_sx_port = mlxsw_sx->ports[local_port]; in __mlxsw_sx_port_eth_remove()
1109 mlxsw_core_port_clear(mlxsw_sx->core, local_port, mlxsw_sx); in __mlxsw_sx_port_eth_remove()
1110 unregister_netdev(mlxsw_sx_port->dev); /* This calls ndo_stop */ in __mlxsw_sx_port_eth_remove()
1111 mlxsw_sx->ports[local_port] = NULL; in __mlxsw_sx_port_eth_remove()
1113 free_percpu(mlxsw_sx_port->pcpu_stats); in __mlxsw_sx_port_eth_remove()
1114 free_netdev(mlxsw_sx_port->dev); in __mlxsw_sx_port_eth_remove()
1119 return mlxsw_sx->ports[local_port] != NULL; in mlxsw_sx_port_created()
1123 u8 module, u8 width) in __mlxsw_sx_port_ib_create() argument
1130 return -ENOMEM; in __mlxsw_sx_port_ib_create()
1131 mlxsw_sx_port->mlxsw_sx = mlxsw_sx; in __mlxsw_sx_port_ib_create()
1132 mlxsw_sx_port->local_port = local_port; in __mlxsw_sx_port_ib_create()
1133 mlxsw_sx_port->mapping.module = module; in __mlxsw_sx_port_ib_create()
1137 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set system port mapping\n", in __mlxsw_sx_port_ib_create()
1138 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1145 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set SWID\n", in __mlxsw_sx_port_ib_create()
1146 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1151 err = mlxsw_sx_port_ib_port_set(mlxsw_sx_port, module + 1); in __mlxsw_sx_port_ib_create()
1153 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set IB port\n", in __mlxsw_sx_port_ib_create()
1154 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1162 MLXSW_REG_PTYS_IB_SPEED_EDR - 1, in __mlxsw_sx_port_ib_create()
1163 BIT(3) - 1); in __mlxsw_sx_port_ib_create()
1165 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set speed\n", in __mlxsw_sx_port_ib_create()
1166 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1175 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to set MTU\n", in __mlxsw_sx_port_ib_create()
1176 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1182 dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to change admin state to UP\n", in __mlxsw_sx_port_ib_create()
1183 mlxsw_sx_port->local_port); in __mlxsw_sx_port_ib_create()
1187 mlxsw_core_port_ib_set(mlxsw_sx->core, mlxsw_sx_port->local_port, in __mlxsw_sx_port_ib_create()
1189 mlxsw_sx->ports[local_port] = mlxsw_sx_port; in __mlxsw_sx_port_ib_create()
1205 struct mlxsw_sx_port *mlxsw_sx_port = mlxsw_sx->ports[local_port]; in __mlxsw_sx_port_ib_remove()
1207 mlxsw_core_port_clear(mlxsw_sx->core, local_port, mlxsw_sx); in __mlxsw_sx_port_ib_remove()
1208 mlxsw_sx->ports[local_port] = NULL; in __mlxsw_sx_port_ib_remove()
1217 mlxsw_core_port_type_get(mlxsw_sx->core, local_port); in __mlxsw_sx_port_remove()
1228 mlxsw_core_port_fini(mlxsw_sx->core, local_port); in mlxsw_sx_port_remove()
1235 for (i = 1; i < mlxsw_core_max_ports(mlxsw_sx->core); i++) in mlxsw_sx_ports_remove()
1238 kfree(mlxsw_sx->ports); in mlxsw_sx_ports_remove()
1239 mlxsw_sx->ports = NULL; in mlxsw_sx_ports_remove()
1244 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sx->core); in mlxsw_sx_ports_create()
1246 u8 module, width; in mlxsw_sx_ports_create() local
1251 mlxsw_sx->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sx_ports_create()
1252 if (!mlxsw_sx->ports) in mlxsw_sx_ports_create()
1253 return -ENOMEM; in mlxsw_sx_ports_create()
1256 err = mlxsw_sx_port_module_info_get(mlxsw_sx, i, &module, in mlxsw_sx_ports_create()
1262 err = mlxsw_sx_port_eth_create(mlxsw_sx, i, module, width); in mlxsw_sx_ports_create()
1270 for (i--; i >= 1; i--) in mlxsw_sx_ports_create()
1273 kfree(mlxsw_sx->ports); in mlxsw_sx_ports_create()
1274 mlxsw_sx->ports = NULL; in mlxsw_sx_ports_create()
1282 netdev_info(mlxsw_sx_port->dev, "link up\n"); in mlxsw_sx_pude_eth_event_func()
1283 netif_carrier_on(mlxsw_sx_port->dev); in mlxsw_sx_pude_eth_event_func()
1285 netdev_info(mlxsw_sx_port->dev, "link down\n"); in mlxsw_sx_pude_eth_event_func()
1286 netif_carrier_off(mlxsw_sx_port->dev); in mlxsw_sx_pude_eth_event_func()
1294 pr_info("ib link for port %d - up\n", in mlxsw_sx_pude_ib_event_func()
1295 mlxsw_sx_port->mapping.module + 1); in mlxsw_sx_pude_ib_event_func()
1297 pr_info("ib link for port %d - down\n", in mlxsw_sx_pude_ib_event_func()
1298 mlxsw_sx_port->mapping.module + 1); in mlxsw_sx_pude_ib_event_func()
1311 mlxsw_sx_port = mlxsw_sx->ports[local_port]; in mlxsw_sx_pude_event_func()
1313 dev_warn(mlxsw_sx->bus_info->dev, "Port %d: Link event received for non-existent port\n", in mlxsw_sx_pude_event_func()
1319 port_type = mlxsw_core_port_type_get(mlxsw_sx->core, local_port); in mlxsw_sx_pude_event_func()
1330 struct mlxsw_sx_port *mlxsw_sx_port = mlxsw_sx->ports[local_port]; in mlxsw_sx_rx_listener_func()
1334 dev_warn_ratelimited(mlxsw_sx->bus_info->dev, "Port %d: skb received for non-existent port\n", in mlxsw_sx_rx_listener_func()
1339 skb->dev = mlxsw_sx_port->dev; in mlxsw_sx_rx_listener_func()
1341 pcpu_stats = this_cpu_ptr(mlxsw_sx_port->pcpu_stats); in mlxsw_sx_rx_listener_func()
1342 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sx_rx_listener_func()
1343 pcpu_stats->rx_packets++; in mlxsw_sx_rx_listener_func()
1344 pcpu_stats->rx_bytes += skb->len; in mlxsw_sx_rx_listener_func()
1345 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sx_rx_listener_func()
1347 skb->protocol = eth_type_trans(skb, skb->dev); in mlxsw_sx_rx_listener_func()
1355 u8 module, width; in mlxsw_sx_port_type_set() local
1358 if (!mlxsw_sx->ports || !mlxsw_sx->ports[local_port]) { in mlxsw_sx_port_type_set()
1359 dev_err(mlxsw_sx->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sx_port_type_set()
1361 return -EINVAL; in mlxsw_sx_port_type_set()
1365 return -EOPNOTSUPP; in mlxsw_sx_port_type_set()
1368 err = mlxsw_sx_port_module_info_get(mlxsw_sx, local_port, &module, in mlxsw_sx_port_type_set()
1374 err = __mlxsw_sx_port_eth_create(mlxsw_sx, local_port, module, in mlxsw_sx_port_type_set()
1377 err = __mlxsw_sx_port_ib_create(mlxsw_sx, local_port, module, in mlxsw_sx_port_type_set()
1424 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sx_traps_init()
1435 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(htgt), htgt_pl); in mlxsw_sx_traps_init()
1440 err = mlxsw_core_trap_register(mlxsw_sx->core, in mlxsw_sx_traps_init()
1450 for (i--; i >= 0; i--) { in mlxsw_sx_traps_init()
1451 mlxsw_core_trap_unregister(mlxsw_sx->core, in mlxsw_sx_traps_init()
1463 mlxsw_core_trap_unregister(mlxsw_sx->core, in mlxsw_sx_traps_fini()
1479 return -ENOMEM; in mlxsw_sx_flood_init()
1482 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sftr), sftr_pl); in mlxsw_sx_flood_init()
1493 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1502 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1511 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1520 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1529 err = mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sfgc), sfgc_pl); in mlxsw_sx_flood_init()
1534 return mlxsw_reg_write(mlxsw_sx->core, MLXSW_REG(sgcr), sgcr_pl); in mlxsw_sx_flood_init()
1558 mlxsw_sx->core = mlxsw_core; in mlxsw_sx_init()
1559 mlxsw_sx->bus_info = mlxsw_bus_info; in mlxsw_sx_init()
1563 dev_err(mlxsw_sx->bus_info->dev, "Failed to get switch HW ID\n"); in mlxsw_sx_init()
1569 dev_err(mlxsw_sx->bus_info->dev, "Failed to create ports\n"); in mlxsw_sx_init()
1575 dev_err(mlxsw_sx->bus_info->dev, "Failed to set traps\n"); in mlxsw_sx_init()
1581 dev_err(mlxsw_sx->bus_info->dev, "Failed to initialize flood tables\n"); in mlxsw_sx_init()
1688 MODULE_DESCRIPTION("Mellanox SwitchX-2 driver");