hw_ops.h revision 7140df6e51ecca70e8963f18e9836e62090221c2
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
28static inline u32
29wlcore_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
37static inline void
38wlcore_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
47static inline void
48wlcore_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
58static inline enum wl_rx_buf_align
59wlcore_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
68static inline void
69wlcore_hw_prepare_read(struct wl1271 *wl, u32 rx_desc, u32 len)
70{
71	if (wl->ops->prepare_read)
72		wl->ops->prepare_read(wl, rx_desc, len);
73}
74
75static inline u32
76wlcore_hw_get_rx_packet_len(struct wl1271 *wl, void *rx_data, u32 data_len)
77{
78	if (!wl->ops->get_rx_packet_len)
79		BUG_ON(1);
80
81	return wl->ops->get_rx_packet_len(wl, rx_data, data_len);
82}
83
84static inline void wlcore_hw_tx_delayed_compl(struct wl1271 *wl)
85{
86	if (wl->ops->tx_delayed_compl)
87		wl->ops->tx_delayed_compl(wl);
88}
89
90static inline void wlcore_hw_tx_immediate_compl(struct wl1271 *wl)
91{
92	if (wl->ops->tx_immediate_compl)
93		wl->ops->tx_immediate_compl(wl);
94}
95
96static inline int
97wlcore_hw_init_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif)
98{
99	if (wl->ops->init_vif)
100		return wl->ops->init_vif(wl, wlvif);
101
102	return 0;
103}
104
105static inline u32
106wlcore_hw_sta_get_ap_rate_mask(struct wl1271 *wl, struct wl12xx_vif *wlvif)
107{
108	if (!wl->ops->sta_get_ap_rate_mask)
109		BUG_ON(1);
110
111	return wl->ops->sta_get_ap_rate_mask(wl, wlvif);
112}
113
114static inline int wlcore_identify_fw(struct wl1271 *wl)
115{
116	if (wl->ops->identify_fw)
117		return wl->ops->identify_fw(wl);
118
119	return 0;
120}
121
122static inline void
123wlcore_hw_set_tx_desc_csum(struct wl1271 *wl,
124			   struct wl1271_tx_hw_descr *desc,
125			   struct sk_buff *skb)
126{
127	if (!wl->ops->set_tx_desc_csum)
128		BUG_ON(1);
129
130	wl->ops->set_tx_desc_csum(wl, desc, skb);
131}
132
133static inline void
134wlcore_hw_set_rx_csum(struct wl1271 *wl,
135		      struct wl1271_rx_descriptor *desc,
136		      struct sk_buff *skb)
137{
138	if (wl->ops->set_rx_csum)
139		wl->ops->set_rx_csum(wl, desc, skb);
140}
141
142static inline u32
143wlcore_hw_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
144				     struct wl12xx_vif *wlvif)
145{
146	if (wl->ops->ap_get_mimo_wide_rate_mask)
147		return wl->ops->ap_get_mimo_wide_rate_mask(wl, wlvif);
148
149	return 0;
150}
151
152static inline int
153wlcore_debugfs_init(struct wl1271 *wl, struct dentry *rootdir)
154{
155	if (wl->ops->debugfs_init)
156		return wl->ops->debugfs_init(wl, rootdir);
157
158	return 0;
159}
160
161static inline int
162wlcore_handle_static_data(struct wl1271 *wl, void *static_data)
163{
164	if (wl->ops->handle_static_data)
165		return wl->ops->handle_static_data(wl, static_data);
166
167	return 0;
168}
169
170#endif
171