Skip to content

Commit

Permalink
6lowpan: change naming for lowpan private data
Browse files Browse the repository at this point in the history
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: Alexander Aring <aar@pengutronix.de>
Reviewed-by: Stefan Schmidt<stefan@osg.samsung.com>
Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Alexander Aring authored and holtmann committed Apr 13, 2016
1 parent 5a7f97e commit 2e4d60c
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 90 deletions.
6 changes: 3 additions & 3 deletions include/net/6lowpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static inline bool lowpan_is_iphc(u8 dispatch)
}

#define LOWPAN_PRIV_SIZE(llpriv_size) \
(sizeof(struct lowpan_priv) + llpriv_size)
(sizeof(struct lowpan_dev) + llpriv_size)

enum lowpan_lltypes {
LOWPAN_LLTYPE_BTLE,
Expand Down Expand Up @@ -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);
}

struct lowpan_priv {
struct lowpan_dev {
enum lowpan_lltypes lltype;
struct dentry *iface_debugfs;
struct lowpan_iphc_ctx_table ctx;
Expand All @@ -139,7 +139,7 @@ struct lowpan_priv {
};

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);
}
Expand Down
8 changes: 4 additions & 4 deletions net/6lowpan/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ int lowpan_register_netdevice(struct net_device *dev,
dev->mtu = IPV6_MIN_MTU;
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++)
lowpan_priv(dev)->ctx.table[i].id = i;
lowpan_dev(dev)->ctx.table[i].id = i;

ret = register_netdevice(dev);
if (ret < 0)
Expand Down Expand Up @@ -85,7 +85,7 @@ static int lowpan_event(struct notifier_block *unused,
case NETDEV_DOWN:
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE,
&lowpan_priv(dev)->ctx.table[i].flags);
&lowpan_dev(dev)->ctx.table[i].flags);
break;
default:
return NOTIFY_DONE;
Expand Down
22 changes: 11 additions & 11 deletions net/6lowpan/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static const struct file_operations lowpan_ctx_pfx_fops = {
static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
struct dentry *ctx, u8 id)
{
struct lowpan_priv *lpriv = lowpan_priv(dev);
struct lowpan_dev *ldev = lowpan_dev(dev);
struct dentry *dentry, *root;
char buf[32];

Expand All @@ -185,25 +185,25 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
return -EINVAL;

dentry = debugfs_create_file("active", 0644, root,
&lpriv->ctx.table[id],
&ldev->ctx.table[id],
&lowpan_ctx_flag_active_fops);
if (!dentry)
return -EINVAL;

dentry = debugfs_create_file("compression", 0644, root,
&lpriv->ctx.table[id],
&ldev->ctx.table[id],
&lowpan_ctx_flag_c_fops);
if (!dentry)
return -EINVAL;

dentry = debugfs_create_file("prefix", 0644, root,
&lpriv->ctx.table[id],
&ldev->ctx.table[id],
&lowpan_ctx_pfx_fops);
if (!dentry)
return -EINVAL;

dentry = debugfs_create_file("prefix_len", 0644, root,
&lpriv->ctx.table[id],
&ldev->ctx.table[id],
&lowpan_ctx_plen_fops);
if (!dentry)
return -EINVAL;
Expand Down Expand Up @@ -247,21 +247,21 @@ static const struct file_operations lowpan_context_fops = {

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;
int ret, i;

/* creating the root */
lpriv->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
if (!lpriv->iface_debugfs)
ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
if (!ldev->iface_debugfs)
goto fail;

contexts = debugfs_create_dir("contexts", lpriv->iface_debugfs);
contexts = debugfs_create_dir("contexts", ldev->iface_debugfs);
if (!contexts)
goto remove_root;

dentry = debugfs_create_file("show", 0644, contexts,
&lowpan_priv(dev)->ctx,
&lowpan_dev(dev)->ctx,
&lowpan_context_fops);
if (!dentry)
goto remove_root;
Expand All @@ -282,7 +282,7 @@ int lowpan_dev_debugfs_init(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)
Expand Down
38 changes: 19 additions & 19 deletions net/6lowpan/iphc.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
static struct lowpan_iphc_ctx *
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))
return NULL;
Expand All @@ -219,7 +219,7 @@ static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_addr(const struct net_device *dev,
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 in6_addr addr_pfx;
u8 addr_plen;
Expand Down Expand Up @@ -263,7 +263,7 @@ static struct lowpan_iphc_ctx *
lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
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 in6_addr addr_mcast, network_pfx = {};
int i;
Expand Down Expand Up @@ -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_DAM_11:
fail = false;
switch (lowpan_priv(dev)->lltype) {
switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154:
iphc_uncompress_802154_lladdr(ipaddr, lladdr);
break;
Expand Down Expand Up @@ -393,7 +393,7 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
case LOWPAN_IPHC_SAM_11:
case LOWPAN_IPHC_DAM_11:
fail = false;
switch (lowpan_priv(dev)->lltype) {
switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154:
iphc_uncompress_802154_lladdr(ipaddr, lladdr);
break;
Expand Down Expand Up @@ -657,17 +657,17 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
}

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));
if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL;
}

pr_debug("SAC bit is set. Handle context based source address.\n");
err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
} else {
/* Source address uncompression */
pr_debug("source address stateless compression\n");
Expand All @@ -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)) {
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));
if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL;
}

Expand All @@ -693,26 +693,26 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
err = lowpan_uncompress_multicast_ctx_daddr(skb, ci,
&hdr.daddr,
iphc1 & LOWPAN_IPHC_DAM_MASK);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
break;
case LOWPAN_IPHC_M:
/* multicast */
err = lowpan_uncompress_multicast_daddr(skb, &hdr.daddr,
iphc1 & LOWPAN_IPHC_DAM_MASK);
break;
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));
if (!ci) {
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
return -EINVAL;
}

/* Destination address context based uncompression */
pr_debug("DAC bit is set. Handle context based destination address.\n");
err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
break;
default:
err = uncompress_addr(skb, dev, &hdr.daddr,
Expand All @@ -736,7 +736,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
return err;
}

switch (lowpan_priv(dev)->lltype) {
switch (lowpan_dev(dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154:
if (lowpan_802154_cb(skb)->d_size)
hdr.payload_len = htons(lowpan_802154_cb(skb)->d_size -
Expand Down Expand Up @@ -1033,7 +1033,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
skb->data, skb->len);

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)
dci = lowpan_iphc_ctx_get_by_mcast_addr(dev, &hdr->daddr);
else
Expand All @@ -1042,15 +1042,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
memcpy(&dci_entry, dci, sizeof(*dci));
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);
if (sci) {
memcpy(&sci_entry, sci, sizeof(*sci));
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) {
Expand Down
2 changes: 1 addition & 1 deletion net/6lowpan/nhc_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* frame
*/
switch (lowpan_priv(skb->dev)->lltype) {
switch (lowpan_dev(skb->dev)->lltype) {
case LOWPAN_LLTYPE_IEEE802154:
if (lowpan_802154_cb(skb)->d_size)
uh.len = htons(lowpan_802154_cb(skb)->d_size -
Expand Down
Loading

0 comments on commit 2e4d60c

Please sign in to comment.