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) \
121 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_get()
138 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl); in mlxsw_sp_flow_counter_clear()
172 if (!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) in mlxsw_sp_skb_requires_ts()
186 txhdr_info->data = true; in mlxsw_sp_txhdr_info_data_init()
187 txhdr_info->max_fid = max_fid; in mlxsw_sp_txhdr_info_data_init()
214 if (!mlxsw_sp->ptp_ops->tx_as_data) in mlxsw_sp_txhdr_preparations()
220 mlxsw_sp_txhdr_info_data_init(mlxsw_sp->core, skb, txhdr_info); in mlxsw_sp_txhdr_preparations()
244 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_stp_set()
250 return -ENOMEM; in mlxsw_sp_port_vid_stp_set()
251 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_vid_stp_set()
254 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_vid_stp_set()
264 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(spad), spad_pl); in mlxsw_sp_base_mac_get()
267 mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_sp->base_mac); in mlxsw_sp_base_mac_get()
274 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set()
277 mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_admin_status_set()
280 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl); in mlxsw_sp_port_admin_status_set()
286 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set()
289 mlxsw_reg_ppad_pack(ppad_pl, true, mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_set()
291 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppad), ppad_pl); in mlxsw_sp_port_dev_addr_set()
296 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init()
298 eth_hw_addr_gen(mlxsw_sp_port->dev, mlxsw_sp->base_mac, in mlxsw_sp_port_dev_addr_init()
299 mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_init()
301 mlxsw_sp_port->dev->dev_addr); in mlxsw_sp_port_dev_addr_init()
306 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set()
311 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu); in mlxsw_sp_port_mtu_set()
312 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); in mlxsw_sp_port_mtu_set()
321 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); in mlxsw_sp_port_swid_set()
326 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set()
329 mlxsw_reg_svpe_pack(svpe_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_vp_mode_set()
330 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(svpe), svpe_pl); in mlxsw_sp_port_vp_mode_set()
336 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set()
342 return -ENOMEM; in mlxsw_sp_port_vid_learning_set()
343 mlxsw_reg_spvmlr_pack(spvmlr_pl, mlxsw_sp_port->local_port, vid, vid, in mlxsw_sp_port_vid_learning_set()
345 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvmlr), spvmlr_pl); in mlxsw_sp_port_vid_learning_set()
352 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_security_set()
356 if (mlxsw_sp_port->security == enable) in mlxsw_sp_port_security_set()
359 mlxsw_reg_spfsr_pack(spfsr_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_security_set()
360 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spfsr), spfsr_pl); in mlxsw_sp_port_security_set()
364 mlxsw_sp_port->security = enable; in mlxsw_sp_port_security_set()
378 return -EINVAL; in mlxsw_sp_ethtype_to_sver_type()
387 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_egress_ethtype_set()
396 mlxsw_reg_spevet_pack(spevet_pl, mlxsw_sp_port->local_port, sver_type); in mlxsw_sp_port_egress_ethtype_set()
397 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spevet), spevet_pl); in mlxsw_sp_port_egress_ethtype_set()
403 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_pvid_set()
412 mlxsw_reg_spvid_pack(spvid_pl, mlxsw_sp_port->local_port, vid, in __mlxsw_sp_port_pvid_set()
415 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl); in __mlxsw_sp_port_pvid_set()
421 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_allow_untagged_set()
424 mlxsw_reg_spaft_pack(spaft_pl, mlxsw_sp_port->local_port, allow); in mlxsw_sp_port_allow_untagged_set()
425 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl); in mlxsw_sp_port_allow_untagged_set()
446 mlxsw_sp_port->pvid = vid; in mlxsw_sp_port_pvid_set()
450 __mlxsw_sp_port_pvid_set(mlxsw_sp_port, mlxsw_sp_port->pvid, ethtype); in mlxsw_sp_port_pvid_set()
457 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set()
460 mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_system_port_mapping_set()
461 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl); in mlxsw_sp_port_system_port_mapping_set()
483 …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()
485 return -EINVAL; in mlxsw_sp_port_module_info_parse()
490 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple modules\n", in mlxsw_sp_port_module_info_parse()
492 return -EINVAL; in mlxsw_sp_port_module_info_parse()
495 …dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unsupported module config: contains multiple slot index… in mlxsw_sp_port_module_info_parse()
497 return -EINVAL; in mlxsw_sp_port_module_info_parse()
502 …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()
504 return -EINVAL; in mlxsw_sp_port_module_info_parse()
507 …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()
509 return -EINVAL; in mlxsw_sp_port_module_info_parse()
513 port_mapping->module = module; in mlxsw_sp_port_module_info_parse()
514 port_mapping->slot_index = slot_index; in mlxsw_sp_port_module_info_parse()
515 port_mapping->width = width; in mlxsw_sp_port_module_info_parse()
516 port_mapping->module_width = width; in mlxsw_sp_port_module_info_parse()
517 port_mapping->lane = mlxsw_reg_pmlp_tx_lane_get(pmlp_pl, 0); in mlxsw_sp_port_module_info_parse()
529 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_info_get()
543 mlxsw_env_module_port_map(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
544 port_mapping->module); in mlxsw_sp_port_module_map()
547 mlxsw_reg_pmlp_width_set(pmlp_pl, port_mapping->width); in mlxsw_sp_port_module_map()
548 for (i = 0; i < port_mapping->width; i++) { in mlxsw_sp_port_module_map()
550 port_mapping->slot_index); in mlxsw_sp_port_module_map()
551 mlxsw_reg_pmlp_module_set(pmlp_pl, i, port_mapping->module); in mlxsw_sp_port_module_map()
552 mlxsw_reg_pmlp_tx_lane_set(pmlp_pl, i, port_mapping->lane + i); /* Rx & Tx */ in mlxsw_sp_port_module_map()
555 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_map()
561 mlxsw_env_module_port_unmap(mlxsw_sp->core, port_mapping->slot_index, in mlxsw_sp_port_module_map()
562 port_mapping->module); in mlxsw_sp_port_module_map()
573 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); in mlxsw_sp_port_module_unmap()
574 mlxsw_env_module_port_unmap(mlxsw_sp->core, slot_index, module); in mlxsw_sp_port_module_unmap()
580 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_open()
583 err = mlxsw_env_module_port_up(mlxsw_sp->core, in mlxsw_sp_port_open()
584 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_open()
585 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_open()
595 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_open()
596 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_open()
597 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_open()
604 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stop()
608 mlxsw_env_module_port_down(mlxsw_sp->core, in mlxsw_sp_port_stop()
609 mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_stop()
610 mlxsw_sp_port->mapping.module); in mlxsw_sp_port_stop()
618 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit()
621 .tx_info.local_port = mlxsw_sp_port->local_port, in mlxsw_sp_port_xmit()
627 memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb)); in mlxsw_sp_port_xmit()
629 if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &txhdr_info.tx_info)) in mlxsw_sp_port_xmit()
633 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
639 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
646 len = skb->len - MLXSW_TXHDR_LEN; in mlxsw_sp_port_xmit()
651 err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &txhdr_info); in mlxsw_sp_port_xmit()
654 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_xmit()
655 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sp_port_xmit()
656 pcpu_stats->tx_packets++; in mlxsw_sp_port_xmit()
657 pcpu_stats->tx_bytes += len; in mlxsw_sp_port_xmit()
658 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sp_port_xmit()
660 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
676 if (!is_valid_ether_addr(addr->sa_data)) in mlxsw_sp_port_set_mac_address()
677 return -EADDRNOTAVAIL; in mlxsw_sp_port_set_mac_address()
679 err = mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr->sa_data); in mlxsw_sp_port_set_mac_address()
682 eth_hw_addr_set(dev, addr->sa_data); in mlxsw_sp_port_set_mac_address()
693 orig_hdroom = *mlxsw_sp_port->hdroom; in mlxsw_sp_port_change_mtu()
708 WRITE_ONCE(dev->mtu, mtu); in mlxsw_sp_port_change_mtu()
718 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_sw_stats64() argument
728 p = per_cpu_ptr(mlxsw_sp_port->pcpu_stats, i); in mlxsw_sp_port_get_sw_stats64()
730 start = u64_stats_fetch_begin(&p->syncp); in mlxsw_sp_port_get_sw_stats64()
731 rx_packets = p->rx_packets; in mlxsw_sp_port_get_sw_stats64()
732 rx_bytes = p->rx_bytes; in mlxsw_sp_port_get_sw_stats64()
733 tx_packets = p->tx_packets; in mlxsw_sp_port_get_sw_stats64()
734 tx_bytes = p->tx_bytes; in mlxsw_sp_port_get_sw_stats64()
735 } while (u64_stats_fetch_retry(&p->syncp, start)); in mlxsw_sp_port_get_sw_stats64()
737 stats->rx_packets += rx_packets; in mlxsw_sp_port_get_sw_stats64()
738 stats->rx_bytes += rx_bytes; in mlxsw_sp_port_get_sw_stats64()
739 stats->tx_packets += tx_packets; in mlxsw_sp_port_get_sw_stats64()
740 stats->tx_bytes += tx_bytes; in mlxsw_sp_port_get_sw_stats64()
742 tx_dropped += p->tx_dropped; in mlxsw_sp_port_get_sw_stats64()
744 stats->tx_dropped = tx_dropped; in mlxsw_sp_port_get_sw_stats64()
766 return -EINVAL; in mlxsw_sp_port_get_offload_stats()
773 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats_raw()
775 mlxsw_reg_ppcnt_pack(ppcnt_pl, mlxsw_sp_port->local_port, grp, prio); in mlxsw_sp_port_get_stats_raw()
776 return mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ppcnt), ppcnt_pl); in mlxsw_sp_port_get_stats_raw()
780 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_hw_stats() argument
790 stats->tx_packets = in mlxsw_sp_port_get_hw_stats()
792 stats->rx_packets = in mlxsw_sp_port_get_hw_stats()
794 stats->tx_bytes = in mlxsw_sp_port_get_hw_stats()
796 stats->rx_bytes = in mlxsw_sp_port_get_hw_stats()
798 stats->multicast = in mlxsw_sp_port_get_hw_stats()
801 stats->rx_crc_errors = in mlxsw_sp_port_get_hw_stats()
803 stats->rx_frame_errors = in mlxsw_sp_port_get_hw_stats()
806 stats->rx_length_errors = ( in mlxsw_sp_port_get_hw_stats()
811 stats->rx_errors = (stats->rx_crc_errors + in mlxsw_sp_port_get_hw_stats()
812 stats->rx_frame_errors + stats->rx_length_errors); in mlxsw_sp_port_get_hw_stats()
828 xstats->ecn = mlxsw_reg_ppcnt_ecn_marked_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
837 xstats->wred_drop[i] = in mlxsw_sp_port_get_hw_xstats()
839 xstats->tc_ecn[i] = mlxsw_reg_ppcnt_ecn_marked_tc_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
847 xstats->backlog[i] = in mlxsw_sp_port_get_hw_xstats()
849 xstats->tail_drop[i] = in mlxsw_sp_port_get_hw_xstats()
859 xstats->tx_packets[i] = mlxsw_reg_ppcnt_tx_frames_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
860 xstats->tx_bytes[i] = mlxsw_reg_ppcnt_tx_octets_get(ppcnt_pl); in mlxsw_sp_port_get_hw_xstats()
870 if (!netif_carrier_ok(mlxsw_sp_port->dev)) in update_stats_cache()
876 mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev, in update_stats_cache()
877 &mlxsw_sp_port->periodic_hw_stats.stats); in update_stats_cache()
878 mlxsw_sp_port_get_hw_xstats(mlxsw_sp_port->dev, in update_stats_cache()
879 &mlxsw_sp_port->periodic_hw_stats.xstats); in update_stats_cache()
882 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, in update_stats_cache()
886 /* Return the stats from a cache that is updated periodically,
891 struct rtnl_link_stats64 *stats) in mlxsw_sp_port_get_stats64() argument
895 memcpy(stats, &mlxsw_sp_port->periodic_hw_stats.stats, sizeof(*stats)); in mlxsw_sp_port_get_stats64()
902 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_vlan_set()
908 return -ENOMEM; in __mlxsw_sp_port_vlan_set()
910 mlxsw_reg_spvm_pack(spvm_pl, mlxsw_sp_port->local_port, vid_begin, in __mlxsw_sp_port_vlan_set()
912 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvm), spvm_pl); in __mlxsw_sp_port_vlan_set()
925 vid_e = min((u16) (vid + MLXSW_REG_SPVM_REC_MAX_COUNT - 1), in mlxsw_sp_port_vlan_set()
943 &mlxsw_sp_port->vlans_list, list) { in mlxsw_sp_port_vlan_flush()
945 mlxsw_sp_port_vlan->vid == MLXSW_SP_DEFAULT_VID) in mlxsw_sp_port_vlan_flush()
954 if (mlxsw_sp_port_vlan->bridge_port) in mlxsw_sp_port_vlan_cleanup()
956 else if (mlxsw_sp_port_vlan->fid) in mlxsw_sp_port_vlan_cleanup()
969 return ERR_PTR(-EEXIST); in mlxsw_sp_port_vlan_create()
977 err = -ENOMEM; in mlxsw_sp_port_vlan_create()
981 mlxsw_sp_port_vlan->mlxsw_sp_port = mlxsw_sp_port; in mlxsw_sp_port_vlan_create()
982 mlxsw_sp_port_vlan->vid = vid; in mlxsw_sp_port_vlan_create()
983 list_add(&mlxsw_sp_port_vlan->list, &mlxsw_sp_port->vlans_list); in mlxsw_sp_port_vlan_create()
994 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp_port_vlan->mlxsw_sp_port; in mlxsw_sp_port_vlan_destroy()
995 u16 vid = mlxsw_sp_port_vlan->vid; in mlxsw_sp_port_vlan_destroy()
998 list_del(&mlxsw_sp_port_vlan->list); in mlxsw_sp_port_vlan_destroy()
1040 switch (f->binder_type) { in mlxsw_sp_setup_tc_block()
1050 return -EOPNOTSUPP; in mlxsw_sp_setup_tc_block()
1073 return -EOPNOTSUPP; in mlxsw_sp_setup_tc()
1082 if (mlxsw_sp_flow_block_rule_count(mlxsw_sp_port->ing_flow_block) || in mlxsw_sp_feature_hw_tc()
1083 mlxsw_sp_flow_block_rule_count(mlxsw_sp_port->eg_flow_block)) { in mlxsw_sp_feature_hw_tc()
1085 return -EINVAL; in mlxsw_sp_feature_hw_tc()
1087 mlxsw_sp_flow_block_disable_inc(mlxsw_sp_port->ing_flow_block); in mlxsw_sp_feature_hw_tc()
1088 mlxsw_sp_flow_block_disable_inc(mlxsw_sp_port->eg_flow_block); in mlxsw_sp_feature_hw_tc()
1090 mlxsw_sp_flow_block_disable_dec(mlxsw_sp_port->ing_flow_block); in mlxsw_sp_feature_hw_tc()
1091 mlxsw_sp_flow_block_disable_dec(mlxsw_sp_port->eg_flow_block); in mlxsw_sp_feature_hw_tc()
1105 mlxsw_reg_pplr_pack(pplr_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_feature_loopback()
1106 err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr), in mlxsw_sp_feature_loopback()
1122 netdev_features_t changes = wanted_features ^ dev->features; in mlxsw_sp_handle_feature()
1137 dev->features |= feature; in mlxsw_sp_handle_feature()
1139 dev->features &= ~feature; in mlxsw_sp_handle_feature()
1146 netdev_features_t oper_features = dev->features; in mlxsw_sp_set_features()
1155 dev->features = oper_features; in mlxsw_sp_set_features()
1156 return -EINVAL; in mlxsw_sp_set_features()
1168 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in mlxsw_sp_port_hwtstamp_set()
1169 return -EFAULT; in mlxsw_sp_port_hwtstamp_set()
1171 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set()
1176 if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) in mlxsw_sp_port_hwtstamp_set()
1177 return -EFAULT; in mlxsw_sp_port_hwtstamp_set()
1188 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_get(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get()
1193 if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) in mlxsw_sp_port_hwtstamp_get()
1194 return -EFAULT; in mlxsw_sp_port_hwtstamp_get()
1203 mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, &config); in mlxsw_sp_port_ptp_clear()
1217 return -EOPNOTSUPP; in mlxsw_sp_port_ioctl()
1241 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_by_width_set()
1248 ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_by_width_set()
1253 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1255 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1259 ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, ð_proto_cap, in mlxsw_sp_port_speed_by_width_set()
1261 eth_proto_cap_masked = ops->ptys_proto_cap_masked_get(eth_proto_cap); in mlxsw_sp_port_speed_by_width_set()
1262 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
1264 mlxsw_sp_port->link.autoneg); in mlxsw_sp_port_speed_by_width_set()
1265 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_by_width_set()
1271 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_get()
1276 port_type_speed_ops = mlxsw_sp->port_type_speed_ops; in mlxsw_sp_port_speed_get()
1277 port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, in mlxsw_sp_port_speed_get()
1278 mlxsw_sp_port->local_port, 0, in mlxsw_sp_port_speed_get()
1280 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl); in mlxsw_sp_port_speed_get()
1283 port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL, in mlxsw_sp_port_speed_get()
1285 *speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper); in mlxsw_sp_port_speed_get()
1293 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_set()
1296 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_set()
1301 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_set()
1308 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_maxrate_set()
1311 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_maxrate_set()
1316 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_ets_maxrate_set()
1323 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_min_bw_set()
1326 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_min_bw_set()
1331 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl); in mlxsw_sp_port_min_bw_set()
1337 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_prio_tc_set()
1340 mlxsw_reg_qtct_pack(qtct_pl, mlxsw_sp_port->local_port, switch_prio, in mlxsw_sp_port_prio_tc_set()
1342 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtct), qtct_pl); in mlxsw_sp_port_prio_tc_set()
1434 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_tc_mc_mode_set()
1437 mlxsw_reg_qtctm_pack(qtctm_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_tc_mc_mode_set()
1438 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qtctm), qtctm_pl); in mlxsw_sp_port_tc_mc_mode_set()
1443 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_overheat_init_val_set()
1444 u8 slot_index = mlxsw_sp_port->mapping.slot_index; in mlxsw_sp_port_overheat_init_val_set()
1445 u8 module = mlxsw_sp_port->mapping.module; in mlxsw_sp_port_overheat_init_val_set()
1449 err = mlxsw_env_module_overheat_counter_get(mlxsw_sp->core, slot_index, in mlxsw_sp_port_overheat_init_val_set()
1454 mlxsw_sp_port->module_overheat_initial_val = overheat_counter; in mlxsw_sp_port_overheat_init_val_set()
1463 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_classification_set()
1466 mlxsw_reg_spvc_pack(spvc_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_vlan_classification_set()
1468 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvc), spvc_pl); in mlxsw_sp_port_vlan_classification_set()
1480 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pllp), pllp_pl); in mlxsw_sp_port_label_info_get()
1494 u32 lanes = port_mapping->width; in mlxsw_sp_port_create()
1504 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to map module\n", in mlxsw_sp_port_create()
1511 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", in mlxsw_sp_port_create()
1519 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get port label information\n", in mlxsw_sp_port_create()
1525 err = mlxsw_core_port_init(mlxsw_sp->core, local_port, slot_index, in mlxsw_sp_port_create()
1527 splittable, lanes, mlxsw_sp->base_mac, in mlxsw_sp_port_create()
1528 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_port_create()
1530 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n", in mlxsw_sp_port_create()
1537 err = -ENOMEM; in mlxsw_sp_port_create()
1540 SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); in mlxsw_sp_port_create()
1543 mlxsw_core_port_netdev_link(mlxsw_sp->core, local_port, in mlxsw_sp_port_create()
1545 mlxsw_sp_port->dev = dev; in mlxsw_sp_port_create()
1546 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1547 mlxsw_sp_port->local_port = local_port; in mlxsw_sp_port_create()
1548 mlxsw_sp_port->pvid = MLXSW_SP_DEFAULT_VID; in mlxsw_sp_port_create()
1549 mlxsw_sp_port->split = split; in mlxsw_sp_port_create()
1550 mlxsw_sp_port->mapping = *port_mapping; in mlxsw_sp_port_create()
1551 mlxsw_sp_port->link.autoneg = 1; in mlxsw_sp_port_create()
1552 INIT_LIST_HEAD(&mlxsw_sp_port->vlans_list); in mlxsw_sp_port_create()
1554 mlxsw_sp_port->pcpu_stats = in mlxsw_sp_port_create()
1556 if (!mlxsw_sp_port->pcpu_stats) { in mlxsw_sp_port_create()
1557 err = -ENOMEM; in mlxsw_sp_port_create()
1561 INIT_DELAYED_WORK(&mlxsw_sp_port->periodic_hw_stats.update_dw, in mlxsw_sp_port_create()
1564 dev->netdev_ops = &mlxsw_sp_port_netdev_ops; in mlxsw_sp_port_create()
1565 dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; in mlxsw_sp_port_create()
1569 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Unable to init port mac address\n", in mlxsw_sp_port_create()
1570 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1576 dev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_FILTER | in mlxsw_sp_port_create()
1578 dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK; in mlxsw_sp_port_create()
1579 dev->lltx = true; in mlxsw_sp_port_create()
1580 dev->netns_local = true; in mlxsw_sp_port_create()
1582 dev->min_mtu = ETH_MIN_MTU; in mlxsw_sp_port_create()
1583 dev->max_mtu = MLXSW_PORT_MAX_MTU - MLXSW_PORT_ETH_FRAME_HDR; in mlxsw_sp_port_create()
1588 dev->needed_headroom = MLXSW_TXHDR_LEN; in mlxsw_sp_port_create()
1592 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set system port mapping\n", in mlxsw_sp_port_create()
1593 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1599 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to enable speeds\n", in mlxsw_sp_port_create()
1600 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1604 err = mlxsw_sp->port_type_speed_ops->ptys_max_speed(mlxsw_sp_port, in mlxsw_sp_port_create()
1605 &mlxsw_sp_port->max_speed); in mlxsw_sp_port_create()
1607 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to get maximum speed\n", in mlxsw_sp_port_create()
1608 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1614 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set MTU\n", in mlxsw_sp_port_create()
1615 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1625 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize buffers\n", in mlxsw_sp_port_create()
1626 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1632 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize ETS\n", in mlxsw_sp_port_create()
1633 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1639 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC MC mode\n", in mlxsw_sp_port_create()
1640 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1647 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize DCB\n", in mlxsw_sp_port_create()
1648 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1654 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize FIDs\n", in mlxsw_sp_port_create()
1655 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1661 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC qdiscs\n", in mlxsw_sp_port_create()
1662 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1666 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 0, VLAN_N_VID - 1, false, in mlxsw_sp_port_create()
1669 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to clear VLAN filter\n", in mlxsw_sp_port_create()
1670 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1676 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize NVE\n", in mlxsw_sp_port_create()
1677 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1684 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set PVID\n", in mlxsw_sp_port_create()
1685 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1692 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n", in mlxsw_sp_port_create()
1693 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1697 mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan; in mlxsw_sp_port_create()
1704 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set default VLAN classification\n", in mlxsw_sp_port_create()
1709 INIT_DELAYED_WORK(&mlxsw_sp_port->ptp.shaper_dw, in mlxsw_sp_port_create()
1710 mlxsw_sp->ptp_ops->shaper_work); in mlxsw_sp_port_create()
1712 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1716 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set overheat initial value\n", in mlxsw_sp_port_create()
1717 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1723 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to register netdev\n", in mlxsw_sp_port_create()
1724 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1728 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0); in mlxsw_sp_port_create()
1735 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_create()
1759 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_create()
1763 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_create()
1770 port_mapping->slot_index, in mlxsw_sp_port_create()
1771 port_mapping->module); in mlxsw_sp_port_create()
1777 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove()
1778 u8 slot_index = mlxsw_sp_port->mapping.slot_index; in mlxsw_sp_port_remove()
1779 u8 module = mlxsw_sp_port->mapping.module; in mlxsw_sp_port_remove()
1781 cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw); in mlxsw_sp_port_remove()
1782 cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw); in mlxsw_sp_port_remove()
1783 unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ in mlxsw_sp_port_remove()
1786 mlxsw_sp->ports[local_port] = NULL; in mlxsw_sp_port_remove()
1794 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_remove()
1795 WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); in mlxsw_sp_port_remove()
1796 free_netdev(mlxsw_sp_port->dev); in mlxsw_sp_port_remove()
1797 mlxsw_core_port_fini(mlxsw_sp->core, local_port); in mlxsw_sp_port_remove()
1810 return -ENOMEM; in mlxsw_sp_cpu_port_create()
1812 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_cpu_port_create()
1813 mlxsw_sp_port->local_port = MLXSW_PORT_CPU_PORT; in mlxsw_sp_cpu_port_create()
1815 err = mlxsw_core_cpu_port_init(mlxsw_sp->core, in mlxsw_sp_cpu_port_create()
1817 mlxsw_sp->base_mac, in mlxsw_sp_cpu_port_create()
1818 sizeof(mlxsw_sp->base_mac)); in mlxsw_sp_cpu_port_create()
1820 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize core CPU port\n"); in mlxsw_sp_cpu_port_create()
1824 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = mlxsw_sp_port; in mlxsw_sp_cpu_port_create()
1835 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp_cpu_port_remove()
1837 mlxsw_core_cpu_port_fini(mlxsw_sp->core); in mlxsw_sp_cpu_port_remove()
1838 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = NULL; in mlxsw_sp_cpu_port_remove()
1851 return mlxsw_sp->ports[local_port] != NULL; in mlxsw_sp_port_created()
1862 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmecr), pmecr_pl); in mlxsw_sp_port_mapping_event_set()
1883 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_port_mapping_events_work()
1885 spin_lock_bh(&events->queue_lock); in mlxsw_sp_port_mapping_events_work()
1886 list_splice_init(&events->queue, &event_queue); in mlxsw_sp_port_mapping_events_work()
1887 spin_unlock_bh(&events->queue_lock); in mlxsw_sp_port_mapping_events_work()
1890 local_port = mlxsw_reg_pmlp_local_port_get(event->pmlp_pl); in mlxsw_sp_port_mapping_events_work()
1892 event->pmlp_pl, &port_mapping); in mlxsw_sp_port_mapping_events_work()
1909 mlxsw_sp->port_mapping[local_port] = port_mapping; in mlxsw_sp_port_mapping_events_work()
1929 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_port_mapping_listener_func()
1933 memcpy(event->pmlp_pl, pmlp_pl, sizeof(event->pmlp_pl)); in mlxsw_sp_port_mapping_listener_func()
1934 spin_lock(&events->queue_lock); in mlxsw_sp_port_mapping_listener_func()
1935 list_add_tail(&event->list, &events->queue); in mlxsw_sp_port_mapping_listener_func()
1936 spin_unlock(&events->queue_lock); in mlxsw_sp_port_mapping_listener_func()
1937 mlxsw_core_schedule_work(&events->work); in mlxsw_sp_port_mapping_listener_func()
1946 events = &mlxsw_sp->port_mapping_events; in __mlxsw_sp_port_mapping_events_cancel()
1949 cancel_work_sync(&events->work); in __mlxsw_sp_port_mapping_events_cancel()
1950 list_for_each_entry_safe(event, next_event, &events->queue, list) { in __mlxsw_sp_port_mapping_events_cancel()
1951 list_del(&event->list); in __mlxsw_sp_port_mapping_events_cancel()
1958 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_remove()
1970 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_remove()
1971 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_remove()
1990 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_ports_create()
1998 mlxsw_sp->ports = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_ports_create()
1999 if (!mlxsw_sp->ports) in mlxsw_sp_ports_create()
2000 return -ENOMEM; in mlxsw_sp_ports_create()
2002 events = &mlxsw_sp->port_mapping_events; in mlxsw_sp_ports_create()
2003 INIT_LIST_HEAD(&events->queue); in mlxsw_sp_ports_create()
2004 spin_lock_init(&events->queue_lock); in mlxsw_sp_ports_create()
2005 INIT_WORK(&events->work, mlxsw_sp_port_mapping_events_work); in mlxsw_sp_ports_create()
2018 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_ports_create()
2019 if (!port_mapping->width) in mlxsw_sp_ports_create()
2028 for (i--; i >= 1; i--) in mlxsw_sp_ports_create()
2035 for (i--; i >= 1; i--) in mlxsw_sp_ports_create()
2039 kfree(mlxsw_sp->ports); in mlxsw_sp_ports_create()
2040 mlxsw_sp->ports = NULL; in mlxsw_sp_ports_create()
2046 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); in mlxsw_sp_port_module_info_init()
2051 mlxsw_sp->port_mapping = kcalloc(max_ports, in mlxsw_sp_port_module_info_init()
2054 if (!mlxsw_sp->port_mapping) in mlxsw_sp_port_module_info_init()
2055 return -ENOMEM; in mlxsw_sp_port_module_info_init()
2058 port_mapping = &mlxsw_sp->port_mapping[i]; in mlxsw_sp_port_module_info_init()
2066 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_init()
2072 kfree(mlxsw_sp->port_mapping); in mlxsw_sp_port_module_info_fini()
2101 for (i--; i >= 0; i--) { in mlxsw_sp_port_split_create()
2121 port_mapping = &mlxsw_sp->port_mapping[local_port]; in mlxsw_sp_port_unsplit_create()
2122 if (!port_mapping->width || !mlxsw_sp_local_port_valid(local_port)) in mlxsw_sp_port_unsplit_create()
2132 if (mlxsw_sp->ports && mlxsw_sp->ports[local_port]) in mlxsw_sp_port_get_by_local_port()
2133 return mlxsw_sp->ports[local_port]; in mlxsw_sp_port_get_by_local_port()
2151 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_split()
2154 return -EINVAL; in mlxsw_sp_port_split()
2157 if (mlxsw_sp_port->split) { in mlxsw_sp_port_split()
2159 return -EINVAL; in mlxsw_sp_port_split()
2162 mlxsw_reg_pmtdb_pack(pmtdb_pl, mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_split()
2163 mlxsw_sp_port->mapping.module, in mlxsw_sp_port_split()
2164 mlxsw_sp_port->mapping.module_width / count, in mlxsw_sp_port_split()
2175 return -EINVAL; in mlxsw_sp_port_split()
2178 port_mapping = mlxsw_sp_port->mapping; in mlxsw_sp_port_split()
2190 dev_err(mlxsw_sp->bus_info->dev, "Failed to create split ports\n"); in mlxsw_sp_port_split()
2214 dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not exist\n", in mlxsw_sp_port_unsplit()
2217 return -EINVAL; in mlxsw_sp_port_unsplit()
2220 if (!mlxsw_sp_port->split) { in mlxsw_sp_port_unsplit()
2222 return -EINVAL; in mlxsw_sp_port_unsplit()
2225 count = mlxsw_sp_port->mapping.module_width / in mlxsw_sp_port_unsplit()
2226 mlxsw_sp_port->mapping.width; in mlxsw_sp_port_unsplit()
2228 mlxsw_reg_pmtdb_pack(pmtdb_pl, mlxsw_sp_port->mapping.slot_index, in mlxsw_sp_port_unsplit()
2229 mlxsw_sp_port->mapping.module, in mlxsw_sp_port_unsplit()
2230 mlxsw_sp_port->mapping.module_width / count, in mlxsw_sp_port_unsplit()
2256 mlxsw_sp_port->periodic_hw_stats.xstats.backlog[i] = 0; in mlxsw_sp_port_down_wipe_counters()
2271 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
2277 netdev_info(mlxsw_sp_port->dev, "link up\n"); in mlxsw_sp_pude_event_func()
2278 netif_carrier_on(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
2279 mlxsw_core_schedule_dw(&mlxsw_sp_port->ptp.shaper_dw, 0); in mlxsw_sp_pude_event_func()
2281 netdev_info(mlxsw_sp_port->dev, "link down\n"); in mlxsw_sp_pude_event_func()
2282 netif_carrier_off(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
2331 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_no_mark_func()
2335 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()
2340 skb->dev = mlxsw_sp_port->dev; in mlxsw_sp_rx_listener_no_mark_func()
2342 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_rx_listener_no_mark_func()
2343 u64_stats_update_begin(&pcpu_stats->syncp); in mlxsw_sp_rx_listener_no_mark_func()
2344 pcpu_stats->rx_packets++; in mlxsw_sp_rx_listener_no_mark_func()
2345 pcpu_stats->rx_bytes += skb->len; in mlxsw_sp_rx_listener_no_mark_func()
2346 u64_stats_update_end(&pcpu_stats->syncp); in mlxsw_sp_rx_listener_no_mark_func()
2348 skb->protocol = eth_type_trans(skb, skb->dev); in mlxsw_sp_rx_listener_no_mark_func()
2349 napi_gro_receive(mlxsw_skb_cb(skb)->rx_md_info.napi, skb); in mlxsw_sp_rx_listener_no_mark_func()
2355 skb->offload_fwd_mark = 1; in mlxsw_sp_rx_listener_mark_func()
2362 skb->offload_l3_fwd_mark = 1; in mlxsw_sp_rx_listener_l3_mark_func()
2363 skb->offload_fwd_mark = 1; in mlxsw_sp_rx_listener_l3_mark_func()
2370 mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_receive()
2437 return -EIO; in mlxsw_sp_cpu_policers_set()
2455 __set_bit(i, mlxsw_sp->trap->policers_usage); in mlxsw_sp_cpu_policers_set()
2477 return -EIO; in mlxsw_sp_trap_groups_set()
2502 return -EIO; in mlxsw_sp_trap_groups_set()
2519 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_CPU_POLICERS)) in mlxsw_sp_traps_init()
2520 return -EIO; in mlxsw_sp_traps_init()
2521 max_policers = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_CPU_POLICERS); in mlxsw_sp_traps_init()
2525 return -ENOMEM; in mlxsw_sp_traps_init()
2526 trap->max_policers = max_policers; in mlxsw_sp_traps_init()
2527 mlxsw_sp->trap = trap; in mlxsw_sp_traps_init()
2529 err = mlxsw_sp_cpu_policers_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2533 err = mlxsw_sp_trap_groups_set(mlxsw_sp->core); in mlxsw_sp_traps_init()
2537 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2543 err = mlxsw_core_traps_register(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_init()
2544 mlxsw_sp->listeners_count, mlxsw_sp); in mlxsw_sp_traps_init()
2551 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_init()
2563 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp->listeners, in mlxsw_sp_traps_fini()
2564 mlxsw_sp->listeners_count, in mlxsw_sp_traps_fini()
2566 mlxsw_core_traps_unregister(mlxsw_sp->core, mlxsw_sp_listener, in mlxsw_sp_traps_fini()
2568 kfree(mlxsw_sp->trap); in mlxsw_sp_traps_fini()
2576 if (mlxsw_core_lag_mode(mlxsw_sp->core) != in mlxsw_sp_lag_pgt_init()
2581 * entries. The LAG table address needs to be 8-aligned, but that ought in mlxsw_sp_lag_pgt_init()
2584 err = mlxsw_sp_pgt_mid_alloc_range(mlxsw_sp, &mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_init()
2585 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_init()
2588 if (WARN_ON_ONCE(mlxsw_sp->lag_pgt_base % 8)) { in mlxsw_sp_lag_pgt_init()
2589 err = -EINVAL; in mlxsw_sp_lag_pgt_init()
2593 mlxsw_reg_sgcr_pack(sgcr_pl, mlxsw_sp->lag_pgt_base); in mlxsw_sp_lag_pgt_init()
2594 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sgcr), sgcr_pl); in mlxsw_sp_lag_pgt_init()
2601 mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_init()
2602 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_init()
2608 if (mlxsw_core_lag_mode(mlxsw_sp->core) != in mlxsw_sp_lag_pgt_fini()
2612 mlxsw_sp_pgt_mid_free_range(mlxsw_sp, mlxsw_sp->lag_pgt_base, in mlxsw_sp_lag_pgt_fini()
2613 mlxsw_sp->max_lag * 8); in mlxsw_sp_lag_pgt_fini()
2630 seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), in mlxsw_sp_lag_init()
2641 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcr), slcr_pl); in mlxsw_sp_lag_init()
2645 err = mlxsw_core_max_lag(mlxsw_sp->core, &mlxsw_sp->max_lag); in mlxsw_sp_lag_init()
2649 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS)) in mlxsw_sp_lag_init()
2650 return -EIO; in mlxsw_sp_lag_init()
2656 mlxsw_sp->lags = kcalloc(mlxsw_sp->max_lag, sizeof(struct mlxsw_sp_lag), in mlxsw_sp_lag_init()
2658 if (!mlxsw_sp->lags) { in mlxsw_sp_lag_init()
2659 err = -ENOMEM; in mlxsw_sp_lag_init()
2673 kfree(mlxsw_sp->lags); in mlxsw_sp_lag_fini()
2751 key->type = trigger->type; in mlxsw_sp_sample_trigger_key_init()
2752 key->local_port = trigger->local_port; in mlxsw_sp_sample_trigger_key_init()
2764 trigger_node = rhashtable_lookup(&mlxsw_sp->sample_trigger_ht, &key, in mlxsw_sp_sample_trigger_params_lookup()
2769 return &trigger_node->params; in mlxsw_sp_sample_trigger_params_lookup()
2782 return -ENOMEM; in mlxsw_sp_sample_trigger_node_init()
2784 trigger_node->trigger = *trigger; in mlxsw_sp_sample_trigger_node_init()
2785 trigger_node->params = *params; in mlxsw_sp_sample_trigger_node_init()
2786 refcount_set(&trigger_node->refcount, 1); in mlxsw_sp_sample_trigger_node_init()
2788 err = rhashtable_insert_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_init()
2789 &trigger_node->ht_node, in mlxsw_sp_sample_trigger_node_init()
2805 rhashtable_remove_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_node_fini()
2806 &trigger_node->ht_node, in mlxsw_sp_sample_trigger_node_fini()
2824 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_set()
2831 if (trigger_node->trigger.local_port) { in mlxsw_sp_sample_trigger_params_set()
2833 return -EINVAL; in mlxsw_sp_sample_trigger_params_set()
2836 if (trigger_node->params.psample_group != params->psample_group || in mlxsw_sp_sample_trigger_params_set()
2837 trigger_node->params.truncate != params->truncate || in mlxsw_sp_sample_trigger_params_set()
2838 trigger_node->params.rate != params->rate || in mlxsw_sp_sample_trigger_params_set()
2839 trigger_node->params.trunc_size != params->trunc_size) { in mlxsw_sp_sample_trigger_params_set()
2841 return -EINVAL; in mlxsw_sp_sample_trigger_params_set()
2844 refcount_inc(&trigger_node->refcount); in mlxsw_sp_sample_trigger_params_set()
2860 trigger_node = rhashtable_lookup_fast(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_sample_trigger_params_unset()
2866 if (!refcount_dec_and_test(&trigger_node->refcount)) in mlxsw_sp_sample_trigger_params_unset()
2881 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 0); in mlxsw_sp_parsing_init()
2882 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_init()
2883 mlxsw_sp->parsing.vxlan_udp_dport = MLXSW_SP_DEFAULT_VXLAN_UDP_DPORT; in mlxsw_sp_parsing_init()
2884 mutex_init(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_init()
2889 mutex_destroy(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_fini()
2890 WARN_ON_ONCE(refcount_read(&mlxsw_sp->parsing.parsing_depth_ref)); in mlxsw_sp_parsing_fini()
2922 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rips), rips_pl); in mlxsw_sp_ipv6_addr_init()
2928 err = -ENOMEM; in mlxsw_sp_ipv6_addr_init()
2932 node->key = *addr6; in mlxsw_sp_ipv6_addr_init()
2933 node->kvdl_index = *p_kvdl_index; in mlxsw_sp_ipv6_addr_init()
2934 refcount_set(&node->refcount, 1); in mlxsw_sp_ipv6_addr_init()
2936 err = rhashtable_insert_fast(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_init()
2937 &node->ht_node, in mlxsw_sp_ipv6_addr_init()
2956 u32 kvdl_index = node->kvdl_index; in mlxsw_sp_ipv6_addr_fini()
2958 rhashtable_remove_fast(&mlxsw_sp->ipv6_addr_ht, &node->ht_node, in mlxsw_sp_ipv6_addr_fini()
2972 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
2973 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_kvdl_index_get()
2976 refcount_inc(&node->refcount); in mlxsw_sp_ipv6_addr_kvdl_index_get()
2977 *p_kvdl_index = node->kvdl_index; in mlxsw_sp_ipv6_addr_kvdl_index_get()
2984 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_kvdl_index_get()
2993 mutex_lock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
2994 node = rhashtable_lookup_fast(&mlxsw_sp->ipv6_addr_ht, addr6, in mlxsw_sp_ipv6_addr_put()
2999 if (!refcount_dec_and_test(&node->refcount)) in mlxsw_sp_ipv6_addr_put()
3005 mutex_unlock(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_put()
3012 err = rhashtable_init(&mlxsw_sp->ipv6_addr_ht, in mlxsw_sp_ipv6_addr_ht_init()
3017 mutex_init(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_init()
3023 mutex_destroy(&mlxsw_sp->ipv6_addr_ht_lock); in mlxsw_sp_ipv6_addr_ht_fini()
3024 rhashtable_destroy(&mlxsw_sp->ipv6_addr_ht); in mlxsw_sp_ipv6_addr_ht_fini()
3034 mlxsw_sp->core = mlxsw_core; in mlxsw_sp_init()
3035 mlxsw_sp->bus_info = mlxsw_bus_info; in mlxsw_sp_init()
3041 dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); in mlxsw_sp_init()
3047 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize KVDL\n"); in mlxsw_sp_init()
3053 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PGT\n"); in mlxsw_sp_init()
3058 * and 8-aligned without overallocation. in mlxsw_sp_init()
3062 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize LAG\n"); in mlxsw_sp_init()
3066 err = mlxsw_sp->fid_core_ops->init(mlxsw_sp); in mlxsw_sp_init()
3068 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize FIDs\n"); in mlxsw_sp_init()
3074 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize policers\n"); in mlxsw_sp_init()
3080 dev_err(mlxsw_sp->bus_info->dev, "Failed to set traps\n"); in mlxsw_sp_init()
3086 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize devlink traps\n"); in mlxsw_sp_init()
3092 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize buffers\n"); in mlxsw_sp_init()
3101 dev_err(mlxsw_sp->bus_info->dev, "Failed to init span system\n"); in mlxsw_sp_init()
3107 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); in mlxsw_sp_init()
3113 dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter pool\n"); in mlxsw_sp_init()
3119 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL actions\n"); in mlxsw_sp_init()
3125 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize hash table for IPv6 addresses\n"); in mlxsw_sp_init()
3131 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize NVE\n"); in mlxsw_sp_init()
3137 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize port ranges\n"); in mlxsw_sp_init()
3143 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize ACL\n"); in mlxsw_sp_init()
3149 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize router\n"); in mlxsw_sp_init()
3153 if (mlxsw_sp->bus_info->read_clock_capable) { in mlxsw_sp_init()
3155 mlxsw_sp->clock = in mlxsw_sp_init()
3156 mlxsw_sp->ptp_ops->clock_init(mlxsw_sp, in mlxsw_sp_init()
3157 mlxsw_sp->bus_info->dev); in mlxsw_sp_init()
3158 if (IS_ERR(mlxsw_sp->clock)) { in mlxsw_sp_init()
3159 err = PTR_ERR(mlxsw_sp->clock); in mlxsw_sp_init()
3160 dev_err(mlxsw_sp->bus_info->dev, "Failed to init ptp clock\n"); in mlxsw_sp_init()
3165 if (mlxsw_sp->clock) { in mlxsw_sp_init()
3166 /* NULL is a valid return value from ptp_ops->init */ in mlxsw_sp_init()
3167 mlxsw_sp->ptp_state = mlxsw_sp->ptp_ops->init(mlxsw_sp); in mlxsw_sp_init()
3168 if (IS_ERR(mlxsw_sp->ptp_state)) { in mlxsw_sp_init()
3169 err = PTR_ERR(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3170 dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize PTP\n"); in mlxsw_sp_init()
3178 mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event; in mlxsw_sp_init()
3180 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3182 dev_err(mlxsw_sp->bus_info->dev, "Failed to register netdev notifier\n"); in mlxsw_sp_init()
3188 dev_err(mlxsw_sp->bus_info->dev, "Failed to init pipeline debug\n"); in mlxsw_sp_init()
3194 dev_err(mlxsw_sp->bus_info->dev, "Failed to init port module info\n"); in mlxsw_sp_init()
3198 err = rhashtable_init(&mlxsw_sp->sample_trigger_ht, in mlxsw_sp_init()
3201 dev_err(mlxsw_sp->bus_info->dev, "Failed to init sampling trigger hashtable\n"); in mlxsw_sp_init()
3207 dev_err(mlxsw_sp->bus_info->dev, "Failed to create ports\n"); in mlxsw_sp_init()
3214 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_init()
3221 &mlxsw_sp->netdevice_nb); in mlxsw_sp_init()
3223 if (mlxsw_sp->clock) in mlxsw_sp_init()
3224 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_init()
3226 if (mlxsw_sp->clock) in mlxsw_sp_init()
3227 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_init()
3255 mlxsw_sp->fid_core_ops->fini(mlxsw_sp); in mlxsw_sp_init()
3272 mlxsw_sp->switchdev_ops = &mlxsw_sp1_switchdev_ops; in mlxsw_sp1_init()
3273 mlxsw_sp->kvdl_ops = &mlxsw_sp1_kvdl_ops; in mlxsw_sp1_init()
3274 mlxsw_sp->afa_ops = &mlxsw_sp1_act_afa_ops; in mlxsw_sp1_init()
3275 mlxsw_sp->afk_ops = &mlxsw_sp1_afk_ops; in mlxsw_sp1_init()
3276 mlxsw_sp->mr_tcam_ops = &mlxsw_sp1_mr_tcam_ops; in mlxsw_sp1_init()
3277 mlxsw_sp->acl_rulei_ops = &mlxsw_sp1_acl_rulei_ops; in mlxsw_sp1_init()
3278 mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops; in mlxsw_sp1_init()
3279 mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr; in mlxsw_sp1_init()
3280 mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask; in mlxsw_sp1_init()
3281 mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals; in mlxsw_sp1_init()
3282 mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops; in mlxsw_sp1_init()
3283 mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops; in mlxsw_sp1_init()
3284 mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops; in mlxsw_sp1_init()
3285 mlxsw_sp->span_ops = &mlxsw_sp1_span_ops; in mlxsw_sp1_init()
3286 mlxsw_sp->policer_core_ops = &mlxsw_sp1_policer_core_ops; in mlxsw_sp1_init()
3287 mlxsw_sp->trap_ops = &mlxsw_sp1_trap_ops; in mlxsw_sp1_init()
3288 mlxsw_sp->mall_ops = &mlxsw_sp1_mall_ops; in mlxsw_sp1_init()
3289 mlxsw_sp->router_ops = &mlxsw_sp1_router_ops; in mlxsw_sp1_init()
3290 mlxsw_sp->listeners = mlxsw_sp1_listener; in mlxsw_sp1_init()
3291 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener); in mlxsw_sp1_init()
3292 mlxsw_sp->fid_core_ops = &mlxsw_sp1_fid_core_ops; in mlxsw_sp1_init()
3293 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1; in mlxsw_sp1_init()
3294 mlxsw_sp->pgt_smpe_index_valid = true; in mlxsw_sp1_init()
3305 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp2_init()
3306 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp2_init()
3307 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp2_init()
3308 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp2_init()
3309 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp2_init()
3310 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp2_init()
3311 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp2_init()
3312 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp2_init()
3313 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp2_init()
3314 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp2_init()
3315 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp2_init()
3316 mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops; in mlxsw_sp2_init()
3317 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp2_init()
3318 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp2_init()
3319 mlxsw_sp->span_ops = &mlxsw_sp2_span_ops; in mlxsw_sp2_init()
3320 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp2_init()
3321 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp2_init()
3322 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp2_init()
3323 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp2_init()
3324 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp2_init()
3325 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp2_init()
3326 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp2_init()
3327 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2; in mlxsw_sp2_init()
3328 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp2_init()
3339 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp3_init()
3340 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp3_init()
3341 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp3_init()
3342 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; in mlxsw_sp3_init()
3343 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp3_init()
3344 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp3_init()
3345 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp3_init()
3346 mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; in mlxsw_sp3_init()
3347 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp3_init()
3348 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp3_init()
3349 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp3_init()
3350 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp3_init()
3351 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp3_init()
3352 mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; in mlxsw_sp3_init()
3353 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp3_init()
3354 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp3_init()
3355 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp3_init()
3356 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp3_init()
3357 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp3_init()
3358 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp3_init()
3359 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp3_init()
3360 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp3_init()
3361 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; in mlxsw_sp3_init()
3362 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp3_init()
3373 mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; in mlxsw_sp4_init()
3374 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; in mlxsw_sp4_init()
3375 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; in mlxsw_sp4_init()
3376 mlxsw_sp->afk_ops = &mlxsw_sp4_afk_ops; in mlxsw_sp4_init()
3377 mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; in mlxsw_sp4_init()
3378 mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; in mlxsw_sp4_init()
3379 mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; in mlxsw_sp4_init()
3380 mlxsw_sp->acl_bf_ops = &mlxsw_sp4_acl_bf_ops; in mlxsw_sp4_init()
3381 mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; in mlxsw_sp4_init()
3382 mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; in mlxsw_sp4_init()
3383 mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; in mlxsw_sp4_init()
3384 mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; in mlxsw_sp4_init()
3385 mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; in mlxsw_sp4_init()
3386 mlxsw_sp->ptp_ops = &mlxsw_sp4_ptp_ops; in mlxsw_sp4_init()
3387 mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; in mlxsw_sp4_init()
3388 mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; in mlxsw_sp4_init()
3389 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; in mlxsw_sp4_init()
3390 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; in mlxsw_sp4_init()
3391 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; in mlxsw_sp4_init()
3392 mlxsw_sp->listeners = mlxsw_sp2_listener; in mlxsw_sp4_init()
3393 mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp2_listener); in mlxsw_sp4_init()
3394 mlxsw_sp->fid_core_ops = &mlxsw_sp2_fid_core_ops; in mlxsw_sp4_init()
3395 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4; in mlxsw_sp4_init()
3396 mlxsw_sp->pgt_smpe_index_valid = false; in mlxsw_sp4_init()
3406 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); in mlxsw_sp_fini()
3410 &mlxsw_sp->netdevice_nb); in mlxsw_sp_fini()
3411 if (mlxsw_sp->clock) { in mlxsw_sp_fini()
3412 mlxsw_sp->ptp_ops->fini(mlxsw_sp->ptp_state); in mlxsw_sp_fini()
3413 mlxsw_sp->ptp_ops->clock_fini(mlxsw_sp->clock); in mlxsw_sp_fini()
3428 mlxsw_sp->fid_core_ops->fini(mlxsw_sp); in mlxsw_sp_fini()
3478 * in Spectrum-2/3, to avoid regression in number of free entries in the PGT
3524 kvd_size - single_size_min - in mlxsw_sp_resource_size_params_prepare()
3530 kvd_size - single_size_min - in mlxsw_sp_resource_size_params_prepare()
3536 kvd_size - double_size_min - in mlxsw_sp_resource_size_params_prepare()
3555 return -EIO; in mlxsw_sp1_resources_kvd_register()
3570 linear_size = profile->kvd_linear_size; in mlxsw_sp1_resources_kvd_register()
3583 double_size = kvd_size - linear_size; in mlxsw_sp1_resources_kvd_register()
3584 double_size *= profile->kvd_hash_double_parts; in mlxsw_sp1_resources_kvd_register()
3585 double_size /= profile->kvd_hash_double_parts + in mlxsw_sp1_resources_kvd_register()
3586 profile->kvd_hash_single_parts; in mlxsw_sp1_resources_kvd_register()
3596 single_size = kvd_size - double_size - linear_size; in mlxsw_sp1_resources_kvd_register()
3615 return -EIO; in mlxsw_sp2_resources_kvd_register()
3635 return -EIO; in mlxsw_sp_resources_span_register()
3678 return -EIO; in mlxsw_sp_resources_rifs_register()
3698 return -EIO; in mlxsw_sp_resources_port_range_register()
3809 return -EIO; in mlxsw_sp_kvd_sizes_get()
3822 *p_linear_size = profile->kvd_linear_size; in mlxsw_sp_kvd_sizes_get()
3828 double_size = MLXSW_CORE_RES_GET(mlxsw_core, KVD_SIZE) - in mlxsw_sp_kvd_sizes_get()
3830 double_size *= profile->kvd_hash_double_parts; in mlxsw_sp_kvd_sizes_get()
3831 double_size /= profile->kvd_hash_double_parts + in mlxsw_sp_kvd_sizes_get()
3832 profile->kvd_hash_single_parts; in mlxsw_sp_kvd_sizes_get()
3841 *p_single_size = MLXSW_CORE_RES_GET(mlxsw_core, KVD_SIZE) - in mlxsw_sp_kvd_sizes_get()
3842 *p_double_size - *p_linear_size; in mlxsw_sp_kvd_sizes_get()
3848 return -EIO; in mlxsw_sp_kvd_sizes_get()
3859 mlxsw_sp->ptp_ops->transmitted(mlxsw_sp, skb, local_port); in mlxsw_sp_ptp_transmitted()
4002 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; in mlxsw_sp_port_dev_check()
4011 priv->data = (void *)netdev_priv(lower_dev); in mlxsw_sp_lower_dev_walk()
4037 return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp : NULL; in mlxsw_sp_lower_get()
4060 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4062 if (refcount_inc_not_zero(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_inc()
4066 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_inc()
4067 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_inc()
4071 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_INCREASED_PARSING_DEPTH; in mlxsw_sp_parsing_depth_inc()
4072 refcount_set(&mlxsw_sp->parsing.parsing_depth_ref, 1); in mlxsw_sp_parsing_depth_inc()
4075 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_inc()
4083 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4085 if (!refcount_dec_and_test(&mlxsw_sp->parsing.parsing_depth_ref)) in mlxsw_sp_parsing_depth_dec()
4089 mlxsw_sp->parsing.vxlan_udp_dport); in mlxsw_sp_parsing_depth_dec()
4090 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_depth_dec()
4091 mlxsw_sp->parsing.parsing_depth = MLXSW_SP_DEFAULT_PARSING_DEPTH; in mlxsw_sp_parsing_depth_dec()
4094 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_depth_dec()
4103 mutex_lock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4105 mlxsw_reg_mprs_pack(mprs_pl, mlxsw_sp->parsing.parsing_depth, in mlxsw_sp_parsing_vxlan_udp_dport_set()
4107 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mprs), mprs_pl); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4111 mlxsw_sp->parsing.vxlan_udp_dport = be16_to_cpu(udp_dport); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4114 mutex_unlock(&mlxsw_sp->parsing.lock); in mlxsw_sp_parsing_vxlan_udp_dport_set()
4146 for (i = 0; i < mlxsw_sp->max_lag; i++) { in mlxsw_sp_lag_create()
4147 if (!mlxsw_sp->lags[i].dev) in mlxsw_sp_lag_create()
4151 if (i == mlxsw_sp->max_lag) { in mlxsw_sp_lag_create()
4154 return ERR_PTR(-EBUSY); in mlxsw_sp_lag_create()
4159 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_create()
4163 lag = &mlxsw_sp->lags[lag_id]; in mlxsw_sp_lag_create()
4164 lag->lag_id = lag_id; in mlxsw_sp_lag_create()
4165 lag->dev = lag_dev; in mlxsw_sp_lag_create()
4166 refcount_set(&lag->ref_count, 1); in mlxsw_sp_lag_create()
4176 lag->dev = NULL; in mlxsw_sp_lag_destroy()
4178 mlxsw_reg_sldr_lag_destroy_pack(sldr_pl, lag->lag_id); in mlxsw_sp_lag_destroy()
4179 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_destroy()
4185 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_add()
4188 mlxsw_reg_slcor_port_add_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_add()
4190 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_add()
4196 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_remove()
4199 mlxsw_reg_slcor_port_remove_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_remove()
4201 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_remove()
4207 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_enable()
4210 mlxsw_reg_slcor_col_enable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_enable()
4212 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_enable()
4218 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_disable()
4221 mlxsw_reg_slcor_col_disable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_disable()
4223 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(slcor), slcor_pl); in mlxsw_sp_lag_col_port_disable()
4231 for (i = 0; i < mlxsw_sp->max_lag; i++) { in mlxsw_sp_lag_find()
4232 if (!mlxsw_sp->lags[i].dev) in mlxsw_sp_lag_find()
4235 if (mlxsw_sp->lags[i].dev == lag_dev) in mlxsw_sp_lag_find()
4236 return &mlxsw_sp->lags[i]; in mlxsw_sp_lag_find()
4250 refcount_inc(&lag->ref_count); in mlxsw_sp_lag_get()
4260 if (!refcount_dec_and_test(&lag->ref_count)) in mlxsw_sp_lag_put()
4272 if (lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { in mlxsw_sp_master_lag_check()
4285 max_lag_members = MLXSW_CORE_RES_GET(mlxsw_sp->core, in mlxsw_sp_port_lag_index_get()
4293 return -EBUSY; in mlxsw_sp_port_lag_index_get()
4301 struct net_device *master; in mlxsw_sp_lag_uppers_bridge_join() local
4306 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_join()
4307 if (master && netif_is_bridge_master(master)) { in mlxsw_sp_lag_uppers_bridge_join()
4308 err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, lag_dev, master, in mlxsw_sp_lag_uppers_bridge_join()
4318 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_join()
4319 if (master && netif_is_bridge_master(master)) { in mlxsw_sp_lag_uppers_bridge_join()
4321 upper_dev, master, in mlxsw_sp_lag_uppers_bridge_join()
4337 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_join()
4338 if (!master || !netif_is_bridge_master(master)) in mlxsw_sp_lag_uppers_bridge_join()
4341 if (!done--) in mlxsw_sp_lag_uppers_bridge_join()
4344 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); in mlxsw_sp_lag_uppers_bridge_join()
4347 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_join()
4348 if (master && netif_is_bridge_master(master)) in mlxsw_sp_lag_uppers_bridge_join()
4349 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); in mlxsw_sp_lag_uppers_bridge_join()
4359 struct net_device *master; in mlxsw_sp_lag_uppers_bridge_leave() local
4366 master = netdev_master_upper_dev_get(upper_dev); in mlxsw_sp_lag_uppers_bridge_leave()
4367 if (!master) in mlxsw_sp_lag_uppers_bridge_leave()
4370 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); in mlxsw_sp_lag_uppers_bridge_leave()
4373 master = netdev_master_upper_dev_get(lag_dev); in mlxsw_sp_lag_uppers_bridge_leave()
4374 if (master) in mlxsw_sp_lag_uppers_bridge_leave()
4375 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); in mlxsw_sp_lag_uppers_bridge_leave()
4382 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_join()
4392 lag_id = lag->lag_id; in mlxsw_sp_port_lag_join()
4406 mlxsw_core_lag_mapping_set(mlxsw_sp->core, lag_id, port_index, in mlxsw_sp_port_lag_join()
4407 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_join()
4408 mlxsw_sp_port->lag_id = lag_id; in mlxsw_sp_port_lag_join()
4409 mlxsw_sp_port->lagged = 1; in mlxsw_sp_port_lag_join()
4416 if (mlxsw_sp_port->default_vlan->fid) in mlxsw_sp_port_lag_join()
4417 mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_join()
4436 mlxsw_sp_port->lagged = 0; in mlxsw_sp_port_lag_join()
4437 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_join()
4438 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_join()
4450 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_leave()
4451 u16 lag_id = mlxsw_sp_port->lag_id; in mlxsw_sp_port_lag_leave()
4454 if (!mlxsw_sp_port->lagged) in mlxsw_sp_port_lag_leave()
4456 lag = &mlxsw_sp->lags[lag_id]; in mlxsw_sp_port_lag_leave()
4462 mlxsw_sp_port_vlan_cleanup(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_leave()
4472 mlxsw_core_lag_mapping_clear(mlxsw_sp->core, lag_id, in mlxsw_sp_port_lag_leave()
4473 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_leave()
4474 mlxsw_sp_port->lagged = 0; in mlxsw_sp_port_lag_leave()
4484 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_add()
4488 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_add()
4489 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_add()
4495 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_remove()
4499 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_remove()
4500 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sldr), sldr_pl); in mlxsw_sp_lag_dist_port_remove()
4509 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4513 err = mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4520 mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
4530 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4535 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4542 mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
4549 if (info->tx_enabled) in mlxsw_sp_port_lag_changed()
4558 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_set()
4569 return -ENOMEM; in mlxsw_sp_port_stp_set()
4570 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_stp_set()
4575 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); in mlxsw_sp_port_stp_set()
4591 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_join()
4596 for (; vid <= VLAN_N_VID - 1; vid++) { in mlxsw_sp_port_ovs_join()
4606 for (vid--; vid >= 1; vid--) in mlxsw_sp_port_ovs_join()
4619 for (vid = VLAN_N_VID - 1; vid >= 1; vid--) in mlxsw_sp_port_ovs_leave()
4623 mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_leave()
4677 NL_SET_ERR_MSG_MOD(extack, "Multiple VxLAN devices are not supported in a VLAN-unaware bridge"); in mlxsw_sp_bridge_vxlan_is_valid()
4714 .master = mlxsw_sp_netdev_is_master(upper_dev, dev), in mlxsw_sp_netdevice_validate_uppers()
4756 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event()
4758 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_port_upper_event()
4762 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_upper_event()
4770 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4772 if (!info->linking) in mlxsw_sp_netdevice_port_upper_event()
4778 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4791 info->upper_info, extack)) in mlxsw_sp_netdevice_port_upper_event()
4792 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4794 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()
4795 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4800 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4803 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()
4804 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4808 return -EINVAL; in mlxsw_sp_netdevice_port_upper_event()
4815 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4821 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4831 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4838 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4840 if (is_vlan_dev(upper_dev) && mlxsw_sp_port->security) { in mlxsw_sp_netdevice_port_upper_event()
4842 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_upper_event()
4846 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_upper_event()
4848 if (info->linking) { in mlxsw_sp_netdevice_port_upper_event()
4863 if (info->linking) { in mlxsw_sp_netdevice_port_upper_event()
4874 if (info->linking) in mlxsw_sp_netdevice_port_upper_event()
4879 if (!info->linking) in mlxsw_sp_netdevice_port_upper_event()
4886 if (info->linking) in mlxsw_sp_netdevice_port_upper_event()
4910 if (netif_is_lag_port(dev) && mlxsw_sp_port->lagged) { in mlxsw_sp_netdevice_port_lower_event()
4912 info->lower_state_info); in mlxsw_sp_netdevice_port_lower_event()
4941 /* Called for LAG or its upper VLAN after the per-LAG-lower processing was done,
4942 * to do any per-LAG / per-LAG-upper processing.
4956 if (info->linking) in mlxsw_sp_netdevice_post_lag_event()
4958 if (netif_is_bridge_master(info->upper_dev)) in mlxsw_sp_netdevice_post_lag_event()
4990 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_vlan_event()
4996 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_port_vlan_event()
5000 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_vlan_event()
5005 return -EINVAL; in mlxsw_sp_netdevice_port_vlan_event()
5007 if (!info->linking) in mlxsw_sp_netdevice_port_vlan_event()
5013 return -EOPNOTSUPP; in mlxsw_sp_netdevice_port_vlan_event()
5026 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_port_vlan_event()
5028 if (info->linking) { in mlxsw_sp_netdevice_port_vlan_event()
5043 if (!info->linking) in mlxsw_sp_netdevice_port_vlan_event()
5087 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_bridge_vlan_event()
5091 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_vlan_event()
5095 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_vlan_event()
5099 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_vlan_event()
5100 if (info->linking) in mlxsw_sp_netdevice_bridge_vlan_event()
5148 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_bridge_event()
5152 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_event()
5157 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5159 if (!info->linking) in mlxsw_sp_netdevice_bridge_event()
5165 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5171 return -EOPNOTSUPP; in mlxsw_sp_netdevice_bridge_event()
5175 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_bridge_event()
5176 if (info->linking) in mlxsw_sp_netdevice_bridge_event()
5199 extack = netdev_notifier_info_to_extack(&info->info); in mlxsw_sp_netdevice_macvlan_event()
5200 upper_dev = info->upper_dev; in mlxsw_sp_netdevice_macvlan_event()
5204 return -EOPNOTSUPP; in mlxsw_sp_netdevice_macvlan_event()
5226 upper_dev = cu_info->upper_dev; in mlxsw_sp_netdevice_vxlan_event()
5232 return -EOPNOTSUPP; in mlxsw_sp_netdevice_vxlan_event()
5233 if (cu_info->linking) { in mlxsw_sp_netdevice_vxlan_event()
5236 /* When the bridge is VLAN-aware, the VNI of the VxLAN in mlxsw_sp_netdevice_vxlan_event()