Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * drivers/net/team/team_mode_broadcast.c - Broadcast mode for team
 4 * Copyright (c) 2012 Jiri Pirko <jpirko@redhat.com>
 
 
 
 
 
 5 */
 6
 7#include <linux/kernel.h>
 8#include <linux/types.h>
 9#include <linux/module.h>
10#include <linux/init.h>
 
11#include <linux/netdevice.h>
12#include <linux/if_team.h>
13
14static bool bc_transmit(struct team *team, struct sk_buff *skb)
15{
16	struct team_port *cur;
17	struct team_port *last = NULL;
18	struct sk_buff *skb2;
19	bool ret;
20	bool sum_ret = false;
21
22	list_for_each_entry_rcu(cur, &team->port_list, list) {
23		if (team_port_txable(cur)) {
24			if (last) {
25				skb2 = skb_clone(skb, GFP_ATOMIC);
26				if (skb2) {
27					ret = !team_dev_queue_xmit(team, last,
28								   skb2);
29					if (!sum_ret)
30						sum_ret = ret;
31				}
32			}
33			last = cur;
34		}
35	}
36	if (last) {
37		ret = !team_dev_queue_xmit(team, last, skb);
38		if (!sum_ret)
39			sum_ret = ret;
40	}
41	return sum_ret;
42}
43
44static const struct team_mode_ops bc_mode_ops = {
45	.transmit		= bc_transmit,
46	.port_enter		= team_modeop_port_enter,
47	.port_change_dev_addr	= team_modeop_port_change_dev_addr,
48};
49
50static const struct team_mode bc_mode = {
51	.kind		= "broadcast",
52	.owner		= THIS_MODULE,
53	.ops		= &bc_mode_ops,
54	.lag_tx_type	= NETDEV_LAG_TX_TYPE_BROADCAST,
55};
56
57static int __init bc_init_module(void)
58{
59	return team_mode_register(&bc_mode);
60}
61
62static void __exit bc_cleanup_module(void)
63{
64	team_mode_unregister(&bc_mode);
65}
66
67module_init(bc_init_module);
68module_exit(bc_cleanup_module);
69
70MODULE_LICENSE("GPL v2");
71MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>");
72MODULE_DESCRIPTION("Broadcast mode for team");
73MODULE_ALIAS_TEAM_MODE("broadcast");
v4.6
 
 1/*
 2 * drivers/net/team/team_mode_broadcast.c - Broadcast mode for team
 3 * Copyright (c) 2012 Jiri Pirko <jpirko@redhat.com>
 4 *
 5 * This program is free software; you can redistribute it and/or modify
 6 * it under the terms of the GNU General Public License as published by
 7 * the Free Software Foundation; either version 2 of the License, or
 8 * (at your option) any later version.
 9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/errno.h>
16#include <linux/netdevice.h>
17#include <linux/if_team.h>
18
19static bool bc_transmit(struct team *team, struct sk_buff *skb)
20{
21	struct team_port *cur;
22	struct team_port *last = NULL;
23	struct sk_buff *skb2;
24	bool ret;
25	bool sum_ret = false;
26
27	list_for_each_entry_rcu(cur, &team->port_list, list) {
28		if (team_port_txable(cur)) {
29			if (last) {
30				skb2 = skb_clone(skb, GFP_ATOMIC);
31				if (skb2) {
32					ret = !team_dev_queue_xmit(team, last,
33								   skb2);
34					if (!sum_ret)
35						sum_ret = ret;
36				}
37			}
38			last = cur;
39		}
40	}
41	if (last) {
42		ret = !team_dev_queue_xmit(team, last, skb);
43		if (!sum_ret)
44			sum_ret = ret;
45	}
46	return sum_ret;
47}
48
49static const struct team_mode_ops bc_mode_ops = {
50	.transmit		= bc_transmit,
51	.port_enter		= team_modeop_port_enter,
52	.port_change_dev_addr	= team_modeop_port_change_dev_addr,
53};
54
55static const struct team_mode bc_mode = {
56	.kind		= "broadcast",
57	.owner		= THIS_MODULE,
58	.ops		= &bc_mode_ops,
59	.lag_tx_type	= NETDEV_LAG_TX_TYPE_BROADCAST,
60};
61
62static int __init bc_init_module(void)
63{
64	return team_mode_register(&bc_mode);
65}
66
67static void __exit bc_cleanup_module(void)
68{
69	team_mode_unregister(&bc_mode);
70}
71
72module_init(bc_init_module);
73module_exit(bc_cleanup_module);
74
75MODULE_LICENSE("GPL v2");
76MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>");
77MODULE_DESCRIPTION("Broadcast mode for team");
78MODULE_ALIAS("team-mode-broadcast");