carlu: fix conflicting function declaration types
[carl9170fw.git] / tools / carlu / src / carlu.h
1 /*
2  * carl9170user - userspace testing utility for ar9170 devices
3  *
4  * common API declaration
5  *
6  * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __CARL9170USER_H
24 #define __CARL9170USER_H
25
26 #include "SDL.h"
27 #include "SDL_thread.h"
28
29 #include "carlfw.h"
30
31 #include "debug.h"
32 #include "hw.h"
33 #include "fwcmd.h"
34 #include "frame.h"
35 #include "eeprom.h"
36 #include "ieee80211.h"
37 #include "wlan.h"
38 #include "usb.h"
39
40 struct carlu {
41         libusb_device_handle *dev;
42         libusb_context *ctx;
43
44         SDL_Thread *event_thread;
45         bool stop_event_polling;
46
47         struct libusb_transfer *rx_ring[AR9170_RX_BULK_BUFS];
48
49         struct libusb_transfer *rx_interrupt;
50         unsigned char irq_buf[AR9170_RX_BULK_IRQ_SIZE];
51
52         union {
53                 unsigned char buf[CARL9170_MAX_CMD_LEN];
54                 uint32_t buf4[CARL9170_MAX_CMD_LEN / sizeof(uint32_t)];
55                 struct carl9170_cmd cmd;
56                 struct carl9170_rsp rsp;
57         } cmd;
58
59         struct list_head tx_queue;
60         SDL_mutex *tx_queue_lock;
61         unsigned int tx_queue_len;
62
63         struct list_head dev_list;
64         unsigned int idx;
65
66         unsigned int miniboot_size;
67         unsigned int rx_max;
68
69         int event_pipe[2];
70
71         SDL_cond *resp_pend;
72         SDL_mutex *resp_lock;
73         uint8_t *resp_buf;
74         size_t resp_len;
75
76         int tx_pending;
77         uint8_t cookie;
78
79         void (*tx_cb)(struct carlu *, struct frame *);
80         void (*tx_fb_cb)(struct carlu *, struct frame *);
81         void (*rx_cb)(struct carlu *, void *, unsigned int);
82         int (*cmd_cb)(struct carlu *, struct carl9170_rsp *,
83                       void *, unsigned int);
84
85         struct carlfw *fw;
86
87         struct ar9170_eeprom eeprom;
88
89         struct frame_queue tx_sent_queue[__AR9170_NUM_TXQ];
90
91         SDL_mutex *mem_lock;
92         unsigned int dma_chunks;
93         unsigned int dma_chunk_size;
94         unsigned int used_dma_chunks;
95
96         unsigned int extra_headroom;
97         bool tx_stream;
98         bool rx_stream;
99
100         /* statistics */
101         unsigned int rxed;
102         unsigned int txed;
103
104         unsigned long tx_octets;
105         unsigned long rx_octets;
106 };
107
108 struct carlu_rate {
109         int8_t rix;
110         int8_t cnt;
111         uint8_t flags;
112 };
113
114 struct carlu_tx_info_tx {
115         unsigned int key;
116 };
117
118 struct carlu_tx_info {
119         uint32_t flags;
120
121         struct carlu_rate rates[CARL9170_TX_MAX_RATES];
122
123         union {
124                 struct carlu_tx_info_tx tx;
125         };
126 };
127
128 static inline struct carlu_tx_info *get_tx_info(struct frame *frame)
129 {
130         return (void *) frame->cb;
131 }
132
133 void *carlu_alloc_driver(size_t size);
134 void carlu_free_driver(struct carlu *ar);
135
136 int carlu_fw_check(struct carlu *ar);
137 void carlu_fw_info(struct carlu *ar);
138
139 void carlu_rx(struct carlu *ar, struct frame *frame);
140 int carlu_tx(struct carlu *ar, struct frame *frame);
141 void carlu_tx_feedback(struct carlu *ar,
142                           struct carl9170_rsp *cmd);
143 void carlu_handle_command(struct carlu *ar, void *buf, unsigned int len);
144
145 struct frame *carlu_alloc_frame(struct carlu *ar, unsigned int size);
146 void carlu_free_frame(struct carlu *ar, struct frame *frame);
147 #endif /* __CARL9170USER_H */