2020-02-06 22:17:22 +07:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0
|
2015-08-12 02:44:10 +07:00
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
==============================================
|
|
|
|
Netdev private dataroom for 6lowpan interfaces
|
|
|
|
==============================================
|
2015-08-12 02:44:10 +07:00
|
|
|
|
|
|
|
All 6lowpan able net devices, means all interfaces with ARPHRD_6LOWPAN,
|
|
|
|
must have "struct lowpan_priv" placed at beginning of netdev_priv.
|
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
The priv_size of each interface should be calculate by::
|
2015-08-12 02:44:10 +07:00
|
|
|
|
|
|
|
dev->priv_size = LOWPAN_PRIV_SIZE(LL_6LOWPAN_PRIV_DATA);
|
|
|
|
|
|
|
|
Where LL_PRIV_6LOWPAN_DATA is sizeof linklayer 6lowpan private data struct.
|
2020-02-06 22:17:22 +07:00
|
|
|
To access the LL_PRIV_6LOWPAN_DATA structure you can cast::
|
2015-08-12 02:44:10 +07:00
|
|
|
|
|
|
|
lowpan_priv(dev)-priv;
|
|
|
|
|
|
|
|
to your LL_6LOWPAN_PRIV_DATA structure.
|
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
Before registering the lowpan netdev interface you must run::
|
2015-08-12 02:44:10 +07:00
|
|
|
|
|
|
|
lowpan_netdev_setup(dev, LOWPAN_LLTYPE_FOOBAR);
|
|
|
|
|
|
|
|
wheres LOWPAN_LLTYPE_FOOBAR is a define for your 6LoWPAN linklayer type of
|
|
|
|
enum lowpan_lltypes.
|
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
Example to evaluate the private usually you can do::
|
2015-08-12 02:44:10 +07:00
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
static inline struct lowpan_priv_foobar *
|
|
|
|
lowpan_foobar_priv(struct net_device *dev)
|
|
|
|
{
|
2018-06-04 17:07:37 +07:00
|
|
|
return (struct lowpan_priv_foobar *)lowpan_priv(dev)->priv;
|
2020-02-06 22:17:22 +07:00
|
|
|
}
|
2015-08-12 02:44:10 +07:00
|
|
|
|
2020-02-06 22:17:22 +07:00
|
|
|
switch (dev->type) {
|
|
|
|
case ARPHRD_6LOWPAN:
|
2015-08-12 02:44:10 +07:00
|
|
|
lowpan_priv = lowpan_priv(dev);
|
|
|
|
/* do great stuff which is ARPHRD_6LOWPAN related */
|
|
|
|
switch (lowpan_priv->lltype) {
|
|
|
|
case LOWPAN_LLTYPE_FOOBAR:
|
|
|
|
/* do 802.15.4 6LoWPAN handling here */
|
|
|
|
lowpan_foobar_priv(dev)->bar = foo;
|
|
|
|
break;
|
|
|
|
...
|
|
|
|
}
|
|
|
|
break;
|
2020-02-06 22:17:22 +07:00
|
|
|
...
|
|
|
|
}
|
2015-08-12 02:44:10 +07:00
|
|
|
|
|
|
|
In case of generic 6lowpan branch ("net/6lowpan") you can remove the check
|
|
|
|
on ARPHRD_6LOWPAN, because you can be sure that these function are called
|
|
|
|
by ARPHRD_6LOWPAN interfaces.
|