• Home
  • Raw
  • Download

Lines Matching refs:mlxsw_sp_port

171 	int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port,
173 int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port,
180 void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
553 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, in mlxsw_sp_port_vid_stp_set() argument
557 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_stp_set()
564 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_vid_stp_set()
584 static int mlxsw_sp_port_sample_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_sample_set() argument
587 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_sample_set()
590 mlxsw_reg_mpsc_pack(mpsc_pl, mlxsw_sp_port->local_port, enable, rate); in mlxsw_sp_port_sample_set()
594 static int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_admin_status_set() argument
597 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set()
600 mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_admin_status_set()
606 static int mlxsw_sp_port_dev_addr_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_dev_addr_set() argument
609 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set()
612 mlxsw_reg_ppad_pack(ppad_pl, true, mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_set()
617 static int mlxsw_sp_port_dev_addr_init(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_dev_addr_init() argument
619 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init()
620 unsigned char *addr = mlxsw_sp_port->dev->dev_addr; in mlxsw_sp_port_dev_addr_init()
623 addr[ETH_ALEN - 1] += mlxsw_sp_port->local_port; in mlxsw_sp_port_dev_addr_init()
624 return mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr); in mlxsw_sp_port_dev_addr_init()
627 static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu) in mlxsw_sp_port_mtu_set() argument
629 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set()
635 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, 0); in mlxsw_sp_port_mtu_set()
644 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu); in mlxsw_sp_port_mtu_set()
648 static int mlxsw_sp_port_swid_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 swid) in mlxsw_sp_port_swid_set() argument
650 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_swid_set()
653 mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sp_port->local_port); in mlxsw_sp_port_swid_set()
657 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable) in mlxsw_sp_port_vp_mode_set() argument
659 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set()
662 mlxsw_reg_svpe_pack(svpe_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_vp_mode_set()
666 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, in mlxsw_sp_port_vid_learning_set() argument
669 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set()
676 mlxsw_reg_spvmlr_pack(spvmlr_pl, mlxsw_sp_port->local_port, vid, vid, in mlxsw_sp_port_vid_learning_set()
683 static int __mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, in __mlxsw_sp_port_pvid_set() argument
686 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_pvid_set()
689 mlxsw_reg_spvid_pack(spvid_pl, mlxsw_sp_port->local_port, vid); in __mlxsw_sp_port_pvid_set()
693 static int mlxsw_sp_port_allow_untagged_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_allow_untagged_set() argument
696 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_allow_untagged_set()
699 mlxsw_reg_spaft_pack(spaft_pl, mlxsw_sp_port->local_port, allow); in mlxsw_sp_port_allow_untagged_set()
703 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid) in mlxsw_sp_port_pvid_set() argument
708 err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port, false); in mlxsw_sp_port_pvid_set()
712 err = __mlxsw_sp_port_pvid_set(mlxsw_sp_port, vid); in mlxsw_sp_port_pvid_set()
715 err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port, true); in mlxsw_sp_port_pvid_set()
720 mlxsw_sp_port->pvid = vid; in mlxsw_sp_port_pvid_set()
724 __mlxsw_sp_port_pvid_set(mlxsw_sp_port, mlxsw_sp_port->pvid); in mlxsw_sp_port_pvid_set()
729 mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_system_port_mapping_set() argument
731 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set()
734 mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_system_port_mapping_set()
755 static int mlxsw_sp_port_module_map(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_module_map() argument
758 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_map()
762 mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_module_map()
772 static int mlxsw_sp_port_module_unmap(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_module_unmap() argument
774 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_unmap()
777 mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_module_unmap()
784 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_open() local
787 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true); in mlxsw_sp_port_open()
796 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_stop() local
799 return mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_stop()
805 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_xmit() local
806 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit()
809 .local_port = mlxsw_sp_port->local_port, in mlxsw_sp_port_xmit()
816 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
827 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
843 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_xmit()
849 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
861 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_mac_address() local
868 err = mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr->sa_data); in mlxsw_sp_port_set_mac_address()
918 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, in __mlxsw_sp_port_headroom_set() argument
922 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_headroom_set()
932 mlxsw_reg_pbmc_pack(pbmc_pl, mlxsw_sp_port->local_port, 0, 0); in __mlxsw_sp_port_headroom_set()
973 static int mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_headroom_set() argument
977 bool dcb_en = !!mlxsw_sp_port->dcb.ets; in mlxsw_sp_port_headroom_set()
981 prio_tc = dcb_en ? mlxsw_sp_port->dcb.ets->prio_tc : def_prio_tc; in mlxsw_sp_port_headroom_set()
982 my_pfc = dcb_en ? mlxsw_sp_port->dcb.pfc : NULL; in mlxsw_sp_port_headroom_set()
984 return __mlxsw_sp_port_headroom_set(mlxsw_sp_port, mtu, prio_tc, in mlxsw_sp_port_headroom_set()
990 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_change_mtu() local
991 bool pause_en = mlxsw_sp_port_is_pause_en(mlxsw_sp_port); in mlxsw_sp_port_change_mtu()
994 err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, mtu, pause_en); in mlxsw_sp_port_change_mtu()
997 err = mlxsw_sp_span_port_mtu_update(mlxsw_sp_port, mtu); in mlxsw_sp_port_change_mtu()
1000 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu); in mlxsw_sp_port_change_mtu()
1007 mlxsw_sp_span_port_mtu_update(mlxsw_sp_port, dev->mtu); in mlxsw_sp_port_change_mtu()
1009 mlxsw_sp_port_headroom_set(mlxsw_sp_port, dev->mtu, pause_en); in mlxsw_sp_port_change_mtu()
1017 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_sw_stats64() local
1025 p = per_cpu_ptr(mlxsw_sp_port->pcpu_stats, i); in mlxsw_sp_port_get_sw_stats64()
1069 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_stats_raw() local
1070 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats_raw()
1072 mlxsw_reg_ppcnt_pack(ppcnt_pl, mlxsw_sp_port->local_port, grp, prio); in mlxsw_sp_port_get_stats_raw()
1159 struct mlxsw_sp_port *mlxsw_sp_port = in update_stats_cache() local
1160 container_of(work, struct mlxsw_sp_port, in update_stats_cache()
1163 if (!netif_carrier_ok(mlxsw_sp_port->dev)) in update_stats_cache()
1169 mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev, in update_stats_cache()
1170 &mlxsw_sp_port->periodic_hw_stats.stats); in update_stats_cache()
1171 mlxsw_sp_port_get_hw_xstats(mlxsw_sp_port->dev, in update_stats_cache()
1172 &mlxsw_sp_port->periodic_hw_stats.xstats); in update_stats_cache()
1175 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, in update_stats_cache()
1186 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_stats64() local
1188 memcpy(stats, &mlxsw_sp_port->periodic_hw_stats.stats, sizeof(*stats)); in mlxsw_sp_port_get_stats64()
1191 static int __mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, in __mlxsw_sp_port_vlan_set() argument
1195 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_vlan_set()
1203 mlxsw_reg_spvm_pack(spvm_pl, mlxsw_sp_port->local_port, vid_begin, in __mlxsw_sp_port_vlan_set()
1210 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, in mlxsw_sp_port_vlan_set() argument
1221 err = __mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid_e, in mlxsw_sp_port_vlan_set()
1230 static void mlxsw_sp_port_vlan_flush(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_vlan_flush() argument
1236 &mlxsw_sp_port->vlans_list, list) { in mlxsw_sp_port_vlan_flush()
1254 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid) in mlxsw_sp_port_vlan_create() argument
1260 mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid); in mlxsw_sp_port_vlan_create()
1264 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, true, untagged); in mlxsw_sp_port_vlan_create()
1274 mlxsw_sp_port_vlan->mlxsw_sp_port = mlxsw_sp_port; in mlxsw_sp_port_vlan_create()
1276 list_add(&mlxsw_sp_port_vlan->list, &mlxsw_sp_port->vlans_list); in mlxsw_sp_port_vlan_create()
1281 mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, false, false); in mlxsw_sp_port_vlan_create()
1287 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp_port_vlan->mlxsw_sp_port; in mlxsw_sp_port_vlan_destroy() local
1293 mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, false, false); in mlxsw_sp_port_vlan_destroy()
1299 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_add_vid() local
1307 return PTR_ERR_OR_ZERO(mlxsw_sp_port_vlan_create(mlxsw_sp_port, vid)); in mlxsw_sp_port_add_vid()
1313 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_kill_vid() local
1322 mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid); in mlxsw_sp_port_kill_vid()
1331 mlxsw_sp_port_mall_tc_entry_find(struct mlxsw_sp_port *port, in mlxsw_sp_port_mall_tc_entry_find()
1343 mlxsw_sp_port_add_cls_matchall_mirror(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_add_cls_matchall_mirror() argument
1351 netdev_err(mlxsw_sp_port->dev, "Could not find requested device\n"); in mlxsw_sp_port_add_cls_matchall_mirror()
1357 return mlxsw_sp_span_mirror_add(mlxsw_sp_port, act->dev, span_type, in mlxsw_sp_port_add_cls_matchall_mirror()
1362 mlxsw_sp_port_del_cls_matchall_mirror(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_del_cls_matchall_mirror() argument
1369 mlxsw_sp_span_mirror_del(mlxsw_sp_port, mirror->span_id, in mlxsw_sp_port_del_cls_matchall_mirror()
1374 mlxsw_sp_port_add_cls_matchall_sample(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_add_cls_matchall_sample() argument
1381 if (!mlxsw_sp_port->sample) in mlxsw_sp_port_add_cls_matchall_sample()
1383 if (rtnl_dereference(mlxsw_sp_port->sample->psample_group)) { in mlxsw_sp_port_add_cls_matchall_sample()
1384 netdev_err(mlxsw_sp_port->dev, "sample already active\n"); in mlxsw_sp_port_add_cls_matchall_sample()
1388 netdev_err(mlxsw_sp_port->dev, "sample rate not supported\n"); in mlxsw_sp_port_add_cls_matchall_sample()
1392 rcu_assign_pointer(mlxsw_sp_port->sample->psample_group, in mlxsw_sp_port_add_cls_matchall_sample()
1394 mlxsw_sp_port->sample->truncate = act->sample.truncate; in mlxsw_sp_port_add_cls_matchall_sample()
1395 mlxsw_sp_port->sample->trunc_size = act->sample.trunc_size; in mlxsw_sp_port_add_cls_matchall_sample()
1396 mlxsw_sp_port->sample->rate = act->sample.rate; in mlxsw_sp_port_add_cls_matchall_sample()
1398 err = mlxsw_sp_port_sample_set(mlxsw_sp_port, true, act->sample.rate); in mlxsw_sp_port_add_cls_matchall_sample()
1404 RCU_INIT_POINTER(mlxsw_sp_port->sample->psample_group, NULL); in mlxsw_sp_port_add_cls_matchall_sample()
1409 mlxsw_sp_port_del_cls_matchall_sample(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_del_cls_matchall_sample() argument
1411 if (!mlxsw_sp_port->sample) in mlxsw_sp_port_del_cls_matchall_sample()
1414 mlxsw_sp_port_sample_set(mlxsw_sp_port, false, 1); in mlxsw_sp_port_del_cls_matchall_sample()
1415 RCU_INIT_POINTER(mlxsw_sp_port->sample->psample_group, NULL); in mlxsw_sp_port_del_cls_matchall_sample()
1418 static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_add_cls_matchall() argument
1428 netdev_err(mlxsw_sp_port->dev, "only singular actions are supported\n"); in mlxsw_sp_port_add_cls_matchall()
1444 err = mlxsw_sp_port_add_cls_matchall_mirror(mlxsw_sp_port, in mlxsw_sp_port_add_cls_matchall()
1450 err = mlxsw_sp_port_add_cls_matchall_sample(mlxsw_sp_port, f, in mlxsw_sp_port_add_cls_matchall()
1459 list_add_tail(&mall_tc_entry->list, &mlxsw_sp_port->mall_tc_list); in mlxsw_sp_port_add_cls_matchall()
1467 static void mlxsw_sp_port_del_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_del_cls_matchall() argument
1472 mall_tc_entry = mlxsw_sp_port_mall_tc_entry_find(mlxsw_sp_port, in mlxsw_sp_port_del_cls_matchall()
1475 netdev_dbg(mlxsw_sp_port->dev, "tc entry not found on port\n"); in mlxsw_sp_port_del_cls_matchall()
1482 mlxsw_sp_port_del_cls_matchall_mirror(mlxsw_sp_port, in mlxsw_sp_port_del_cls_matchall()
1486 mlxsw_sp_port_del_cls_matchall_sample(mlxsw_sp_port); in mlxsw_sp_port_del_cls_matchall()
1495 static int mlxsw_sp_setup_tc_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_setup_tc_cls_matchall() argument
1501 return mlxsw_sp_port_add_cls_matchall(mlxsw_sp_port, f, in mlxsw_sp_setup_tc_cls_matchall()
1504 mlxsw_sp_port_del_cls_matchall(mlxsw_sp_port, f); in mlxsw_sp_setup_tc_cls_matchall()
1539 struct mlxsw_sp_port *mlxsw_sp_port = cb_priv; in mlxsw_sp_setup_tc_block_cb_matchall() local
1543 if (!tc_cls_can_offload_and_chain0(mlxsw_sp_port->dev, in mlxsw_sp_setup_tc_block_cb_matchall()
1547 return mlxsw_sp_setup_tc_cls_matchall(mlxsw_sp_port, type_data, in mlxsw_sp_setup_tc_block_cb_matchall()
1600 mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_setup_tc_block_flower_bind() argument
1603 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_setup_tc_block_flower_bind()
1630 mlxsw_sp_port, ingress, f->extack); in mlxsw_sp_setup_tc_block_flower_bind()
1635 mlxsw_sp_port->ing_acl_block = acl_block; in mlxsw_sp_setup_tc_block_flower_bind()
1637 mlxsw_sp_port->eg_acl_block = acl_block; in mlxsw_sp_setup_tc_block_flower_bind()
1654 mlxsw_sp_setup_tc_block_flower_unbind(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_setup_tc_block_flower_unbind() argument
1657 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_setup_tc_block_flower_unbind()
1669 mlxsw_sp_port->ing_acl_block = NULL; in mlxsw_sp_setup_tc_block_flower_unbind()
1671 mlxsw_sp_port->eg_acl_block = NULL; in mlxsw_sp_setup_tc_block_flower_unbind()
1675 mlxsw_sp_port, ingress); in mlxsw_sp_setup_tc_block_flower_unbind()
1682 static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_setup_tc_block() argument
1704 if (flow_block_cb_is_busy(cb, mlxsw_sp_port, in mlxsw_sp_setup_tc_block()
1708 block_cb = flow_block_cb_alloc(cb, mlxsw_sp_port, in mlxsw_sp_setup_tc_block()
1709 mlxsw_sp_port, NULL); in mlxsw_sp_setup_tc_block()
1712 err = mlxsw_sp_setup_tc_block_flower_bind(mlxsw_sp_port, f, in mlxsw_sp_setup_tc_block()
1722 mlxsw_sp_setup_tc_block_flower_unbind(mlxsw_sp_port, in mlxsw_sp_setup_tc_block()
1724 block_cb = flow_block_cb_lookup(f->block, cb, mlxsw_sp_port); in mlxsw_sp_setup_tc_block()
1739 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_setup_tc() local
1743 return mlxsw_sp_setup_tc_block(mlxsw_sp_port, type_data); in mlxsw_sp_setup_tc()
1745 return mlxsw_sp_setup_tc_red(mlxsw_sp_port, type_data); in mlxsw_sp_setup_tc()
1747 return mlxsw_sp_setup_tc_prio(mlxsw_sp_port, type_data); in mlxsw_sp_setup_tc()
1756 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_feature_hw_tc() local
1759 if (mlxsw_sp_acl_block_rule_count(mlxsw_sp_port->ing_acl_block) || in mlxsw_sp_feature_hw_tc()
1760 mlxsw_sp_acl_block_rule_count(mlxsw_sp_port->eg_acl_block) || in mlxsw_sp_feature_hw_tc()
1761 !list_empty(&mlxsw_sp_port->mall_tc_list)) { in mlxsw_sp_feature_hw_tc()
1765 mlxsw_sp_acl_block_disable_inc(mlxsw_sp_port->ing_acl_block); in mlxsw_sp_feature_hw_tc()
1766 mlxsw_sp_acl_block_disable_inc(mlxsw_sp_port->eg_acl_block); in mlxsw_sp_feature_hw_tc()
1768 mlxsw_sp_acl_block_disable_dec(mlxsw_sp_port->ing_acl_block); in mlxsw_sp_feature_hw_tc()
1769 mlxsw_sp_acl_block_disable_dec(mlxsw_sp_port->eg_acl_block); in mlxsw_sp_feature_hw_tc()
1776 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_feature_loopback() local
1781 mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_feature_loopback()
1783 mlxsw_reg_pplr_pack(pplr_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_feature_loopback()
1784 err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr), in mlxsw_sp_feature_loopback()
1788 mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true); in mlxsw_sp_feature_loopback()
1843 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_devlink_port() local
1844 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_devlink_port()
1847 mlxsw_sp_port->local_port); in mlxsw_sp_port_get_devlink_port()
1850 static int mlxsw_sp_port_hwtstamp_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set() argument
1859 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_set()
1870 static int mlxsw_sp_port_hwtstamp_get(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get() argument
1876 err = mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_get(mlxsw_sp_port, in mlxsw_sp_port_hwtstamp_get()
1887 static inline void mlxsw_sp_port_ptp_clear(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_ptp_clear() argument
1891 mlxsw_sp_port->mlxsw_sp->ptp_ops->hwtstamp_set(mlxsw_sp_port, &config); in mlxsw_sp_port_ptp_clear()
1897 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_ioctl() local
1901 return mlxsw_sp_port_hwtstamp_set(mlxsw_sp_port, ifr); in mlxsw_sp_port_ioctl()
1903 return mlxsw_sp_port_hwtstamp_get(mlxsw_sp_port, ifr); in mlxsw_sp_port_ioctl()
1930 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_drvinfo() local
1931 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_drvinfo()
1949 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_pauseparam() local
1951 pause->rx_pause = mlxsw_sp_port->link.rx_pause; in mlxsw_sp_port_get_pauseparam()
1952 pause->tx_pause = mlxsw_sp_port->link.tx_pause; in mlxsw_sp_port_get_pauseparam()
1955 static int mlxsw_sp_port_pause_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_pause_set() argument
1960 mlxsw_reg_pfcc_pack(pfcc_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_pause_set()
1964 return mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pfcc), in mlxsw_sp_port_pause_set()
1971 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_pauseparam() local
1975 if (mlxsw_sp_port->dcb.pfc && mlxsw_sp_port->dcb.pfc->pfc_en) { in mlxsw_sp_port_set_pauseparam()
1985 err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, dev->mtu, pause_en); in mlxsw_sp_port_set_pauseparam()
1991 err = mlxsw_sp_port_pause_set(mlxsw_sp_port, pause); in mlxsw_sp_port_set_pauseparam()
1997 mlxsw_sp_port->link.rx_pause = pause->rx_pause; in mlxsw_sp_port_set_pauseparam()
1998 mlxsw_sp_port->link.tx_pause = pause->tx_pause; in mlxsw_sp_port_set_pauseparam()
2003 pause_en = mlxsw_sp_port_is_pause_en(mlxsw_sp_port); in mlxsw_sp_port_set_pauseparam()
2004 mlxsw_sp_port_headroom_set(mlxsw_sp_port, dev->mtu, pause_en); in mlxsw_sp_port_set_pauseparam()
2333 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_strings() local
2375 mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats_strings(&p); in mlxsw_sp_port_get_strings()
2383 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_phys_id() local
2384 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_set_phys_id()
2399 mlxsw_reg_mlcr_pack(mlcr_pl, mlxsw_sp_port->local_port, active); in mlxsw_sp_port_set_phys_id()
2447 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in __mlxsw_sp_port_get_stats() local
2448 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in __mlxsw_sp_port_get_stats()
2470 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_stats() local
2513 mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats(mlxsw_sp_port, in mlxsw_sp_port_get_stats()
2515 data_index += mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats_count(); in mlxsw_sp_port_get_stats()
2520 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_sset_count() local
2525 mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats_count(); in mlxsw_sp_port_get_sset_count()
3295 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_link_ksettings() local
3296 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_link_ksettings()
3305 autoneg = mlxsw_sp_port->link.autoneg; in mlxsw_sp_port_get_link_ksettings()
3306 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_get_link_ksettings()
3315 mlxsw_sp_port->mapping.width, cmd); in mlxsw_sp_port_get_link_ksettings()
3318 mlxsw_sp_port->mapping.width, cmd); in mlxsw_sp_port_get_link_ksettings()
3333 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_link_ksettings() local
3334 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_set_link_ksettings()
3343 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_set_link_ksettings()
3352 ops->to_ptys_advert_link(mlxsw_sp, mlxsw_sp_port->mapping.width, in mlxsw_sp_port_set_link_ksettings()
3354 ops->to_ptys_speed(mlxsw_sp, mlxsw_sp_port->mapping.width, in mlxsw_sp_port_set_link_ksettings()
3363 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_set_link_ksettings()
3369 mlxsw_sp_port->link.autoneg = autoneg; in mlxsw_sp_port_set_link_ksettings()
3374 mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_set_link_ksettings()
3375 mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true); in mlxsw_sp_port_set_link_ksettings()
3383 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); in mlxsw_sp_get_module_info() local
3384 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_get_module_info()
3388 mlxsw_sp_port->mapping.module, in mlxsw_sp_get_module_info()
3398 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); in mlxsw_sp_get_module_eeprom() local
3399 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_get_module_eeprom()
3403 mlxsw_sp_port->mapping.module, ee, in mlxsw_sp_get_module_eeprom()
3412 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev); in mlxsw_sp_get_ts_info() local
3413 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_get_ts_info()
3435 mlxsw_sp_port_speed_by_width_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 width) in mlxsw_sp_port_speed_by_width_set() argument
3437 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_speed_by_width_set()
3447 err = ops->port_speed_base(mlxsw_sp, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
3454 ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_speed_by_width_set()
3455 eth_proto_admin, mlxsw_sp_port->link.autoneg); in mlxsw_sp_port_speed_by_width_set()
3459 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_ets_set() argument
3463 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_set()
3466 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_set()
3474 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_ets_maxrate_set() argument
3478 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_ets_maxrate_set()
3481 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_ets_maxrate_set()
3488 static int mlxsw_sp_port_min_bw_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_min_bw_set() argument
3492 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_min_bw_set()
3495 mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index, in mlxsw_sp_port_min_bw_set()
3503 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_prio_tc_set() argument
3506 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_prio_tc_set()
3509 mlxsw_reg_qtct_pack(qtct_pl, mlxsw_sp_port->local_port, switch_prio, in mlxsw_sp_port_prio_tc_set()
3514 static int mlxsw_sp_port_ets_init(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_ets_init() argument
3521 err = mlxsw_sp_port_ets_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3527 err = mlxsw_sp_port_ets_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3534 err = mlxsw_sp_port_ets_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3540 err = mlxsw_sp_port_ets_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3552 err = mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3558 err = mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3566 err = mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3573 err = mlxsw_sp_port_ets_maxrate_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3583 err = mlxsw_sp_port_min_bw_set(mlxsw_sp_port, in mlxsw_sp_port_ets_init()
3593 err = mlxsw_sp_port_prio_tc_set(mlxsw_sp_port, i, 0); in mlxsw_sp_port_ets_init()
3601 static int mlxsw_sp_port_tc_mc_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_tc_mc_mode_set() argument
3604 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_tc_mc_mode_set()
3607 mlxsw_reg_qtctm_pack(qtctm_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_tc_mc_mode_set()
3615 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_create() local
3629 dev = alloc_etherdev(sizeof(struct mlxsw_sp_port)); in mlxsw_sp_port_create()
3635 mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_create()
3636 mlxsw_sp_port->dev = dev; in mlxsw_sp_port_create()
3637 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
3638 mlxsw_sp_port->local_port = local_port; in mlxsw_sp_port_create()
3639 mlxsw_sp_port->pvid = MLXSW_SP_DEFAULT_VID; in mlxsw_sp_port_create()
3640 mlxsw_sp_port->split = split; in mlxsw_sp_port_create()
3641 mlxsw_sp_port->mapping.module = module; in mlxsw_sp_port_create()
3642 mlxsw_sp_port->mapping.width = width; in mlxsw_sp_port_create()
3643 mlxsw_sp_port->mapping.lane = lane; in mlxsw_sp_port_create()
3644 mlxsw_sp_port->link.autoneg = 1; in mlxsw_sp_port_create()
3645 INIT_LIST_HEAD(&mlxsw_sp_port->vlans_list); in mlxsw_sp_port_create()
3646 INIT_LIST_HEAD(&mlxsw_sp_port->mall_tc_list); in mlxsw_sp_port_create()
3648 mlxsw_sp_port->pcpu_stats = in mlxsw_sp_port_create()
3650 if (!mlxsw_sp_port->pcpu_stats) { in mlxsw_sp_port_create()
3655 mlxsw_sp_port->sample = kzalloc(sizeof(*mlxsw_sp_port->sample), in mlxsw_sp_port_create()
3657 if (!mlxsw_sp_port->sample) { in mlxsw_sp_port_create()
3662 INIT_DELAYED_WORK(&mlxsw_sp_port->periodic_hw_stats.update_dw, in mlxsw_sp_port_create()
3668 err = mlxsw_sp_port_module_map(mlxsw_sp_port, module, width, lane); in mlxsw_sp_port_create()
3671 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3675 err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); in mlxsw_sp_port_create()
3678 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3682 err = mlxsw_sp_port_dev_addr_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3685 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3703 err = mlxsw_sp_port_system_port_mapping_set(mlxsw_sp_port); in mlxsw_sp_port_create()
3706 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3710 err = mlxsw_sp_port_speed_by_width_set(mlxsw_sp_port, width); in mlxsw_sp_port_create()
3713 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3717 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, ETH_DATA_LEN); in mlxsw_sp_port_create()
3720 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3724 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_create()
3728 err = mlxsw_sp_port_buffers_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3731 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3735 err = mlxsw_sp_port_ets_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3738 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3742 err = mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, true); in mlxsw_sp_port_create()
3745 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3750 err = mlxsw_sp_port_dcb_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3753 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3757 err = mlxsw_sp_port_fids_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3760 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3764 err = mlxsw_sp_tc_qdisc_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3767 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3771 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 0, VLAN_N_VID - 1, false, in mlxsw_sp_port_create()
3775 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3779 err = mlxsw_sp_port_nve_init(mlxsw_sp_port); in mlxsw_sp_port_create()
3782 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3786 err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID); in mlxsw_sp_port_create()
3789 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3793 mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_create(mlxsw_sp_port, in mlxsw_sp_port_create()
3797 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3801 mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan; in mlxsw_sp_port_create()
3803 INIT_DELAYED_WORK(&mlxsw_sp_port->ptp.shaper_dw, in mlxsw_sp_port_create()
3806 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
3810 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
3814 mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port, in mlxsw_sp_port_create()
3815 mlxsw_sp_port, dev); in mlxsw_sp_port_create()
3816 mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0); in mlxsw_sp_port_create()
3824 mlxsw_sp_port_nve_fini(mlxsw_sp_port); in mlxsw_sp_port_create()
3827 mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port); in mlxsw_sp_port_create()
3829 mlxsw_sp_port_fids_fini(mlxsw_sp_port); in mlxsw_sp_port_create()
3831 mlxsw_sp_port_dcb_fini(mlxsw_sp_port); in mlxsw_sp_port_create()
3833 mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false); in mlxsw_sp_port_create()
3842 mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); in mlxsw_sp_port_create()
3844 mlxsw_sp_port_module_unmap(mlxsw_sp_port); in mlxsw_sp_port_create()
3846 kfree(mlxsw_sp_port->sample); in mlxsw_sp_port_create()
3848 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_create()
3858 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove() local
3860 cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw); in mlxsw_sp_port_remove()
3861 cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw); in mlxsw_sp_port_remove()
3862 mlxsw_sp_port_ptp_clear(mlxsw_sp_port); in mlxsw_sp_port_remove()
3864 unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ in mlxsw_sp_port_remove()
3866 mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true); in mlxsw_sp_port_remove()
3867 mlxsw_sp_port_nve_fini(mlxsw_sp_port); in mlxsw_sp_port_remove()
3868 mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port); in mlxsw_sp_port_remove()
3869 mlxsw_sp_port_fids_fini(mlxsw_sp_port); in mlxsw_sp_port_remove()
3870 mlxsw_sp_port_dcb_fini(mlxsw_sp_port); in mlxsw_sp_port_remove()
3871 mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false); in mlxsw_sp_port_remove()
3872 mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); in mlxsw_sp_port_remove()
3873 mlxsw_sp_port_module_unmap(mlxsw_sp_port); in mlxsw_sp_port_remove()
3874 kfree(mlxsw_sp_port->sample); in mlxsw_sp_port_remove()
3875 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_remove()
3876 WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); in mlxsw_sp_port_remove()
3877 free_netdev(mlxsw_sp_port->dev); in mlxsw_sp_port_remove()
3883 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_cpu_port_create() local
3886 mlxsw_sp_port = kzalloc(sizeof(*mlxsw_sp_port), GFP_KERNEL); in mlxsw_sp_cpu_port_create()
3887 if (!mlxsw_sp_port) in mlxsw_sp_cpu_port_create()
3890 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_cpu_port_create()
3891 mlxsw_sp_port->local_port = MLXSW_PORT_CPU_PORT; in mlxsw_sp_cpu_port_create()
3894 mlxsw_sp_port, in mlxsw_sp_cpu_port_create()
3902 mlxsw_sp->ports[MLXSW_PORT_CPU_PORT] = mlxsw_sp_port; in mlxsw_sp_cpu_port_create()
3906 kfree(mlxsw_sp_port); in mlxsw_sp_cpu_port_create()
3912 struct mlxsw_sp_port *mlxsw_sp_port = in mlxsw_sp_cpu_port_remove() local
3917 kfree(mlxsw_sp_port); in mlxsw_sp_cpu_port_remove()
3945 alloc_size = sizeof(struct mlxsw_sp_port *) * max_ports; in mlxsw_sp_ports_create()
4049 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_split() local
4061 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_split()
4062 if (!mlxsw_sp_port) { in mlxsw_sp_port_split()
4069 module = mlxsw_sp_port->mapping.module; in mlxsw_sp_port_split()
4070 cur_width = mlxsw_sp_port->mapping.width; in mlxsw_sp_port_split()
4073 netdev_err(mlxsw_sp_port->dev, "Port can only be split into 2 or 4 ports\n"); in mlxsw_sp_port_split()
4079 netdev_err(mlxsw_sp_port->dev, "Port cannot be split further\n"); in mlxsw_sp_port_split()
4089 netdev_err(mlxsw_sp_port->dev, "Invalid split configuration\n"); in mlxsw_sp_port_split()
4098 netdev_err(mlxsw_sp_port->dev, "Invalid split configuration\n"); in mlxsw_sp_port_split()
4127 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_unsplit() local
4139 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_unsplit()
4140 if (!mlxsw_sp_port) { in mlxsw_sp_port_unsplit()
4147 if (!mlxsw_sp_port->split) { in mlxsw_sp_port_unsplit()
4148 netdev_err(mlxsw_sp_port->dev, "Port was not split\n"); in mlxsw_sp_port_unsplit()
4153 cur_width = mlxsw_sp_port->mapping.width; in mlxsw_sp_port_unsplit()
4177 mlxsw_sp_port_down_wipe_counters(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_down_wipe_counters() argument
4182 mlxsw_sp_port->periodic_hw_stats.xstats.backlog[i] = 0; in mlxsw_sp_port_down_wipe_counters()
4189 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_pude_event_func() local
4194 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
4195 if (!mlxsw_sp_port) in mlxsw_sp_pude_event_func()
4200 netdev_info(mlxsw_sp_port->dev, "link up\n"); in mlxsw_sp_pude_event_func()
4201 netif_carrier_on(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
4202 mlxsw_core_schedule_dw(&mlxsw_sp_port->ptp.shaper_dw, 0); in mlxsw_sp_pude_event_func()
4204 netdev_info(mlxsw_sp_port->dev, "link down\n"); in mlxsw_sp_pude_event_func()
4205 netif_carrier_off(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
4206 mlxsw_sp_port_down_wipe_counters(mlxsw_sp_port); in mlxsw_sp_pude_event_func()
4254 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_no_mark_func() local
4257 if (unlikely(!mlxsw_sp_port)) { in mlxsw_sp_rx_listener_no_mark_func()
4263 skb->dev = mlxsw_sp_port->dev; in mlxsw_sp_rx_listener_no_mark_func()
4265 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_rx_listener_no_mark_func()
4294 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_sample_func() local
4298 if (unlikely(!mlxsw_sp_port)) { in mlxsw_sp_rx_listener_sample_func()
4303 if (unlikely(!mlxsw_sp_port->sample)) { in mlxsw_sp_rx_listener_sample_func()
4309 size = mlxsw_sp_port->sample->truncate ? in mlxsw_sp_rx_listener_sample_func()
4310 mlxsw_sp_port->sample->trunc_size : skb->len; in mlxsw_sp_rx_listener_sample_func()
4313 psample_group = rcu_dereference(mlxsw_sp_port->sample->psample_group); in mlxsw_sp_rx_listener_sample_func()
4317 mlxsw_sp_port->dev->ifindex, 0, in mlxsw_sp_rx_listener_sample_func()
4318 mlxsw_sp_port->sample->rate); in mlxsw_sp_rx_listener_sample_func()
5472 struct mlxsw_sp_port **p_mlxsw_sp_port = data; in mlxsw_sp_lower_dev_walk()
5483 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev) in mlxsw_sp_port_dev_lower_find()
5485 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_dev_lower_find() local
5490 mlxsw_sp_port = NULL; in mlxsw_sp_port_dev_lower_find()
5491 netdev_walk_all_lower_dev(dev, mlxsw_sp_lower_dev_walk, &mlxsw_sp_port); in mlxsw_sp_port_dev_lower_find()
5493 return mlxsw_sp_port; in mlxsw_sp_port_dev_lower_find()
5498 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_lower_get() local
5500 mlxsw_sp_port = mlxsw_sp_port_dev_lower_find(dev); in mlxsw_sp_lower_get()
5501 return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp : NULL; in mlxsw_sp_lower_get()
5504 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev) in mlxsw_sp_port_dev_lower_find_rcu()
5506 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_dev_lower_find_rcu() local
5511 mlxsw_sp_port = NULL; in mlxsw_sp_port_dev_lower_find_rcu()
5513 &mlxsw_sp_port); in mlxsw_sp_port_dev_lower_find_rcu()
5515 return mlxsw_sp_port; in mlxsw_sp_port_dev_lower_find_rcu()
5518 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev) in mlxsw_sp_port_lower_dev_hold()
5520 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_lower_dev_hold() local
5523 mlxsw_sp_port = mlxsw_sp_port_dev_lower_find_rcu(dev); in mlxsw_sp_port_lower_dev_hold()
5524 if (mlxsw_sp_port) in mlxsw_sp_port_lower_dev_hold()
5525 dev_hold(mlxsw_sp_port->dev); in mlxsw_sp_port_lower_dev_hold()
5527 return mlxsw_sp_port; in mlxsw_sp_port_lower_dev_hold()
5530 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_dev_put() argument
5532 dev_put(mlxsw_sp_port->dev); in mlxsw_sp_port_dev_put()
5536 mlxsw_sp_port_lag_uppers_cleanup(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_lag_uppers_cleanup() argument
5544 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, br_dev); in mlxsw_sp_port_lag_uppers_cleanup()
5550 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, br_dev); in mlxsw_sp_port_lag_uppers_cleanup()
5570 static int mlxsw_sp_lag_col_port_add(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_col_port_add() argument
5573 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_add()
5576 mlxsw_reg_slcor_port_add_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_add()
5581 static int mlxsw_sp_lag_col_port_remove(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_col_port_remove() argument
5584 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_remove()
5587 mlxsw_reg_slcor_port_remove_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_remove()
5592 static int mlxsw_sp_lag_col_port_enable(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_col_port_enable() argument
5595 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_enable()
5598 mlxsw_reg_slcor_col_enable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_enable()
5603 static int mlxsw_sp_lag_col_port_disable(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_col_port_disable() argument
5606 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_col_port_disable()
5609 mlxsw_reg_slcor_col_disable_pack(slcor_pl, mlxsw_sp_port->local_port, in mlxsw_sp_lag_col_port_disable()
5677 static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_lag_join() argument
5680 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_join()
5700 err = mlxsw_sp_lag_col_port_add(mlxsw_sp_port, lag_id, port_index); in mlxsw_sp_port_lag_join()
5705 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_join()
5706 mlxsw_sp_port->lag_id = lag_id; in mlxsw_sp_port_lag_join()
5707 mlxsw_sp_port->lagged = 1; in mlxsw_sp_port_lag_join()
5711 if (mlxsw_sp_port->default_vlan->fid) in mlxsw_sp_port_lag_join()
5712 mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_join()
5722 static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_lag_leave() argument
5725 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_lag_leave()
5726 u16 lag_id = mlxsw_sp_port->lag_id; in mlxsw_sp_port_lag_leave()
5729 if (!mlxsw_sp_port->lagged) in mlxsw_sp_port_lag_leave()
5734 mlxsw_sp_lag_col_port_remove(mlxsw_sp_port, lag_id); in mlxsw_sp_port_lag_leave()
5737 mlxsw_sp_port_vlan_flush(mlxsw_sp_port, false); in mlxsw_sp_port_lag_leave()
5738 mlxsw_sp_port_vlan_cleanup(mlxsw_sp_port->default_vlan); in mlxsw_sp_port_lag_leave()
5742 mlxsw_sp_port_lag_uppers_cleanup(mlxsw_sp_port, lag_dev); in mlxsw_sp_port_lag_leave()
5748 mlxsw_sp_port->local_port); in mlxsw_sp_port_lag_leave()
5749 mlxsw_sp_port->lagged = 0; in mlxsw_sp_port_lag_leave()
5753 mlxsw_sp_port_pvid_set(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID); in mlxsw_sp_port_lag_leave()
5756 static int mlxsw_sp_lag_dist_port_add(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_dist_port_add() argument
5759 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_add()
5763 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_add()
5767 static int mlxsw_sp_lag_dist_port_remove(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_lag_dist_port_remove() argument
5770 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_lag_dist_port_remove()
5774 mlxsw_sp_port->local_port); in mlxsw_sp_lag_dist_port_remove()
5779 mlxsw_sp_port_lag_col_dist_enable(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_lag_col_dist_enable() argument
5783 err = mlxsw_sp_lag_col_port_enable(mlxsw_sp_port, in mlxsw_sp_port_lag_col_dist_enable()
5784 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
5788 err = mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
5795 mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_enable()
5800 mlxsw_sp_port_lag_col_dist_disable(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_lag_col_dist_disable() argument
5804 err = mlxsw_sp_lag_dist_port_remove(mlxsw_sp_port, in mlxsw_sp_port_lag_col_dist_disable()
5805 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
5809 err = mlxsw_sp_lag_col_port_disable(mlxsw_sp_port, in mlxsw_sp_port_lag_col_dist_disable()
5810 mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
5817 mlxsw_sp_lag_dist_port_add(mlxsw_sp_port, mlxsw_sp_port->lag_id); in mlxsw_sp_port_lag_col_dist_disable()
5821 static int mlxsw_sp_port_lag_changed(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_lag_changed() argument
5825 return mlxsw_sp_port_lag_col_dist_enable(mlxsw_sp_port); in mlxsw_sp_port_lag_changed()
5827 return mlxsw_sp_port_lag_col_dist_disable(mlxsw_sp_port); in mlxsw_sp_port_lag_changed()
5830 static int mlxsw_sp_port_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_stp_set() argument
5833 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_set()
5845 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_stp_set()
5855 static int mlxsw_sp_port_ovs_join(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_ovs_join() argument
5860 err = mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, true); in mlxsw_sp_port_ovs_join()
5863 err = mlxsw_sp_port_stp_set(mlxsw_sp_port, true); in mlxsw_sp_port_ovs_join()
5866 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_join()
5872 err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, in mlxsw_sp_port_ovs_join()
5882 mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, vid, true); in mlxsw_sp_port_ovs_join()
5884 mlxsw_sp_port_stp_set(mlxsw_sp_port, false); in mlxsw_sp_port_ovs_join()
5886 mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false); in mlxsw_sp_port_ovs_join()
5890 static void mlxsw_sp_port_ovs_leave(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_ovs_leave() argument
5895 mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, in mlxsw_sp_port_ovs_leave()
5898 mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2, in mlxsw_sp_port_ovs_leave()
5900 mlxsw_sp_port_stp_set(mlxsw_sp_port, false); in mlxsw_sp_port_ovs_leave()
5901 mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false); in mlxsw_sp_port_ovs_leave()
5970 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_netdevice_port_upper_event() local
5976 mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_netdevice_port_upper_event()
5977 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_upper_event()
6037 err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, in mlxsw_sp_netdevice_port_upper_event()
6042 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, in mlxsw_sp_netdevice_port_upper_event()
6047 err = mlxsw_sp_port_lag_join(mlxsw_sp_port, in mlxsw_sp_netdevice_port_upper_event()
6050 mlxsw_sp_port_lag_col_dist_disable(mlxsw_sp_port); in mlxsw_sp_netdevice_port_upper_event()
6051 mlxsw_sp_port_lag_leave(mlxsw_sp_port, in mlxsw_sp_netdevice_port_upper_event()
6056 err = mlxsw_sp_port_ovs_join(mlxsw_sp_port); in mlxsw_sp_netdevice_port_upper_event()
6058 mlxsw_sp_port_ovs_leave(mlxsw_sp_port); in mlxsw_sp_netdevice_port_upper_event()
6070 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, in mlxsw_sp_netdevice_port_upper_event()
6083 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_netdevice_port_lower_event() local
6086 mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_netdevice_port_lower_event()
6091 if (netif_is_lag_port(dev) && mlxsw_sp_port->lagged) { in mlxsw_sp_netdevice_port_lower_event()
6092 err = mlxsw_sp_port_lag_changed(mlxsw_sp_port, in mlxsw_sp_netdevice_port_lower_event()
6144 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_netdevice_port_vlan_event() local
6145 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_port_vlan_event()
6185 err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, in mlxsw_sp_netdevice_port_vlan_event()
6190 mlxsw_sp_port_bridge_leave(mlxsw_sp_port, in mlxsw_sp_netdevice_port_vlan_event()