Skip to content

Commit

Permalink
docs: networking: convert 6lowpan.txt to ReST
Browse files Browse the repository at this point in the history
- add SPDX header;
- use document title markup;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Mauro Carvalho Chehab authored and Marcel Holtmann committed Feb 28, 2020
1 parent 8788a1e commit 107db7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
.. SPDX-License-Identifier: GPL-2.0
Netdev private dataroom for 6lowpan interfaces:
==============================================
Netdev private dataroom for 6lowpan interfaces
==============================================

All 6lowpan able net devices, means all interfaces with ARPHRD_6LOWPAN,
must have "struct lowpan_priv" placed at beginning of netdev_priv.

The priv_size of each interface should be calculate by:
The priv_size of each interface should be calculate by::

dev->priv_size = LOWPAN_PRIV_SIZE(LL_6LOWPAN_PRIV_DATA);

Where LL_PRIV_6LOWPAN_DATA is sizeof linklayer 6lowpan private data struct.
To access the LL_PRIV_6LOWPAN_DATA structure you can cast:
To access the LL_PRIV_6LOWPAN_DATA structure you can cast::

lowpan_priv(dev)-priv;

to your LL_6LOWPAN_PRIV_DATA structure.

Before registering the lowpan netdev interface you must run:
Before registering the lowpan netdev interface you must run::

lowpan_netdev_setup(dev, LOWPAN_LLTYPE_FOOBAR);

wheres LOWPAN_LLTYPE_FOOBAR is a define for your 6LoWPAN linklayer type of
enum lowpan_lltypes.

Example to evaluate the private usually you can do:
Example to evaluate the private usually you can do::

static inline struct lowpan_priv_foobar *
lowpan_foobar_priv(struct net_device *dev)
{
static inline struct lowpan_priv_foobar *
lowpan_foobar_priv(struct net_device *dev)
{
return (struct lowpan_priv_foobar *)lowpan_priv(dev)->priv;
}
}

switch (dev->type) {
case ARPHRD_6LOWPAN:
switch (dev->type) {
case ARPHRD_6LOWPAN:
lowpan_priv = lowpan_priv(dev);
/* do great stuff which is ARPHRD_6LOWPAN related */
switch (lowpan_priv->lltype) {
Expand All @@ -42,8 +45,8 @@ case ARPHRD_6LOWPAN:
...
}
break;
...
}
...
}

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
Expand Down
1 change: 1 addition & 0 deletions Documentation/networking/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Contents:
tls
tls-offload
nfc
6lowpan

.. only:: subproject and html

Expand Down

0 comments on commit 107db7e

Please sign in to comment.