Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / net / wireless / ti / wlcore / hw_ops.h
blobeec56935b1b6acb7625c0ee0018ef023484b9c6e
1 /*
2 * This file is part of wlcore
4 * Copyright (C) 2011 Texas Instruments Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
22 #ifndef __WLCORE_HW_OPS_H__
23 #define __WLCORE_HW_OPS_H__
25 #include "wlcore.h"
26 #include "rx.h"
28 static inline u32
29 wlcore_hw_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
31 if (!wl->ops->calc_tx_blocks)
32 BUG_ON(1);
34 return wl->ops->calc_tx_blocks(wl, len, spare_blks);
37 static inline void
38 wlcore_hw_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
39 u32 blks, u32 spare_blks)
41 if (!wl->ops->set_tx_desc_blocks)
42 BUG_ON(1);
44 return wl->ops->set_tx_desc_blocks(wl, desc, blks, spare_blks);
47 static inline void
48 wlcore_hw_set_tx_desc_data_len(struct wl1271 *wl,
49 struct wl1271_tx_hw_descr *desc,
50 struct sk_buff *skb)
52 if (!wl->ops->set_tx_desc_data_len)
53 BUG_ON(1);
55 wl->ops->set_tx_desc_data_len(wl, desc, skb);
58 static inline enum wl_rx_buf_align
59 wlcore_hw_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
62 if (!wl->ops->get_rx_buf_align)
63 BUG_ON(1);
65 return wl->ops->get_rx_buf_align(wl, rx_desc);
68 static inline int
69 wlcore_hw_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len)
71 if (wl->ops->prepare_read)
72 return wl->ops->prepare_read(wl, rx_desc, len);
74 return 0;
77 static inline u32
78 wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len)
80 if (!wl->ops->get_rx_packet_len)
81 BUG_ON(1);
83 return wl->ops->get_rx_packet_len(wl, rx_data, data_len);
86 static inline int wlcore_hw_tx_delayed_compl(struct wl1271 *wl)
88 if (wl->ops->tx_delayed_compl)
89 return wl->ops->tx_delayed_compl(wl);
91 return 0;
94 static inline void wlcore_hw_tx_immediate_compl(struct wl1271 *wl)
96 if (wl->ops->tx_immediate_compl)
97 wl->ops->tx_immediate_compl(wl);
100 static inline int
101 wlcore_hw_init_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif)
103 if (wl->ops->init_vif)
104 return wl->ops->init_vif(wl, wlvif);
106 return 0;
109 static inline void
110 wlcore_hw_convert_fw_status(struct wl1271 *wl, void *raw_fw_status,
111 struct wl_fw_status *fw_status)
113 BUG_ON(!wl->ops->convert_fw_status);
115 wl->ops->convert_fw_status(wl, raw_fw_status, fw_status);
118 static inline u32
119 wlcore_hw_sta_get_ap_rate_mask(struct wl1271 *wl, struct wl12xx_vif *wlvif)
121 if (!wl->ops->sta_get_ap_rate_mask)
122 BUG_ON(1);
124 return wl->ops->sta_get_ap_rate_mask(wl, wlvif);
127 static inline int wlcore_identify_fw(struct wl1271 *wl)
129 if (wl->ops->identify_fw)
130 return wl->ops->identify_fw(wl);
132 return 0;
135 static inline void
136 wlcore_hw_set_tx_desc_csum(struct wl1271 *wl,
137 struct wl1271_tx_hw_descr *desc,
138 struct sk_buff *skb)
140 if (!wl->ops->set_tx_desc_csum)
141 BUG_ON(1);
143 wl->ops->set_tx_desc_csum(wl, desc, skb);
146 static inline void
147 wlcore_hw_set_rx_csum(struct wl1271 *wl,
148 struct wl1271_rx_descriptor *desc,
149 struct sk_buff *skb)
151 if (wl->ops->set_rx_csum)
152 wl->ops->set_rx_csum(wl, desc, skb);
155 static inline u32
156 wlcore_hw_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
157 struct wl12xx_vif *wlvif)
159 if (wl->ops->ap_get_mimo_wide_rate_mask)
160 return wl->ops->ap_get_mimo_wide_rate_mask(wl, wlvif);
162 return 0;
165 static inline int
166 wlcore_debugfs_init(struct wl1271 *wl, struct dentry *rootdir)
168 if (wl->ops->debugfs_init)
169 return wl->ops->debugfs_init(wl, rootdir);
171 return 0;
174 static inline int
175 wlcore_handle_static_data(struct wl1271 *wl, void *static_data)
177 if (wl->ops->handle_static_data)
178 return wl->ops->handle_static_data(wl, static_data);
180 return 0;
183 static inline int
184 wlcore_hw_get_spare_blocks(struct wl1271 *wl, bool is_gem)
186 if (!wl->ops->get_spare_blocks)
187 BUG_ON(1);
189 return wl->ops->get_spare_blocks(wl, is_gem);
192 static inline int
193 wlcore_hw_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
194 struct ieee80211_vif *vif,
195 struct ieee80211_sta *sta,
196 struct ieee80211_key_conf *key_conf)
198 if (!wl->ops->set_key)
199 BUG_ON(1);
201 return wl->ops->set_key(wl, cmd, vif, sta, key_conf);
204 static inline u32
205 wlcore_hw_pre_pkt_send(struct wl1271 *wl, u32 buf_offset, u32 last_len)
207 if (wl->ops->pre_pkt_send)
208 return wl->ops->pre_pkt_send(wl, buf_offset, last_len);
210 return buf_offset;
213 static inline void
214 wlcore_hw_sta_rc_update(struct wl1271 *wl, struct wl12xx_vif *wlvif)
216 if (wl->ops->sta_rc_update)
217 wl->ops->sta_rc_update(wl, wlvif);
220 static inline int
221 wlcore_hw_interrupt_notify(struct wl1271 *wl, bool action)
223 if (wl->ops->interrupt_notify)
224 return wl->ops->interrupt_notify(wl, action);
225 return 0;
228 static inline int
229 wlcore_hw_rx_ba_filter(struct wl1271 *wl, bool action)
231 if (wl->ops->rx_ba_filter)
232 return wl->ops->rx_ba_filter(wl, action);
233 return 0;
236 static inline int
237 wlcore_hw_ap_sleep(struct wl1271 *wl)
239 if (wl->ops->ap_sleep)
240 return wl->ops->ap_sleep(wl);
242 return 0;
245 static inline int
246 wlcore_hw_set_peer_cap(struct wl1271 *wl,
247 struct ieee80211_sta_ht_cap *ht_cap,
248 bool allow_ht_operation,
249 u32 rate_set, u8 hlid)
251 if (wl->ops->set_peer_cap)
252 return wl->ops->set_peer_cap(wl, ht_cap, allow_ht_operation,
253 rate_set, hlid);
255 return 0;
258 static inline u32
259 wlcore_hw_convert_hwaddr(struct wl1271 *wl, u32 hwaddr)
261 if (!wl->ops->convert_hwaddr)
262 BUG_ON(1);
264 return wl->ops->convert_hwaddr(wl, hwaddr);
267 static inline bool
268 wlcore_hw_lnk_high_prio(struct wl1271 *wl, u8 hlid,
269 struct wl1271_link *lnk)
271 if (!wl->ops->lnk_high_prio)
272 BUG_ON(1);
274 return wl->ops->lnk_high_prio(wl, hlid, lnk);
277 static inline bool
278 wlcore_hw_lnk_low_prio(struct wl1271 *wl, u8 hlid,
279 struct wl1271_link *lnk)
281 if (!wl->ops->lnk_low_prio)
282 BUG_ON(1);
284 return wl->ops->lnk_low_prio(wl, hlid, lnk);
287 static inline int
288 wlcore_smart_config_start(struct wl1271 *wl, u32 group_bitmap)
290 if (!wl->ops->smart_config_start)
291 return -EINVAL;
293 return wl->ops->smart_config_start(wl, group_bitmap);
296 static inline int
297 wlcore_smart_config_stop(struct wl1271 *wl)
299 if (!wl->ops->smart_config_stop)
300 return -EINVAL;
302 return wl->ops->smart_config_stop(wl);
305 static inline int
306 wlcore_smart_config_set_group_key(struct wl1271 *wl, u16 group_id,
307 u8 key_len, u8 *key)
309 if (!wl->ops->smart_config_set_group_key)
310 return -EINVAL;
312 return wl->ops->smart_config_set_group_key(wl, group_id, key_len, key);
315 static inline int
316 wlcore_hw_set_cac(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool start)
318 if (!wl->ops->set_cac)
319 return -EINVAL;
321 return wl->ops->set_cac(wl, wlvif, start);
324 static inline int
325 wlcore_hw_dfs_master_restart(struct wl1271 *wl, struct wl12xx_vif *wlvif)
327 if (!wl->ops->dfs_master_restart)
328 return -EINVAL;
330 return wl->ops->dfs_master_restart(wl, wlvif);
332 #endif