Lines Matching +full:master +full:- +full:stats

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
63 "mellanox/mlxsw_spectrum-" __stringify(MLXSW_SP1_FWREV_MAJOR) \
76 "mellanox/mlxsw_spectrum2-" __stringify(MLXSW_SP2_FWREV_MAJOR) \
89 "mellanox/mlxsw_spectrum3-" __stringify(MLXSW_SP3_FWREV_MAJOR) \
118 * 0 - Ethernet control (e.g. EMADs, LACP)
119 * 1 - Ethernet data
173 * 0 - Data packets
174 * 6 - Control packets
189 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_get()
206 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_clear()
248 mlxsw_tx_hdr_port_mid_set(txhdr, tx_info->local_port); in mlxsw_sp_txhdr_construct()
263 err = -ENOMEM; in mlxsw_sp_txhdr_ptp_data_construct()
268 err = -EIO; in mlxsw_sp_txhdr_ptp_data_construct()
280 mlxsw_tx_hdr_fid_set(txhdr, max_fid + tx_info->local_port - 1); in mlxsw_sp_txhdr_ptp_data_construct()
286 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_txhdr_ptp_data_construct()
295 if (!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) in mlxsw_sp_skb_requires_ts()
309 /* In Spectrum-2 and Spectrum-3, PTP events that require a time stamp in mlxsw_sp_txhdr_handle()
314 return mlxsw_sp->ptp_ops->txhdr_construct(mlxsw_core, in mlxsw_sp_txhdr_handle()
319 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_txhdr_handle()
321 return -ENOMEM; in mlxsw_sp_txhdr_handle()
348 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_stp_set()
354 return -ENOMEM; in mlxsw_sp_port_vid_stp_set()
355 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_vid_stp_set()
358 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_vid_stp_set()
368 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(spad), spad_pl); in mlxsw_sp_base_mac_get()
371 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sp->base_mac); in mlxsw_sp_base_mac_get()
378 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set()
381 mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_admin_status_set()
384 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_admin_status_set()
390 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set()
393 mlxsw_reg_ppad_pack(ppad_pl, true, mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_set()
395 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sp_port_dev_addr_set()
400 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init()
402 eth_hw_addr_gen(mlxsw_sp_port->dev, mlxsw_sp->base_mac, in mlxsw_sp_port_dev_addr_init()
403 mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_init()
405 mlxsw_sp_port->dev->dev_addr); in mlxsw_sp_port_dev_addr_init()
410 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set()
415 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu); in mlxsw_sp_port_mtu_set()
416 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
425 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sp_port_swid_set()
430 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set()
433 mlxsw_reg_svpe_pack(svpe_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_vp_mode_set()
434 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svpe), svpe_pl); in mlxsw_sp_port_vp_mode_set()
440 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set()
446 return -ENOMEM; in mlxsw_sp_port_vid_learning_set()
447 mlxsw_reg_spvmlr_pack(spvmlr_pl, mlxsw_sp_port->local_port, vid, vid, in mlxsw_sp_port_vid_learning_set()
449 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvmlr), spvmlr_pl); in mlxsw_sp_port_vid_learning_set()
456 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_security_set()
460 if (mlxsw_sp_port->security == enable) in mlxsw_sp_port_security_set()
463 mlxsw_reg_spfsr_pack(spfsr_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_security_set()
464 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spfsr), spfsr_pl); in mlxsw_sp_port_security_set()
468 mlxsw_sp_port->security = enable; in mlxsw_sp_port_security_set()
482 return -EINVAL; in mlxsw_sp_ethtype_to_sver_type()
491 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_egress_ethtype_set()
500 mlxsw_reg_spevet_pack(spevet_pl, mlxsw_sp_port->local_port, sver_type); in mlxsw_sp_port_egress_ethtype_set()
501 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spevet), spevet_pl); in mlxsw_sp_port_egress_ethtype_set()
507 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_pvid_set()
516 mlxsw_reg_spvid_pack(spvid_pl, mlxsw_sp_port->local_port, vid, in __mlxsw_sp_port_pvid_set()
519 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl); in __mlxsw_sp_port_pvid_set()
525 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_allow_untagged_set()
528 mlxsw_reg_spaft_pack(spaft_pl, mlxsw_sp_port->local_port, allow); in mlxsw_sp_port_allow_untagged_set()
529 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl); in mlxsw_sp_port_allow_untagged_set()
550 mlxsw_sp_port->pvid = vid; in mlxsw_sp_port_pvid_set()
554 __mlxsw_sp_port_pvid_set(mlxsw_sp_port, mlxsw_sp_port->pvid, ethtype); in mlxsw_sp_port_pvid_set()
561 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set()
564 mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_system_port_mapping_set()
565 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sp_port_system_port_mapping_set()
587 …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()
589 return -EINVAL; in mlxsw_sp_port_module_info_parse()
594 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple modules\n", in mlxsw_sp_port_module_info_parse()
596 return -EINVAL; in mlxsw_sp_port_module_info_parse()
599 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple slot index… in mlxsw_sp_port_module_info_parse()
601 return -EINVAL; in mlxsw_sp_port_module_info_parse()
606 …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()
608 return -EINVAL; in mlxsw_sp_port_module_info_parse()
611 …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()
613 return -EINVAL; in mlxsw_sp_port_module_info_parse()
617 port_mapping->module = module; in mlxsw_sp_port_module_info_parse()
618 port_mapping->slot_index = slot_index; in mlxsw_sp_port_module_info_parse()
619 port_mapping->width = width; in mlxsw_sp_port_module_info_parse()
620 port_mapping->module_width = width; in mlxsw_sp_port_module_info_parse()
621 port_mapping->lane = mlxsw_reg_pmlp_tx_lane_get(pmlp_pl, 0); in mlxsw_sp_port_module_info_parse()
633 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_info_get()
647 mlxsw_env_module_port_map(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
648 port_mapping->module); in mlxsw_sp_port_module_map()
651 mlxsw_reg_pmlp_width_set(pmlp_pl, port_mapping->width); in mlxsw_sp_port_module_map()
652 for (i = 0; i < port_mapping->width; i++) { in mlxsw_sp_port_module_map()
654 port_mapping->slot_index); in mlxsw_sp_port_module_map()
655 mlxsw_reg_pmlp_module_set(pmlp_pl, i, port_mapping->module); in mlxsw_sp_port_module_map()
656 mlxsw_reg_pmlp_tx_lane_set(pmlp_pl, i, port_mapping->lane + i); /* Rx & Tx */ in mlxsw_sp_port_module_map()
659 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_map()
665 mlxsw_env_module_port_unmap(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
666 port_mapping->module); in mlxsw_sp_port_module_map()
677 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_unmap()
678 mlxsw_env_module_port_unmap(mlxsw_sp->core, slot_index, module); in mlxsw_sp_port_module_unmap()
684 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_open()
687 err = mlxsw_env_module_port_up(mlxsw_sp->core, in mlxsw_sp_port_open()
688 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_open()
689 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_open()
699 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_open()
700 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_open()
701 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_open()
708 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stop()
712 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_stop()
713 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_stop()
714 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_stop()
722 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit()
725 .local_port = mlxsw_sp_port->local_port, in mlxsw_sp_port_xmit()
731 memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb)); in mlxsw_sp_port_xmit()
733 if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &tx_info)) in mlxsw_sp_port_xmit()
737 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
741 err = mlxsw_sp_txhdr_handle(mlxsw_sp->core, mlxsw_sp_port, skb, in mlxsw_sp_port_xmit()
749 len = skb->len - MLXSW_TXHDR_LEN; in mlxsw_sp_port_xmit()
754 err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &tx_info); in mlxsw_sp_port_xmit()
757 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_xmit()
758 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sp_port_xmit()
759 pcpu_stats->tx_packets++; in mlxsw_sp_port_xmit()
760 pcpu_stats->tx_bytes += len; in mlxsw_sp_port_xmit()
761 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sp_port_xmit()
763 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
779 if (!is_valid_ether_addr(addr->sa_data)) in mlxsw_sp_port_set_mac_address()
780 return -EADDRNOTAVAIL; in mlxsw_sp_port_set_mac_address()
782 err = mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr->sa_data); in mlxsw_sp_port_set_mac_address()
785 eth_hw_addr_set(dev, addr->sa_data); in mlxsw_sp_port_set_mac_address()
796 orig_hdroom = *mlxsw_sp_port->hdroom; in mlxsw_sp_port_change_mtu()
811 WRITE_ONCE(dev->mtu, mtu); in mlxsw_sp_port_change_mtu()
821 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_sw_stats64() argument
831 p = per_cpu_ptr(mlxsw_sp_port->pcpu_stats, i); in mlxsw_sp_port_get_sw_stats64()
833 start = u64_stats_fetch_begin(&p->syncp); in mlxsw_sp_port_get_sw_stats64()
834 rx_packets = p->rx_packets; in mlxsw_sp_port_get_sw_stats64()
835 rx_bytes = p->rx_bytes; in mlxsw_sp_port_get_sw_stats64()
836 tx_packets = p->tx_packets; in mlxsw_sp_port_get_sw_stats64()
837 tx_bytes = p->tx_bytes; in mlxsw_sp_port_get_sw_stats64()
838 } while (u64_stats_fetch_retry(&p->syncp, start)); in mlxsw_sp_port_get_sw_stats64()
840 stats->rx_packets += rx_packets; in mlxsw_sp_port_get_sw_stats64()
841 stats->rx_bytes += rx_bytes; in mlxsw_sp_port_get_sw_stats64()
842 stats->tx_packets += tx_packets; in mlxsw_sp_port_get_sw_stats64()
843 stats->tx_bytes += tx_bytes; in mlxsw_sp_port_get_sw_stats64()
845 tx_dropped += p->tx_dropped; in mlxsw_sp_port_get_sw_stats64()
847 stats->tx_dropped = tx_dropped; in mlxsw_sp_port_get_sw_stats64()
869 return -EINVAL; in mlxsw_sp_port_get_offload_stats()
876 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats_raw()
878 mlxsw_reg_ppcnt_pack(ppcnt_pl, mlxsw_sp_port->local_port, grp, prio); in mlxsw_sp_port_get_stats_raw()
879 return mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sp_port_get_stats_raw()
883 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_hw_stats() argument
893 stats->tx_packets = in mlxsw_sp_port_get_hw_stats()
895 stats->rx_packets = in mlxsw_sp_port_get_hw_stats()
897 stats->tx_bytes = in mlxsw_sp_port_get_hw_stats()
899 stats->rx_bytes = in mlxsw_sp_port_get_hw_stats()
901 stats->multicast = in mlxsw_sp_port_get_hw_stats()
904 stats->rx_crc_errors = in mlxsw_sp_port_get_hw_stats()
906 stats->rx_frame_errors = in mlxsw_sp_port_get_hw_stats()
909 stats->rx_length_errors = ( in mlxsw_sp_port_get_hw_stats()
914 stats->rx_errors = (stats->rx_crc_errors + in mlxsw_sp_port_get_hw_stats()
915 stats->rx_frame_errors + stats->rx_length_errors); in mlxsw_sp_port_get_hw_stats()
931 xstats->ecn = mlxsw_reg_ppcnt_ecn_marked_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
940 xstats->wred_drop[i] = in mlxsw_sp_port_get_hw_xstats()
942 xstats->tc_ecn[i] = mlxsw_reg_ppcnt_ecn_marked_tc_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
950 xstats->backlog[i] = in mlxsw_sp_port_get_hw_xstats()
952 xstats->tail_drop[i] = in mlxsw_sp_port_get_hw_xstats()
962 xstats->tx_packets[i] = mlxsw_reg_ppcnt_tx_frames_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
963 xstats->tx_bytes[i] = mlxsw_reg_ppcnt_tx_octets_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
973 if (!netif_carrier_ok(mlxsw_sp_port->dev)) in update_stats_cache()
979 mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev, in update_stats_cache()
980 &mlxsw_sp_port->periodic_hw_stats.stats); in update_stats_cache()
981 mlxsw_sp_port_get_hw_xstats(mlxsw_sp_port->dev, in update_stats_cache()
982 &mlxsw_sp_port->periodic_hw_stats.xstats); in update_stats_cache()
985 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, in update_stats_cache()
989 /* Return the stats from a cache that is updated periodically,
994 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_stats64() argument
998 memcpy(stats, &mlxsw_sp_port->periodic_hw_stats.stats, sizeof(*stats)); in mlxsw_sp_port_get_stats64()
1005 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_vlan_set()
1011 return -ENOMEM; in __mlxsw_sp_port_vlan_set()
1013 mlxsw_reg_spvm_pack(spvm_pl, mlxsw_sp_port->local_port, vid_begin, in __mlxsw_sp_port_vlan_set()
1015 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvm), spvm_pl); in __mlxsw_sp_port_vlan_set()
1028 vid_e = min((u16) (vid + MLXSW_REG_SPVM_REC_MAX_COUNT - 1), in mlxsw_sp_port_vlan_set()
1046 &mlxsw_sp_port->vlans_list, list) { in mlxsw_sp_port_vlan_flush()
1048 mlxsw_sp_port_vlan->vid == MLXSW_SP_DEFAULT_VID) in mlxsw_sp_port_vlan_flush()
1057 if (mlxsw_sp_port_vlan->bridge_port) in mlxsw_sp_port_vlan_cleanup()
1059 else if (mlxsw_sp_port_vlan->fid) in mlxsw_sp_port_vlan_cleanup()
1072 return ERR_PTR(-EEXIST); in mlxsw_sp_port_vlan_create()
1080 err = -ENOMEM; in mlxsw_sp_port_vlan_create()
1084 mlxsw_sp_port_vlan->mlxsw_sp_port = mlxsw_sp_port; in mlxsw_sp_port_vlan_create()
1085 mlxsw_sp_port_vlan->vid = vid; in mlxsw_sp_port_vlan_create()
1086 list_add(&mlxsw_sp_port_vlan->list, &mlxsw_sp_port->vlans_list); in mlxsw_sp_port_vlan_create()
1097 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp_port_vlan->mlxsw_sp_port; in mlxsw_sp_port_vlan_destroy()
1098 u16 vid = mlxsw_sp_port_vlan->vid; in mlxsw_sp_port_vlan_destroy()
1101 list_del(&mlxsw_sp_port_vlan->list); in mlxsw_sp_port_vlan_destroy()
1143 switch (f->binder_type) { in mlxsw_sp_setup_tc_block()
1153 return -EOPNOTSUPP; in mlxsw_sp_setup_tc_block()
1176 return -EOPNOTSUPP; in mlxsw_sp_setup_tc()
1185 if (mlxsw_sp_flow_block_rule_count(mlxsw_sp_port->ing_flow_block) || in mlxsw_sp_feature_hw_tc()
1186 mlxsw_sp_flow_block_rule_count(mlxsw_sp_port->eg_flow_block)) { in mlxsw_sp_feature_hw_tc()
1188 return -EINVAL; in mlxsw_sp_feature_hw_tc()
1190 mlxsw_sp_flow_block_disable_inc(mlxsw_sp_port->ing_flow_block); in mlxsw_sp_feature_hw_tc()
1191 mlxsw_sp_flow_block_disable_inc(mlxsw_sp_port->eg_flow_block); in mlxsw_sp_feature_hw_tc()
1193 mlxsw_sp_flow_block_disable_dec(mlxsw_sp_port->ing_flow_block); in mlxsw_sp_feature_hw_tc()
1194 mlxsw_sp_flow_block_disable_dec(mlxsw_sp_port->eg_flow_block); in mlxsw_sp_feature_hw_tc()
1208 mlxsw_reg_pplr_pack(pplr_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_feature_loopback()
1209 err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr), in mlxsw_sp_feature_loopback()
1225 netdev_features_t changes = wanted_features ^ dev->features; in mlxsw_sp_handle_feature()
1240 dev->features |= feature; in mlxsw_sp_handle_feature()
1242 dev->features &= ~feature; in mlxsw_sp_handle_feature()
1249 netdev_features_t oper_features = dev->features; in mlxsw_sp_set_features()
1258 dev->features = oper_features; in mlxsw_sp_set_features()
1259 return -EINVAL; in mlxsw_sp_set_features()
1271 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in mlxsw_sp_port_hwtstamp_set()
1272 return -EFAULT; in mlxsw_sp_port_hwtstamp_set()
1274 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set()
1279 if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) in mlxsw_sp_port_hwtstamp_set()
1280 return -EFAULT; in mlxsw_sp_port_hwtstamp_set()
1291 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_get(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get()
1296 if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) in mlxsw_sp_port_hwtstamp_get()
1297 return -EFAULT; in mlxsw_sp_port_hwtstamp_get()
1306 mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, &config); in mlxsw_sp_port_ptp_clear()
1320 return -EOPNOTSUPP; in mlxsw_sp_port_ioctl()
1344 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_by_width_set()
1351 ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_by_width_set()
1356 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1358 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1362 ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, &eth_proto_cap, in mlxsw_sp_port_speed_by_width_set()
1364 eth_proto_cap_masked = ops->ptys_proto_cap_masked_get(eth_proto_cap); in mlxsw_sp_port_speed_by_width_set()
1365 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1367 mlxsw_sp_port->link.autoneg); in mlxsw_sp_port_speed_by_width_set()
1368 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1374 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_get()
1379 port_type_speed_ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_get()
1380 port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, in mlxsw_sp_port_speed_get()
1381 mlxsw_sp_port->local_port, 0, in mlxsw_sp_port_speed_get()
1383 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_get()
1386 port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL, in mlxsw_sp_port_speed_get()
1388 *speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper); in mlxsw_sp_port_speed_get()
1396 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_set()
1399 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_set()
1404 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_set()
1411 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_maxrate_set()
1414 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_maxrate_set()
1419 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_maxrate_set()
1426 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_min_bw_set()
1429 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_min_bw_set()
1434 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_min_bw_set()
1440 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_prio_tc_set()
1443 mlxsw_reg_qtct_pack(qtct_pl, mlxsw_sp_port->local_port, switch_prio, in mlxsw_sp_port_prio_tc_set()
1445 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtct), qtct_pl); in mlxsw_sp_port_prio_tc_set()
1537 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_tc_mc_mode_set()
1540 mlxsw_reg_qtctm_pack(qtctm_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_tc_mc_mode_set()
1541 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtctm), qtctm_pl); in mlxsw_sp_port_tc_mc_mode_set()
1546 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_overheat_init_val_set()
1547 u8 slot_index = mlxsw_sp_port->mapping.slot_index; in mlxsw_sp_port_overheat_init_val_set()
1548 u8 module = mlxsw_sp_port->mapping.module; in mlxsw_sp_port_overheat_init_val_set()
1552 err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, slot_index, in mlxsw_sp_port_overheat_init_val_set()
1557 mlxsw_sp_port->module_overheat_initial_val = overheat_counter; in mlxsw_sp_port_overheat_init_val_set()
1566 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_classification_set()
1569 mlxsw_reg_spvc_pack(spvc_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_vlan_classification_set()
1571 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvc), spvc_pl); in mlxsw_sp_port_vlan_classification_set()
1583 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pllp), pllp_pl); in mlxsw_sp_port_label_info_get()
1597 u32 lanes = port_mapping->width; in mlxsw_sp_port_create()
1607 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to map module\n", in mlxsw_sp_port_create()
1614 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sp_port_create()
1622 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get port label information\n", in mlxsw_sp_port_create()
1628 err = mlxsw_core_port_init(mlxsw_sp->core, local_port, slot_index, in mlxsw_sp_port_create()
1630 splittable, lanes, mlxsw_sp->base_mac, in mlxsw_sp_port_create()
1631 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_port_create()
1633 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n", in mlxsw_sp_port_create()
1640 err = -ENOMEM; in mlxsw_sp_port_create()
1643 SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); in mlxsw_sp_port_create()
1646 mlxsw_core_port_netdev_link(mlxsw_sp->core, local_port, in mlxsw_sp_port_create()
1648 mlxsw_sp_port->dev = dev; in mlxsw_sp_port_create()
1649 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1650 mlxsw_sp_port->local_port = local_port; in mlxsw_sp_port_create()
1651 mlxsw_sp_port->pvid = MLXSW_SP_DEFAULT_VID; in mlxsw_sp_port_create()
1652 mlxsw_sp_port->split = split; in mlxsw_sp_port_create()
1653 mlxsw_sp_port->mapping = *port_mapping; in mlxsw_sp_port_create()
1654 mlxsw_sp_port->link.autoneg = 1; in mlxsw_sp_port_create()
1655 INIT_LIST_HEAD(&mlxsw_sp_port->vlans_list); in mlxsw_sp_port_create()
1657 mlxsw_sp_port->pcpu_stats = in mlxsw_sp_port_create()
1659 if (!mlxsw_sp_port->pcpu_stats) { in mlxsw_sp_port_create()
1660 err = -ENOMEM; in mlxsw_sp_port_create()
1664 INIT_DELAYED_WORK(&mlxsw_sp_port->periodic_hw_stats.update_dw, in mlxsw_sp_port_create()
1667 dev->netdev_ops = &mlxsw_sp_port_netdev_ops; in mlxsw_sp_port_create()
1668 dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; in mlxsw_sp_port_create()
1672 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", in mlxsw_sp_port_create()
1673 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1679 dev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_FILTER | in mlxsw_sp_port_create()
1681 dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK; in mlxsw_sp_port_create()
1682 dev->lltx = true; in mlxsw_sp_port_create()
1683 dev->netns_local = true; in mlxsw_sp_port_create()
1685 dev->min_mtu = ETH_MIN_MTU; in mlxsw_sp_port_create()
1686 dev->max_mtu = MLXSW_PORT_MAX_MTU - MLXSW_PORT_ETH_FRAME_HDR; in mlxsw_sp_port_create()
1691 dev->needed_headroom = MLXSW_TXHDR_LEN; in mlxsw_sp_port_create()
1695 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sp_port_create()
1696 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1702 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", in mlxsw_sp_port_create()
1703 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1707 err = mlxsw_sp->port_type_speed_ops->ptys_max_speed(mlxsw_sp_port, in mlxsw_sp_port_create()
1708 &mlxsw_sp_port->max_speed); in mlxsw_sp_port_create()
1710 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum speed\n", in mlxsw_sp_port_create()
1711 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1717 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sp_port_create()
1718 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1728 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize buffers\n", in mlxsw_sp_port_create()
1729 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1735 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize ETS\n", in mlxsw_sp_port_create()
1736 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1742 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC MC mode\n", in mlxsw_sp_port_create()
1743 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1750 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize DCB\n", in mlxsw_sp_port_create()
1751 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1757 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize FIDs\n", in mlxsw_sp_port_create()
1758 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1764 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC qdiscs\n", in mlxsw_sp_port_create()
1765 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1769 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 0, VLAN_N_VID - 1, false, in mlxsw_sp_port_create()
1772 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to clear VLAN filter\n", in mlxsw_sp_port_create()
1773 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1779 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize NVE\n", in mlxsw_sp_port_create()
1780 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1787 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set PVID\n", in mlxsw_sp_port_create()
1788 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1795 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n", in mlxsw_sp_port_create()
1796 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1800 mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan; in mlxsw_sp_port_create()
1807 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set default VLAN classification\n", in mlxsw_sp_port_create()
1812 INIT_DELAYED_WORK(&mlxsw_sp_port->ptp.shaper_dw, in mlxsw_sp_port_create()
1813 mlxsw_sp->ptp_ops->shaper_work); in mlxsw_sp_port_create()
1815 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1819 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set overheat initial value\n", in mlxsw_sp_port_create()
1820 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1826 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sp_port_create()
1827 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1831 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0); in mlxsw_sp_port_create()
1838 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_create()
1862 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_create()
1866 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_create()
1873 port_mapping->slot_index, in mlxsw_sp_port_create()
1874 port_mapping->module); in mlxsw_sp_port_create()
1880 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove()
1881 u8 slot_index = mlxsw_sp_port->mapping.slot_index; in mlxsw_sp_port_remove()
1882 u8 module = mlxsw_sp_port->mapping.module; in mlxsw_sp_port_remove()
1884 cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw); in mlxsw_sp_port_remove()
1885 cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw); in mlxsw_sp_port_remove()
1886 unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ in mlxsw_sp_port_remove()
1889 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_remove()
1897 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_remove()
1898 WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); in mlxsw_sp_port_remove()
1899 free_netdev(mlxsw_sp_port->dev); in mlxsw_sp_port_remove()
1900 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_remove()
1913 return -ENOMEM; in mlxsw_sp_cpu_port_create()
1915 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_cpu_port_create()
1916 mlxsw_sp_port->local_port = MLXSW_PORT_CPU_PORT; in mlxsw_sp_cpu_port_create()
1918 err = mlxsw_core_cpu_port_init(mlxsw_sp->core, in mlxsw_sp_cpu_port_create()
1920 mlxsw_sp->base_mac, in mlxsw_sp_cpu_port_create()
1921 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_cpu_port_create()
1923 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize core CPU port\n"); in mlxsw_sp_cpu_port_create()
1927 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = mlxsw_sp_port; in mlxsw_sp_cpu_port_create()
1938 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp_cpu_port_remove()
1940 mlxsw_core_cpu_port_fini(mlxsw_sp->core); in mlxsw_sp_cpu_port_remove()
1941 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = NULL; in mlxsw_sp_cpu_port_remove()
1954 return mlxsw_sp->ports[local_port] != NULL; in mlxsw_sp_port_created()
1965 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmecr), pmecr_pl); in mlxsw_sp_port_mapping_event_set()
1986 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_port_mapping_events_work()
1988 spin_lock_bh(&events->queue_lock); in mlxsw_sp_port_mapping_events_work()
1989 list_splice_init(&events->queue, &event_queue); in mlxsw_sp_port_mapping_events_work()
1990 spin_unlock_bh(&events->queue_lock); in mlxsw_sp_port_mapping_events_work()
1993 local_port = mlxsw_reg_pmlp_local_port_get(event->pmlp_pl); in mlxsw_sp_port_mapping_events_work()
1995 event->pmlp_pl, &port_mapping); in mlxsw_sp_port_mapping_events_work()
2012 mlxsw_sp->port_mapping[local_port] = port_mapping; in mlxsw_sp_port_mapping_events_work()
2032 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_port_mapping_listener_func()
2036 memcpy(event->pmlp_pl, pmlp_pl, sizeof(event->pmlp_pl)); in mlxsw_sp_port_mapping_listener_func()
2037 spin_lock(&events->queue_lock); in mlxsw_sp_port_mapping_listener_func()
2038 list_add_tail(&event->list, &events->queue); in mlxsw_sp_port_mapping_listener_func()
2039 spin_unlock(&events->queue_lock); in mlxsw_sp_port_mapping_listener_func()
2040 mlxsw_core_schedule_work(&events->work); in mlxsw_sp_port_mapping_listener_func()
2049 events = &mlxsw_sp->port_mapping_events; in __mlxsw_sp_port_mapping_events_cancel()
2052 cancel_work_sync(&events->work); in __mlxsw_sp_port_mapping_events_cancel()
2053 list_for_each_entry_safe(event, next_event, &events->queue, list) { in __mlxsw_sp_port_mapping_events_cancel()
2054 list_del(&event->list); in __mlxsw_sp_port_mapping_events_cancel()
2061 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_remove()
2073 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_remove()
2074 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_remove()
2093 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_create()
2101 mlxsw_sp->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_ports_create()
2102 if (!mlxsw_sp->ports) in mlxsw_sp_ports_create()
2103 return -ENOMEM; in mlxsw_sp_ports_create()
2105 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_ports_create()
2106 INIT_LIST_HEAD(&events->queue); in mlxsw_sp_ports_create()
2107 spin_lock_init(&events->queue_lock); in mlxsw_sp_ports_create()
2108 INIT_WORK(&events->work, mlxsw_sp_port_mapping_events_work); in mlxsw_sp_ports_create()
2121 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_ports_create()
2122 if (!port_mapping->width) in mlxsw_sp_ports_create()
2131 for (i--; i >= 1; i--) in mlxsw_sp_ports_create()
2138 for (i--; i >= 1; i--) in mlxsw_sp_ports_create()
2142 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_create()
2143 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_create()
2149 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_port_module_info_init()
2154 mlxsw_sp->port_mapping = kcalloc(max_ports, in mlxsw_sp_port_module_info_init()
2157 if (!mlxsw_sp->port_mapping) in mlxsw_sp_port_module_info_init()
2158 return -ENOMEM; in mlxsw_sp_port_module_info_init()
2161 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_port_module_info_init()
2169 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_init()
2175 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_fini()
2204 for (i--; i >= 0; i--) { in mlxsw_sp_port_split_create()
2224 port_mapping = &mlxsw_sp->port_mapping[local_port]; in mlxsw_sp_port_unsplit_create()
2225 if (!port_mapping->width || !mlxsw_sp_local_port_valid(local_port)) in mlxsw_sp_port_unsplit_create()
2235 if (mlxsw_sp->ports && mlxsw_sp->ports[local_port]) in mlxsw_sp_port_get_by_local_port()
2236 return mlxsw_sp->ports[local_port]; in mlxsw_sp_port_get_by_local_port()
2254 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_split()
2257 return -EINVAL; in mlxsw_sp_port_split()
2260 if (mlxsw_sp_port->split) { in mlxsw_sp_port_split()
2262 return -EINVAL; in mlxsw_sp_port_split()
2265 mlxsw_reg_pmtdb_pack(pmtdb_pl, mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_split()
2266 mlxsw_sp_port->mapping.module, in mlxsw_sp_port_split()
2267 mlxsw_sp_port->mapping.module_width / count, in mlxsw_sp_port_split()
2278 return -EINVAL; in mlxsw_sp_port_split()
2281 port_mapping = mlxsw_sp_port->mapping; in mlxsw_sp_port_split()
2293 dev_err(mlxsw_sp->bus_info->dev, "Failed to create split ports\n"); in mlxsw_sp_port_split()
2317 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_unsplit()
2320 return -EINVAL; in mlxsw_sp_port_unsplit()
2323 if (!mlxsw_sp_port->split) { in mlxsw_sp_port_unsplit()
2325 return -EINVAL; in mlxsw_sp_port_unsplit()
2328 count = mlxsw_sp_port->mapping.module_width / in mlxsw_sp_port_unsplit()
2329 mlxsw_sp_port->mapping.width; in mlxsw_sp_port_unsplit()
2331 mlxsw_reg_pmtdb_pack(pmtdb_pl, mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_unsplit()
2332 mlxsw_sp_port->mapping.module, in mlxsw_sp_port_unsplit()
2333 mlxsw_sp_port->mapping.module_width / count, in mlxsw_sp_port_unsplit()
2359 mlxsw_sp_port->periodic_hw_stats.xstats.backlog[i] = 0; in mlxsw_sp_port_down_wipe_counters()
2374 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
2380 netdev_info(mlxsw_sp_port->dev, "link up\n"); in mlxsw_sp_pude_event_func()
2381 netif_carrier_on(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
2382 mlxsw_core_schedule_dw(&mlxsw_sp_port->ptp.shaper_dw, 0); in mlxsw_sp_pude_event_func()
2384 netdev_info(mlxsw_sp_port->dev, "link down\n"); in mlxsw_sp_pude_event_func()
2385 netif_carrier_off(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
2434 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_no_mark_func()
2438 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()
2443 skb->dev = mlxsw_sp_port->dev; in mlxsw_sp_rx_listener_no_mark_func()
2445 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_rx_listener_no_mark_func()
2446 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sp_rx_listener_no_mark_func()
2447 pcpu_stats->rx_packets++; in mlxsw_sp_rx_listener_no_mark_func()
2448 pcpu_stats->rx_bytes += skb->len; in mlxsw_sp_rx_listener_no_mark_func()
2449 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sp_rx_listener_no_mark_func()
2451 skb->protocol = eth_type_trans(skb, skb->dev); in mlxsw_sp_rx_listener_no_mark_func()
2458 skb->offload_fwd_mark = 1; in mlxsw_sp_rx_listener_mark_func()
2465 skb->offload_l3_fwd_mark = 1; in mlxsw_sp_rx_listener_l3_mark_func()
2466 skb->offload_fwd_mark = 1; in mlxsw_sp_rx_listener_l3_mark_func()
2473 mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_receive()
2540 return -EIO; in mlxsw_sp_cpu_policers_set()
2558 __set_bit(i, mlxsw_sp->trap->policers_usage); in mlxsw_sp_cpu_policers_set()
2580 return -EIO; in mlxsw_sp_trap_groups_set()
2605 return -EIO; in mlxsw_sp_trap_groups_set()
2622 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_CPU_POLICERS)) in mlxsw_sp_traps_init()
2623 return -EIO; in mlxsw_sp_traps_init()
2624 max_policers = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_CPU_POLICERS); in mlxsw_sp_traps_init()
2628 return -ENOMEM; in mlxsw_sp_traps_init()
2629 trap->max_policers = max_policers; in mlxsw_sp_traps_init()
2630 mlxsw_sp->trap = trap; in mlxsw_sp_traps_init()
2632 err = mlxsw_sp_cpu_policers_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2636 err = mlxsw_sp_trap_groups_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2640 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2646 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_init()
2647 mlxsw_sp->listeners_count, mlxsw_sp); in mlxsw_sp_traps_init()
2654 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2666 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_fini()
2667 mlxsw_sp->listeners_count, in mlxsw_sp_traps_fini()
2669 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_fini()
2671 kfree(mlxsw_sp->trap); in mlxsw_sp_traps_fini()
2679 if (mlxsw_core_lag_mode(mlxsw_sp->core) != in mlxsw_sp_lag_pgt_init()
2684 * entries. The LAG table address needs to be 8-aligned, but that ought in mlxsw_sp_lag_pgt_init()
2687 err = mlxsw_sp_pgt_mid_alloc_range(mlxsw_sp, &mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_init()
2688 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_init()
2691 if (WARN_ON_ONCE(mlxsw_sp->lag_pgt_base % 8)) { in mlxsw_sp_lag_pgt_init()
2692 err = -EINVAL; in mlxsw_sp_lag_pgt_init()
2696 mlxsw_reg_sgcr_pack(sgcr_pl, mlxsw_sp->lag_pgt_base); in mlxsw_sp_lag_pgt_init()
2697 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sgcr), sgcr_pl); in mlxsw_sp_lag_pgt_init()
2704 mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_init()
2705 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_init()
2711 if (mlxsw_core_lag_mode(mlxsw_sp->core) != in mlxsw_sp_lag_pgt_fini()
2715 mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_fini()
2716 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_fini()
2733 seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), in mlxsw_sp_lag_init()
2744 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcr), slcr_pl); in mlxsw_sp_lag_init()
2748 err = mlxsw_core_max_lag(mlxsw_sp->core, &mlxsw_sp->max_lag); in mlxsw_sp_lag_init()
2752 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS)) in mlxsw_sp_lag_init()
2753 return -EIO; in mlxsw_sp_lag_init()
2759 mlxsw_sp->lags = kcalloc(mlxsw_sp->max_lag, sizeof(struct mlxsw_sp_lag), in mlxsw_sp_lag_init()
2761 if (!mlxsw_sp->lags) { in mlxsw_sp_lag_init()
2762 err = -ENOMEM; in mlxsw_sp_lag_init()
2776 kfree(mlxsw_sp->lags); in mlxsw_sp_lag_fini()
2856 key->type = trigger->type; in mlxsw_sp_sample_trigger_key_init()
2857 key->local_port = trigger->local_port; in mlxsw_sp_sample_trigger_key_init()
2869 trigger_node = rhashtable_lookup(&mlxsw_sp->sample_trigger_ht, &key, in mlxsw_sp_sample_trigger_params_lookup()
2874 return &trigger_node->params; in mlxsw_sp_sample_trigger_params_lookup()
2887 return -ENOMEM; in mlxsw_sp_sample_trigger_node_init()
2889 trigger_node->trigger = *trigger; in mlxsw_sp_sample_trigger_node_init()
2890 trigger_node->params = *params; in mlxsw_sp_sample_trigger_node_init()
2891 refcount_set(&trigger_node->refcount, 1); in mlxsw_sp_sample_trigger_node_init()
2893 err = rhashtable_insert_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_init()
2894 &trigger_node->ht_node, in mlxsw_sp_sample_trigger_node_init()
2910 rhashtable_remove_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_fini()
2911 &trigger_node->ht_node, in mlxsw_sp_sample_trigger_node_fini()
2929 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_set()
2936 if (trigger_node->trigger.local_port) { in mlxsw_sp_sample_trigger_params_set()
2938 return -EINVAL; in mlxsw_sp_sample_trigger_params_set()
2941 if (trigger_node->params.psample_group != params->psample_group || in mlxsw_sp_sample_trigger_params_set()
2942 trigger_node->params.truncate != params->truncate || in mlxsw_sp_sample_trigger_params_set()
2943 trigger_node->params.rate != params->rate || in mlxsw_sp_sample_trigger_params_set()
2944 trigger_node->params.trunc_size != params->trunc_size) { in mlxsw_sp_sample_trigger_params_set()
2946 return -EINVAL; in mlxsw_sp_sample_trigger_params_set()
2949 refcount_inc(&trigger_node->refcount); in mlxsw_sp_sample_trigger_params_set()
2965 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_unset()
2971 if (!refcount_dec_and_test(&trigger_node->refcount)) in mlxsw_sp_sample_trigger_params_unset()
2986 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 0); in mlxsw_sp_parsing_init()
2987 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_init()
2988 mlxsw_sp->parsing.vxlan_udp_dport = MLXSW_SP_DEFAULT_VXLAN_UDP_DPORT; in mlxsw_sp_parsing_init()
2989 mutex_init(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_init()
2994 mutex_destroy(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_fini()
2995 WARN_ON_ONCE(refcount_read(&mlxsw_sp->parsing.parsing_depth_ref)); in mlxsw_sp_parsing_fini()
3027 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rips), rips_pl); in mlxsw_sp_ipv6_addr_init()
3033 err = -ENOMEM; in mlxsw_sp_ipv6_addr_init()
3037 node->key = *addr6; in mlxsw_sp_ipv6_addr_init()
3038 node->kvdl_index = *p_kvdl_index; in mlxsw_sp_ipv6_addr_init()
3039 refcount_set(&node->refcount, 1); in mlxsw_sp_ipv6_addr_init()
3041 err = rhashtable_insert_fast(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_init()
3042 &node->ht_node, in mlxsw_sp_ipv6_addr_init()
3061 u32 kvdl_index = node->kvdl_index; in mlxsw_sp_ipv6_addr_fini()
3063 rhashtable_remove_fast(&mlxsw_sp->ipv6_addr_ht, &node->ht_node, in mlxsw_sp_ipv6_addr_fini()
3077 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3078 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_kvdl_index_get()
3081 refcount_inc(&node->refcount); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3082 *p_kvdl_index = node->kvdl_index; in mlxsw_sp_ipv6_addr_kvdl_index_get()
3089 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
3098 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
3099 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_put()
3104 if (!refcount_dec_and_test(&node->refcount)) in mlxsw_sp_ipv6_addr_put()
3110 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
3117 err = rhashtable_init(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_ht_init()
3122 mutex_init(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_init()
3128 mutex_destroy(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_fini()
3129 rhashtable_destroy(&mlxsw_sp->ipv6_addr_ht); in mlxsw_sp_ipv6_addr_ht_fini()
3139 mlxsw_sp->core = mlxsw_core; in mlxsw_sp_init()
3140 mlxsw_sp->bus_info = mlxsw_bus_info; in mlxsw_sp_init()
3146 dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); in mlxsw_sp_init()
3152 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize KVDL\n"); in mlxsw_sp_init()
3158 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PGT\n"); in mlxsw_sp_init()
3163 * and 8-aligned without overallocation. in mlxsw_sp_init()
3167 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize LAG\n"); in mlxsw_sp_init()
3171 err = mlxsw_sp->fid_core_ops->init(mlxsw_sp); in mlxsw_sp_init()
3173 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize FIDs\n"); in mlxsw_sp_init()
3179 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize policers\n"); in mlxsw_sp_init()
3185 dev_err(mlxsw_sp->bus_info->dev, "Failed to set traps\n"); in mlxsw_sp_init()
3191 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize devlink traps\n"); in mlxsw_sp_init()
3197 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize buffers\n"); in mlxsw_sp_init()
3206 dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n"); in mlxsw_sp_init()
3212 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); in mlxsw_sp_init()
3218 dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter pool\n"); in mlxsw_sp_init()
3224 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL actions\n"); in mlxsw_sp_init()
3230 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize hash table for IPv6 addresses\n"); in mlxsw_sp_init()
3236 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize NVE\n"); in mlxsw_sp_init()
3242 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize port ranges\n"); in mlxsw_sp_init()
3248 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL\n"); in mlxsw_sp_init()
3254 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize router\n"); in mlxsw_sp_init()
3258 if (mlxsw_sp->bus_info->read_clock_capable) { in mlxsw_sp_init()
3260 mlxsw_sp->clock = in mlxsw_sp_init()
3261 mlxsw_sp->ptp_ops->clock_init(mlxsw_sp, in mlxsw_sp_init()
3262 mlxsw_sp->bus_info->dev); in mlxsw_sp_init()
3263 if (IS_ERR(mlxsw_sp->clock)) { in mlxsw_sp_init()
3264 err = PTR_ERR(mlxsw_sp->clock); in mlxsw_sp_init()
3265 dev_err(mlxsw_sp->bus_info->dev, "Failed to init ptp clock\n"); in mlxsw_sp_init()
3270 if (mlxsw_sp->clock) { in mlxsw_sp_init()
3271 /* NULL is a valid return value from ptp_ops->init */ in mlxsw_sp_init()
3272 mlxsw_sp->ptp_state = mlxsw_sp->ptp_ops->init(mlxsw_sp); in mlxsw_sp_init()
3273 if (IS_ERR(mlxsw_sp->ptp_state)) { in mlxsw_sp_init()
3274 err = PTR_ERR(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3275 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PTP\n"); in mlxsw_sp_init()
3283 mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event; in mlxsw_sp_init()
3285 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3287 dev_err(mlxsw_sp->bus_info->dev, "Failed to register netdev notifier\n"); in mlxsw_sp_init()
3293 dev_err(mlxsw_sp->bus_info->dev, "Failed to init pipeline debug\n"); in mlxsw_sp_init()
3299 dev_err(mlxsw_sp->bus_info->dev, "Failed to init port module info\n"); in mlxsw_sp_init()
3303 err = rhashtable_init(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_init()
3306 dev_err(mlxsw_sp->bus_info->dev, "Failed to init sampling trigger hashtable\n"); in mlxsw_sp_init()
3312 dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n"); in mlxsw_sp_init()
3319 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_init()
3326 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3328 if (mlxsw_sp->clock) in mlxsw_sp_init()
3329 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3331 if (mlxsw_sp->clock) in mlxsw_sp_init()
3332 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_init()
3360 mlxsw_sp->fid_core_ops->fini(mlxsw_sp); in mlxsw_sp_init()
3377 mlxsw_sp->switchdev_ops = &mlxsw_sp1_switchdev_ops; in mlxsw_sp1_init()
3378 mlxsw_sp->kvdl_ops = &mlxsw_sp1_kvdl_ops; in mlxsw_sp1_init()
3379 mlxsw_sp->afa_ops = &mlxsw_sp1_act_afa_ops; in mlxsw_sp1_init()
3380 mlxsw_sp->afk_ops = &mlxsw_sp1_afk_ops; in mlxsw_sp1_init()
3381 mlxsw_sp->mr_tcam_ops = &mlxsw_sp1_mr_tcam_ops; in mlxsw_sp1_init()
3382 mlxsw_sp->acl_rulei_ops = &mlxsw_sp1_acl_rulei_ops; in mlxsw_sp1_init()
3383 mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops; in mlxsw_sp1_init()
3384 mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr; in mlxsw_sp1_init()
3385 mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask; in mlxsw_sp1_init()
3386 mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals; in mlxsw_sp1_init()
3387 mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops; in mlxsw_sp1_init()
3388 mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops; in mlxsw_sp1_init()
3389 mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops; in mlxsw_sp1_init()
3390 mlxsw_sp->span_ops = &mlxsw_sp1_span_ops; in mlxsw_sp1_init()
3391 mlxsw_sp->policer_core_ops = &mlxsw_sp1_policer_core_ops; in mlxsw_sp1_init()
3392 mlxsw_sp->trap_ops = &mlxsw_sp1_trap_ops; in mlxsw_sp1_init()
3393 mlxsw_sp->mall_ops = &mlxsw_sp1_mall_ops; in mlxsw_sp1_init()
3394 mlxsw_sp->router_ops = &mlxsw_sp1_router_ops; in mlxsw_sp1_init()
3395 mlxsw_sp->listeners = mlxsw_sp1_listener; in mlxsw_sp1_init()
3396 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener); in mlxsw_sp1_init()
3397 mlxsw_sp->fid_core_ops = &mlxsw_sp1_fid_core_ops; in mlxsw_sp1_init()
3398 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1; in mlxsw_sp1_init()
3399 mlxsw_sp->pgt_smpe_index_valid = true; in mlxsw_sp1_init()
3410 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp2_init()
3411 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp2_init()
3412 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp2_init()
3413 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp2_init()
3414 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp2_init()
3415 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp2_init()
3416 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp2_init()
3417 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp2_init()
3418 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp2_init()
3419 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp2_init()
3420 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp2_init()
3421 mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops; in mlxsw_sp2_init()
3422 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp2_init()
3423 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp2_init()
3424 mlxsw_sp->span_ops = &mlxsw_sp2_span_ops; in mlxsw_sp2_init()
3425 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp2_init()
3426 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp2_init()
3427 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp2_init()
3428 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp2_init()
3429 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp2_init()
3430 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp2_init()
3431 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp2_init()
3432 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2; in mlxsw_sp2_init()
3433 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp2_init()
3444 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp3_init()
3445 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp3_init()
3446 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp3_init()
3447 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp3_init()
3448 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp3_init()
3449 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp3_init()
3450 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp3_init()
3451 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp3_init()
3452 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp3_init()
3453 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp3_init()
3454 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp3_init()
3455 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp3_init()
3456 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp3_init()
3457 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp3_init()
3458 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp3_init()
3459 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp3_init()
3460 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp3_init()
3461 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp3_init()
3462 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp3_init()
3463 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp3_init()
3464 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp3_init()
3465 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp3_init()
3466 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; in mlxsw_sp3_init()
3467 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp3_init()
3478 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp4_init()
3479 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp4_init()
3480 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp4_init()
3481 mlxsw_sp->afk_ops = &mlxsw_sp4_afk_ops; in mlxsw_sp4_init()
3482 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp4_init()
3483 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp4_init()
3484 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp4_init()
3485 mlxsw_sp->acl_bf_ops = &mlxsw_sp4_acl_bf_ops; in mlxsw_sp4_init()
3486 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp4_init()
3487 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp4_init()
3488 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp4_init()
3489 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp4_init()
3490 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp4_init()
3491 mlxsw_sp->ptp_ops = &mlxsw_sp4_ptp_ops; in mlxsw_sp4_init()
3492 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp4_init()
3493 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp4_init()
3494 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp4_init()
3495 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp4_init()
3496 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp4_init()
3497 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp4_init()
3498 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp4_init()
3499 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp4_init()
3500 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4; in mlxsw_sp4_init()
3501 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp4_init()
3511 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_fini()
3515 &mlxsw_sp->netdevice_nb); in mlxsw_sp_fini()
3516 if (mlxsw_sp->clock) { in mlxsw_sp_fini()
3517 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_fini()
3518 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_fini()
3533 mlxsw_sp->fid_core_ops->fini(mlxsw_sp); in mlxsw_sp_fini()
3583 * in Spectrum-2/3, to avoid regression in number of free entries in the PGT
3629 kvd_size - single_size_min - in mlxsw_sp_resource_size_params_prepare()
3635 kvd_size - single_size_min - in mlxsw_sp_resource_size_params_prepare()
3641 kvd_size - double_size_min - in mlxsw_sp_resource_size_params_prepare()
3660 return -EIO; in mlxsw_sp1_resources_kvd_register()
3675 linear_size = profile->kvd_linear_size; in mlxsw_sp1_resources_kvd_register()
3688 double_size = kvd_size - linear_size; in mlxsw_sp1_resources_kvd_register()
3689 double_size *= profile->kvd_hash_double_parts; in mlxsw_sp1_resources_kvd_register()
3690 double_size /= profile->kvd_hash_double_parts + in mlxsw_sp1_resources_kvd_register()
3691 profile->kvd_hash_single_parts; in mlxsw_sp1_resources_kvd_register()
3701 single_size = kvd_size - double_size - linear_size; in mlxsw_sp1_resources_kvd_register()
3720 return -EIO; in mlxsw_sp2_resources_kvd_register()
3740 return -EIO; in mlxsw_sp_resources_span_register()
3783 return -EIO; in mlxsw_sp_resources_rifs_register()
3803 return -EIO; in mlxsw_sp_resources_port_range_register()
3914 return -EIO; in mlxsw_sp_kvd_sizes_get()
3927 *p_linear_size = profile->kvd_linear_size; in mlxsw_sp_kvd_sizes_get()
3933 double_size = MLXSW_CORE_RES_GET(mlxsw_core, KVD_SIZE) - in mlxsw_sp_kvd_sizes_get()
3935 double_size *= profile->kvd_hash_double_parts; in mlxsw_sp_kvd_sizes_get()
3936 double_size /= profile->kvd_hash_double_parts + in mlxsw_sp_kvd_sizes_get()
3937 profile->kvd_hash_single_parts; in mlxsw_sp_kvd_sizes_get()
3946 *p_single_size = MLXSW_CORE_RES_GET(mlxsw_core, KVD_SIZE) - in mlxsw_sp_kvd_sizes_get()
3947 *p_double_size - *p_linear_size; in mlxsw_sp_kvd_sizes_get()
3953 return -EIO; in mlxsw_sp_kvd_sizes_get()
3964 mlxsw_sp->ptp_ops->transmitted(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_transmitted()
4115 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; in mlxsw_sp_port_dev_check()
4124 priv->data = (void *)netdev_priv(lower_dev); in mlxsw_sp_lower_dev_walk()
4150 return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp : NULL; in mlxsw_sp_lower_get()
4173 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4175 if (refcount_inc_not_zero(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_inc()
4179 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_inc()
4180 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_inc()
4184 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_INCREASED_PARSING_DEPTH; in mlxsw_sp_parsing_depth_inc()
4185 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 1); in mlxsw_sp_parsing_depth_inc()
4188 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4196 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4198 if (!refcount_dec_and_test(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_dec()
4202 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_dec()
4203 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_dec()
4204 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_depth_dec()
4207 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4216 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4218 mlxsw_reg_mprs_pack(mprs_pl, mlxsw_sp->parsing.parsing_depth, in mlxsw_sp_parsing_vxlan_udp_dport_set()
4220 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4224 mlxsw_sp->parsing.vxlan_udp_dport = be16_to_cpu(udp_dport); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4227 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4259 for (i = 0; i < mlxsw_sp->max_lag; i++) { in mlxsw_sp_lag_create()
4260 if (!mlxsw_sp->lags[i].dev) in mlxsw_sp_lag_create()
4264 if (i == mlxsw_sp->max_lag) { in mlxsw_sp_lag_create()
4267 return ERR_PTR(-EBUSY); in mlxsw_sp_lag_create()
4272 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_create()
4276 lag = &mlxsw_sp->lags[lag_id]; in mlxsw_sp_lag_create()
4277 lag->lag_id = lag_id; in mlxsw_sp_lag_create()
4278 lag->dev = lag_dev; in mlxsw_sp_lag_create()
4279 refcount_set(&lag->ref_count, 1); in mlxsw_sp_lag_create()
4289 lag->dev = NULL; in mlxsw_sp_lag_destroy()
4291 mlxsw_reg_sldr_lag_destroy_pack(sldr_pl, lag->lag_id); in mlxsw_sp_lag_destroy()
4292 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_destroy()
4298 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_add()
4301 mlxsw_reg_slcor_port_add_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_add()
4303 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_add()
4309 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_remove()
4312 mlxsw_reg_slcor_port_remove_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_remove()
4314 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_remove()
4320 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_enable()
4323 mlxsw_reg_slcor_col_enable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_enable()
4325 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_enable()
4331 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_disable()
4334 mlxsw_reg_slcor_col_disable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_disable()
4336 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_disable()
4344 for (i = 0; i < mlxsw_sp->max_lag; i++) { in mlxsw_sp_lag_find()
4345 if (!mlxsw_sp->lags[i].dev) in mlxsw_sp_lag_find()
4348 if (mlxsw_sp->lags[i].dev == lag_dev) in mlxsw_sp_lag_find()
4349 return &mlxsw_sp->lags[i]; in mlxsw_sp_lag_find()
4363 refcount_inc(&lag->ref_count); in mlxsw_sp_lag_get()
4373 if (!refcount_dec_and_test(&lag->ref_count)) in mlxsw_sp_lag_put()
4385 if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { in mlxsw_sp_master_lag_check()
4398 max_lag_members = MLXSW_CORE_RES_GET(mlxsw_sp->core, in mlxsw_sp_port_lag_index_get()
4406 return -EBUSY; in mlxsw_sp_port_lag_index_get()
4414 struct net_device *master; in mlxsw_sp_lag_uppers_bridge_join() local
4419 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_join()
4420 if (master && netif_is_bridge_master(master)) { in mlxsw_sp_lag_uppers_bridge_join()
4421 err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, lag_dev, master, in mlxsw_sp_lag_uppers_bridge_join()
4431 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_join()
4432 if (master && netif_is_bridge_master(master)) { in mlxsw_sp_lag_uppers_bridge_join()
4434 upper_dev, master, in mlxsw_sp_lag_uppers_bridge_join()
4450 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_join()
4451 if (!master || !netif_is_bridge_master(master)) in mlxsw_sp_lag_uppers_bridge_join()
4454 if (!done--) in mlxsw_sp_lag_uppers_bridge_join()
4457 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); in mlxsw_sp_lag_uppers_bridge_join()
4460 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_join()
4461 if (master && netif_is_bridge_master(master)) in mlxsw_sp_lag_uppers_bridge_join()
4462 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); in mlxsw_sp_lag_uppers_bridge_join()
4472 struct net_device *master; in mlxsw_sp_lag_uppers_bridge_leave() local
4479 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_leave()
4480 if (!master) in mlxsw_sp_lag_uppers_bridge_leave()
4483 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); in mlxsw_sp_lag_uppers_bridge_leave()
4486 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_leave()
4487 if (master) in mlxsw_sp_lag_uppers_bridge_leave()
4488 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); in mlxsw_sp_lag_uppers_bridge_leave()
4495 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_join()
4505 lag_id = lag->lag_id; in mlxsw_sp_port_lag_join()
4519 mlxsw_core_lag_mapping_set(mlxsw_sp->core, lag_id, port_index, in mlxsw_sp_port_lag_join()
4520 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_join()
4521 mlxsw_sp_port->lag_id = lag_id; in mlxsw_sp_port_lag_join()
4522 mlxsw_sp_port->lagged = 1; in mlxsw_sp_port_lag_join()
4529 if (mlxsw_sp_port->default_vlan->fid) in mlxsw_sp_port_lag_join()
4530 mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_join()
4549 mlxsw_sp_port->lagged = 0; in mlxsw_sp_port_lag_join()
4550 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_join()
4551 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_join()
4563 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_leave()
4564 u16 lag_id = mlxsw_sp_port->lag_id; in mlxsw_sp_port_lag_leave()
4567 if (!mlxsw_sp_port->lagged) in mlxsw_sp_port_lag_leave()
4569 lag = &mlxsw_sp->lags[lag_id]; in mlxsw_sp_port_lag_leave()
4575 mlxsw_sp_port_vlan_cleanup(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_leave()
4585 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_leave()
4586 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_leave()
4587 mlxsw_sp_port->lagged = 0; in mlxsw_sp_port_lag_leave()
4597 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_add()
4601 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_add()
4602 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_add()
4608 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_remove()
4612 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_remove()
4613 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_remove()
4622 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4626 err = mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4633 mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4643 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4648 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4655 mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4662 if (info->tx_enabled) in mlxsw_sp_port_lag_changed()
4671 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_set()
4682 return -ENOMEM; in mlxsw_sp_port_stp_set()
4683 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_stp_set()
4688 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_stp_set()
4704 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_join()
4709 for (; vid <= VLAN_N_VID - 1; vid++) { in mlxsw_sp_port_ovs_join()
4719 for (vid--; vid >= 1; vid--) in mlxsw_sp_port_ovs_join()
4732 for (vid = VLAN_N_VID - 1; vid >= 1; vid--) in mlxsw_sp_port_ovs_leave()
4736 mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_leave()
4790 NL_SET_ERR_MSG_MOD(extack, "Multiple VxLAN devices are not supported in a VLAN-unaware bridge"); in mlxsw_sp_bridge_vxlan_is_valid()
4827 .master = mlxsw_sp_netdev_is_master(upper_dev, dev), in mlxsw_sp_netdevice_validate_uppers()
4869 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event()
4871 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_port_upper_event()
4875 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_upper_event()
4883 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4885 if (!info->linking) in mlxsw_sp_netdevice_port_upper_event()
4891 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4904 info->upper_info, extack)) in mlxsw_sp_netdevice_port_upper_event()
4905 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4907 NL_SET_ERR_MSG_MOD(extack, "Master device is a LAG master and this device has a VLAN"); in mlxsw_sp_netdevice_port_upper_event()
4908 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4913 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4916 NL_SET_ERR_MSG_MOD(extack, "Master device is an OVS master and this device has a VLAN"); in mlxsw_sp_netdevice_port_upper_event()
4917 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4921 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4928 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4934 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4944 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4951 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4953 if (is_vlan_dev(upper_dev) && mlxsw_sp_port->security) { in mlxsw_sp_netdevice_port_upper_event()
4955 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4959 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_upper_event()
4961 if (info->linking) { in mlxsw_sp_netdevice_port_upper_event()
4976 if (info->linking) { in mlxsw_sp_netdevice_port_upper_event()
4987 if (info->linking) in mlxsw_sp_netdevice_port_upper_event()
4992 if (!info->linking) in mlxsw_sp_netdevice_port_upper_event()
4999 if (info->linking) in mlxsw_sp_netdevice_port_upper_event()
5023 if (netif_is_lag_port(dev) && mlxsw_sp_port->lagged) { in mlxsw_sp_netdevice_port_lower_event()
5025 info->lower_state_info); in mlxsw_sp_netdevice_port_lower_event()
5054 /* Called for LAG or its upper VLAN after the per-LAG-lower processing was done,
5055 * to do any per-LAG / per-LAG-upper processing.
5069 if (info->linking) in mlxsw_sp_netdevice_post_lag_event()
5071 if (netif_is_bridge_master(info->upper_dev)) in mlxsw_sp_netdevice_post_lag_event()
5103 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_vlan_event()
5109 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_port_vlan_event()
5113 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_vlan_event()
5118 return -EINVAL; in mlxsw_sp_netdevice_port_vlan_event()
5120 if (!info->linking) in mlxsw_sp_netdevice_port_vlan_event()
5126 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_vlan_event()
5139 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_vlan_event()
5141 if (info->linking) { in mlxsw_sp_netdevice_port_vlan_event()
5156 if (!info->linking) in mlxsw_sp_netdevice_port_vlan_event()
5200 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_bridge_vlan_event()
5204 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_vlan_event()
5208 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_vlan_event()
5212 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_vlan_event()
5213 if (info->linking) in mlxsw_sp_netdevice_bridge_vlan_event()
5261 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_bridge_event()
5265 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_event()
5270 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5272 if (!info->linking) in mlxsw_sp_netdevice_bridge_event()
5278 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5284 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5288 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_event()
5289 if (info->linking) in mlxsw_sp_netdevice_bridge_event()
5312 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_macvlan_event()
5313 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_macvlan_event()
5317 return -EOPNOTSUPP; in mlxsw_sp_netdevice_macvlan_event()
5339 upper_dev = cu_info->upper_dev; in mlxsw_sp_netdevice_vxlan_event()
5345 return -EOPNOTSUPP; in mlxsw_sp_netdevice_vxlan_event()
5346 if (cu_info->linking) { in mlxsw_sp_netdevice_vxlan_event()
5349 /* When the bridge is VLAN-aware, the VNI of the VxLAN in mlxsw_sp_netdevice_vxlan_event()