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

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: default avatarStefan <Schmidt&lt;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
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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,
@@ -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;
@@ -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);
}
+4 −4
Original line number Diff line number Diff line
@@ -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)
@@ -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;
+11 −11
Original line number Diff line number Diff line
@@ -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];

@@ -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;
@@ -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;
@@ -282,7 +282,7 @@ fail:

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)
+19 −19
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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");
@@ -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;
		}

@@ -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,
							    &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 */
@@ -701,10 +701,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
							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;
		}

@@ -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");
		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,
@@ -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 -
@@ -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
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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 -
Loading