Lines Matching +full:lan966x +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0+
7 static void lan966x_lag_set_aggr_pgids(struct lan966x *lan966x) in lan966x_lag_set_aggr_pgids() argument
9 u32 visited = GENMASK(lan966x->num_phys_ports - 1, 0); in lan966x_lag_set_aggr_pgids()
13 for (p = 0; p < lan966x->num_phys_ports; ++p) in lan966x_lag_set_aggr_pgids()
15 lan966x, ANA_PGID(p)); in lan966x_lag_set_aggr_pgids()
19 lan966x, ANA_PGID(p)); in lan966x_lag_set_aggr_pgids()
29 for (p = 0; p < lan966x->num_phys_ports; ++p) { in lan966x_lag_set_aggr_pgids()
30 struct lan966x_port *port = lan966x->ports[p]; in lan966x_lag_set_aggr_pgids()
32 if (!port || !port->bond) in lan966x_lag_set_aggr_pgids()
39 for (lag = 0; lag < lan966x->num_phys_ports; ++lag) { in lan966x_lag_set_aggr_pgids()
40 struct lan966x_port *port = lan966x->ports[lag]; in lan966x_lag_set_aggr_pgids()
46 if (!port || !port->bond || (visited & BIT(lag))) in lan966x_lag_set_aggr_pgids()
49 bond = port->bond; in lan966x_lag_set_aggr_pgids()
50 bond_mask = lan966x_lag_get_mask(lan966x, bond); in lan966x_lag_set_aggr_pgids()
52 for_each_set_bit(p, &bond_mask, lan966x->num_phys_ports) { in lan966x_lag_set_aggr_pgids()
53 struct lan966x_port *port = lan966x->ports[p]; in lan966x_lag_set_aggr_pgids()
59 lan966x, ANA_PGID(p)); in lan966x_lag_set_aggr_pgids()
60 if (port->lag_tx_active) in lan966x_lag_set_aggr_pgids()
67 ac = lan_rd(lan966x, ANA_PGID(i)); in lan966x_lag_set_aggr_pgids()
75 lan966x, ANA_PGID(i)); in lan966x_lag_set_aggr_pgids()
81 for (p = lag; p < lan966x->num_phys_ports; p++) { in lan966x_lag_set_aggr_pgids()
82 struct lan966x_port *port = lan966x->ports[p]; in lan966x_lag_set_aggr_pgids()
87 if (port->bond == bond) in lan966x_lag_set_aggr_pgids()
93 static void lan966x_lag_set_port_ids(struct lan966x *lan966x) in lan966x_lag_set_port_ids() argument
100 for (p = 0; p < lan966x->num_phys_ports; ++p) { in lan966x_lag_set_port_ids()
101 port = lan966x->ports[p]; in lan966x_lag_set_port_ids()
105 lag_id = port->chip_port; in lan966x_lag_set_port_ids()
107 bond_mask = lan966x_lag_get_mask(lan966x, port->bond); in lan966x_lag_set_port_ids()
113 lan966x, ANA_PORT_CFG(port->chip_port)); in lan966x_lag_set_port_ids()
117 static void lan966x_lag_update_ids(struct lan966x *lan966x) in lan966x_lag_update_ids() argument
119 lan966x_lag_set_port_ids(lan966x); in lan966x_lag_update_ids()
120 lan966x_update_fwd_mask(lan966x); in lan966x_lag_update_ids()
121 lan966x_lag_set_aggr_pgids(lan966x); in lan966x_lag_update_ids()
129 struct lan966x *lan966x = port->lan966x; in lan966x_lag_port_join() local
130 struct net_device *dev = port->dev; in lan966x_lag_port_join()
131 u32 lag_id = -1; in lan966x_lag_port_join()
135 bond_mask = lan966x_lag_get_mask(lan966x, bond); in lan966x_lag_port_join()
139 port->bond = bond; in lan966x_lag_port_join()
140 lan966x_lag_update_ids(lan966x); in lan966x_lag_port_join()
151 if (lan966x_lag_first_port(port->bond, port->dev) && in lan966x_lag_port_join()
152 lag_id != -1) in lan966x_lag_port_join()
153 lan966x_mac_lag_replace_port_entry(lan966x, in lan966x_lag_port_join()
154 lan966x->ports[lag_id], in lan966x_lag_port_join()
160 port->bond = NULL; in lan966x_lag_port_join()
161 lan966x_lag_update_ids(lan966x); in lan966x_lag_port_join()
168 struct lan966x *lan966x = port->lan966x; in lan966x_lag_port_leave() local
172 if (lan966x_lag_first_port(port->bond, port->dev)) { in lan966x_lag_port_leave()
173 bond_mask = lan966x_lag_get_mask(lan966x, port->bond); in lan966x_lag_port_leave()
174 bond_mask &= ~BIT(port->chip_port); in lan966x_lag_port_leave()
177 lan966x_mac_lag_replace_port_entry(lan966x, port, in lan966x_lag_port_leave()
178 lan966x->ports[lag_id]); in lan966x_lag_port_leave()
180 lan966x_mac_lag_remove_port_entry(lan966x, port); in lan966x_lag_port_leave()
184 port->bond = NULL; in lan966x_lag_port_leave()
185 lan966x_lag_update_ids(lan966x); in lan966x_lag_port_leave()
189 static bool lan966x_lag_port_check_hash_types(struct lan966x *lan966x, in lan966x_lag_port_check_hash_types() argument
194 for (p = 0; p < lan966x->num_phys_ports; ++p) { in lan966x_lag_port_check_hash_types()
195 struct lan966x_port *port = lan966x->ports[p]; in lan966x_lag_port_check_hash_types()
197 if (!port || !port->bond) in lan966x_lag_port_check_hash_types()
200 if (port->hash_type != hash_type) in lan966x_lag_port_check_hash_types()
211 struct lan966x *lan966x = port->lan966x; in lan966x_lag_port_prechangeupper() local
215 extack = netdev_notifier_info_to_extack(&info->info); in lan966x_lag_port_prechangeupper()
216 lui = info->upper_info; in lan966x_lag_port_prechangeupper()
218 port->hash_type = NETDEV_LAG_HASH_NONE; in lan966x_lag_port_prechangeupper()
222 if (lui->tx_type != NETDEV_LAG_TX_TYPE_HASH) { in lan966x_lag_port_prechangeupper()
225 return -EINVAL; in lan966x_lag_port_prechangeupper()
228 if (!lan966x_lag_port_check_hash_types(lan966x, lui->hash_type)) { in lan966x_lag_port_prechangeupper()
231 return -EINVAL; in lan966x_lag_port_prechangeupper()
234 switch (lui->hash_type) { in lan966x_lag_port_prechangeupper()
238 lan966x, ANA_AGGR_CFG); in lan966x_lag_port_prechangeupper()
244 lan966x, ANA_AGGR_CFG); in lan966x_lag_port_prechangeupper()
251 lan966x, ANA_AGGR_CFG); in lan966x_lag_port_prechangeupper()
256 return -EINVAL; in lan966x_lag_port_prechangeupper()
259 port->hash_type = lui->hash_type; in lan966x_lag_port_prechangeupper()
267 struct netdev_lag_lower_state_info *lag = info->lower_state_info; in lan966x_lag_port_changelowerstate()
269 struct lan966x *lan966x = port->lan966x; in lan966x_lag_port_changelowerstate() local
272 if (!port->bond) in lan966x_lag_port_changelowerstate()
275 is_active = lag->link_up && lag->tx_enabled; in lan966x_lag_port_changelowerstate()
276 if (port->lag_tx_active == is_active) in lan966x_lag_port_changelowerstate()
279 port->lag_tx_active = is_active; in lan966x_lag_port_changelowerstate()
280 lan966x_lag_set_aggr_pgids(lan966x); in lan966x_lag_port_changelowerstate()
298 if (port->bond != dev) in lan966x_lag_netdev_prechangeupper()
322 if (port->bond != dev) in lan966x_lag_netdev_changeupper()
336 struct lan966x *lan966x = port->lan966x; in lan966x_lag_first_port() local
339 if (port->bond != lag) in lan966x_lag_first_port()
342 bond_mask = lan966x_lag_get_mask(lan966x, lag); in lan966x_lag_first_port()
343 if (bond_mask && port->chip_port == __ffs(bond_mask)) in lan966x_lag_first_port()
349 u32 lan966x_lag_get_mask(struct lan966x *lan966x, struct net_device *bond) in lan966x_lag_get_mask() argument
358 for (p = 0; p < lan966x->num_phys_ports; p++) { in lan966x_lag_get_mask()
359 port = lan966x->ports[p]; in lan966x_lag_get_mask()
363 if (port->bond == bond) in lan966x_lag_get_mask()