rdev-ops.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #ifndef __CFG802154_RDEV_OPS
  2. #define __CFG802154_RDEV_OPS
  3. #include <net/cfg802154.h>
  4. #include "core.h"
  5. #include "trace.h"
  6. static inline struct net_device *
  7. rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
  8. const char *name,
  9. unsigned char name_assign_type,
  10. int type)
  11. {
  12. return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
  13. name_assign_type, type);
  14. }
  15. static inline void
  16. rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
  17. struct net_device *dev)
  18. {
  19. rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev);
  20. }
  21. static inline int
  22. rdev_suspend(struct cfg802154_registered_device *rdev)
  23. {
  24. int ret;
  25. trace_802154_rdev_suspend(&rdev->wpan_phy);
  26. ret = rdev->ops->suspend(&rdev->wpan_phy);
  27. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  28. return ret;
  29. }
  30. static inline int
  31. rdev_resume(struct cfg802154_registered_device *rdev)
  32. {
  33. int ret;
  34. trace_802154_rdev_resume(&rdev->wpan_phy);
  35. ret = rdev->ops->resume(&rdev->wpan_phy);
  36. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  37. return ret;
  38. }
  39. static inline int
  40. rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
  41. unsigned char name_assign_type,
  42. enum nl802154_iftype type, __le64 extended_addr)
  43. {
  44. int ret;
  45. trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
  46. extended_addr);
  47. ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
  48. name_assign_type, type,
  49. extended_addr);
  50. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  51. return ret;
  52. }
  53. static inline int
  54. rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
  55. struct wpan_dev *wpan_dev)
  56. {
  57. int ret;
  58. trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
  59. ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
  60. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  61. return ret;
  62. }
  63. static inline int
  64. rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
  65. {
  66. int ret;
  67. trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
  68. ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
  69. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  70. return ret;
  71. }
  72. static inline int
  73. rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
  74. const struct wpan_phy_cca *cca)
  75. {
  76. int ret;
  77. trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
  78. ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
  79. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  80. return ret;
  81. }
  82. static inline int
  83. rdev_set_cca_ed_level(struct cfg802154_registered_device *rdev, s32 ed_level)
  84. {
  85. int ret;
  86. trace_802154_rdev_set_cca_ed_level(&rdev->wpan_phy, ed_level);
  87. ret = rdev->ops->set_cca_ed_level(&rdev->wpan_phy, ed_level);
  88. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  89. return ret;
  90. }
  91. static inline int
  92. rdev_set_tx_power(struct cfg802154_registered_device *rdev,
  93. s32 power)
  94. {
  95. int ret;
  96. trace_802154_rdev_set_tx_power(&rdev->wpan_phy, power);
  97. ret = rdev->ops->set_tx_power(&rdev->wpan_phy, power);
  98. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  99. return ret;
  100. }
  101. static inline int
  102. rdev_set_pan_id(struct cfg802154_registered_device *rdev,
  103. struct wpan_dev *wpan_dev, __le16 pan_id)
  104. {
  105. int ret;
  106. trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
  107. ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
  108. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  109. return ret;
  110. }
  111. static inline int
  112. rdev_set_short_addr(struct cfg802154_registered_device *rdev,
  113. struct wpan_dev *wpan_dev, __le16 short_addr)
  114. {
  115. int ret;
  116. trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
  117. ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
  118. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  119. return ret;
  120. }
  121. static inline int
  122. rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
  123. struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
  124. {
  125. int ret;
  126. trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
  127. min_be, max_be);
  128. ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
  129. min_be, max_be);
  130. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  131. return ret;
  132. }
  133. static inline int
  134. rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
  135. struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
  136. {
  137. int ret;
  138. trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
  139. max_csma_backoffs);
  140. ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
  141. max_csma_backoffs);
  142. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  143. return ret;
  144. }
  145. static inline int
  146. rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
  147. struct wpan_dev *wpan_dev, s8 max_frame_retries)
  148. {
  149. int ret;
  150. trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
  151. max_frame_retries);
  152. ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
  153. max_frame_retries);
  154. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  155. return ret;
  156. }
  157. static inline int
  158. rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
  159. struct wpan_dev *wpan_dev, bool mode)
  160. {
  161. int ret;
  162. trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
  163. ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
  164. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  165. return ret;
  166. }
  167. static inline int
  168. rdev_set_ackreq_default(struct cfg802154_registered_device *rdev,
  169. struct wpan_dev *wpan_dev, bool ackreq)
  170. {
  171. int ret;
  172. trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev,
  173. ackreq);
  174. ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq);
  175. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  176. return ret;
  177. }
  178. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  179. /* TODO this is already a nl802154, so move into ieee802154 */
  180. static inline void
  181. rdev_get_llsec_table(struct cfg802154_registered_device *rdev,
  182. struct wpan_dev *wpan_dev,
  183. struct ieee802154_llsec_table **table)
  184. {
  185. rdev->ops->get_llsec_table(&rdev->wpan_phy, wpan_dev, table);
  186. }
  187. static inline void
  188. rdev_lock_llsec_table(struct cfg802154_registered_device *rdev,
  189. struct wpan_dev *wpan_dev)
  190. {
  191. rdev->ops->lock_llsec_table(&rdev->wpan_phy, wpan_dev);
  192. }
  193. static inline void
  194. rdev_unlock_llsec_table(struct cfg802154_registered_device *rdev,
  195. struct wpan_dev *wpan_dev)
  196. {
  197. rdev->ops->unlock_llsec_table(&rdev->wpan_phy, wpan_dev);
  198. }
  199. static inline int
  200. rdev_get_llsec_params(struct cfg802154_registered_device *rdev,
  201. struct wpan_dev *wpan_dev,
  202. struct ieee802154_llsec_params *params)
  203. {
  204. return rdev->ops->get_llsec_params(&rdev->wpan_phy, wpan_dev, params);
  205. }
  206. static inline int
  207. rdev_set_llsec_params(struct cfg802154_registered_device *rdev,
  208. struct wpan_dev *wpan_dev,
  209. const struct ieee802154_llsec_params *params,
  210. u32 changed)
  211. {
  212. return rdev->ops->set_llsec_params(&rdev->wpan_phy, wpan_dev, params,
  213. changed);
  214. }
  215. static inline int
  216. rdev_add_llsec_key(struct cfg802154_registered_device *rdev,
  217. struct wpan_dev *wpan_dev,
  218. const struct ieee802154_llsec_key_id *id,
  219. const struct ieee802154_llsec_key *key)
  220. {
  221. return rdev->ops->add_llsec_key(&rdev->wpan_phy, wpan_dev, id, key);
  222. }
  223. static inline int
  224. rdev_del_llsec_key(struct cfg802154_registered_device *rdev,
  225. struct wpan_dev *wpan_dev,
  226. const struct ieee802154_llsec_key_id *id)
  227. {
  228. return rdev->ops->del_llsec_key(&rdev->wpan_phy, wpan_dev, id);
  229. }
  230. static inline int
  231. rdev_add_seclevel(struct cfg802154_registered_device *rdev,
  232. struct wpan_dev *wpan_dev,
  233. const struct ieee802154_llsec_seclevel *sl)
  234. {
  235. return rdev->ops->add_seclevel(&rdev->wpan_phy, wpan_dev, sl);
  236. }
  237. static inline int
  238. rdev_del_seclevel(struct cfg802154_registered_device *rdev,
  239. struct wpan_dev *wpan_dev,
  240. const struct ieee802154_llsec_seclevel *sl)
  241. {
  242. return rdev->ops->del_seclevel(&rdev->wpan_phy, wpan_dev, sl);
  243. }
  244. static inline int
  245. rdev_add_device(struct cfg802154_registered_device *rdev,
  246. struct wpan_dev *wpan_dev,
  247. const struct ieee802154_llsec_device *dev_desc)
  248. {
  249. return rdev->ops->add_device(&rdev->wpan_phy, wpan_dev, dev_desc);
  250. }
  251. static inline int
  252. rdev_del_device(struct cfg802154_registered_device *rdev,
  253. struct wpan_dev *wpan_dev, __le64 extended_addr)
  254. {
  255. return rdev->ops->del_device(&rdev->wpan_phy, wpan_dev, extended_addr);
  256. }
  257. static inline int
  258. rdev_add_devkey(struct cfg802154_registered_device *rdev,
  259. struct wpan_dev *wpan_dev, __le64 extended_addr,
  260. const struct ieee802154_llsec_device_key *devkey)
  261. {
  262. return rdev->ops->add_devkey(&rdev->wpan_phy, wpan_dev, extended_addr,
  263. devkey);
  264. }
  265. static inline int
  266. rdev_del_devkey(struct cfg802154_registered_device *rdev,
  267. struct wpan_dev *wpan_dev, __le64 extended_addr,
  268. const struct ieee802154_llsec_device_key *devkey)
  269. {
  270. return rdev->ops->del_devkey(&rdev->wpan_phy, wpan_dev, extended_addr,
  271. devkey);
  272. }
  273. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  274. #endif /* __CFG802154_RDEV_OPS */