ieee802154_i.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (C) 2007-2012 Siemens AG
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * Written by:
  14. * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
  15. * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
  16. * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
  17. * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
  18. */
  19. #ifndef __IEEE802154_I_H
  20. #define __IEEE802154_I_H
  21. #include <linux/mutex.h>
  22. #include <net/mac802154.h>
  23. #include <net/ieee802154_netdev.h>
  24. #include "llsec.h"
  25. /* mac802154 device private data */
  26. struct ieee802154_local {
  27. struct ieee802154_hw hw;
  28. struct ieee802154_ops *ops;
  29. /* ieee802154 phy */
  30. struct wpan_phy *phy;
  31. int open_count;
  32. /* As in mac80211 slaves list is modified:
  33. * 1) under the RTNL
  34. * 2) protected by slaves_mtx;
  35. * 3) in an RCU manner
  36. *
  37. * So atomic readers can use any of this protection methods.
  38. */
  39. struct list_head interfaces;
  40. struct mutex iflist_mtx;
  41. /* This one is used for scanning and other jobs not to be interfered
  42. * with serial driver.
  43. */
  44. struct workqueue_struct *workqueue;
  45. /* SoftMAC device is registered and running. One can add subinterfaces.
  46. * This flag should be modified under slaves_mtx and RTNL, so you can
  47. * read them using any of protection methods.
  48. */
  49. bool running;
  50. struct tasklet_struct tasklet;
  51. struct sk_buff_head skb_queue;
  52. };
  53. #define MAC802154_DEVICE_STOPPED 0x00
  54. #define MAC802154_DEVICE_RUN 0x01
  55. enum {
  56. IEEE802154_RX_MSG = 1,
  57. };
  58. /* Slave interface definition.
  59. *
  60. * Slaves represent typical network interfaces available from userspace.
  61. * Each ieee802154 device/transceiver may have several slaves and able
  62. * to be associated with several networks at the same time.
  63. */
  64. struct ieee802154_sub_if_data {
  65. struct list_head list; /* the ieee802154_priv->slaves list */
  66. struct ieee802154_local *local;
  67. struct net_device *dev;
  68. int type;
  69. bool running;
  70. spinlock_t mib_lock;
  71. __le16 pan_id;
  72. __le16 short_addr;
  73. __le64 extended_addr;
  74. u8 chan;
  75. u8 page;
  76. struct ieee802154_mac_params mac_params;
  77. /* MAC BSN field */
  78. u8 bsn;
  79. /* MAC DSN field */
  80. u8 dsn;
  81. /* protects sec from concurrent access by netlink. access by
  82. * encrypt/decrypt/header_create safe without additional protection.
  83. */
  84. struct mutex sec_mtx;
  85. struct mac802154_llsec sec;
  86. };
  87. #define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
  88. static inline struct ieee802154_local *
  89. hw_to_local(struct ieee802154_hw *hw)
  90. {
  91. return container_of(hw, struct ieee802154_local, hw);
  92. }
  93. static inline struct ieee802154_sub_if_data *
  94. IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
  95. {
  96. return netdev_priv(dev);
  97. }
  98. extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
  99. extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
  100. int mac802154_slave_open(struct net_device *dev);
  101. int mac802154_slave_close(struct net_device *dev);
  102. void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb);
  103. void mac802154_monitor_setup(struct net_device *dev);
  104. netdev_tx_t
  105. ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  106. void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
  107. void mac802154_wpan_setup(struct net_device *dev);
  108. netdev_tx_t
  109. ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  110. /* MIB callbacks */
  111. void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
  112. __le16 mac802154_dev_get_short_addr(const struct net_device *dev);
  113. void mac802154_dev_set_ieee_addr(struct net_device *dev);
  114. __le16 mac802154_dev_get_pan_id(const struct net_device *dev);
  115. void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val);
  116. void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
  117. u8 mac802154_dev_get_dsn(const struct net_device *dev);
  118. int mac802154_set_mac_params(struct net_device *dev,
  119. const struct ieee802154_mac_params *params);
  120. void mac802154_get_mac_params(struct net_device *dev,
  121. struct ieee802154_mac_params *params);
  122. int mac802154_get_params(struct net_device *dev,
  123. struct ieee802154_llsec_params *params);
  124. int mac802154_set_params(struct net_device *dev,
  125. const struct ieee802154_llsec_params *params,
  126. int changed);
  127. int mac802154_add_key(struct net_device *dev,
  128. const struct ieee802154_llsec_key_id *id,
  129. const struct ieee802154_llsec_key *key);
  130. int mac802154_del_key(struct net_device *dev,
  131. const struct ieee802154_llsec_key_id *id);
  132. int mac802154_add_dev(struct net_device *dev,
  133. const struct ieee802154_llsec_device *llsec_dev);
  134. int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
  135. int mac802154_add_devkey(struct net_device *dev,
  136. __le64 device_addr,
  137. const struct ieee802154_llsec_device_key *key);
  138. int mac802154_del_devkey(struct net_device *dev,
  139. __le64 device_addr,
  140. const struct ieee802154_llsec_device_key *key);
  141. int mac802154_add_seclevel(struct net_device *dev,
  142. const struct ieee802154_llsec_seclevel *sl);
  143. int mac802154_del_seclevel(struct net_device *dev,
  144. const struct ieee802154_llsec_seclevel *sl);
  145. void mac802154_lock_table(struct net_device *dev);
  146. void mac802154_get_table(struct net_device *dev,
  147. struct ieee802154_llsec_table **t);
  148. void mac802154_unlock_table(struct net_device *dev);
  149. #endif /* __IEEE802154_I_H */