mac802154.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * IEEE802.15.4-2003 specification
  3. *
  4. * Copyright (C) 2007-2012 Siemens AG
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. #ifndef NET_MAC802154_H
  20. #define NET_MAC802154_H
  21. #include <net/af_ieee802154.h>
  22. /* The following flags are used to indicate changed address settings from
  23. * the stack to the hardware.
  24. */
  25. /* indicates that the Short Address changed */
  26. #define IEEE802515_AFILT_SADDR_CHANGED 0x00000001
  27. /* indicates that the IEEE Address changed */
  28. #define IEEE802515_AFILT_IEEEADDR_CHANGED 0x00000002
  29. /* indicates that the PAN ID changed */
  30. #define IEEE802515_AFILT_PANID_CHANGED 0x00000004
  31. /* indicates that PAN Coordinator status changed */
  32. #define IEEE802515_AFILT_PANC_CHANGED 0x00000008
  33. struct ieee802154_hw_addr_filt {
  34. __le16 pan_id; /* Each independent PAN selects a unique
  35. * identifier. This PAN id allows communication
  36. * between devices within a network using short
  37. * addresses and enables transmissions between
  38. * devices across independent networks.
  39. */
  40. __le16 short_addr;
  41. u8 ieee_addr[IEEE802154_ADDR_LEN];
  42. u8 pan_coord;
  43. };
  44. struct ieee802154_dev {
  45. /* filled by the driver */
  46. int extra_tx_headroom;
  47. u32 flags;
  48. struct device *parent;
  49. /* filled by mac802154 core */
  50. struct ieee802154_hw_addr_filt hw_filt;
  51. void *priv;
  52. struct wpan_phy *phy;
  53. };
  54. /* Checksum is in hardware and is omitted from a packet
  55. *
  56. * These following flags are used to indicate hardware capabilities to
  57. * the stack. Generally, flags here should have their meaning
  58. * done in a way that the simplest hardware doesn't need setting
  59. * any particular flags. There are some exceptions to this rule,
  60. * however, so you are advised to review these flags carefully.
  61. */
  62. /* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */
  63. #define IEEE802154_HW_OMIT_CKSUM 0x00000001
  64. /* Indicates that receiver will autorespond with ACK frames. */
  65. #define IEEE802154_HW_AACK 0x00000002
  66. /* struct ieee802154_ops - callbacks from mac802154 to the driver
  67. *
  68. * This structure contains various callbacks that the driver may
  69. * handle or, in some cases, must handle, for example to transmit
  70. * a frame.
  71. *
  72. * start: Handler that 802.15.4 module calls for device initialization.
  73. * This function is called before the first interface is attached.
  74. *
  75. * stop: Handler that 802.15.4 module calls for device cleanup.
  76. * This function is called after the last interface is removed.
  77. *
  78. * xmit: Handler that 802.15.4 module calls for each transmitted frame.
  79. * skb cntains the buffer starting from the IEEE 802.15.4 header.
  80. * The low-level driver should send the frame based on available
  81. * configuration.
  82. * This function should return zero or negative errno. Called with
  83. * pib_lock held.
  84. *
  85. * ed: Handler that 802.15.4 module calls for Energy Detection.
  86. * This function should place the value for detected energy
  87. * (usually device-dependant) in the level pointer and return
  88. * either zero or negative errno. Called with pib_lock held.
  89. *
  90. * set_channel:
  91. * Set radio for listening on specific channel.
  92. * Set the device for listening on specified channel.
  93. * Returns either zero, or negative errno. Called with pib_lock held.
  94. *
  95. * set_hw_addr_filt:
  96. * Set radio for listening on specific address.
  97. * Set the device for listening on specified address.
  98. * Returns either zero, or negative errno.
  99. */
  100. struct ieee802154_ops {
  101. struct module *owner;
  102. int (*start)(struct ieee802154_dev *dev);
  103. void (*stop)(struct ieee802154_dev *dev);
  104. int (*xmit)(struct ieee802154_dev *dev,
  105. struct sk_buff *skb);
  106. int (*ed)(struct ieee802154_dev *dev, u8 *level);
  107. int (*set_channel)(struct ieee802154_dev *dev,
  108. int page,
  109. int channel);
  110. int (*set_hw_addr_filt)(struct ieee802154_dev *dev,
  111. struct ieee802154_hw_addr_filt *filt,
  112. unsigned long changed);
  113. int (*ieee_addr)(struct ieee802154_dev *dev,
  114. u8 addr[IEEE802154_ADDR_LEN]);
  115. };
  116. /* Basic interface to register ieee802154 device */
  117. struct ieee802154_dev *
  118. ieee802154_alloc_device(size_t priv_data_lex, struct ieee802154_ops *ops);
  119. void ieee802154_free_device(struct ieee802154_dev *dev);
  120. int ieee802154_register_device(struct ieee802154_dev *dev);
  121. void ieee802154_unregister_device(struct ieee802154_dev *dev);
  122. void ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb,
  123. u8 lqi);
  124. #endif /* NET_MAC802154_H */