aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2013-01-25 05:12:38 -0500
committerAntonio Quartulli <ordex@autistici.org>2013-03-13 17:53:48 -0400
commitd353d8d4d9f0184ac43a90c6e04b593c33bd28ea (patch)
treeb38d3477b0daab818b41fbb36664d1f8c0789801 /net/batman-adv
parentc1d07431b9f7fe3c5eb372f3a35d7cd7a18c3b15 (diff)
batman-adv: network coding - add the initial infrastructure code
Network coding exploits the 802.11 shared medium to allow multiple packets to be sent in a single transmission. In brief, a relay can XOR two packets, and send the coded packet to two destinations. The receivers can decode one of the original packets by XOR'ing the coded packet with the other original packet. This will lead to increased throughput in topologies where two packets cross one relay. In a simple topology with three nodes, it takes four transmissions without network coding to get one packet from Node A to Node B and one from Node B to Node A: 1. Node A ---- p1 ---> Node R Node B 2. Node A Node R <--- p2 ---- Node B 3. Node A <--- p2 ---- Node R Node B 4. Node A Node R ---- p1 ---> Node B With network coding, the relay only needs one transmission, which saves us one slot of valuable airtime: 1. Node A ---- p1 ---> Node R Node B 2. Node A Node R <--- p2 ---- Node B 3. Node A <- p1 x p2 - Node R - p1 x p2 -> Node B The same principle holds for a topology including five nodes. Here the packets from Node A and Node B are overheard by Node C and Node D, respectively. This allows Node R to send a network coded packet to save one transmission: Node A Node B | \ / | | p1 p2 | | \ / | p1 > Node R < p2 | | | / \ | | p1 x p2 p1 x p2 | v / \ v / \ Node C < > Node D More information is available on the open-mesh.org wiki[1]. This patch adds the initial code to support network coding in batman-adv. It sets up a worker thread to do house keeping and adds a sysfs file to enable/disable network coding. The feature is disabled by default, as it requires a wifi-driver with working promiscuous mode, and also because it adds a small delay at each hop. [1] http://www.open-mesh.org/projects/batman-adv/wiki/Catwoman Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/Kconfig14
-rw-r--r--net/batman-adv/Makefile1
-rw-r--r--net/batman-adv/main.c6
-rw-r--r--net/batman-adv/main.h4
-rw-r--r--net/batman-adv/network-coding.c81
-rw-r--r--net/batman-adv/network-coding.h48
-rw-r--r--net/batman-adv/soft-interface.c3
-rw-r--r--net/batman-adv/sysfs.c6
-rw-r--r--net/batman-adv/types.h14
9 files changed, 176 insertions, 1 deletions
diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index 8d8afb134b3a..fa780b76630e 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -36,6 +36,20 @@ config BATMAN_ADV_DAT
36 mesh networks. If you think that your network does not need 36 mesh networks. If you think that your network does not need
37 this option you can safely remove it and save some space. 37 this option you can safely remove it and save some space.
38 38
39config BATMAN_ADV_NC
40 bool "Network Coding"
41 depends on BATMAN_ADV
42 default n
43 help
44 This option enables network coding, a mechanism that aims to
45 increase the overall network throughput by fusing multiple
46 packets in one transmission.
47 Note that interfaces controlled by batman-adv must be manually
48 configured to have promiscuous mode enabled in order to make
49 network coding work.
50 If you think that your network does not need this feature you
51 can safely disable it and save some space.
52
39config BATMAN_ADV_DEBUG 53config BATMAN_ADV_DEBUG
40 bool "B.A.T.M.A.N. debugging" 54 bool "B.A.T.M.A.N. debugging"
41 depends on BATMAN_ADV 55 depends on BATMAN_ADV
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index e45e3b4e32e3..4b8f192a9e43 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -30,6 +30,7 @@ batman-adv-y += hard-interface.o
30batman-adv-y += hash.o 30batman-adv-y += hash.o
31batman-adv-y += icmp_socket.o 31batman-adv-y += icmp_socket.o
32batman-adv-y += main.o 32batman-adv-y += main.o
33batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
33batman-adv-y += originator.o 34batman-adv-y += originator.o
34batman-adv-y += ring_buffer.o 35batman-adv-y += ring_buffer.o
35batman-adv-y += routing.o 36batman-adv-y += routing.o
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 0488d70c8c35..0495a7dc7505 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -35,6 +35,7 @@
35#include "vis.h" 35#include "vis.h"
36#include "hash.h" 36#include "hash.h"
37#include "bat_algo.h" 37#include "bat_algo.h"
38#include "network-coding.h"
38 39
39 40
40/* List manipulations on hardif_list have to be rtnl_lock()'ed, 41/* List manipulations on hardif_list have to be rtnl_lock()'ed,
@@ -135,6 +136,10 @@ int batadv_mesh_init(struct net_device *soft_iface)
135 if (ret < 0) 136 if (ret < 0)
136 goto err; 137 goto err;
137 138
139 ret = batadv_nc_init(bat_priv);
140 if (ret < 0)
141 goto err;
142
138 atomic_set(&bat_priv->gw.reselect, 0); 143 atomic_set(&bat_priv->gw.reselect, 0);
139 atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE); 144 atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
140 145
@@ -157,6 +162,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
157 162
158 batadv_gw_node_purge(bat_priv); 163 batadv_gw_node_purge(bat_priv);
159 batadv_originator_free(bat_priv); 164 batadv_originator_free(bat_priv);
165 batadv_nc_free(bat_priv);
160 166
161 batadv_tt_free(bat_priv); 167 batadv_tt_free(bat_priv);
162 168
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index ced08b936a96..59ba2ff8e252 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -185,6 +185,7 @@ __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
185 * @BATADV_DBG_TT: translation table messages 185 * @BATADV_DBG_TT: translation table messages
186 * @BATADV_DBG_BLA: bridge loop avoidance messages 186 * @BATADV_DBG_BLA: bridge loop avoidance messages
187 * @BATADV_DBG_DAT: ARP snooping and DAT related messages 187 * @BATADV_DBG_DAT: ARP snooping and DAT related messages
188 * @BATADV_DBG_NC: network coding related messages
188 * @BATADV_DBG_ALL: the union of all the above log levels 189 * @BATADV_DBG_ALL: the union of all the above log levels
189 */ 190 */
190enum batadv_dbg_level { 191enum batadv_dbg_level {
@@ -193,7 +194,8 @@ enum batadv_dbg_level {
193 BATADV_DBG_TT = BIT(2), 194 BATADV_DBG_TT = BIT(2),
194 BATADV_DBG_BLA = BIT(3), 195 BATADV_DBG_BLA = BIT(3),
195 BATADV_DBG_DAT = BIT(4), 196 BATADV_DBG_DAT = BIT(4),
196 BATADV_DBG_ALL = 31, 197 BATADV_DBG_NC = BIT(5),
198 BATADV_DBG_ALL = 63,
197}; 199};
198 200
199#ifdef CONFIG_BATMAN_ADV_DEBUG 201#ifdef CONFIG_BATMAN_ADV_DEBUG
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
new file mode 100644
index 000000000000..9c2d54bdd2ce
--- /dev/null
+++ b/net/batman-adv/network-coding.c
@@ -0,0 +1,81 @@
1/* Copyright (C) 2012-2013 B.A.T.M.A.N. contributors:
2 *
3 * Martin Hundebøll, Jeppe Ledet-Pedersen
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA
18 */
19
20#include "main.h"
21#include "network-coding.h"
22
23static void batadv_nc_worker(struct work_struct *work);
24
25/**
26 * batadv_nc_start_timer - initialise the nc periodic worker
27 * @bat_priv: the bat priv with all the soft interface information
28 */
29static void batadv_nc_start_timer(struct batadv_priv *bat_priv)
30{
31 queue_delayed_work(batadv_event_workqueue, &bat_priv->nc.work,
32 msecs_to_jiffies(10));
33}
34
35/**
36 * batadv_nc_init - initialise coding hash table and start house keeping
37 * @bat_priv: the bat priv with all the soft interface information
38 */
39int batadv_nc_init(struct batadv_priv *bat_priv)
40{
41 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker);
42 batadv_nc_start_timer(bat_priv);
43
44 return 0;
45}
46
47/**
48 * batadv_nc_init_bat_priv - initialise the nc specific bat_priv variables
49 * @bat_priv: the bat priv with all the soft interface information
50 */
51void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv)
52{
53 atomic_set(&bat_priv->network_coding, 1);
54}
55
56/**
57 * batadv_nc_worker - periodic task for house keeping related to network coding
58 * @work: kernel work struct
59 */
60static void batadv_nc_worker(struct work_struct *work)
61{
62 struct delayed_work *delayed_work;
63 struct batadv_priv_nc *priv_nc;
64 struct batadv_priv *bat_priv;
65
66 delayed_work = container_of(work, struct delayed_work, work);
67 priv_nc = container_of(delayed_work, struct batadv_priv_nc, work);
68 bat_priv = container_of(priv_nc, struct batadv_priv, nc);
69
70 /* Schedule a new check */
71 batadv_nc_start_timer(bat_priv);
72}
73
74/**
75 * batadv_nc_free - clean up network coding memory
76 * @bat_priv: the bat priv with all the soft interface information
77 */
78void batadv_nc_free(struct batadv_priv *bat_priv)
79{
80 cancel_delayed_work_sync(&bat_priv->nc.work);
81}
diff --git a/net/batman-adv/network-coding.h b/net/batman-adv/network-coding.h
new file mode 100644
index 000000000000..7483cba4b5d4
--- /dev/null
+++ b/net/batman-adv/network-coding.h
@@ -0,0 +1,48 @@
1/* Copyright (C) 2012-2013 B.A.T.M.A.N. contributors:
2 *
3 * Martin Hundebøll, Jeppe Ledet-Pedersen
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA
18 */
19
20#ifndef _NET_BATMAN_ADV_NETWORK_CODING_H_
21#define _NET_BATMAN_ADV_NETWORK_CODING_H_
22
23#ifdef CONFIG_BATMAN_ADV_NC
24
25int batadv_nc_init(struct batadv_priv *bat_priv);
26void batadv_nc_free(struct batadv_priv *bat_priv);
27void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv);
28
29#else /* ifdef CONFIG_BATMAN_ADV_NC */
30
31static inline int batadv_nc_init(struct batadv_priv *bat_priv)
32{
33 return 0;
34}
35
36static inline void batadv_nc_free(struct batadv_priv *bat_priv)
37{
38 return;
39}
40
41static inline void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv)
42{
43 return;
44}
45
46#endif /* ifdef CONFIG_BATMAN_ADV_NC */
47
48#endif /* _NET_BATMAN_ADV_NETWORK_CODING_H_ */
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 2711e870f557..7188e07dfc6f 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -37,6 +37,7 @@
37#include <linux/if_ether.h> 37#include <linux/if_ether.h>
38#include "unicast.h" 38#include "unicast.h"
39#include "bridge_loop_avoidance.h" 39#include "bridge_loop_avoidance.h"
40#include "network-coding.h"
40 41
41 42
42static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); 43static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
@@ -544,6 +545,8 @@ struct net_device *batadv_softif_create(const char *name)
544 if (ret < 0) 545 if (ret < 0)
545 goto unreg_soft_iface; 546 goto unreg_soft_iface;
546 547
548 batadv_nc_init_bat_priv(bat_priv);
549
547 ret = batadv_sysfs_add_meshif(soft_iface); 550 ret = batadv_sysfs_add_meshif(soft_iface);
548 if (ret < 0) 551 if (ret < 0)
549 goto unreg_soft_iface; 552 goto unreg_soft_iface;
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 6a44fed12837..ce39f62f751e 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -442,6 +442,9 @@ static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
442#ifdef CONFIG_BATMAN_ADV_DEBUG 442#ifdef CONFIG_BATMAN_ADV_DEBUG
443BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); 443BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL);
444#endif 444#endif
445#ifdef CONFIG_BATMAN_ADV_NC
446BATADV_ATTR_SIF_BOOL(network_coding, S_IRUGO | S_IWUSR, NULL);
447#endif
445 448
446static struct batadv_attribute *batadv_mesh_attrs[] = { 449static struct batadv_attribute *batadv_mesh_attrs[] = {
447 &batadv_attr_aggregated_ogms, 450 &batadv_attr_aggregated_ogms,
@@ -464,6 +467,9 @@ static struct batadv_attribute *batadv_mesh_attrs[] = {
464#ifdef CONFIG_BATMAN_ADV_DEBUG 467#ifdef CONFIG_BATMAN_ADV_DEBUG
465 &batadv_attr_log_level, 468 &batadv_attr_log_level,
466#endif 469#endif
470#ifdef CONFIG_BATMAN_ADV_NC
471 &batadv_attr_network_coding,
472#endif
467 NULL, 473 NULL,
468}; 474};
469 475
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 4cd87a0b5b80..83bfe7c38f81 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -428,6 +428,14 @@ struct batadv_priv_dat {
428#endif 428#endif
429 429
430/** 430/**
431 * struct batadv_priv_nc - per mesh interface network coding private data
432 * @work: work queue callback item for cleanup
433 */
434struct batadv_priv_nc {
435 struct delayed_work work;
436};
437
438/**
431 * struct batadv_priv - per mesh interface data 439 * struct batadv_priv - per mesh interface data
432 * @mesh_state: current status of the mesh (inactive/active/deactivating) 440 * @mesh_state: current status of the mesh (inactive/active/deactivating)
433 * @soft_iface: net device which holds this struct as private data 441 * @soft_iface: net device which holds this struct as private data
@@ -470,6 +478,8 @@ struct batadv_priv_dat {
470 * @tt: translation table data 478 * @tt: translation table data
471 * @vis: vis data 479 * @vis: vis data
472 * @dat: distributed arp table data 480 * @dat: distributed arp table data
481 * @network_coding: bool indicating whether network coding is enabled
482 * @batadv_priv_nc: network coding data
473 */ 483 */
474struct batadv_priv { 484struct batadv_priv {
475 atomic_t mesh_state; 485 atomic_t mesh_state;
@@ -522,6 +532,10 @@ struct batadv_priv {
522#ifdef CONFIG_BATMAN_ADV_DAT 532#ifdef CONFIG_BATMAN_ADV_DAT
523 struct batadv_priv_dat dat; 533 struct batadv_priv_dat dat;
524#endif 534#endif
535#ifdef CONFIG_BATMAN_ADV_NC
536 atomic_t network_coding;
537 struct batadv_priv_nc nc;
538#endif /* CONFIG_BATMAN_ADV_NC */
525}; 539};
526 540
527/** 541/**