xref: /openbmc/linux/net/mac80211/driver-ops.h (revision 3ac64bee)
124487981SJohannes Berg #ifndef __MAC80211_DRIVER_OPS
224487981SJohannes Berg #define __MAC80211_DRIVER_OPS
324487981SJohannes Berg 
424487981SJohannes Berg #include <net/mac80211.h>
524487981SJohannes Berg #include "ieee80211_i.h"
60a2b8bb2SJohannes Berg #include "driver-trace.h"
724487981SJohannes Berg 
824487981SJohannes Berg static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
924487981SJohannes Berg {
1024487981SJohannes Berg 	return local->ops->tx(&local->hw, skb);
1124487981SJohannes Berg }
1224487981SJohannes Berg 
1324487981SJohannes Berg static inline int drv_start(struct ieee80211_local *local)
1424487981SJohannes Berg {
150a2b8bb2SJohannes Berg 	int ret = local->ops->start(&local->hw);
160a2b8bb2SJohannes Berg 	trace_drv_start(local, ret);
170a2b8bb2SJohannes Berg 	return ret;
1824487981SJohannes Berg }
1924487981SJohannes Berg 
2024487981SJohannes Berg static inline void drv_stop(struct ieee80211_local *local)
2124487981SJohannes Berg {
2224487981SJohannes Berg 	local->ops->stop(&local->hw);
230a2b8bb2SJohannes Berg 	trace_drv_stop(local);
2424487981SJohannes Berg }
2524487981SJohannes Berg 
2624487981SJohannes Berg static inline int drv_add_interface(struct ieee80211_local *local,
2724487981SJohannes Berg 				    struct ieee80211_if_init_conf *conf)
2824487981SJohannes Berg {
290a2b8bb2SJohannes Berg 	int ret = local->ops->add_interface(&local->hw, conf);
300a2b8bb2SJohannes Berg 	trace_drv_add_interface(local, conf->mac_addr, conf->vif, ret);
310a2b8bb2SJohannes Berg 	return ret;
3224487981SJohannes Berg }
3324487981SJohannes Berg 
3424487981SJohannes Berg static inline void drv_remove_interface(struct ieee80211_local *local,
3524487981SJohannes Berg 					struct ieee80211_if_init_conf *conf)
3624487981SJohannes Berg {
3724487981SJohannes Berg 	local->ops->remove_interface(&local->hw, conf);
380a2b8bb2SJohannes Berg 	trace_drv_remove_interface(local, conf->mac_addr, conf->vif);
3924487981SJohannes Berg }
4024487981SJohannes Berg 
4124487981SJohannes Berg static inline int drv_config(struct ieee80211_local *local, u32 changed)
4224487981SJohannes Berg {
430a2b8bb2SJohannes Berg 	int ret = local->ops->config(&local->hw, changed);
440a2b8bb2SJohannes Berg 	trace_drv_config(local, changed, ret);
450a2b8bb2SJohannes Berg 	return ret;
4624487981SJohannes Berg }
4724487981SJohannes Berg 
4824487981SJohannes Berg static inline void drv_bss_info_changed(struct ieee80211_local *local,
4924487981SJohannes Berg 					struct ieee80211_vif *vif,
5024487981SJohannes Berg 					struct ieee80211_bss_conf *info,
5124487981SJohannes Berg 					u32 changed)
5224487981SJohannes Berg {
5324487981SJohannes Berg 	if (local->ops->bss_info_changed)
5424487981SJohannes Berg 		local->ops->bss_info_changed(&local->hw, vif, info, changed);
550a2b8bb2SJohannes Berg 	trace_drv_bss_info_changed(local, vif, info, changed);
5624487981SJohannes Berg }
5724487981SJohannes Berg 
583ac64beeSJohannes Berg static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
5924487981SJohannes Berg 					int mc_count,
6024487981SJohannes Berg 					struct dev_addr_list *mc_list)
6124487981SJohannes Berg {
623ac64beeSJohannes Berg 	u64 ret = 0;
633ac64beeSJohannes Berg 
643ac64beeSJohannes Berg 	if (local->ops->prepare_multicast)
653ac64beeSJohannes Berg 		ret = local->ops->prepare_multicast(&local->hw, mc_count,
663ac64beeSJohannes Berg 						    mc_list);
673ac64beeSJohannes Berg 
683ac64beeSJohannes Berg 	trace_drv_prepare_multicast(local, mc_count, ret);
693ac64beeSJohannes Berg 
703ac64beeSJohannes Berg 	return ret;
713ac64beeSJohannes Berg }
723ac64beeSJohannes Berg 
733ac64beeSJohannes Berg static inline void drv_configure_filter(struct ieee80211_local *local,
743ac64beeSJohannes Berg 					unsigned int changed_flags,
753ac64beeSJohannes Berg 					unsigned int *total_flags,
763ac64beeSJohannes Berg 					u64 multicast)
773ac64beeSJohannes Berg {
783ac64beeSJohannes Berg 	might_sleep();
793ac64beeSJohannes Berg 
8024487981SJohannes Berg 	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
813ac64beeSJohannes Berg 				     multicast);
820a2b8bb2SJohannes Berg 	trace_drv_configure_filter(local, changed_flags, total_flags,
833ac64beeSJohannes Berg 				   multicast);
8424487981SJohannes Berg }
8524487981SJohannes Berg 
8624487981SJohannes Berg static inline int drv_set_tim(struct ieee80211_local *local,
8724487981SJohannes Berg 			      struct ieee80211_sta *sta, bool set)
8824487981SJohannes Berg {
890a2b8bb2SJohannes Berg 	int ret = 0;
9024487981SJohannes Berg 	if (local->ops->set_tim)
910a2b8bb2SJohannes Berg 		ret = local->ops->set_tim(&local->hw, sta, set);
920a2b8bb2SJohannes Berg 	trace_drv_set_tim(local, sta, set, ret);
930a2b8bb2SJohannes Berg 	return ret;
9424487981SJohannes Berg }
9524487981SJohannes Berg 
9624487981SJohannes Berg static inline int drv_set_key(struct ieee80211_local *local,
9724487981SJohannes Berg 			      enum set_key_cmd cmd, struct ieee80211_vif *vif,
9824487981SJohannes Berg 			      struct ieee80211_sta *sta,
9924487981SJohannes Berg 			      struct ieee80211_key_conf *key)
10024487981SJohannes Berg {
1010a2b8bb2SJohannes Berg 	int ret = local->ops->set_key(&local->hw, cmd, vif, sta, key);
1020a2b8bb2SJohannes Berg 	trace_drv_set_key(local, cmd, vif, sta, key, ret);
1030a2b8bb2SJohannes Berg 	return ret;
10424487981SJohannes Berg }
10524487981SJohannes Berg 
10624487981SJohannes Berg static inline void drv_update_tkip_key(struct ieee80211_local *local,
10724487981SJohannes Berg 				       struct ieee80211_key_conf *conf,
10824487981SJohannes Berg 				       const u8 *address, u32 iv32,
10924487981SJohannes Berg 				       u16 *phase1key)
11024487981SJohannes Berg {
11124487981SJohannes Berg 	if (local->ops->update_tkip_key)
11224487981SJohannes Berg 		local->ops->update_tkip_key(&local->hw, conf, address,
11324487981SJohannes Berg 					    iv32, phase1key);
1140a2b8bb2SJohannes Berg 	trace_drv_update_tkip_key(local, conf, address, iv32);
11524487981SJohannes Berg }
11624487981SJohannes Berg 
11724487981SJohannes Berg static inline int drv_hw_scan(struct ieee80211_local *local,
11824487981SJohannes Berg 			      struct cfg80211_scan_request *req)
11924487981SJohannes Berg {
1200a2b8bb2SJohannes Berg 	int ret = local->ops->hw_scan(&local->hw, req);
1210a2b8bb2SJohannes Berg 	trace_drv_hw_scan(local, req, ret);
1220a2b8bb2SJohannes Berg 	return ret;
12324487981SJohannes Berg }
12424487981SJohannes Berg 
12524487981SJohannes Berg static inline void drv_sw_scan_start(struct ieee80211_local *local)
12624487981SJohannes Berg {
12724487981SJohannes Berg 	if (local->ops->sw_scan_start)
12824487981SJohannes Berg 		local->ops->sw_scan_start(&local->hw);
1290a2b8bb2SJohannes Berg 	trace_drv_sw_scan_start(local);
13024487981SJohannes Berg }
13124487981SJohannes Berg 
13224487981SJohannes Berg static inline void drv_sw_scan_complete(struct ieee80211_local *local)
13324487981SJohannes Berg {
13424487981SJohannes Berg 	if (local->ops->sw_scan_complete)
13524487981SJohannes Berg 		local->ops->sw_scan_complete(&local->hw);
1360a2b8bb2SJohannes Berg 	trace_drv_sw_scan_complete(local);
13724487981SJohannes Berg }
13824487981SJohannes Berg 
13924487981SJohannes Berg static inline int drv_get_stats(struct ieee80211_local *local,
14024487981SJohannes Berg 				struct ieee80211_low_level_stats *stats)
14124487981SJohannes Berg {
1420a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
1430a2b8bb2SJohannes Berg 
1440a2b8bb2SJohannes Berg 	if (local->ops->get_stats)
1450a2b8bb2SJohannes Berg 		ret = local->ops->get_stats(&local->hw, stats);
1460a2b8bb2SJohannes Berg 	trace_drv_get_stats(local, stats, ret);
1470a2b8bb2SJohannes Berg 
1480a2b8bb2SJohannes Berg 	return ret;
14924487981SJohannes Berg }
15024487981SJohannes Berg 
15124487981SJohannes Berg static inline void drv_get_tkip_seq(struct ieee80211_local *local,
15224487981SJohannes Berg 				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
15324487981SJohannes Berg {
15424487981SJohannes Berg 	if (local->ops->get_tkip_seq)
15524487981SJohannes Berg 		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
1560a2b8bb2SJohannes Berg 	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
15724487981SJohannes Berg }
15824487981SJohannes Berg 
15924487981SJohannes Berg static inline int drv_set_rts_threshold(struct ieee80211_local *local,
16024487981SJohannes Berg 					u32 value)
16124487981SJohannes Berg {
1620a2b8bb2SJohannes Berg 	int ret = 0;
16324487981SJohannes Berg 	if (local->ops->set_rts_threshold)
1640a2b8bb2SJohannes Berg 		ret = local->ops->set_rts_threshold(&local->hw, value);
1650a2b8bb2SJohannes Berg 	trace_drv_set_rts_threshold(local, value, ret);
1660a2b8bb2SJohannes Berg 	return ret;
16724487981SJohannes Berg }
16824487981SJohannes Berg 
16924487981SJohannes Berg static inline void drv_sta_notify(struct ieee80211_local *local,
17024487981SJohannes Berg 				  struct ieee80211_vif *vif,
17124487981SJohannes Berg 				  enum sta_notify_cmd cmd,
17224487981SJohannes Berg 				  struct ieee80211_sta *sta)
17324487981SJohannes Berg {
17424487981SJohannes Berg 	if (local->ops->sta_notify)
17524487981SJohannes Berg 		local->ops->sta_notify(&local->hw, vif, cmd, sta);
1760a2b8bb2SJohannes Berg 	trace_drv_sta_notify(local, vif, cmd, sta);
17724487981SJohannes Berg }
17824487981SJohannes Berg 
17924487981SJohannes Berg static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
18024487981SJohannes Berg 			      const struct ieee80211_tx_queue_params *params)
18124487981SJohannes Berg {
1820a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
18324487981SJohannes Berg 	if (local->ops->conf_tx)
1840a2b8bb2SJohannes Berg 		ret = local->ops->conf_tx(&local->hw, queue, params);
1850a2b8bb2SJohannes Berg 	trace_drv_conf_tx(local, queue, params, ret);
1860a2b8bb2SJohannes Berg 	return ret;
18724487981SJohannes Berg }
18824487981SJohannes Berg 
18924487981SJohannes Berg static inline int drv_get_tx_stats(struct ieee80211_local *local,
19024487981SJohannes Berg 				   struct ieee80211_tx_queue_stats *stats)
19124487981SJohannes Berg {
1920a2b8bb2SJohannes Berg 	int ret = local->ops->get_tx_stats(&local->hw, stats);
1930a2b8bb2SJohannes Berg 	trace_drv_get_tx_stats(local, stats, ret);
1940a2b8bb2SJohannes Berg 	return ret;
19524487981SJohannes Berg }
19624487981SJohannes Berg 
19724487981SJohannes Berg static inline u64 drv_get_tsf(struct ieee80211_local *local)
19824487981SJohannes Berg {
1990a2b8bb2SJohannes Berg 	u64 ret = -1ULL;
20024487981SJohannes Berg 	if (local->ops->get_tsf)
2010a2b8bb2SJohannes Berg 		ret = local->ops->get_tsf(&local->hw);
2020a2b8bb2SJohannes Berg 	trace_drv_get_tsf(local, ret);
2030a2b8bb2SJohannes Berg 	return ret;
20424487981SJohannes Berg }
20524487981SJohannes Berg 
20624487981SJohannes Berg static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
20724487981SJohannes Berg {
20824487981SJohannes Berg 	if (local->ops->set_tsf)
20924487981SJohannes Berg 		local->ops->set_tsf(&local->hw, tsf);
2100a2b8bb2SJohannes Berg 	trace_drv_set_tsf(local, tsf);
21124487981SJohannes Berg }
21224487981SJohannes Berg 
21324487981SJohannes Berg static inline void drv_reset_tsf(struct ieee80211_local *local)
21424487981SJohannes Berg {
21524487981SJohannes Berg 	if (local->ops->reset_tsf)
21624487981SJohannes Berg 		local->ops->reset_tsf(&local->hw);
2170a2b8bb2SJohannes Berg 	trace_drv_reset_tsf(local);
21824487981SJohannes Berg }
21924487981SJohannes Berg 
22024487981SJohannes Berg static inline int drv_tx_last_beacon(struct ieee80211_local *local)
22124487981SJohannes Berg {
2220a2b8bb2SJohannes Berg 	int ret = 1;
22324487981SJohannes Berg 	if (local->ops->tx_last_beacon)
2240a2b8bb2SJohannes Berg 		ret = local->ops->tx_last_beacon(&local->hw);
2250a2b8bb2SJohannes Berg 	trace_drv_tx_last_beacon(local, ret);
2260a2b8bb2SJohannes Berg 	return ret;
22724487981SJohannes Berg }
22824487981SJohannes Berg 
22924487981SJohannes Berg static inline int drv_ampdu_action(struct ieee80211_local *local,
23024487981SJohannes Berg 				   enum ieee80211_ampdu_mlme_action action,
23124487981SJohannes Berg 				   struct ieee80211_sta *sta, u16 tid,
23224487981SJohannes Berg 				   u16 *ssn)
23324487981SJohannes Berg {
2340a2b8bb2SJohannes Berg 	int ret = -EOPNOTSUPP;
23524487981SJohannes Berg 	if (local->ops->ampdu_action)
2360a2b8bb2SJohannes Berg 		ret = local->ops->ampdu_action(&local->hw, action,
23724487981SJohannes Berg 					       sta, tid, ssn);
2380a2b8bb2SJohannes Berg 	trace_drv_ampdu_action(local, action, sta, tid, ssn, ret);
2390a2b8bb2SJohannes Berg 	return ret;
24024487981SJohannes Berg }
2411f87f7d3SJohannes Berg 
2421f87f7d3SJohannes Berg 
2431f87f7d3SJohannes Berg static inline void drv_rfkill_poll(struct ieee80211_local *local)
2441f87f7d3SJohannes Berg {
2451f87f7d3SJohannes Berg 	if (local->ops->rfkill_poll)
2461f87f7d3SJohannes Berg 		local->ops->rfkill_poll(&local->hw);
2471f87f7d3SJohannes Berg }
24824487981SJohannes Berg #endif /* __MAC80211_DRIVER_OPS */
249