xref: /openbmc/linux/net/ieee802154/rdev-ops.h (revision c91208d819c814e7f418c7a083059cf533ad0396)
14a9a816aSAlexander Aring #ifndef __CFG802154_RDEV_OPS
24a9a816aSAlexander Aring #define __CFG802154_RDEV_OPS
34a9a816aSAlexander Aring 
44a9a816aSAlexander Aring #include <net/cfg802154.h>
54a9a816aSAlexander Aring 
64a9a816aSAlexander Aring #include "core.h"
71cc800e7SGuido Günther #include "trace.h"
84a9a816aSAlexander Aring 
94a9a816aSAlexander Aring static inline struct net_device *
104a9a816aSAlexander Aring rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
115b4a1039SVarka Bhadram 				 const char *name,
125b4a1039SVarka Bhadram 				 unsigned char name_assign_type,
135b4a1039SVarka Bhadram 				 int type)
144a9a816aSAlexander Aring {
154a9a816aSAlexander Aring 	return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
165b4a1039SVarka Bhadram 						      name_assign_type, type);
174a9a816aSAlexander Aring }
184a9a816aSAlexander Aring 
194a9a816aSAlexander Aring static inline void
204a9a816aSAlexander Aring rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
214a9a816aSAlexander Aring 				 struct net_device *dev)
224a9a816aSAlexander Aring {
234a9a816aSAlexander Aring 	rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev);
244a9a816aSAlexander Aring }
254a9a816aSAlexander Aring 
26ab0bd561SAlexander Aring static inline int
27a6cb869bSVarka Bhadram rdev_suspend(struct cfg802154_registered_device *rdev)
28a6cb869bSVarka Bhadram {
29a6cb869bSVarka Bhadram 	int ret;
30a6cb869bSVarka Bhadram 	trace_802154_rdev_suspend(&rdev->wpan_phy);
31a6cb869bSVarka Bhadram 	ret = rdev->ops->suspend(&rdev->wpan_phy);
32a6cb869bSVarka Bhadram 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
33a6cb869bSVarka Bhadram 	return ret;
34a6cb869bSVarka Bhadram }
35a6cb869bSVarka Bhadram 
36a6cb869bSVarka Bhadram static inline int
37a6cb869bSVarka Bhadram rdev_resume(struct cfg802154_registered_device *rdev)
38a6cb869bSVarka Bhadram {
39a6cb869bSVarka Bhadram 	int ret;
40a6cb869bSVarka Bhadram 	trace_802154_rdev_resume(&rdev->wpan_phy);
41a6cb869bSVarka Bhadram 	ret = rdev->ops->resume(&rdev->wpan_phy);
42a6cb869bSVarka Bhadram 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
43a6cb869bSVarka Bhadram 	return ret;
44a6cb869bSVarka Bhadram }
45a6cb869bSVarka Bhadram 
46a6cb869bSVarka Bhadram static inline int
47f3ea5e44SAlexander Aring rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
485b4a1039SVarka Bhadram 		      unsigned char name_assign_type,
490e57547eSAlexander Aring 		      enum nl802154_iftype type, __le64 extended_addr)
50f3ea5e44SAlexander Aring {
511cc800e7SGuido Günther 	int ret;
521cc800e7SGuido Günther 
531cc800e7SGuido Günther 	trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
540e57547eSAlexander Aring 					   extended_addr);
555b4a1039SVarka Bhadram 	ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
565b4a1039SVarka Bhadram 					  name_assign_type, type,
571cc800e7SGuido Günther 					  extended_addr);
581cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
591cc800e7SGuido Günther 	return ret;
60f3ea5e44SAlexander Aring }
61f3ea5e44SAlexander Aring 
62f3ea5e44SAlexander Aring static inline int
63b821ecd4SAlexander Aring rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
64b821ecd4SAlexander Aring 		      struct wpan_dev *wpan_dev)
65b821ecd4SAlexander Aring {
661cc800e7SGuido Günther 	int ret;
671cc800e7SGuido Günther 
681cc800e7SGuido Günther 	trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
691cc800e7SGuido Günther 	ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
701cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
711cc800e7SGuido Günther 	return ret;
72b821ecd4SAlexander Aring }
73b821ecd4SAlexander Aring 
74b821ecd4SAlexander Aring static inline int
75628b1e11SAlexander Aring rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
76ab0bd561SAlexander Aring {
771cc800e7SGuido Günther 	int ret;
781cc800e7SGuido Günther 
791cc800e7SGuido Günther 	trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
801cc800e7SGuido Günther 	ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
811cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
821cc800e7SGuido Günther 	return ret;
83ab0bd561SAlexander Aring }
84ab0bd561SAlexander Aring 
85702bf371SAlexander Aring static inline int
86ba2a9506SAlexander Aring rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
87ba2a9506SAlexander Aring 		  const struct wpan_phy_cca *cca)
88ba2a9506SAlexander Aring {
891cc800e7SGuido Günther 	int ret;
901cc800e7SGuido Günther 
911cc800e7SGuido Günther 	trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
921cc800e7SGuido Günther 	ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
931cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
941cc800e7SGuido Günther 	return ret;
95ba2a9506SAlexander Aring }
96ba2a9506SAlexander Aring 
97ba2a9506SAlexander Aring static inline int
98b69644c1SAlexander Aring rdev_set_cca_ed_level(struct cfg802154_registered_device *rdev, s32 ed_level)
99b69644c1SAlexander Aring {
100b69644c1SAlexander Aring 	int ret;
101b69644c1SAlexander Aring 
102b69644c1SAlexander Aring 	trace_802154_rdev_set_cca_ed_level(&rdev->wpan_phy, ed_level);
103b69644c1SAlexander Aring 	ret = rdev->ops->set_cca_ed_level(&rdev->wpan_phy, ed_level);
104b69644c1SAlexander Aring 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
105b69644c1SAlexander Aring 	return ret;
106b69644c1SAlexander Aring }
107b69644c1SAlexander Aring 
108b69644c1SAlexander Aring static inline int
1090f999b09SVarka Bhadram rdev_set_tx_power(struct cfg802154_registered_device *rdev,
1100f999b09SVarka Bhadram 		  s32 power)
1110f999b09SVarka Bhadram {
1120f999b09SVarka Bhadram 	int ret;
1130f999b09SVarka Bhadram 
1140f999b09SVarka Bhadram 	trace_802154_rdev_set_tx_power(&rdev->wpan_phy, power);
1150f999b09SVarka Bhadram 	ret = rdev->ops->set_tx_power(&rdev->wpan_phy, power);
1160f999b09SVarka Bhadram 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1170f999b09SVarka Bhadram 	return ret;
1180f999b09SVarka Bhadram }
1190f999b09SVarka Bhadram 
1200f999b09SVarka Bhadram static inline int
121702bf371SAlexander Aring rdev_set_pan_id(struct cfg802154_registered_device *rdev,
122ee7b9053SAlexander Aring 		struct wpan_dev *wpan_dev, __le16 pan_id)
123702bf371SAlexander Aring {
1241cc800e7SGuido Günther 	int ret;
1251cc800e7SGuido Günther 
1261cc800e7SGuido Günther 	trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
1271cc800e7SGuido Günther 	ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
1281cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1291cc800e7SGuido Günther 	return ret;
130702bf371SAlexander Aring }
131702bf371SAlexander Aring 
1329830c62aSAlexander Aring static inline int
1339830c62aSAlexander Aring rdev_set_short_addr(struct cfg802154_registered_device *rdev,
134ee7b9053SAlexander Aring 		    struct wpan_dev *wpan_dev, __le16 short_addr)
1359830c62aSAlexander Aring {
1361cc800e7SGuido Günther 	int ret;
1371cc800e7SGuido Günther 
1381cc800e7SGuido Günther 	trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
1391cc800e7SGuido Günther 	ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
1401cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1411cc800e7SGuido Günther 	return ret;
1429830c62aSAlexander Aring }
1439830c62aSAlexander Aring 
144656a999eSAlexander Aring static inline int
145656a999eSAlexander Aring rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
146628b1e11SAlexander Aring 			  struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
147656a999eSAlexander Aring {
1481cc800e7SGuido Günther 	int ret;
1491cc800e7SGuido Günther 
1501cc800e7SGuido Günther 	trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
151656a999eSAlexander Aring 					       min_be, max_be);
1521cc800e7SGuido Günther 	ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
1531cc800e7SGuido Günther 					      min_be, max_be);
1541cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1551cc800e7SGuido Günther 	return ret;
156656a999eSAlexander Aring }
157656a999eSAlexander Aring 
158a01ba765SAlexander Aring static inline int
159a01ba765SAlexander Aring rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
160628b1e11SAlexander Aring 			   struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
161a01ba765SAlexander Aring {
1621cc800e7SGuido Günther 	int ret;
1631cc800e7SGuido Günther 
1641cc800e7SGuido Günther 	trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
165a01ba765SAlexander Aring 					    max_csma_backoffs);
1661cc800e7SGuido Günther 	ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
1671cc800e7SGuido Günther 					       max_csma_backoffs);
1681cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1691cc800e7SGuido Günther 	return ret;
170a01ba765SAlexander Aring }
171a01ba765SAlexander Aring 
17217a3a46bSAlexander Aring static inline int
17317a3a46bSAlexander Aring rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
174628b1e11SAlexander Aring 			   struct wpan_dev *wpan_dev, s8 max_frame_retries)
17517a3a46bSAlexander Aring {
1761cc800e7SGuido Günther 	int ret;
1771cc800e7SGuido Günther 
1781cc800e7SGuido Günther 	trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
17917a3a46bSAlexander Aring 						max_frame_retries);
1801cc800e7SGuido Günther 	ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
1811cc800e7SGuido Günther 					       max_frame_retries);
1821cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1831cc800e7SGuido Günther 	return ret;
18417a3a46bSAlexander Aring }
18517a3a46bSAlexander Aring 
186c8937a1dSAlexander Aring static inline int
187c8937a1dSAlexander Aring rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
188628b1e11SAlexander Aring 		  struct wpan_dev *wpan_dev, bool mode)
189c8937a1dSAlexander Aring {
1901cc800e7SGuido Günther 	int ret;
1911cc800e7SGuido Günther 
1921cc800e7SGuido Günther 	trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
1931cc800e7SGuido Günther 	ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
1941cc800e7SGuido Günther 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
1951cc800e7SGuido Günther 	return ret;
196c8937a1dSAlexander Aring }
197c8937a1dSAlexander Aring 
198*c91208d8SAlexander Aring static inline int
199*c91208d8SAlexander Aring rdev_set_ackreq_default(struct cfg802154_registered_device *rdev,
200*c91208d8SAlexander Aring 			struct wpan_dev *wpan_dev, bool ackreq)
201*c91208d8SAlexander Aring {
202*c91208d8SAlexander Aring 	int ret;
203*c91208d8SAlexander Aring 
204*c91208d8SAlexander Aring 	trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev,
205*c91208d8SAlexander Aring 					     ackreq);
206*c91208d8SAlexander Aring 	ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq);
207*c91208d8SAlexander Aring 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
208*c91208d8SAlexander Aring 	return ret;
209*c91208d8SAlexander Aring }
210*c91208d8SAlexander Aring 
2114a9a816aSAlexander Aring #endif /* __CFG802154_RDEV_OPS */
212