diff options
author | Sven Eckelmann <sven.eckelmann@gmx.de> | 2010-09-05 01:58:30 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-09-05 00:29:47 -0700 |
commit | b706007b8903bb3a6ada97665653ba522ae49bb2 (patch) | |
tree | 737bd7b23a427b6437528bbcdd3954d823bafa3f /drivers/staging/batman-adv/aggregation.c | |
parent | 43bfee7693f458e1ef120d2b310ef0288ab747e8 (diff) | |
download | op-kernel-dev-b706007b8903bb3a6ada97665653ba522ae49bb2.zip op-kernel-dev-b706007b8903bb3a6ada97665653ba522ae49bb2.tar.gz |
Staging: batman-adv: Aggregate batman packets directly in skb
All originator messages are send through aggregation buffers. Those
buffers can directly be allocated as skb to reduce the cost of
allocation an extra buffer and copying them to a new allocated skb
directly before it gets send.
Now only the skb must be cloned in case of send_packet_to_if as it gets
called by send_packet for each interface. Non-primary ogms must not
cloned at all because they will only send once and the forward_packet
structure is freed by send_outstanding_bat_packet afterwards.
Reported-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv/aggregation.c')
-rw-r--r-- | drivers/staging/batman-adv/aggregation.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/staging/batman-adv/aggregation.c b/drivers/staging/batman-adv/aggregation.c index d738b7a..5896cf2 100644 --- a/drivers/staging/batman-adv/aggregation.c +++ b/drivers/staging/batman-adv/aggregation.c @@ -39,7 +39,7 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet, struct forw_packet *forw_packet) { struct batman_packet *batman_packet = - (struct batman_packet *)forw_packet->packet_buff; + (struct batman_packet *)forw_packet->skb->data; int aggregated_bytes = forw_packet->packet_len + packet_len; /** @@ -106,6 +106,7 @@ static void new_aggregated_packet(unsigned char *packet_buff, { struct forw_packet *forw_packet_aggr; unsigned long flags; + unsigned char *skb_buff; /* FIXME: each batman_if will be attached to a softif */ struct bat_priv *bat_priv = netdev_priv(soft_device); @@ -125,23 +126,22 @@ static void new_aggregated_packet(unsigned char *packet_buff, return; } - forw_packet_aggr->packet_buff = kmalloc(MAX_AGGREGATION_BYTES, - GFP_ATOMIC); - if (!forw_packet_aggr->packet_buff) { + forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES + + sizeof(struct ethhdr)); + if (!forw_packet_aggr->skb) { if (!own_packet) atomic_inc(&bat_priv->batman_queue_left); kfree(forw_packet_aggr); return; } + skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr)); INIT_HLIST_NODE(&forw_packet_aggr->list); + skb_buff = skb_put(forw_packet_aggr->skb, packet_len); forw_packet_aggr->packet_len = packet_len; - memcpy(forw_packet_aggr->packet_buff, - packet_buff, - forw_packet_aggr->packet_len); + memcpy(skb_buff, packet_buff, packet_len); - forw_packet_aggr->skb = NULL; forw_packet_aggr->own = own_packet; forw_packet_aggr->if_incoming = if_incoming; forw_packet_aggr->num_packets = 0; @@ -171,8 +171,10 @@ static void aggregate(struct forw_packet *forw_packet_aggr, int packet_len, bool direct_link) { - memcpy((forw_packet_aggr->packet_buff + forw_packet_aggr->packet_len), - packet_buff, packet_len); + unsigned char *skb_buff; + + skb_buff = skb_put(forw_packet_aggr->skb, packet_len); + memcpy(skb_buff, packet_buff, packet_len); forw_packet_aggr->packet_len += packet_len; forw_packet_aggr->num_packets++; |