6lowpan.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==============================================
  3. Netdev private dataroom for 6lowpan interfaces
  4. ==============================================
  5. All 6lowpan able net devices, means all interfaces with ARPHRD_6LOWPAN,
  6. must have "struct lowpan_priv" placed at beginning of netdev_priv.
  7. The priv_size of each interface should be calculate by::
  8. dev->priv_size = LOWPAN_PRIV_SIZE(LL_6LOWPAN_PRIV_DATA);
  9. Where LL_PRIV_6LOWPAN_DATA is sizeof linklayer 6lowpan private data struct.
  10. To access the LL_PRIV_6LOWPAN_DATA structure you can cast::
  11. lowpan_priv(dev)-priv;
  12. to your LL_6LOWPAN_PRIV_DATA structure.
  13. Before registering the lowpan netdev interface you must run::
  14. lowpan_netdev_setup(dev, LOWPAN_LLTYPE_FOOBAR);
  15. wheres LOWPAN_LLTYPE_FOOBAR is a define for your 6LoWPAN linklayer type of
  16. enum lowpan_lltypes.
  17. Example to evaluate the private usually you can do::
  18. static inline struct lowpan_priv_foobar *
  19. lowpan_foobar_priv(struct net_device *dev)
  20. {
  21. return (struct lowpan_priv_foobar *)lowpan_priv(dev)->priv;
  22. }
  23. switch (dev->type) {
  24. case ARPHRD_6LOWPAN:
  25. lowpan_priv = lowpan_priv(dev);
  26. /* do great stuff which is ARPHRD_6LOWPAN related */
  27. switch (lowpan_priv->lltype) {
  28. case LOWPAN_LLTYPE_FOOBAR:
  29. /* do 802.15.4 6LoWPAN handling here */
  30. lowpan_foobar_priv(dev)->bar = foo;
  31. break;
  32. ...
  33. }
  34. break;
  35. ...
  36. }
  37. In case of generic 6lowpan branch ("net/6lowpan") you can remove the check
  38. on ARPHRD_6LOWPAN, because you can be sure that these function are called
  39. by ARPHRD_6LOWPAN interfaces.