Skip to contentSkip to conversation

batman-adv: BATMAN_V: OGMv2 packet aggregation

PATCH Superseded Linus Lüssing 2 participants 7 messages Aug 4, 2019 Batman advanced

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover batman-adv: BATMAN_V: OGMv2 packet aggregation

Hi,

This small patchset implements the transmission side for the OGMv2 packet aggregation in BATMAN_V. The receiver part was already implemented and seems to work nicely.

The first patch implements the necessary queueing mechanism, utilizing skb queues.

The second patch then implements the actual OGMv2 packet aggregation for the queued packets.

Opportunities for later improvements (left out on purpose, to keep this patchset simple):

* Reset queue timer on full queue / if flushing in batadv_v_ogm_queue_on_if():
-> to avoid sending small aggregates in the worker afterwards
* Remove BATADV_MAX_AGGREGATION_BYTES (512 bytes) limitation:
-> not needed for BATMAN_V, would break compatibility though...
(* Increase BATADV_MAX_AGGREGATION_MS (100ms):
-> BATMAN_V has less averaging, therefore could use slower OGM intervals
and therefore slightly larger aggregtion time window)

Regards, Linus

Ref./obsolete: Previous, generic aggregation patchset:
https://patchwork.open-mesh.org/patch/17013/

==

Changelog v2:

* PATCH 1/2:
* added lockdep_assert_held()
* fixed aggr_len kerneldoc in types.h
* fixed alignment in batadv_v_ogm_queue_left()
* added missing includes in bat_v_ogm.{c,h}
* fixed @hard_iface kerneldoc for batadv_v_ogm_aggr_list_free()
* removed unused bat_priv in batadv_v_ogm_aggr_work()
* PATCH 2/2:
* unchanged

#1 lore raw

PATCH v2 1/2 batman-adv: BATMAN_V: introduce per hard-iface OGMv2 queues

In preparation for the OGMv2 packet aggregation, hold OGMv2 packets for up to BATADV_MAX_AGGREGATION_MS milliseconds (100ms) on per hard-interface queues, before transmitting.

This allows us to later squash multiple OGMs into a single frame and transmission for reduced overhead.

---
 net/batman-adv/bat_v.c     |   7 ++
 net/batman-adv/bat_v_ogm.c | 152 ++++++++++++++++++++++++++++++++++++-
 net/batman-adv/bat_v_ogm.h |   3 +
 net/batman-adv/types.h     |  15 ++++
 4 files changed, 175 insertions(+), 2 deletions(-)
net/batman-adv/bat_v.c +7 -0
index 22672cb3..64054edc 100644
@@ -79,6 +79,7 @@ static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
 
 static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
 {
+	batadv_v_ogm_iface_disable(hard_iface);
 	batadv_v_elp_iface_disable(hard_iface);
 }
 
@@ -1081,6 +1082,12 @@ void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
 	 */
 	atomic_set(&hard_iface->bat_v.throughput_override, 0);
 	atomic_set(&hard_iface->bat_v.elp_interval, 500);
+
+	hard_iface->bat_v.aggr_len = 0;
+	skb_queue_head_init(&hard_iface->bat_v.aggr_list);
+	spin_lock_init(&hard_iface->bat_v.aggr_list_lock);
+	INIT_DELAYED_WORK(&hard_iface->bat_v.aggr_wq,
+			  batadv_v_ogm_aggr_work);
 }
 
 /**
net/batman-adv/bat_v_ogm.c +150 -2

199 lines not on this page · raw message

net/batman-adv/bat_v_ogm.h +3 -0
index 2a50df7f..bf16d040 100644
@@ -11,10 +11,13 @@
 
 #include <linux/skbuff.h>
 #include <linux/types.h>
+#include <linux/workqueue.h>
 
 int batadv_v_ogm_init(struct batadv_priv *bat_priv);
 void batadv_v_ogm_free(struct batadv_priv *bat_priv);
+void batadv_v_ogm_aggr_work(struct work_struct *work);
 int batadv_v_ogm_iface_enable(struct batadv_hard_iface *hard_iface);
+void batadv_v_ogm_iface_disable(struct batadv_hard_iface *hard_iface);
 struct batadv_orig_node *batadv_v_ogm_orig_get(struct batadv_priv *bat_priv,
 					       const u8 *addr);
 void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface);
net/batman-adv/types.h +15 -0
index 6ae139d7..3e286e0d 100644
@@ -117,6 +117,21 @@ struct batadv_hard_iface_bat_v {
 	/** @elp_wq: workqueue used to schedule ELP transmissions */
 	struct delayed_work elp_wq;
 
+	/** @aggr_wq: workqueue used to transmit queued OGM packets */
+	struct delayed_work aggr_wq;
+
+	/** @aggr_list: queue for to be aggregated OGM packets */
+	struct sk_buff_head aggr_list;
+
+	/**
+	 * @aggr_len: length of the OGM aggregate (excluding ethernet frame
+	 *  size)
+	 */
+	unsigned int aggr_len;
+
+	/** @aggr_list_lock: protects aggr_list */
+	spinlock_t aggr_list_lock;
+
 	/**
 	 * @throughput_override: throughput override to disable link
 	 *  auto-detection
Signature · 1 line
2.22.0
maintainer
#2 lore raw

Re: [PATCH v2 1/2] batman-adv: BATMAN_V: introduce per hard-iface OGMv2 queues

On Sunday, 4 August 2019 20:06:31 CEST Linus Lüssing wrote:
[...]

net/batman-adv/bat_v_ogm.c line 29

Quoted 12 lines
net/batman-adv/bat_v_ogm.c +1 -0
index fad95ef6..c33041f6 100644
@@ -23,6 +23,7 @@
 #include <linux/rcupdate.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
+#include <linux/spinlock.h>
 #include <linux/stddef.h>
 #include <linux/string.h>
 #include <linux/types.h>

Please also include the <linux/lockdep.h> for lockdep_assert_held(...)

Kind regards,
Sven

maintainer
#3 lore raw

Re: [PATCH v2 1/2] batman-adv: BATMAN_V: introduce per hard-iface OGMv2 queues

In reply to Linus Lüssing

Review

Quoted 2 lines · On Sunday, 4 August 2019 20:06:31 CEST Linus Lüssing wrote:
(quoted diff) +2 -0
+static inline unsigned int batadv_v_ogm_len(struct sk_buff *skb)
+{

Please drop the inline here.

Kind regards,
Sven

maintainer
#4 lore raw

Re: [PATCH v2 1/2] batman-adv: BATMAN_V: introduce per hard-iface OGMv2 queues

In reply to Linus Lüssing

net/batman-adv/types.h struct batadv_hard_iface_bat_v { · line 128

Quoted 2 lines · On Sunday, 4 August 2019 20:06:31 CEST Linus Lüssing wrote:
net/batman-adv/types.h +2 -0
+        * @aggr_len: length of the OGM aggregate (excluding ethernet frame
+        *  size)

Did you really mean "ethernet frame size" here? Not ethernet header size? At least this would match following part of the second patch:

Review

Quoted 5 lines · On Sunday, 4 August 2019 20:06:32 CEST Linus Lüssing wrote:
(quoted diff) +5 -0
+       skb_aggr = dev_alloc_skb(aggr_len + ETH_HLEN + NET_IP_ALIGN);
+       if (!skb_aggr) {
+               batadv_v_ogm_aggr_list_free(hard_iface);
+               return;
+       }

Kind regards,
Sven

#5 lore raw

PATCH v2 2/2 batman-adv: BATMAN_V: aggregate OGMv2 packets

In reply to Linus Lüssing

Instead of transmitting individual OGMv2 packets from the aggregation queue merge those OGMv2 packets into a single one and transmit this aggregate instead.

This reduces overhead as it saves an ethernet header and a transmission per aggregated OGMv2 packet.

---
 net/batman-adv/bat_v_ogm.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
net/batman-adv/bat_v_ogm.c +27 -2
index c33041f6..069fdada 100644
@@ -190,18 +190,43 @@ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface)
  * batadv_v_ogm_aggr_send() - flush & send aggregation queue
  * @hard_iface: the interface with the aggregation queue to flush
  *
+ * Aggregates all OGMv2 packets currently in the aggregation queue into a
+ * single OGMv2 packet and transmits this aggregate.
+ *
+ * The aggregation queue is empty after this call.
+ *
  * Caller needs to hold the hard_iface->bat_v.aggr_list_lock.
  */
 static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface)
 {
-	struct sk_buff *skb;
+	unsigned int aggr_len = hard_iface->bat_v.aggr_len;
+	struct sk_buff *skb, *skb_aggr;
+	unsigned int ogm_len;
 
 	lockdep_assert_held(&hard_iface->bat_v.aggr_list_lock);
 
+	if (!aggr_len)
+		return;
+
+	skb_aggr = dev_alloc_skb(aggr_len + ETH_HLEN + NET_IP_ALIGN);
+	if (!skb_aggr) {
+		batadv_v_ogm_aggr_list_free(hard_iface);
+		return;
+	}
+
+	skb_reserve(skb_aggr, ETH_HLEN + NET_IP_ALIGN);
+	skb_reset_network_header(skb_aggr);
+
 	while ((skb = skb_dequeue(&hard_iface->bat_v.aggr_list))) {
 		hard_iface->bat_v.aggr_len -= batadv_v_ogm_len(skb);
-		batadv_v_ogm_send_to_if(skb, hard_iface);
+
+		ogm_len = batadv_v_ogm_len(skb);
+		skb_put_data(skb_aggr, skb->data, ogm_len);
+
+		consume_skb(skb);
 	}
+
+	batadv_v_ogm_send_to_if(skb_aggr, hard_iface);
 }
 
 /**
Signature · 1 line
2.22.0
maintainer
#6 lore raw

Re: [PATCH v2 2/2] batman-adv: BATMAN_V: aggregate OGMv2 packets

net/batman-adv/bat_v_ogm.c static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface) · line 203

Quoted 5 lines · On Sunday, 4 August 2019 20:06:32 CEST Linus Lüssing wrote:

static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface) {

net/batman-adv/bat_v_ogm.c +2 -1
-       struct sk_buff *skb;
+       unsigned int aggr_len = hard_iface->bat_v.aggr_len;
+       struct sk_buff *skb, *skb_aggr;

Please don't declare multiple variables per line.

Kind regards,
Sven