• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of wlcore
3  *
4  * Copyright (C) 2011 Texas Instruments Inc.
5  *
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.
9  *
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.
14  *
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
19  *
20  */
21 
22 #ifndef __WLCORE_HW_OPS_H__
23 #define __WLCORE_HW_OPS_H__
24 
25 #include "wlcore.h"
26 #include "rx.h"
27 
28 static inline u32
wlcore_hw_calc_tx_blocks(struct wl1271 * wl,u32 len,u32 spare_blks)29 wlcore_hw_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
30 {
31 	if (!wl->ops->calc_tx_blocks)
32 		BUG_ON(1);
33 
34 	return wl->ops->calc_tx_blocks(wl, len, spare_blks);
35 }
36 
37 static inline void
wlcore_hw_set_tx_desc_blocks(struct wl1271 * wl,struct wl1271_tx_hw_descr * desc,u32 blks,u32 spare_blks)38 wlcore_hw_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
39 			     u32 blks, u32 spare_blks)
40 {
41 	if (!wl->ops->set_tx_desc_blocks)
42 		BUG_ON(1);
43 
44 	return wl->ops->set_tx_desc_blocks(wl, desc, blks, spare_blks);
45 }
46 
47 static inline void
wlcore_hw_set_tx_desc_data_len(struct wl1271 * wl,struct wl1271_tx_hw_descr * desc,struct sk_buff * skb)48 wlcore_hw_set_tx_desc_data_len(struct wl1271 *wl,
49 			       struct wl1271_tx_hw_descr *desc,
50 			       struct sk_buff *skb)
51 {
52 	if (!wl->ops->set_tx_desc_data_len)
53 		BUG_ON(1);
54 
55 	wl->ops->set_tx_desc_data_len(wl, desc, skb);
56 }
57 
58 static inline enum wl_rx_buf_align
wlcore_hw_get_rx_buf_align(struct wl1271 * wl,u32 rx_desc)59 wlcore_hw_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
60 {
61 
62 	if (!wl->ops->get_rx_buf_align)
63 		BUG_ON(1);
64 
65 	return wl->ops->get_rx_buf_align(wl, rx_desc);
66 }
67 
68 static inline int
wlcore_hw_prepare_read(struct wl1271 * wl,u32 rx_desc,u32 len)69 wlcore_hw_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len)
70 {
71 	if (wl->ops->prepare_read)
72 		return wl->ops->prepare_read(wl, rx_desc, len);
73 
74 	return 0;
75 }
76 
77 static inline u32
wlcore_hw_get_rx_packet_len(struct wl1271 * wl,void * rx_data,u32 data_len)78 wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len)
79 {
80 	if (!wl->ops->get_rx_packet_len)
81 		BUG_ON(1);
82 
83 	return wl->ops->get_rx_packet_len(wl, rx_data, data_len);
84 }
85 
wlcore_hw_tx_delayed_compl(struct wl1271 * wl)86 static inline int wlcore_hw_tx_delayed_compl(struct wl1271 *wl)
87 {
88 	if (wl->ops->tx_delayed_compl)
89 		return wl->ops->tx_delayed_compl(wl);
90 
91 	return 0;
92 }
93 
wlcore_hw_tx_immediate_compl(struct wl1271 * wl)94 static inline void wlcore_hw_tx_immediate_compl(struct wl1271 *wl)
95 {
96 	if (wl->ops->tx_immediate_compl)
97 		wl->ops->tx_immediate_compl(wl);
98 }
99 
100 static inline int
wlcore_hw_init_vif(struct wl1271 * wl,struct wl12xx_vif * wlvif)101 wlcore_hw_init_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif)
102 {
103 	if (wl->ops->init_vif)
104 		return wl->ops->init_vif(wl, wlvif);
105 
106 	return 0;
107 }
108 
109 static inline u32
wlcore_hw_sta_get_ap_rate_mask(struct wl1271 * wl,struct wl12xx_vif * wlvif)110 wlcore_hw_sta_get_ap_rate_mask(struct wl1271 *wl, struct wl12xx_vif *wlvif)
111 {
112 	if (!wl->ops->sta_get_ap_rate_mask)
113 		BUG_ON(1);
114 
115 	return wl->ops->sta_get_ap_rate_mask(wl, wlvif);
116 }
117 
wlcore_identify_fw(struct wl1271 * wl)118 static inline int wlcore_identify_fw(struct wl1271 *wl)
119 {
120 	if (wl->ops->identify_fw)
121 		return wl->ops->identify_fw(wl);
122 
123 	return 0;
124 }
125 
126 static inline void
wlcore_hw_set_tx_desc_csum(struct wl1271 * wl,struct wl1271_tx_hw_descr * desc,struct sk_buff * skb)127 wlcore_hw_set_tx_desc_csum(struct wl1271 *wl,
128 			   struct wl1271_tx_hw_descr *desc,
129 			   struct sk_buff *skb)
130 {
131 	if (!wl->ops->set_tx_desc_csum)
132 		BUG_ON(1);
133 
134 	wl->ops->set_tx_desc_csum(wl, desc, skb);
135 }
136 
137 static inline void
wlcore_hw_set_rx_csum(struct wl1271 * wl,struct wl1271_rx_descriptor * desc,struct sk_buff * skb)138 wlcore_hw_set_rx_csum(struct wl1271 *wl,
139 		      struct wl1271_rx_descriptor *desc,
140 		      struct sk_buff *skb)
141 {
142 	if (wl->ops->set_rx_csum)
143 		wl->ops->set_rx_csum(wl, desc, skb);
144 }
145 
146 static inline u32
wlcore_hw_ap_get_mimo_wide_rate_mask(struct wl1271 * wl,struct wl12xx_vif * wlvif)147 wlcore_hw_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
148 				     struct wl12xx_vif *wlvif)
149 {
150 	if (wl->ops->ap_get_mimo_wide_rate_mask)
151 		return wl->ops->ap_get_mimo_wide_rate_mask(wl, wlvif);
152 
153 	return 0;
154 }
155 
156 static inline int
wlcore_debugfs_init(struct wl1271 * wl,struct dentry * rootdir)157 wlcore_debugfs_init(struct wl1271 *wl, struct dentry *rootdir)
158 {
159 	if (wl->ops->debugfs_init)
160 		return wl->ops->debugfs_init(wl, rootdir);
161 
162 	return 0;
163 }
164 
165 static inline int
wlcore_handle_static_data(struct wl1271 * wl,void * static_data)166 wlcore_handle_static_data(struct wl1271 *wl, void *static_data)
167 {
168 	if (wl->ops->handle_static_data)
169 		return wl->ops->handle_static_data(wl, static_data);
170 
171 	return 0;
172 }
173 
174 static inline int
wlcore_hw_get_spare_blocks(struct wl1271 * wl,bool is_gem)175 wlcore_hw_get_spare_blocks(struct wl1271 *wl, bool is_gem)
176 {
177 	if (!wl->ops->get_spare_blocks)
178 		BUG_ON(1);
179 
180 	return wl->ops->get_spare_blocks(wl, is_gem);
181 }
182 
183 static inline int
wlcore_hw_set_key(struct wl1271 * wl,enum set_key_cmd cmd,struct ieee80211_vif * vif,struct ieee80211_sta * sta,struct ieee80211_key_conf * key_conf)184 wlcore_hw_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
185 		  struct ieee80211_vif *vif,
186 		  struct ieee80211_sta *sta,
187 		  struct ieee80211_key_conf *key_conf)
188 {
189 	if (!wl->ops->set_key)
190 		BUG_ON(1);
191 
192 	return wl->ops->set_key(wl, cmd, vif, sta, key_conf);
193 }
194 
195 static inline u32
wlcore_hw_pre_pkt_send(struct wl1271 * wl,u32 buf_offset,u32 last_len)196 wlcore_hw_pre_pkt_send(struct wl1271 *wl, u32 buf_offset, u32 last_len)
197 {
198 	if (wl->ops->pre_pkt_send)
199 		return wl->ops->pre_pkt_send(wl, buf_offset, last_len);
200 
201 	return buf_offset;
202 }
203 
204 static inline void
wlcore_hw_sta_rc_update(struct wl1271 * wl,struct wl12xx_vif * wlvif,struct ieee80211_sta * sta,u32 changed)205 wlcore_hw_sta_rc_update(struct wl1271 *wl, struct wl12xx_vif *wlvif,
206 			struct ieee80211_sta *sta, u32 changed)
207 {
208 	if (wl->ops->sta_rc_update)
209 		wl->ops->sta_rc_update(wl, wlvif, sta, changed);
210 }
211 
212 static inline int
wlcore_hw_set_peer_cap(struct wl1271 * wl,struct ieee80211_sta_ht_cap * ht_cap,bool allow_ht_operation,u32 rate_set,u8 hlid)213 wlcore_hw_set_peer_cap(struct wl1271 *wl,
214 		       struct ieee80211_sta_ht_cap *ht_cap,
215 		       bool allow_ht_operation,
216 		       u32 rate_set, u8 hlid)
217 {
218 	if (wl->ops->set_peer_cap)
219 		return wl->ops->set_peer_cap(wl, ht_cap, allow_ht_operation,
220 					     rate_set, hlid);
221 
222 	return 0;
223 }
224 
225 static inline bool
wlcore_hw_lnk_high_prio(struct wl1271 * wl,u8 hlid,struct wl1271_link * lnk)226 wlcore_hw_lnk_high_prio(struct wl1271 *wl, u8 hlid,
227 			struct wl1271_link *lnk)
228 {
229 	if (!wl->ops->lnk_high_prio)
230 		BUG_ON(1);
231 
232 	return wl->ops->lnk_high_prio(wl, hlid, lnk);
233 }
234 
235 static inline bool
wlcore_hw_lnk_low_prio(struct wl1271 * wl,u8 hlid,struct wl1271_link * lnk)236 wlcore_hw_lnk_low_prio(struct wl1271 *wl, u8 hlid,
237 		       struct wl1271_link *lnk)
238 {
239 	if (!wl->ops->lnk_low_prio)
240 		BUG_ON(1);
241 
242 	return wl->ops->lnk_low_prio(wl, hlid, lnk);
243 }
244 
245 #endif
246