mac802154: add support for perm_extended_addr
authorAlexander Aring <alex.aring@gmail.com>
Wed, 5 Nov 2014 19:51:25 +0000 (20:51 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 5 Nov 2014 20:53:05 +0000 (21:53 +0100)
This patch adding support for a perm extended address. This is useful
when a device supports an eeprom with a programmed static extended address.
If a device doesn't support such eeprom or serial registers then the
driver should generate a random extended address.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/cfg802154.h
net/mac802154/iface.c

index 57333f1ee75c1ae0616e70b760aac10fdc430198..9d99b965576083cc7a20cdec5e848f239d07bada 100644 (file)
@@ -57,6 +57,8 @@ struct wpan_phy {
        u8 csma_retries;
        s8 frame_retries;
 
+       __le64 perm_extended_addr;
+
        bool lbt;
        s32 cca_ed_level;
 
index a1aa09b03d127ddf2c84fd0f890cc7582771b073..97e5bed9f91726682338044d440f5b88cc7b228d 100644 (file)
@@ -410,6 +410,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata, int type)
        /* for compatibility, actual default is 3 */
        sdata->mac_params.frame_retries = -1;
 
+       ieee802154_be64_to_le64(&sdata->extended_addr, sdata->dev->dev_addr);
        sdata->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
        sdata->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
 
@@ -471,6 +472,9 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
                goto err;
        }
 
+       ieee802154_le64_to_be64(ndev->perm_addr,
+                               &local->hw.phy->perm_extended_addr);
+       memcpy(ndev->dev_addr, ndev->perm_addr, IEEE802154_EXTENDED_ADDR_LEN);
        /* TODO check this */
        SET_NETDEV_DEV(ndev, &local->phy->dev);
        sdata = netdev_priv(ndev);