summaryrefslogtreecommitdiffstats
path: root/net/mac802154/iface.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-05-22 17:43:53 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-05-23 17:57:08 +0200
commit344f8c119df742f2bf7098cf8fc326351f583249 (patch)
tree032162247fc24529b2809f4e3a914e66ef836400 /net/mac802154/iface.c
parentmac802154: remove pib lock (diff)
downloadlinux-344f8c119df742f2bf7098cf8fc326351f583249.tar.xz
linux-344f8c119df742f2bf7098cf8fc326351f583249.zip
mac802154: use atomic ops for sequence incrementation
This patch will use atomic operations for sequence number incrementation while MAC header generation. Upper layers like af_802154 or 6LoWPAN could call this function in a parallel context while generating 802.15.4 MAC header before queuing into wpan interfaces transmit queue. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/mac802154/iface.c')
-rw-r--r--net/mac802154/iface.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 22f478be7489..0ec7bc402e29 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -368,7 +368,7 @@ static int mac802154_header_create(struct sk_buff *skb,
hdr.fc.type = cb->type;
hdr.fc.security_enabled = cb->secen;
hdr.fc.ack_request = cb->ackreq;
- hdr.seq = ieee802154_mlme_ops(dev)->get_dsn(dev);
+ hdr.seq = atomic_inc_return(&dev->ieee802154_ptr->dsn) & 0xFF;
if (mac802154_set_header_security(sdata, &hdr, cb) < 0)
return -EINVAL;
@@ -468,13 +468,16 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
enum nl802154_iftype type)
{
struct wpan_dev *wpan_dev = &sdata->wpan_dev;
+ u8 tmp;
/* set some type-dependent values */
sdata->vif.type = type;
sdata->wpan_dev.iftype = type;
- get_random_bytes(&wpan_dev->bsn, 1);
- get_random_bytes(&wpan_dev->dsn, 1);
+ get_random_bytes(&tmp, sizeof(tmp));
+ atomic_set(&wpan_dev->bsn, tmp);
+ get_random_bytes(&tmp, sizeof(tmp));
+ atomic_set(&wpan_dev->dsn, tmp);
/* defaults per 802.15.4-2011 */
wpan_dev->min_be = 3;