Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ==============================================
0004 Netdev private dataroom for 6lowpan interfaces
0005 ==============================================
0006 
0007 All 6lowpan able net devices, means all interfaces with ARPHRD_6LOWPAN,
0008 must have "struct lowpan_priv" placed at beginning of netdev_priv.
0009 
0010 The priv_size of each interface should be calculate by::
0011 
0012  dev->priv_size = LOWPAN_PRIV_SIZE(LL_6LOWPAN_PRIV_DATA);
0013 
0014 Where LL_PRIV_6LOWPAN_DATA is sizeof linklayer 6lowpan private data struct.
0015 To access the LL_PRIV_6LOWPAN_DATA structure you can cast::
0016 
0017  lowpan_priv(dev)-priv;
0018 
0019 to your LL_6LOWPAN_PRIV_DATA structure.
0020 
0021 Before registering the lowpan netdev interface you must run::
0022 
0023  lowpan_netdev_setup(dev, LOWPAN_LLTYPE_FOOBAR);
0024 
0025 wheres LOWPAN_LLTYPE_FOOBAR is a define for your 6LoWPAN linklayer type of
0026 enum lowpan_lltypes.
0027 
0028 Example to evaluate the private usually you can do::
0029 
0030  static inline struct lowpan_priv_foobar *
0031  lowpan_foobar_priv(struct net_device *dev)
0032  {
0033         return (struct lowpan_priv_foobar *)lowpan_priv(dev)->priv;
0034  }
0035 
0036  switch (dev->type) {
0037  case ARPHRD_6LOWPAN:
0038         lowpan_priv = lowpan_priv(dev);
0039         /* do great stuff which is ARPHRD_6LOWPAN related */
0040         switch (lowpan_priv->lltype) {
0041         case LOWPAN_LLTYPE_FOOBAR:
0042                 /* do 802.15.4 6LoWPAN handling here */
0043                 lowpan_foobar_priv(dev)->bar = foo;
0044                 break;
0045         ...
0046         }
0047         break;
0048  ...
0049  }
0050 
0051 In case of generic 6lowpan branch ("net/6lowpan") you can remove the check
0052 on ARPHRD_6LOWPAN, because you can be sure that these function are called
0053 by ARPHRD_6LOWPAN interfaces.