hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c
....@@ -1,35 +1,5 @@
1
-/*
2
- * Copyright (C) 2018 Netronome Systems, Inc.
3
- *
4
- * This software is dual licensed under the GNU General License Version 2,
5
- * June 1991 as shown in the file COPYING in the top-level directory of this
6
- * source tree or the BSD 2-Clause License provided below. You have the
7
- * option to license this software under the complete terms of either license.
8
- *
9
- * The BSD 2-Clause License:
10
- *
11
- * Redistribution and use in source and binary forms, with or
12
- * without modification, are permitted provided that the following
13
- * conditions are met:
14
- *
15
- * 1. Redistributions of source code must retain the above
16
- * copyright notice, this list of conditions and the following
17
- * disclaimer.
18
- *
19
- * 2. Redistributions in binary form must reproduce the above
20
- * copyright notice, this list of conditions and the following
21
- * disclaimer in the documentation and/or other materials
22
- * provided with the distribution.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
1
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
+/* Copyright (C) 2018 Netronome Systems, Inc. */
333
344 #include "main.h"
355
....@@ -186,7 +156,8 @@
186156
187157 int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
188158 struct net_device *master,
189
- struct nfp_fl_pre_lag *pre_act)
159
+ struct nfp_fl_pre_lag *pre_act,
160
+ struct netlink_ext_ack *extack)
190161 {
191162 struct nfp_flower_priv *priv = app->priv;
192163 struct nfp_fl_lag_group *group = NULL;
....@@ -197,6 +168,7 @@
197168 master);
198169 if (!group) {
199170 mutex_unlock(&priv->nfp_lag.lock);
171
+ NL_SET_ERR_MSG_MOD(extack, "invalid entry: group does not exist for LAG action");
200172 return -ENOENT;
201173 }
202174
....@@ -502,17 +474,25 @@
502474 schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY);
503475 }
504476
505
-static int
477
+static void
506478 nfp_fl_lag_schedule_group_delete(struct nfp_fl_lag *lag,
507479 struct net_device *master)
508480 {
509481 struct nfp_fl_lag_group *group;
482
+ struct nfp_flower_priv *priv;
483
+
484
+ priv = container_of(lag, struct nfp_flower_priv, nfp_lag);
485
+
486
+ if (!netif_is_bond_master(master))
487
+ return;
510488
511489 mutex_lock(&lag->lock);
512490 group = nfp_fl_lag_find_group_for_master_with_lag(lag, master);
513491 if (!group) {
514492 mutex_unlock(&lag->lock);
515
- return -ENOENT;
493
+ nfp_warn(priv->app->cpp, "untracked bond got unregistered %s\n",
494
+ netdev_name(master));
495
+ return;
516496 }
517497
518498 group->to_remove = true;
....@@ -520,7 +500,6 @@
520500 mutex_unlock(&lag->lock);
521501
522502 schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY);
523
- return 0;
524503 }
525504
526505 static int
....@@ -605,7 +584,7 @@
605584 return 0;
606585 }
607586
608
-static int
587
+static void
609588 nfp_fl_lag_changels_event(struct nfp_fl_lag *lag, struct net_device *netdev,
610589 struct netdev_notifier_changelowerstate_info *info)
611590 {
....@@ -616,18 +595,18 @@
616595 unsigned long *flags;
617596
618597 if (!netif_is_lag_port(netdev) || !nfp_netdev_is_nfp_repr(netdev))
619
- return 0;
598
+ return;
620599
621600 lag_lower_info = info->lower_state_info;
622601 if (!lag_lower_info)
623
- return 0;
602
+ return;
624603
625604 priv = container_of(lag, struct nfp_flower_priv, nfp_lag);
626605 repr = netdev_priv(netdev);
627606
628607 /* Verify that the repr is associated with this app. */
629608 if (repr->app != priv->app)
630
- return 0;
609
+ return;
631610
632611 repr_priv = repr->app_priv;
633612 flags = &repr_priv->lag_port_flags;
....@@ -647,19 +626,14 @@
647626 mutex_unlock(&lag->lock);
648627
649628 schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY);
650
- return 0;
651629 }
652630
653
-static int
654
-nfp_fl_lag_netdev_event(struct notifier_block *nb, unsigned long event,
655
- void *ptr)
631
+int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv,
632
+ struct net_device *netdev,
633
+ unsigned long event, void *ptr)
656634 {
657
- struct net_device *netdev;
658
- struct nfp_fl_lag *lag;
635
+ struct nfp_fl_lag *lag = &priv->nfp_lag;
659636 int err;
660
-
661
- netdev = netdev_notifier_info_to_dev(ptr);
662
- lag = container_of(nb, struct nfp_fl_lag, lag_nb);
663637
664638 switch (event) {
665639 case NETDEV_CHANGEUPPER:
....@@ -668,17 +642,11 @@
668642 return NOTIFY_BAD;
669643 return NOTIFY_OK;
670644 case NETDEV_CHANGELOWERSTATE:
671
- err = nfp_fl_lag_changels_event(lag, netdev, ptr);
672
- if (err)
673
- return NOTIFY_BAD;
645
+ nfp_fl_lag_changels_event(lag, netdev, ptr);
674646 return NOTIFY_OK;
675647 case NETDEV_UNREGISTER:
676
- if (netif_is_bond_master(netdev)) {
677
- err = nfp_fl_lag_schedule_group_delete(lag, netdev);
678
- if (err)
679
- return NOTIFY_BAD;
680
- return NOTIFY_OK;
681
- }
648
+ nfp_fl_lag_schedule_group_delete(lag, netdev);
649
+ return NOTIFY_OK;
682650 }
683651
684652 return NOTIFY_DONE;
....@@ -703,8 +671,6 @@
703671
704672 /* 0 is a reserved batch version so increment to first valid value. */
705673 nfp_fl_increment_version(lag);
706
-
707
- lag->lag_nb.notifier_call = nfp_fl_lag_netdev_event;
708674 }
709675
710676 void nfp_flower_lag_cleanup(struct nfp_fl_lag *lag)