Lines Matching refs:mlxsw_sp_port
160 static int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_admin_status_set() argument
163 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_admin_status_set()
166 mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, in mlxsw_sp_port_admin_status_set()
172 static int mlxsw_sp_port_oper_status_get(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_oper_status_get() argument
175 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_oper_status_get()
180 mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, 0); in mlxsw_sp_port_oper_status_get()
216 static int mlxsw_sp_port_dev_addr_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_dev_addr_set() argument
219 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_set()
222 mlxsw_reg_ppad_pack(ppad_pl, true, mlxsw_sp_port->local_port); in mlxsw_sp_port_dev_addr_set()
227 static int mlxsw_sp_port_dev_addr_init(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_dev_addr_init() argument
229 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_dev_addr_init()
230 unsigned char *addr = mlxsw_sp_port->dev->dev_addr; in mlxsw_sp_port_dev_addr_init()
233 addr[ETH_ALEN - 1] += mlxsw_sp_port->local_port; in mlxsw_sp_port_dev_addr_init()
234 return mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr); in mlxsw_sp_port_dev_addr_init()
237 static int mlxsw_sp_port_stp_state_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_stp_state_set() argument
240 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_stp_state_set()
247 mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_stp_state_set()
254 static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu) in mlxsw_sp_port_mtu_set() argument
256 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_mtu_set()
262 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, 0); in mlxsw_sp_port_mtu_set()
271 mlxsw_reg_pmtu_pack(pmtu_pl, mlxsw_sp_port->local_port, mtu); in mlxsw_sp_port_mtu_set()
275 static int mlxsw_sp_port_swid_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 swid) in mlxsw_sp_port_swid_set() argument
277 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_swid_set()
280 mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sp_port->local_port); in mlxsw_sp_port_swid_set()
284 static int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_vp_mode_set() argument
287 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vp_mode_set()
290 mlxsw_reg_svpe_pack(svpe_pl, mlxsw_sp_port->local_port, enable); in mlxsw_sp_port_vp_mode_set()
294 int mlxsw_sp_port_vid_to_fid_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_vid_to_fid_set() argument
298 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_to_fid_set()
301 mlxsw_reg_svfa_pack(svfa_pl, mlxsw_sp_port->local_port, mt, valid, in mlxsw_sp_port_vid_to_fid_set()
306 static int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_vid_learning_set() argument
309 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vid_learning_set()
316 mlxsw_reg_spvmlr_pack(spvmlr_pl, mlxsw_sp_port->local_port, vid, vid, in mlxsw_sp_port_vid_learning_set()
324 mlxsw_sp_port_system_port_mapping_set(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_system_port_mapping_set() argument
326 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_system_port_mapping_set()
329 mlxsw_reg_sspr_pack(sspr_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_system_port_mapping_set()
333 static int mlxsw_sp_port_module_check(struct mlxsw_sp_port *mlxsw_sp_port, in mlxsw_sp_port_module_check() argument
336 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_module_check()
340 mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_module_check()
350 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_open() local
353 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true); in mlxsw_sp_port_open()
362 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_stop() local
365 return mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_stop()
371 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_xmit() local
372 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_xmit()
375 .local_port = mlxsw_sp_port->local_port, in mlxsw_sp_port_xmit()
389 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
396 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
408 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_xmit()
414 this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); in mlxsw_sp_port_xmit()
422 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_mac_address() local
429 err = mlxsw_sp_port_dev_addr_set(mlxsw_sp_port, addr->sa_data); in mlxsw_sp_port_set_mac_address()
438 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_change_mtu() local
441 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu); in mlxsw_sp_port_change_mtu()
452 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_stats64() local
460 p = per_cpu_ptr(mlxsw_sp_port->pcpu_stats, i); in mlxsw_sp_port_get_stats64()
480 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, in mlxsw_sp_port_vlan_set() argument
483 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_set()
491 mlxsw_reg_spvm_pack(spvm_pl, mlxsw_sp_port->local_port, vid_begin, in mlxsw_sp_port_vlan_set()
498 static int mlxsw_sp_port_vp_mode_trans(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_vp_mode_trans() argument
504 for_each_set_bit(vid, mlxsw_sp_port->active_vlans, VLAN_N_VID) { in mlxsw_sp_port_vp_mode_trans()
505 err = mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, mt, true, vid, in mlxsw_sp_port_vp_mode_trans()
513 err = mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, true); in mlxsw_sp_port_vp_mode_trans()
522 for_each_set_bit(vid, mlxsw_sp_port->active_vlans, last_visited_vid) in mlxsw_sp_port_vp_mode_trans()
523 mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, mt, false, vid, in mlxsw_sp_port_vp_mode_trans()
528 static int mlxsw_sp_port_vlan_mode_trans(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_vlan_mode_trans() argument
534 err = mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false); in mlxsw_sp_port_vlan_mode_trans()
538 for_each_set_bit(vid, mlxsw_sp_port->active_vlans, VLAN_N_VID) { in mlxsw_sp_port_vlan_mode_trans()
539 err = mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, mt, false, in mlxsw_sp_port_vlan_mode_trans()
551 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_add_vid() local
552 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_add_vid()
562 if (test_bit(vid, mlxsw_sp_port->active_vfids)) { in mlxsw_sp_port_add_vid()
599 if (!mlxsw_sp_port->nr_vfids) { in mlxsw_sp_port_add_vid()
600 err = mlxsw_sp_port_vp_mode_trans(mlxsw_sp_port); in mlxsw_sp_port_add_vid()
607 err = mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, in mlxsw_sp_port_add_vid()
616 err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, vid, false); in mlxsw_sp_port_add_vid()
622 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, true, false); in mlxsw_sp_port_add_vid()
629 err = mlxsw_sp_port_stp_state_set(mlxsw_sp_port, vid, in mlxsw_sp_port_add_vid()
636 mlxsw_sp_port->nr_vfids++; in mlxsw_sp_port_add_vid()
637 set_bit(vid, mlxsw_sp_port->active_vfids); in mlxsw_sp_port_add_vid()
647 mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, false, false); in mlxsw_sp_port_add_vid()
649 mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, vid, true); in mlxsw_sp_port_add_vid()
651 mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, in mlxsw_sp_port_add_vid()
655 mlxsw_sp_port_vlan_mode_trans(mlxsw_sp_port); in mlxsw_sp_port_add_vid()
662 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_kill_vid() local
671 if (!test_bit(vid, mlxsw_sp_port->active_vfids)) { in mlxsw_sp_port_kill_vid()
676 err = mlxsw_sp_port_stp_state_set(mlxsw_sp_port, vid, in mlxsw_sp_port_kill_vid()
683 err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, vid, vid, false, false); in mlxsw_sp_port_kill_vid()
690 err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_port, vid, true); in mlxsw_sp_port_kill_vid()
696 err = mlxsw_sp_port_vid_to_fid_set(mlxsw_sp_port, in mlxsw_sp_port_kill_vid()
710 if (mlxsw_sp_port->nr_vfids == 1) { in mlxsw_sp_port_kill_vid()
711 err = mlxsw_sp_port_vlan_mode_trans(mlxsw_sp_port); in mlxsw_sp_port_kill_vid()
718 mlxsw_sp_port->nr_vfids--; in mlxsw_sp_port_kill_vid()
719 clear_bit(vid, mlxsw_sp_port->active_vfids); in mlxsw_sp_port_kill_vid()
744 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_drvinfo() local
745 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_drvinfo()
865 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_stats() local
866 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_stats()
871 mlxsw_reg_ppcnt_pack(ppcnt_pl, mlxsw_sp_port->local_port); in mlxsw_sp_port_get_stats()
1083 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_get_settings() local
1084 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_get_settings()
1091 mlxsw_reg_ptys_pack(ptys_pl, mlxsw_sp_port->local_port, 0); in mlxsw_sp_port_get_settings()
1142 struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_set_settings() local
1143 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_set_settings()
1158 mlxsw_reg_ptys_pack(ptys_pl, mlxsw_sp_port->local_port, 0); in mlxsw_sp_port_set_settings()
1174 mlxsw_reg_ptys_pack(ptys_pl, mlxsw_sp_port->local_port, eth_proto_new); in mlxsw_sp_port_set_settings()
1181 err = mlxsw_sp_port_oper_status_get(mlxsw_sp_port, &is_up); in mlxsw_sp_port_set_settings()
1189 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_set_settings()
1195 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true); in mlxsw_sp_port_set_settings()
1216 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_port_create() local
1221 dev = alloc_etherdev(sizeof(struct mlxsw_sp_port)); in mlxsw_sp_port_create()
1224 mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_port_create()
1225 mlxsw_sp_port->dev = dev; in mlxsw_sp_port_create()
1226 mlxsw_sp_port->mlxsw_sp = mlxsw_sp; in mlxsw_sp_port_create()
1227 mlxsw_sp_port->local_port = local_port; in mlxsw_sp_port_create()
1228 mlxsw_sp_port->learning = 1; in mlxsw_sp_port_create()
1229 mlxsw_sp_port->learning_sync = 1; in mlxsw_sp_port_create()
1230 mlxsw_sp_port->uc_flood = 1; in mlxsw_sp_port_create()
1231 mlxsw_sp_port->pvid = 1; in mlxsw_sp_port_create()
1233 mlxsw_sp_port->pcpu_stats = in mlxsw_sp_port_create()
1235 if (!mlxsw_sp_port->pcpu_stats) { in mlxsw_sp_port_create()
1243 err = mlxsw_sp_port_dev_addr_init(mlxsw_sp_port); in mlxsw_sp_port_create()
1246 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1260 err = mlxsw_sp_port_module_check(mlxsw_sp_port, &usable); in mlxsw_sp_port_create()
1263 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1269 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1273 err = mlxsw_sp_port_system_port_mapping_set(mlxsw_sp_port); in mlxsw_sp_port_create()
1276 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1280 err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); in mlxsw_sp_port_create()
1283 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1287 err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, ETH_DATA_LEN); in mlxsw_sp_port_create()
1290 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1294 err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false); in mlxsw_sp_port_create()
1298 err = mlxsw_sp_port_buffers_init(mlxsw_sp_port); in mlxsw_sp_port_create()
1301 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1305 mlxsw_sp_port_switchdev_init(mlxsw_sp_port); in mlxsw_sp_port_create()
1309 mlxsw_sp_port->local_port); in mlxsw_sp_port_create()
1313 err = mlxsw_sp_port_vlan_init(mlxsw_sp_port); in mlxsw_sp_port_create()
1317 mlxsw_sp->ports[local_port] = mlxsw_sp_port; in mlxsw_sp_port_create()
1331 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_create()
1347 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_port_remove() local
1349 if (!mlxsw_sp_port) in mlxsw_sp_port_remove()
1351 mlxsw_sp_port_kill_vid(mlxsw_sp_port->dev, 0, 1); in mlxsw_sp_port_remove()
1352 unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ in mlxsw_sp_port_remove()
1353 mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); in mlxsw_sp_port_remove()
1354 free_percpu(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_port_remove()
1355 free_netdev(mlxsw_sp_port->dev); in mlxsw_sp_port_remove()
1373 alloc_size = sizeof(struct mlxsw_sp_port *) * MLXSW_PORT_MAX_PORTS; in mlxsw_sp_ports_create()
1396 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_pude_event_func() local
1401 mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_pude_event_func()
1402 if (!mlxsw_sp_port) { in mlxsw_sp_pude_event_func()
1410 netdev_info(mlxsw_sp_port->dev, "link up\n"); in mlxsw_sp_pude_event_func()
1411 netif_carrier_on(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
1413 netdev_info(mlxsw_sp_port->dev, "link down\n"); in mlxsw_sp_pude_event_func()
1414 netif_carrier_off(mlxsw_sp_port->dev); in mlxsw_sp_pude_event_func()
1468 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; in mlxsw_sp_rx_listener_func() local
1471 if (unlikely(!mlxsw_sp_port)) { in mlxsw_sp_rx_listener_func()
1477 skb->dev = mlxsw_sp_port->dev; in mlxsw_sp_rx_listener_func()
1479 pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats); in mlxsw_sp_rx_listener_func()
1815 static int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_bridge_join() argument
1817 struct net_device *dev = mlxsw_sp_port->dev; in mlxsw_sp_port_bridge_join()
1832 static int mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port) in mlxsw_sp_port_bridge_leave() argument
1834 struct net_device *dev = mlxsw_sp_port->dev; in mlxsw_sp_port_bridge_leave()
1873 struct mlxsw_sp_port *mlxsw_sp_port; in mlxsw_sp_netdevice_event() local
1881 mlxsw_sp_port = netdev_priv(dev); in mlxsw_sp_netdevice_event()
1882 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_netdevice_event()
1899 err = mlxsw_sp_port_bridge_join(mlxsw_sp_port); in mlxsw_sp_netdevice_event()
1903 mlxsw_sp_port->bridged = 1; in mlxsw_sp_netdevice_event()
1905 err = mlxsw_sp_port_bridge_leave(mlxsw_sp_port); in mlxsw_sp_netdevice_event()
1908 mlxsw_sp_port->bridged = 0; in mlxsw_sp_netdevice_event()