ieee802154_i.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. const 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. bool started;
  46. struct tasklet_struct tasklet;
  47. struct sk_buff_head skb_queue;
  48. };
  49. enum {
  50. IEEE802154_RX_MSG = 1,
  51. };
  52. enum ieee802154_sdata_state_bits {
  53. SDATA_STATE_RUNNING,
  54. };
  55. /* Slave interface definition.
  56. *
  57. * Slaves represent typical network interfaces available from userspace.
  58. * Each ieee802154 device/transceiver may have several slaves and able
  59. * to be associated with several networks at the same time.
  60. */
  61. struct ieee802154_sub_if_data {
  62. struct list_head list; /* the ieee802154_priv->slaves list */
  63. struct ieee802154_local *local;
  64. struct net_device *dev;
  65. int type;
  66. unsigned long state;
  67. spinlock_t mib_lock;
  68. __le16 pan_id;
  69. __le16 short_addr;
  70. __le64 extended_addr;
  71. bool promisuous_mode;
  72. struct ieee802154_mac_params mac_params;
  73. /* MAC BSN field */
  74. u8 bsn;
  75. /* MAC DSN field */
  76. u8 dsn;
  77. /* protects sec from concurrent access by netlink. access by
  78. * encrypt/decrypt/header_create safe without additional protection.
  79. */
  80. struct mutex sec_mtx;
  81. struct mac802154_llsec sec;
  82. };
  83. #define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
  84. static inline struct ieee802154_local *
  85. hw_to_local(struct ieee802154_hw *hw)
  86. {
  87. return container_of(hw, struct ieee802154_local, hw);
  88. }
  89. static inline struct ieee802154_sub_if_data *
  90. IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
  91. {
  92. return netdev_priv(dev);
  93. }
  94. static inline bool
  95. ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
  96. {
  97. return test_bit(SDATA_STATE_RUNNING, &sdata->state);
  98. }
  99. extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
  100. extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
  101. void mac802154_monitor_setup(struct net_device *dev);
  102. netdev_tx_t
  103. ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  104. void mac802154_wpan_setup(struct net_device *dev);
  105. netdev_tx_t
  106. ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  107. /* MIB callbacks */
  108. void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
  109. __le16 mac802154_dev_get_short_addr(const struct net_device *dev);
  110. __le16 mac802154_dev_get_pan_id(const struct net_device *dev);
  111. void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val);
  112. void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
  113. u8 mac802154_dev_get_dsn(const struct net_device *dev);
  114. int mac802154_get_params(struct net_device *dev,
  115. struct ieee802154_llsec_params *params);
  116. int mac802154_set_params(struct net_device *dev,
  117. const struct ieee802154_llsec_params *params,
  118. int changed);
  119. int mac802154_add_key(struct net_device *dev,
  120. const struct ieee802154_llsec_key_id *id,
  121. const struct ieee802154_llsec_key *key);
  122. int mac802154_del_key(struct net_device *dev,
  123. const struct ieee802154_llsec_key_id *id);
  124. int mac802154_add_dev(struct net_device *dev,
  125. const struct ieee802154_llsec_device *llsec_dev);
  126. int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
  127. int mac802154_add_devkey(struct net_device *dev,
  128. __le64 device_addr,
  129. const struct ieee802154_llsec_device_key *key);
  130. int mac802154_del_devkey(struct net_device *dev,
  131. __le64 device_addr,
  132. const struct ieee802154_llsec_device_key *key);
  133. int mac802154_add_seclevel(struct net_device *dev,
  134. const struct ieee802154_llsec_seclevel *sl);
  135. int mac802154_del_seclevel(struct net_device *dev,
  136. const struct ieee802154_llsec_seclevel *sl);
  137. void mac802154_lock_table(struct net_device *dev);
  138. void mac802154_get_table(struct net_device *dev,
  139. struct ieee802154_llsec_table **t);
  140. void mac802154_unlock_table(struct net_device *dev);
  141. struct net_device *
  142. mac802154_add_iface(struct wpan_phy *phy, const char *name, int type);
  143. void mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev);
  144. #endif /* __IEEE802154_I_H */