Commit 2e4d60cb authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

6lowpan: change naming for lowpan private data

This patch changes the naming for interface private data for lowpan
intefaces. The current private data scheme is:

-------------------------------------------------
|    6LoWPAN Generic   |    LinkLayer 6LoWPAN   |
-------------------------------------------------

the current naming schemes are:

- 6LoWPAN Generic:
  - lowpan_priv
- LinkLayer 6LoWPAN:
  - BTLE
    - lowpan_dev
  - 802.15.4:
    - lowpan_dev_info

the new naming scheme with this patch will be:

- 6LoWPAN Generic:
  - lowpan_dev
- LinkLayer 6LoWPAN:
  - BTLE
    - lowpan_btle_dev
  - 802.15.4:
    - lowpan_802154_dev
Signed-off-by: default avatarAlexander Aring <aar@pengutronix.de>
Reviewed-by: Stefan Schmidt<stefan@osg.samsung.com>
Acked-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 5a7f97e5
...@@ -93,7 +93,7 @@ static inline bool lowpan_is_iphc(u8 dispatch) ...@@ -93,7 +93,7 @@ static inline bool lowpan_is_iphc(u8 dispatch)
} }
#define LOWPAN_PRIV_SIZE(llpriv_size) \ #define LOWPAN_PRIV_SIZE(llpriv_size) \
(sizeof(struct lowpan_priv) + llpriv_size) (sizeof(struct lowpan_dev) + llpriv_size)
enum lowpan_lltypes { enum lowpan_lltypes {
LOWPAN_LLTYPE_BTLE, LOWPAN_LLTYPE_BTLE,
...@@ -129,7 +129,7 @@ lowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx *ctx) ...@@ -129,7 +129,7 @@ lowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx *ctx)
return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags); return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
} }
struct lowpan_priv { struct lowpan_dev {
enum lowpan_lltypes lltype; enum lowpan_lltypes lltype;
struct dentry *iface_debugfs; struct dentry *iface_debugfs;
struct lowpan_iphc_ctx_table ctx; struct lowpan_iphc_ctx_table ctx;
...@@ -139,7 +139,7 @@ struct lowpan_priv { ...@@ -139,7 +139,7 @@ struct lowpan_priv {
}; };
static inline static inline
struct lowpan_priv *lowpan_priv(const struct net_device *dev) struct lowpan_dev *lowpan_dev(const struct net_device *dev)
{ {
return netdev_priv(dev); return netdev_priv(dev);
} }
......
...@@ -27,11 +27,11 @@ int lowpan_register_netdevice(struct net_device *dev, ...@@ -27,11 +27,11 @@ int lowpan_register_netdevice(struct net_device *dev,
dev->mtu = IPV6_MIN_MTU; dev->mtu = IPV6_MIN_MTU;
dev->priv_flags |= IFF_NO_QUEUE; dev->priv_flags |= IFF_NO_QUEUE;
lowpan_priv(dev)->lltype = lltype; lowpan_dev(dev)->lltype = lltype;
spin_lock_init(&lowpan_priv(dev)->ctx.lock); spin_lock_init(&lowpan_dev(dev)->ctx.lock);
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
lowpan_priv(dev)->ctx.table[i].id = i; lowpan_dev(dev)->ctx.table[i].id = i;
ret = register_netdevice(dev); ret = register_netdevice(dev);
if (ret < 0) if (ret < 0)
...@@ -85,7 +85,7 @@ static int lowpan_event(struct notifier_block *unused, ...@@ -85,7 +85,7 @@ static int lowpan_event(struct notifier_block *unused,
case NETDEV_DOWN: case NETDEV_DOWN:
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE, clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE,
&lowpan_priv(dev)->ctx.table[i].flags); &lowpan_dev(dev)->ctx.table[i].flags);
break; break;
default: default:
return NOTIFY_DONE; return NOTIFY_DONE;
......
...@@ -172,7 +172,7 @@ static const struct file_operations lowpan_ctx_pfx_fops = { ...@@ -172,7 +172,7 @@ static const struct file_operations lowpan_ctx_pfx_fops = {
static int lowpan_dev_debugfs_ctx_init(struct net_device *dev, static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
struct dentry *ctx, u8 id) struct dentry *ctx, u8 id)
{ {
struct lowpan_priv *lpriv = lowpan_priv(dev); struct lowpan_dev *ldev = lowpan_dev(dev);
struct dentry *dentry, *root; struct dentry *dentry, *root;
char buf[32]; char buf[32];
...@@ -185,25 +185,25 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev, ...@@ -185,25 +185,25 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
return -EINVAL; return -EINVAL;
dentry = debugfs_create_file("active", 0644, root, dentry = debugfs_create_file("active", 0644, root,
&lpriv->ctx.table[id], &ldev->ctx.table[id],
&lowpan_ctx_flag_active_fops); &lowpan_ctx_flag_active_fops);
if (!dentry) if (!dentry)
return -EINVAL; return -EINVAL;
dentry = debugfs_create_file("compression", 0644, root, dentry = debugfs_create_file("compression", 0644, root,
&lpriv->ctx.table[id], &ldev->ctx.table[id],
&lowpan_ctx_flag_c_fops); &lowpan_ctx_flag_c_fops);
if (!dentry) if (!dentry)
return -EINVAL; return -EINVAL;
dentry = debugfs_create_file("prefix", 0644, root, dentry = debugfs_create_file("prefix", 0644, root,
&lpriv->ctx.table[id], &ldev->ctx.table[id],
&lowpan_ctx_pfx_fops); &lowpan_ctx_pfx_fops);
if (!dentry) if (!dentry)
return -EINVAL; return -EINVAL;
dentry = debugfs_create_file("prefix_len", 0644, root, dentry = debugfs_create_file("prefix_len", 0644, root,
&lpriv->ctx.table[id], &ldev->ctx.table[id],
&lowpan_ctx_plen_fops); &lowpan_ctx_plen_fops);
if (!dentry) if (!dentry)
return -EINVAL; return -EINVAL;
...@@ -247,21 +247,21 @@ static const struct file_operations lowpan_context_fops = { ...@@ -247,21 +247,21 @@ static const struct file_operations lowpan_context_fops = {
int lowpan_dev_debugfs_init(struct net_device *dev) int lowpan_dev_debugfs_init(struct net_device *dev)
{ {
struct lowpan_priv *lpriv = lowpan_priv(dev); struct lowpan_dev *ldev = lowpan_dev(dev);
struct dentry *contexts, *dentry; struct dentry *contexts, *dentry;
int ret, i; int ret, i;
/* creating the root */ /* creating the root */
lpriv->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs); ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
if (!lpriv->iface_debugfs) if (!ldev->iface_debugfs)
goto fail; goto fail;
contexts = debugfs_create_dir("contexts", lpriv->iface_debugfs); contexts = debugfs_create_dir("contexts", ldev->iface_debugfs);
if (!contexts) if (!contexts)
goto remove_root; goto remove_root;
dentry = debugfs_create_file("show", 0644, contexts, dentry = debugfs_create_file("show", 0644, contexts,
&lowpan_priv(dev)->ctx, &lowpan_dev(dev)->ctx,
&lowpan_context_fops); &lowpan_context_fops);
if (!dentry) if (!dentry)
goto remove_root; goto remove_root;
...@@ -282,7 +282,7 @@ int lowpan_dev_debugfs_init(struct net_device *dev) ...@@ -282,7 +282,7 @@ int lowpan_dev_debugfs_init(struct net_device *dev)
void lowpan_dev_debugfs_exit(struct net_device *dev) void lowpan_dev_debugfs_exit(struct net_device *dev)
{ {
debugfs_remove_recursive(lowpan_priv(dev)->iface_debugfs); debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs);
} }
int __init lowpan_debugfs_init(void) int __init lowpan_debugfs_init(void)
......
...@@ -207,7 +207,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr, ...@@ -207,7 +207,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
static struct lowpan_iphc_ctx * static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_id(const struct net_device *dev, u8 id) lowpan_iphc_ctx_get_by_id(const struct net_device *dev, u8 id)
{ {
struct lowpan_iphc_ctx *ret = &lowpan_priv(dev)->ctx.table[id]; struct lowpan_iphc_ctx *ret = &lowpan_dev(dev)->ctx.table[id];
if (!lowpan_iphc_ctx_is_active(ret)) if (!lowpan_iphc_ctx_is_active(ret))
return NULL; return NULL;
...@@ -219,7 +219,7 @@ static struct lowpan_iphc_ctx * ...@@ -219,7 +219,7 @@ static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_addr(const struct net_device *dev, lowpan_iphc_ctx_get_by_addr(const struct net_device *dev,
const struct in6_addr *addr) const struct in6_addr *addr)
{ {
struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table; struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
struct lowpan_iphc_ctx *ret = NULL; struct lowpan_iphc_ctx *ret = NULL;
struct in6_addr addr_pfx; struct in6_addr addr_pfx;
u8 addr_plen; u8 addr_plen;
...@@ -263,7 +263,7 @@ static struct lowpan_iphc_ctx * ...@@ -263,7 +263,7 @@ static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev, lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
const struct in6_addr *addr) const struct in6_addr *addr)
{ {
struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table; struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
struct lowpan_iphc_ctx *ret = NULL; struct lowpan_iphc_ctx *ret = NULL;
struct in6_addr addr_mcast, network_pfx = {}; struct in6_addr addr_mcast, network_pfx = {};
int i; int i;
...@@ -332,7 +332,7 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev, ...@@ -332,7 +332,7 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
case LOWPAN_IPHC_SAM_11: case LOWPAN_IPHC_SAM_11:
case LOWPAN_IPHC_DAM_11: case LOWPAN_IPHC_DAM_11:
fail = false; fail = false;
switch (lowpan_priv(dev)->lltype) { switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154: case LOWPAN_LLTYPE_IEEE802154:
iphc_uncompress_802154_lladdr(ipaddr, lladdr); iphc_uncompress_802154_lladdr(ipaddr, lladdr);
break; break;
...@@ -393,7 +393,7 @@ static int uncompress_ctx_addr(struct sk_buff *skb, ...@@ -393,7 +393,7 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
case LOWPAN_IPHC_SAM_11: case LOWPAN_IPHC_SAM_11:
case LOWPAN_IPHC_DAM_11: case LOWPAN_IPHC_DAM_11:
fail = false; fail = false;
switch (lowpan_priv(dev)->lltype) { switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154: case LOWPAN_LLTYPE_IEEE802154:
iphc_uncompress_802154_lladdr(ipaddr, lladdr); iphc_uncompress_802154_lladdr(ipaddr, lladdr);
break; break;
...@@ -657,17 +657,17 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -657,17 +657,17 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
} }
if (iphc1 & LOWPAN_IPHC_SAC) { if (iphc1 & LOWPAN_IPHC_SAC) {
spin_lock_bh(&lowpan_priv(dev)->ctx.lock); spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_SCI(cid)); ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_SCI(cid));
if (!ci) { if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL; return -EINVAL;
} }
pr_debug("SAC bit is set. Handle context based source address.\n"); pr_debug("SAC bit is set. Handle context based source address.\n");
err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr, err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
iphc1 & LOWPAN_IPHC_SAM_MASK, saddr); iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
} else { } else {
/* Source address uncompression */ /* Source address uncompression */
pr_debug("source address stateless compression\n"); pr_debug("source address stateless compression\n");
...@@ -681,10 +681,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -681,10 +681,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
switch (iphc1 & (LOWPAN_IPHC_M | LOWPAN_IPHC_DAC)) { switch (iphc1 & (LOWPAN_IPHC_M | LOWPAN_IPHC_DAC)) {
case LOWPAN_IPHC_M | LOWPAN_IPHC_DAC: case LOWPAN_IPHC_M | LOWPAN_IPHC_DAC:
spin_lock_bh(&lowpan_priv(dev)->ctx.lock); spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid)); ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid));
if (!ci) { if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL; return -EINVAL;
} }
...@@ -693,7 +693,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -693,7 +693,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
err = lowpan_uncompress_multicast_ctx_daddr(skb, ci, err = lowpan_uncompress_multicast_ctx_daddr(skb, ci,
&hdr.daddr, &hdr.daddr,
iphc1 & LOWPAN_IPHC_DAM_MASK); iphc1 & LOWPAN_IPHC_DAM_MASK);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
break; break;
case LOWPAN_IPHC_M: case LOWPAN_IPHC_M:
/* multicast */ /* multicast */
...@@ -701,10 +701,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -701,10 +701,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
iphc1 & LOWPAN_IPHC_DAM_MASK); iphc1 & LOWPAN_IPHC_DAM_MASK);
break; break;
case LOWPAN_IPHC_DAC: case LOWPAN_IPHC_DAC:
spin_lock_bh(&lowpan_priv(dev)->ctx.lock); spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid)); ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid));
if (!ci) { if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL; return -EINVAL;
} }
...@@ -712,7 +712,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -712,7 +712,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
pr_debug("DAC bit is set. Handle context based destination address.\n"); pr_debug("DAC bit is set. Handle context based destination address.\n");
err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr, err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
iphc1 & LOWPAN_IPHC_DAM_MASK, daddr); iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
break; break;
default: default:
err = uncompress_addr(skb, dev, &hdr.daddr, err = uncompress_addr(skb, dev, &hdr.daddr,
...@@ -736,7 +736,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, ...@@ -736,7 +736,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
return err; return err;
} }
switch (lowpan_priv(dev)->lltype) { switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154: case LOWPAN_LLTYPE_IEEE802154:
if (lowpan_802154_cb(skb)->d_size) if (lowpan_802154_cb(skb)->d_size)
hdr.payload_len = htons(lowpan_802154_cb(skb)->d_size - hdr.payload_len = htons(lowpan_802154_cb(skb)->d_size -
...@@ -1033,7 +1033,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, ...@@ -1033,7 +1033,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
skb->data, skb->len); skb->data, skb->len);
ipv6_daddr_type = ipv6_addr_type(&hdr->daddr); ipv6_daddr_type = ipv6_addr_type(&hdr->daddr);
spin_lock_bh(&lowpan_priv(dev)->ctx.lock); spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
if (ipv6_daddr_type & IPV6_ADDR_MULTICAST) if (ipv6_daddr_type & IPV6_ADDR_MULTICAST)
dci = lowpan_iphc_ctx_get_by_mcast_addr(dev, &hdr->daddr); dci = lowpan_iphc_ctx_get_by_mcast_addr(dev, &hdr->daddr);
else else
...@@ -1042,15 +1042,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, ...@@ -1042,15 +1042,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
memcpy(&dci_entry, dci, sizeof(*dci)); memcpy(&dci_entry, dci, sizeof(*dci));
cid |= dci->id; cid |= dci->id;
} }
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
spin_lock_bh(&lowpan_priv(dev)->ctx.lock); spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
sci = lowpan_iphc_ctx_get_by_addr(dev, &hdr->saddr); sci = lowpan_iphc_ctx_get_by_addr(dev, &hdr->saddr);
if (sci) { if (sci) {
memcpy(&sci_entry, sci, sizeof(*sci)); memcpy(&sci_entry, sci, sizeof(*sci));
cid |= (sci->id << 4); cid |= (sci->id << 4);
} }
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock); spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
/* if cid is zero it will be compressed */ /* if cid is zero it will be compressed */
if (cid) { if (cid) {
......
...@@ -91,7 +91,7 @@ static int udp_uncompress(struct sk_buff *skb, size_t needed) ...@@ -91,7 +91,7 @@ static int udp_uncompress(struct sk_buff *skb, size_t needed)
* here, we obtain the hint from the remaining size of the * here, we obtain the hint from the remaining size of the
* frame * frame
*/ */
switch (lowpan_priv(skb->dev)->lltype) { switch (lowpan_dev(skb->dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154: case LOWPAN_LLTYPE_IEEE802154:
if (lowpan_802154_cb(skb)->d_size) if (lowpan_802154_cb(skb)->d_size)
uh.len = htons(lowpan_802154_cb(skb)->d_size - uh.len = htons(lowpan_802154_cb(skb)->d_size -
......
...@@ -68,7 +68,7 @@ struct lowpan_peer { ...@@ -68,7 +68,7 @@ struct lowpan_peer {
struct in6_addr peer_addr; struct in6_addr peer_addr;
}; };
struct lowpan_dev { struct lowpan_btle_dev {
struct list_head list; struct list_head list;
struct hci_dev *hdev; struct hci_dev *hdev;
...@@ -80,18 +80,21 @@ struct lowpan_dev { ...@@ -80,18 +80,21 @@ struct lowpan_dev {
struct delayed_work notify_peers; struct delayed_work notify_peers;
}; };
static inline struct lowpan_dev *lowpan_dev(const struct net_device *netdev) static inline struct lowpan_btle_dev *
lowpan_btle_dev(const struct net_device *netdev)
{ {
return (struct lowpan_dev *)lowpan_priv(netdev)->priv; return (struct lowpan_btle_dev *)lowpan_dev(netdev)->priv;
} }
static inline void peer_add(struct lowpan_dev *dev, struct lowpan_peer *peer) static inline void peer_add(struct lowpan_btle_dev *dev,
struct lowpan_peer *peer)
{ {
list_add_rcu(&peer->list, &dev->peers); list_add_rcu(&peer->list, &dev->peers);
atomic_inc(&dev->peer_count); atomic_inc(&dev->peer_count);
} }
static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer) static inline bool peer_del(struct lowpan_btle_dev *dev,
struct lowpan_peer *peer)
{ {
list_del_rcu(&peer->list); list_del_rcu(&peer->list);
kfree_rcu(peer, rcu); kfree_rcu(peer, rcu);
...@@ -106,7 +109,7 @@ static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer) ...@@ -106,7 +109,7 @@ static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer)
return false; return false;
} }
static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev, static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_btle_dev *dev,
bdaddr_t *ba, __u8 type) bdaddr_t *ba, __u8 type)
{ {
struct lowpan_peer *peer; struct lowpan_peer *peer;
...@@ -134,8 +137,8 @@ static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev, ...@@ -134,8 +137,8 @@ static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev,
return NULL; return NULL;
} }
static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev, static inline struct lowpan_peer *
struct l2cap_chan *chan) __peer_lookup_chan(struct lowpan_btle_dev *dev, struct l2cap_chan *chan)
{ {
struct lowpan_peer *peer; struct lowpan_peer *peer;
...@@ -147,8 +150,8 @@ static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev, ...@@ -147,8 +150,8 @@ static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev,
return NULL; return NULL;
} }
static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev, static inline struct lowpan_peer *
struct l2cap_conn *conn) __peer_lookup_conn(struct lowpan_btle_dev *dev, struct l2cap_conn *conn)
{ {
struct lowpan_peer *peer; struct lowpan_peer *peer;
...@@ -160,7 +163,7 @@ static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev, ...@@ -160,7 +163,7 @@ static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev,
return NULL; return NULL;
} }
static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev, static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_btle_dev *dev,
struct in6_addr *daddr, struct in6_addr *daddr,
struct sk_buff *skb) struct sk_buff *skb)
{ {
...@@ -220,7 +223,7 @@ static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev, ...@@ -220,7 +223,7 @@ static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev,
static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn) static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn)
{ {
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
struct lowpan_peer *peer = NULL; struct lowpan_peer *peer = NULL;
rcu_read_lock(); rcu_read_lock();
...@@ -236,10 +239,10 @@ static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn) ...@@ -236,10 +239,10 @@ static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn)
return peer; return peer;
} }
static struct lowpan_dev *lookup_dev(struct l2cap_conn *conn) static struct lowpan_btle_dev *lookup_dev(struct l2cap_conn *conn)
{ {
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
struct lowpan_dev *dev = NULL; struct lowpan_btle_dev *dev = NULL;
rcu_read_lock(); rcu_read_lock();
...@@ -270,10 +273,10 @@ static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, ...@@ -270,10 +273,10 @@ static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev,
struct l2cap_chan *chan) struct l2cap_chan *chan)
{ {
const u8 *saddr, *daddr; const u8 *saddr, *daddr;
struct lowpan_dev *dev; struct lowpan_btle_dev *dev;
struct lowpan_peer *peer; struct lowpan_peer *peer;
dev = lowpan_dev(netdev); dev = lowpan_btle_dev(netdev);
rcu_read_lock(); rcu_read_lock();
peer = __peer_lookup_chan(dev, chan); peer = __peer_lookup_chan(dev, chan);
...@@ -375,7 +378,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, ...@@ -375,7 +378,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
/* Packet from BT LE device */ /* Packet from BT LE device */
static int chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) static int chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
{ {
struct lowpan_dev *dev; struct lowpan_btle_dev *dev;
struct lowpan_peer *peer; struct lowpan_peer *peer;
int err; int err;
...@@ -431,13 +434,13 @@ static int setup_header(struct sk_buff *skb, struct net_device *netdev, ...@@ -431,13 +434,13 @@ static int setup_header(struct sk_buff *skb, struct net_device *netdev,
bdaddr_t *peer_addr, u8 *peer_addr_type) bdaddr_t *peer_addr, u8 *peer_addr_type)
{ {
struct in6_addr ipv6_daddr; struct in6_addr ipv6_daddr;
struct lowpan_dev *dev; struct lowpan_btle_dev *dev;
struct lowpan_peer *peer; struct lowpan_peer *peer;
bdaddr_t addr, *any = BDADDR_ANY; bdaddr_t addr, *any = BDADDR_ANY;
u8 *daddr = any->b; u8 *daddr = any->b;
int err, status = 0; int err, status = 0;
dev = lowpan_dev(netdev); dev = lowpan_btle_dev(netdev);
memcpy(&ipv6_daddr, &lowpan_cb(skb)->addr, sizeof(ipv6_daddr)); memcpy(&ipv6_daddr, &lowpan_cb(skb)->addr, sizeof(ipv6_daddr));
...@@ -543,19 +546,19 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb, ...@@ -543,19 +546,19 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev) static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev)
{ {
struct sk_buff *local_skb; struct sk_buff *local_skb;
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
int err = 0; int err = 0;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
struct lowpan_peer *pentry; struct lowpan_peer *pentry;
struct lowpan_dev *dev; struct lowpan_btle_dev *dev;
if (entry->netdev != netdev) if (entry->netdev != netdev)
continue; continue;
dev = lowpan_dev(entry->netdev); dev = lowpan_btle_dev(entry->netdev);
list_for_each_entry_rcu(pentry, &dev->peers, list) { list_for_each_entry_rcu(pentry, &dev->peers, list) {
int ret; int ret;
...@@ -723,7 +726,7 @@ static void ifdown(struct net_device *netdev) ...@@ -723,7 +726,7 @@ static void ifdown(struct net_device *netdev)
static void do_notify_peers(struct work_struct *work) static void do_notify_peers(struct work_struct *work)
{ {
struct lowpan_dev *dev = container_of(work, struct lowpan_dev, struct lowpan_btle_dev *dev = container_of(work, struct lowpan_btle_dev,
notify_peers.work); notify_peers.work);
netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */ netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */
...@@ -766,7 +769,7 @@ static void set_ip_addr_bits(u8 addr_type, u8 *addr) ...@@ -766,7 +769,7 @@ static void set_ip_addr_bits(u8 addr_type, u8 *addr)
} }
static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan, static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
struct lowpan_dev *dev) struct lowpan_btle_dev *dev)
{ {
struct lowpan_peer *peer; struct lowpan_peer *peer;
...@@ -803,12 +806,12 @@ static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan, ...@@ -803,12 +806,12 @@ static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
return peer->chan; return peer->chan;
} }
static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev) static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)
{ {
struct net_device *netdev; struct net_device *netdev;
int err = 0; int err = 0;
netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev)), netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_btle_dev)),
IFACE_NAME_TEMPLATE, NET_NAME_UNKNOWN, IFACE_NAME_TEMPLATE, NET_NAME_UNKNOWN,
netdev_setup); netdev_setup);
if (!netdev) if (!netdev)
...@@ -820,7 +823,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev) ...@@ -820,7 +823,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev); SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev);
SET_NETDEV_DEVTYPE(netdev, &bt_type); SET_NETDEV_DEVTYPE(netdev, &bt_type);
*dev = lowpan_dev(netdev); *dev = lowpan_btle_dev(netdev);
(*dev)->netdev = netdev; (*dev)->netdev = netdev;
(*dev)->hdev = chan->conn->hcon->hdev; (*dev)->hdev = chan->conn->hcon->hdev;
INIT_LIST_HEAD(&(*dev)->peers); INIT_LIST_HEAD(&(*dev)->peers);
...@@ -853,7 +856,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev) ...@@ -853,7 +856,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
static inline void chan_ready_cb(struct l2cap_chan *chan) static inline void chan_ready_cb(struct l2cap_chan *chan)
{ {
struct lowpan_dev *dev; struct lowpan_btle_dev *dev;
dev = lookup_dev(chan->conn); dev = lookup_dev(chan->conn);
...@@ -890,7 +893,8 @@ static inline struct l2cap_chan *chan_new_conn_cb(struct l2cap_chan *pchan) ...@@ -890,7 +893,8 @@ static inline struct l2cap_chan *chan_new_conn_cb(struct l2cap_chan *pchan)
static void delete_netdev(struct work_struct *work) static void delete_netdev(struct work_struct *work)
{ {
struct lowpan_dev *entry = container_of(work, struct lowpan_dev, struct lowpan_btle_dev *entry = container_of(work,
struct lowpan_btle_dev,
delete_netdev); delete_netdev);
lowpan_unregister_netdev(entry->netdev); lowpan_unregister_netdev(entry->netdev);
...@@ -900,8 +904,8 @@ static void delete_netdev(struct work_struct *work) ...@@ -900,8 +904,8 @@ static void delete_netdev(struct work_struct *work)
static void chan_close_cb(struct l2cap_chan *chan) static void chan_close_cb(struct l2cap_chan *chan)
{ {
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
struct lowpan_dev *dev = NULL; struct lowpan_btle_dev *dev = NULL;
struct lowpan_peer *peer; struct lowpan_peer *peer;
int err = -ENOENT; int err = -ENOENT;
bool last = false, remove = true; bool last = false, remove = true;
...@@ -921,7 +925,7 @@ static void chan_close_cb(struct l2cap_chan *chan) ...@@ -921,7 +925,7 @@ static void chan_close_cb(struct l2cap_chan *chan)
spin_lock(&devices_lock); spin_lock(&devices_lock);
list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
dev = lowpan_dev(entry->netdev); dev = lowpan_btle_dev(entry->netdev);
peer = __peer_lookup_chan(dev, chan); peer = __peer_lookup_chan(dev, chan);
if (peer) { if (peer) {
last = peer_del(dev, peer); last = peer_del(dev, peer);
...@@ -1131,7 +1135,7 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type, ...@@ -1131,7 +1135,7 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
static void disconnect_all_peers(void) static void disconnect_all_peers(void)
{ {
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
struct lowpan_peer *peer, *tmp_peer, *new_peer; struct lowpan_peer *peer, *tmp_peer, *new_peer;
struct list_head peers; struct list_head peers;
...@@ -1291,7 +1295,7 @@ static ssize_t lowpan_control_write(struct file *fp, ...@@ -1291,7 +1295,7 @@ static ssize_t lowpan_control_write(struct file *fp,
static int lowpan_control_show(struct seq_file *f, void *ptr) static int lowpan_control_show(struct seq_file *f, void *ptr)
{ {
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
struct lowpan_peer *peer; struct lowpan_peer *peer;
spin_lock(&devices_lock); spin_lock(&devices_lock);
...@@ -1322,7 +1326,7 @@ static const struct file_operations lowpan_control_fops = { ...@@ -1322,7 +1326,7 @@ static const struct file_operations lowpan_control_fops = {
static void disconnect_devices(void) static void disconnect_devices(void)
{ {
struct lowpan_dev *entry, *tmp, *new_dev; struct lowpan_btle_dev *entry, *tmp, *new_dev;
struct list_head devices; struct list_head devices;
INIT_LIST_HEAD(&devices); INIT_LIST_HEAD(&devices);
...@@ -1360,7 +1364,7 @@ static int device_event(struct notifier_block *unused, ...@@ -1360,7 +1364,7 @@ static int device_event(struct notifier_block *unused,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct net_device *netdev = netdev_notifier_info_to_dev(ptr); struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
struct lowpan_dev *entry; struct lowpan_btle_dev *entry;
if (netdev->type != ARPHRD_6LOWPAN) if (netdev->type != ARPHRD_6LOWPAN)
return NOTIFY_DONE; return NOTIFY_DONE;
......
...@@ -48,15 +48,15 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a) ...@@ -48,15 +48,15 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
} }
/* private device info */ /* private device info */
struct lowpan_dev_info { struct lowpan_802154_dev {
struct net_device *wdev; /* wpan device ptr */ struct net_device *wdev; /* wpan device ptr */
u16 fragment_tag; u16 fragment_tag;
}; };
static inline struct static inline struct
lowpan_dev_info *lowpan_dev_info(const struct net_device *dev) lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
{ {
return (struct lowpan_dev_info *)lowpan_priv(dev)->priv; return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
} }
int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type); int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
......
...@@ -148,7 +148,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev, ...@@ -148,7 +148,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
return -EBUSY; return -EBUSY;
} }
lowpan_dev_info(ldev)->wdev = wdev; lowpan_802154_dev(ldev)->wdev = wdev;
/* Set the lowpan hardware address to the wpan hardware address. */ /* Set the lowpan hardware address to the wpan hardware address. */
memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN); memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN);
/* We need headroom for possible wpan_dev_hard_header call and tailroom /* We need headroom for possible wpan_dev_hard_header call and tailroom
...@@ -173,7 +173,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev, ...@@ -173,7 +173,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
static void lowpan_dellink(struct net_device *ldev, struct list_head *head) static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
{ {
struct net_device *wdev = lowpan_dev_info(ldev)->wdev; struct net_device *wdev = lowpan_802154_dev(ldev)->wdev;
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -184,7 +184,7 @@ static void lowpan_dellink(struct net_device *ldev, struct list_head *head) ...@@ -184,7 +184,7 @@ static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
static struct rtnl_link_ops lowpan_link_ops __read_mostly = { static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
.kind = "lowpan", .kind = "lowpan",
.priv_size = LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev_info)), .priv_size = LOWPAN_PRIV_SIZE(sizeof(struct lowpan_802154_dev)),
.setup = lowpan_setup, .setup = lowpan_setup,
.newlink = lowpan_newlink, .newlink = lowpan_newlink,
.dellink = lowpan_dellink, .dellink = lowpan_dellink,
......
...@@ -84,7 +84,7 @@ static struct sk_buff* ...@@ -84,7 +84,7 @@ static struct sk_buff*
lowpan_alloc_frag(struct sk_buff *skb, int size, lowpan_alloc_frag(struct sk_buff *skb, int size,
const struct ieee802154_hdr *master_hdr, bool frag1) const struct ieee802154_hdr *master_hdr, bool frag1)
{ {
struct net_device *wdev = lowpan_dev_info(skb->dev)->wdev; struct net_device *wdev = lowpan_802154_dev(skb->dev)->wdev;
struct sk_buff *frag; struct sk_buff *frag;
int rc; int rc;
...@@ -148,8 +148,8 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev, ...@@ -148,8 +148,8 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
int frag_cap, frag_len, payload_cap, rc; int frag_cap, frag_len, payload_cap, rc;
int skb_unprocessed, skb_offset; int skb_unprocessed, skb_offset;
frag_tag = htons(lowpan_dev_info(ldev)->fragment_tag); frag_tag = htons(lowpan_802154_dev(ldev)->fragment_tag);
lowpan_dev_info(ldev)->fragment_tag++; lowpan_802154_dev(ldev)->fragment_tag++;
frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07); frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07);
frag_hdr[1] = dgram_size & 0xff; frag_hdr[1] = dgram_size & 0xff;
...@@ -208,7 +208,7 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev, ...@@ -208,7 +208,7 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
static int lowpan_header(struct sk_buff *skb, struct net_device *ldev, static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
u16 *dgram_size, u16 *dgram_offset) u16 *dgram_size, u16 *dgram_offset)
{ {
struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr; struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr;
struct ieee802154_addr sa, da; struct ieee802154_addr sa, da;
struct ieee802154_mac_cb *cb = mac_cb_init(skb); struct ieee802154_mac_cb *cb = mac_cb_init(skb);
struct lowpan_addr_info info; struct lowpan_addr_info info;
...@@ -248,8 +248,8 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev, ...@@ -248,8 +248,8 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
cb->ackreq = wpan_dev->ackreq; cb->ackreq = wpan_dev->ackreq;
} }
return wpan_dev_hard_header(skb, lowpan_dev_info(ldev)->wdev, &da, &sa, return wpan_dev_hard_header(skb, lowpan_802154_dev(ldev)->wdev, &da,
0); &sa, 0);
} }
netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
...@@ -283,7 +283,7 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) ...@@ -283,7 +283,7 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
max_single = ieee802154_max_payload(&wpan_hdr); max_single = ieee802154_max_payload(&wpan_hdr);
if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) { if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) {
skb->dev = lowpan_dev_info(ldev)->wdev; skb->dev = lowpan_802154_dev(ldev)->wdev;
ldev->stats.tx_packets++; ldev->stats.tx_packets++;
ldev->stats.tx_bytes += dgram_size; ldev->stats.tx_bytes += dgram_size;
return dev_queue_xmit(skb); return dev_queue_xmit(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment