.. | .. |
---|
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. */ |
---|
33 | 3 | |
---|
34 | 4 | #include "main.h" |
---|
35 | 5 | |
---|
.. | .. |
---|
186 | 156 | |
---|
187 | 157 | int nfp_flower_lag_populate_pre_action(struct nfp_app *app, |
---|
188 | 158 | 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) |
---|
190 | 161 | { |
---|
191 | 162 | struct nfp_flower_priv *priv = app->priv; |
---|
192 | 163 | struct nfp_fl_lag_group *group = NULL; |
---|
.. | .. |
---|
197 | 168 | master); |
---|
198 | 169 | if (!group) { |
---|
199 | 170 | mutex_unlock(&priv->nfp_lag.lock); |
---|
| 171 | + NL_SET_ERR_MSG_MOD(extack, "invalid entry: group does not exist for LAG action"); |
---|
200 | 172 | return -ENOENT; |
---|
201 | 173 | } |
---|
202 | 174 | |
---|
.. | .. |
---|
502 | 474 | schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY); |
---|
503 | 475 | } |
---|
504 | 476 | |
---|
505 | | -static int |
---|
| 477 | +static void |
---|
506 | 478 | nfp_fl_lag_schedule_group_delete(struct nfp_fl_lag *lag, |
---|
507 | 479 | struct net_device *master) |
---|
508 | 480 | { |
---|
509 | 481 | 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; |
---|
510 | 488 | |
---|
511 | 489 | mutex_lock(&lag->lock); |
---|
512 | 490 | group = nfp_fl_lag_find_group_for_master_with_lag(lag, master); |
---|
513 | 491 | if (!group) { |
---|
514 | 492 | 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; |
---|
516 | 496 | } |
---|
517 | 497 | |
---|
518 | 498 | group->to_remove = true; |
---|
.. | .. |
---|
520 | 500 | mutex_unlock(&lag->lock); |
---|
521 | 501 | |
---|
522 | 502 | schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY); |
---|
523 | | - return 0; |
---|
524 | 503 | } |
---|
525 | 504 | |
---|
526 | 505 | static int |
---|
.. | .. |
---|
605 | 584 | return 0; |
---|
606 | 585 | } |
---|
607 | 586 | |
---|
608 | | -static int |
---|
| 587 | +static void |
---|
609 | 588 | nfp_fl_lag_changels_event(struct nfp_fl_lag *lag, struct net_device *netdev, |
---|
610 | 589 | struct netdev_notifier_changelowerstate_info *info) |
---|
611 | 590 | { |
---|
.. | .. |
---|
616 | 595 | unsigned long *flags; |
---|
617 | 596 | |
---|
618 | 597 | if (!netif_is_lag_port(netdev) || !nfp_netdev_is_nfp_repr(netdev)) |
---|
619 | | - return 0; |
---|
| 598 | + return; |
---|
620 | 599 | |
---|
621 | 600 | lag_lower_info = info->lower_state_info; |
---|
622 | 601 | if (!lag_lower_info) |
---|
623 | | - return 0; |
---|
| 602 | + return; |
---|
624 | 603 | |
---|
625 | 604 | priv = container_of(lag, struct nfp_flower_priv, nfp_lag); |
---|
626 | 605 | repr = netdev_priv(netdev); |
---|
627 | 606 | |
---|
628 | 607 | /* Verify that the repr is associated with this app. */ |
---|
629 | 608 | if (repr->app != priv->app) |
---|
630 | | - return 0; |
---|
| 609 | + return; |
---|
631 | 610 | |
---|
632 | 611 | repr_priv = repr->app_priv; |
---|
633 | 612 | flags = &repr_priv->lag_port_flags; |
---|
.. | .. |
---|
647 | 626 | mutex_unlock(&lag->lock); |
---|
648 | 627 | |
---|
649 | 628 | schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY); |
---|
650 | | - return 0; |
---|
651 | 629 | } |
---|
652 | 630 | |
---|
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) |
---|
656 | 634 | { |
---|
657 | | - struct net_device *netdev; |
---|
658 | | - struct nfp_fl_lag *lag; |
---|
| 635 | + struct nfp_fl_lag *lag = &priv->nfp_lag; |
---|
659 | 636 | int err; |
---|
660 | | - |
---|
661 | | - netdev = netdev_notifier_info_to_dev(ptr); |
---|
662 | | - lag = container_of(nb, struct nfp_fl_lag, lag_nb); |
---|
663 | 637 | |
---|
664 | 638 | switch (event) { |
---|
665 | 639 | case NETDEV_CHANGEUPPER: |
---|
.. | .. |
---|
668 | 642 | return NOTIFY_BAD; |
---|
669 | 643 | return NOTIFY_OK; |
---|
670 | 644 | 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); |
---|
674 | 646 | return NOTIFY_OK; |
---|
675 | 647 | 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; |
---|
682 | 650 | } |
---|
683 | 651 | |
---|
684 | 652 | return NOTIFY_DONE; |
---|
.. | .. |
---|
703 | 671 | |
---|
704 | 672 | /* 0 is a reserved batch version so increment to first valid value. */ |
---|
705 | 673 | nfp_fl_increment_version(lag); |
---|
706 | | - |
---|
707 | | - lag->lag_nb.notifier_call = nfp_fl_lag_netdev_event; |
---|
708 | 674 | } |
---|
709 | 675 | |
---|
710 | 676 | void nfp_flower_lag_cleanup(struct nfp_fl_lag *lag) |
---|