Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87a93e4e authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann
Browse files

ieee802154: change needed headroom/tailroom



This patch cleanups needed_headroom, needed_tailroom and hard_header_len
fields for wpan and lowpan interfaces.

For wpan interfaces the worst case mac header len should be part of
needed_headroom, currently this is set as hard_header_len, but
hard_header_len should be set to the minimum header length which xmit
call assumes and this is the minimum frame length of 802.15.4.
The hard_header_len value will check inside send callbacl of AF_PACKET
raw sockets.

For lowpan interfaces, if fragmentation isn't needed the skb will
call dev_hard_header for 802154 layer and queue it afterwards. This
happens without new skb allocation, so we need the same headroom and
tailroom lengths like 802154 inside 802154 6lowpan layer. At least we
assume as minimum header length an ipv6 header size.

Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 838b83d6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,17 @@
#define IEEE802154_ACK_PSDU_LEN		5
#define IEEE802154_MIN_PSDU_LEN		9
#define IEEE802154_FCS_LEN		2
#define IEEE802154_MAX_AUTH_TAG_LEN	16

/*  General MAC frame format:
 *  2 bytes: Frame Control
 *  1 byte:  Sequence Number
 * 20 bytes: Addressing fields
 * 14 bytes: Auxiliary Security Header
 */
#define IEEE802154_MAX_HEADER_LEN	(2 + 1 + 20 + 14)
#define IEEE802154_MIN_HEADER_LEN	(IEEE802154_ACK_PSDU_LEN - \
					 IEEE802154_FCS_LEN)

#define IEEE802154_PAN_ID_BROADCAST	0xffff
#define IEEE802154_ADDR_SHORT_BROADCAST	0xffff
+8 −0
Original line number Diff line number Diff line
@@ -61,6 +61,14 @@
#define UIP_PROTO_UDP			17 /* ipv6 next header value for UDP */
#define UIP_FRAGH_LEN			8  /* ipv6 fragment header size */

#define LOWPAN_NHC_MAX_ID_LEN	1
/* Max IPHC Header len without IPv6 hdr specific inline data.
 * Useful for getting the "extra" bytes we need at worst case compression.
 *
 * LOWPAN_IPHC + CID + LOWPAN_NHC_MAX_ID_LEN
 */
#define LOWPAN_IPHC_MAX_HEADER_LEN	(2 + 1 + LOWPAN_NHC_MAX_ID_LEN)

/*
 * ipv6 address based on mac
 * second bit-flip (Universe/Local) is done according RFC2464
+0 −8
Original line number Diff line number Diff line
@@ -23,14 +23,6 @@

#include <net/cfg802154.h>

/* General MAC frame format:
 *  2 bytes: Frame Control
 *  1 byte:  Sequence Number
 * 20 bytes: Addressing fields
 * 14 bytes: Auxiliary Security Header
 */
#define MAC802154_FRAME_HARD_HEADER_LEN		(2 + 1 + 20 + 14)

/**
 * enum ieee802154_hw_addr_filt_flags - hardware address filtering flags
 *
+0 −2
Original line number Diff line number Diff line
@@ -8,8 +8,6 @@
#include <net/6lowpan.h>
#include <net/ipv6.h>

#define LOWPAN_NHC_MAX_ID_LEN	1

/**
 * LOWPAN_NHC - helper macro to generate nh id fields and lowpan_nhc struct
 *
+11 −3
Original line number Diff line number Diff line
@@ -104,9 +104,8 @@ static void lowpan_setup(struct net_device *ldev)
	ldev->addr_len		= IEEE802154_ADDR_LEN;
	memset(ldev->broadcast, 0xff, IEEE802154_ADDR_LEN);
	ldev->type		= ARPHRD_6LOWPAN;
	/* Frame Control + Sequence Number + Address fields + Security Header */
	ldev->hard_header_len	= 2 + 1 + 20 + 14;
	ldev->needed_tailroom	= 2; /* FCS */
	/* We need an ipv6hdr as minimum len when calling xmit */
	ldev->hard_header_len	= sizeof(struct ipv6hdr);
	ldev->mtu		= IPV6_MIN_MTU;
	ldev->priv_flags	|= IFF_NO_QUEUE;
	ldev->flags		= IFF_BROADCAST | IFF_MULTICAST;
@@ -156,6 +155,15 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
	lowpan_dev_info(ldev)->wdev = wdev;
	/* Set the lowpan hardware address to the wpan hardware address. */
	memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN);
	/* We need headroom for possible wpan_dev_hard_header call and tailroom
	 * for encryption/fcs handling. The lowpan interface will replace
	 * the IPv6 header with 6LoWPAN header. At worst case the 6LoWPAN
	 * header has LOWPAN_IPHC_MAX_HEADER_LEN more bytes than the IPv6
	 * header.
	 */
	ldev->needed_headroom = LOWPAN_IPHC_MAX_HEADER_LEN +
				wdev->needed_headroom;
	ldev->needed_tailroom = wdev->needed_tailroom;

	lowpan_netdev_setup(ldev, LOWPAN_LLTYPE_IEEE802154);

Loading