Lines Matching full:lag
10 * ice_lag_nop_handler - no-op Rx handler to disable LAG
19 * ice_lag_set_primary - set PF LAG state as Primary
20 * @lag: LAG info struct
22 static void ice_lag_set_primary(struct ice_lag *lag) in ice_lag_set_primary() argument
24 struct ice_pf *pf = lag->pf; in ice_lag_set_primary()
29 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_BACKUP) { in ice_lag_set_primary()
31 netdev_name(lag->netdev)); in ice_lag_set_primary()
35 lag->role = ICE_LAG_PRIMARY; in ice_lag_set_primary()
39 * ice_lag_set_backup - set PF LAG state to Backup
40 * @lag: LAG info struct
42 static void ice_lag_set_backup(struct ice_lag *lag) in ice_lag_set_backup() argument
44 struct ice_pf *pf = lag->pf; in ice_lag_set_backup()
49 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_PRIMARY) { in ice_lag_set_backup()
51 netdev_name(lag->netdev)); in ice_lag_set_backup()
55 lag->role = ICE_LAG_BACKUP; in ice_lag_set_backup()
59 * ice_display_lag_info - print LAG info
60 * @lag: LAG info struct
62 static void ice_display_lag_info(struct ice_lag *lag) in ice_display_lag_info() argument
65 struct device *dev = &lag->pf->pdev->dev; in ice_display_lag_info()
67 name = lag->netdev ? netdev_name(lag->netdev) : "unset"; in ice_display_lag_info()
68 peer = lag->peer_netdev ? netdev_name(lag->peer_netdev) : "unset"; in ice_display_lag_info()
69 upper = lag->upper_netdev ? netdev_name(lag->upper_netdev) : "unset"; in ice_display_lag_info()
70 primary = lag->primary ? "TRUE" : "FALSE"; in ice_display_lag_info()
71 bonded = lag->bonded ? "BONDED" : "UNBONDED"; in ice_display_lag_info()
73 switch (lag->role) { in ice_display_lag_info()
96 * @lag: LAG info struct
101 static void ice_lag_info_event(struct ice_lag *lag, void *ptr) in ice_lag_info_event() argument
110 lag_netdev_name = netdev_name(lag->netdev); in ice_lag_info_event()
113 if (event_netdev != lag->netdev || !lag->bonded || !lag->upper_netdev) in ice_lag_info_event()
117 netdev_dbg(lag->netdev, "Bonding event recv, but mode not active/backup\n"); in ice_lag_info_event()
122 netdev_dbg(lag->netdev, "Bonding event recv, but secondary info not for us\n"); in ice_lag_info_event()
127 ice_lag_set_backup(lag); in ice_lag_info_event()
129 ice_lag_set_primary(lag); in ice_lag_info_event()
132 ice_display_lag_info(lag); in ice_lag_info_event()
136 * ice_lag_link - handle LAG link event
137 * @lag: LAG info struct
141 ice_lag_link(struct ice_lag *lag, struct netdev_notifier_changeupper_info *info) in ice_lag_link() argument
144 struct ice_pf *pf = lag->pf; in ice_lag_link()
147 if (lag->bonded) in ice_lag_link()
149 netdev_name(lag->netdev)); in ice_lag_link()
156 if (lag->upper_netdev != upper) { in ice_lag_link()
158 lag->upper_netdev = upper; in ice_lag_link()
164 lag->bonded = true; in ice_lag_link()
165 lag->role = ICE_LAG_UNSET; in ice_lag_link()
167 /* if this is the first element in an LAG mark as primary */ in ice_lag_link()
168 lag->primary = !!(peers == 1); in ice_lag_link()
173 * @lag: LAG info struct
177 ice_lag_unlink(struct ice_lag *lag, in ice_lag_unlink() argument
181 struct ice_pf *pf = lag->pf; in ice_lag_unlink()
184 if (!lag->bonded) { in ice_lag_unlink()
185 netdev_dbg(lag->netdev, "bonding unlink event on non-LAG netdev\n"); in ice_lag_unlink()
189 /* determine if we are in the new LAG config or not */ in ice_lag_unlink()
192 if (netdev_tmp == lag->netdev) { in ice_lag_unlink()
202 if (lag->upper_netdev) { in ice_lag_unlink()
203 dev_put(lag->upper_netdev); in ice_lag_unlink()
204 lag->upper_netdev = NULL; in ice_lag_unlink()
207 lag->peer_netdev = NULL; in ice_lag_unlink()
210 lag->bonded = false; in ice_lag_unlink()
211 lag->role = ICE_LAG_NONE; in ice_lag_unlink()
216 * @lag: LAG info struct
219 static void ice_lag_unregister(struct ice_lag *lag, struct net_device *netdev) in ice_lag_unregister() argument
221 struct ice_pf *pf = lag->pf; in ice_lag_unregister()
226 if (netdev != lag->netdev || !lag->bonded) in ice_lag_unregister()
229 if (lag->upper_netdev) { in ice_lag_unregister()
230 dev_put(lag->upper_netdev); in ice_lag_unregister()
231 lag->upper_netdev = NULL; in ice_lag_unregister()
236 lag->bonded = false; in ice_lag_unregister()
237 lag->role = ICE_LAG_NONE; in ice_lag_unregister()
241 * ice_lag_changeupper_event - handle LAG changeupper event
242 * @lag: LAG info struct
247 static void ice_lag_changeupper_event(struct ice_lag *lag, void *ptr) in ice_lag_changeupper_event() argument
256 if (netdev != lag->netdev) in ice_lag_changeupper_event()
272 ice_lag_link(lag, info); in ice_lag_changeupper_event()
274 ice_lag_unlink(lag, info); in ice_lag_changeupper_event()
276 ice_display_lag_info(lag); in ice_lag_changeupper_event()
280 * ice_lag_changelower_event - handle LAG changelower event
281 * @lag: LAG info struct
286 static void ice_lag_changelower_event(struct ice_lag *lag, void *ptr) in ice_lag_changelower_event() argument
290 if (netdev != lag->netdev) in ice_lag_changelower_event()
296 netdev_dbg(netdev, "CHANGELOWER rcvd, but netdev not in LAG. Bail\n"); in ice_lag_changelower_event()
300 * ice_lag_event_handler - handle LAG events from netdev
310 struct ice_lag *lag; in ice_lag_event_handler() local
312 lag = container_of(notif_blk, struct ice_lag, notif_block); in ice_lag_event_handler()
314 if (!lag->netdev) in ice_lag_event_handler()
323 ice_lag_changeupper_event(lag, ptr); in ice_lag_event_handler()
326 ice_lag_changelower_event(lag, ptr); in ice_lag_event_handler()
329 ice_lag_info_event(lag, ptr); in ice_lag_event_handler()
332 ice_lag_unregister(lag, netdev); in ice_lag_event_handler()
342 * ice_register_lag_handler - register LAG handler on netdev
343 * @lag: LAG struct
345 static int ice_register_lag_handler(struct ice_lag *lag) in ice_register_lag_handler() argument
347 struct device *dev = ice_pf_to_dev(lag->pf); in ice_register_lag_handler()
350 notif_blk = &lag->notif_block; in ice_register_lag_handler()
356 dev_err(dev, "FAIL register LAG event handler!\n"); in ice_register_lag_handler()
359 dev_dbg(dev, "LAG event handler registered\n"); in ice_register_lag_handler()
365 * ice_unregister_lag_handler - unregister LAG handler on netdev
366 * @lag: LAG struct
368 static void ice_unregister_lag_handler(struct ice_lag *lag) in ice_unregister_lag_handler() argument
370 struct device *dev = ice_pf_to_dev(lag->pf); in ice_unregister_lag_handler()
373 notif_blk = &lag->notif_block; in ice_unregister_lag_handler()
376 dev_dbg(dev, "LAG event handler unregistered\n"); in ice_unregister_lag_handler()
381 * ice_init_lag - initialize support for LAG
384 * Alloc memory for LAG structs and initialize the elements.
390 struct ice_lag *lag; in ice_init_lag() local
394 pf->lag = kzalloc(sizeof(*lag), GFP_KERNEL); in ice_init_lag()
395 if (!pf->lag) in ice_init_lag()
397 lag = pf->lag; in ice_init_lag()
406 lag->pf = pf; in ice_init_lag()
407 lag->netdev = vsi->netdev; in ice_init_lag()
408 lag->role = ICE_LAG_NONE; in ice_init_lag()
409 lag->bonded = false; in ice_init_lag()
410 lag->peer_netdev = NULL; in ice_init_lag()
411 lag->upper_netdev = NULL; in ice_init_lag()
412 lag->notif_block.notifier_call = NULL; in ice_init_lag()
414 err = ice_register_lag_handler(lag); in ice_init_lag()
416 dev_warn(dev, "INIT LAG: Failed to register event handler\n"); in ice_init_lag()
420 ice_display_lag_info(lag); in ice_init_lag()
422 dev_dbg(dev, "INIT LAG complete\n"); in ice_init_lag()
426 kfree(lag); in ice_init_lag()
427 pf->lag = NULL; in ice_init_lag()
432 * ice_deinit_lag - Clean up LAG
435 * Clean up kernel LAG info and free memory
440 struct ice_lag *lag; in ice_deinit_lag() local
442 lag = pf->lag; in ice_deinit_lag()
444 if (!lag) in ice_deinit_lag()
447 if (lag->pf) in ice_deinit_lag()
448 ice_unregister_lag_handler(lag); in ice_deinit_lag()
450 dev_put(lag->upper_netdev); in ice_deinit_lag()
452 dev_put(lag->peer_netdev); in ice_deinit_lag()
454 kfree(lag); in ice_deinit_lag()
456 pf->lag = NULL; in ice_deinit_lag()