aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-dev.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-07-24 14:13:05 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-27 15:24:21 -0400
commitc2acea8e9b86ba5a5469ff477445676a223af4e2 (patch)
tree3c4705b13dd5c85817a1132a17743757135b7047 /drivers/net/wireless/iwlwifi/iwl-dev.h
parentfbf3a2af3834e8e93e9c2876de62c5b49988e352 (diff)
iwlwifi: fix up command sending
The current command sending in iwlwifi is a bit of a mess: 1) there is a struct, iwl_cmd, that contains both driver and device data in a single packed structure -- this is very confusing 2) the on-stack data and the command metadata share a structure by embedding the latter in the former, which is also rather confusing because it leads to weird unions and similarly odd constructs 3) each txq always has enough space for 256 commands, even if only 32 end up being used This patch fixes these things: 1) rename iwl_cmd to iwl_device_cmd and keep track of command metadata and device command separately, in two arrays in each tx queue 2) remove the 'meta' member from iwl_host_cmd and only put in the required members 3) allocate the cmd/meta arrays separately instead of embedding them into the txq structure Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-dev.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h69
1 files changed, 40 insertions, 29 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index cddf17350c4b..ce765f79275a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -150,6 +150,31 @@ struct iwl_rx_mem_buffer {
150 struct list_head list; 150 struct list_head list;
151}; 151};
152 152
153/* defined below */
154struct iwl_device_cmd;
155
156struct iwl_cmd_meta {
157 /* only for SYNC commands, iff the reply skb is wanted */
158 struct iwl_host_cmd *source;
159 /*
160 * only for ASYNC commands
161 * (which is somewhat stupid -- look at iwl-sta.c for instance
162 * which duplicates a bunch of code because the callback isn't
163 * invoked for SYNC commands, if it were and its result passed
164 * through it would be simpler...)
165 */
166 int (*callback)(struct iwl_priv *priv,
167 struct iwl_device_cmd *cmd,
168 struct sk_buff *skb);
169
170 /* The CMD_SIZE_HUGE flag bit indicates that the command
171 * structure is stored at the end of the shared queue memory. */
172 u32 flags;
173
174 DECLARE_PCI_UNMAP_ADDR(mapping)
175 DECLARE_PCI_UNMAP_LEN(len)
176};
177
153/* 178/*
154 * Generic queue structure 179 * Generic queue structure
155 * 180 *
@@ -177,7 +202,8 @@ struct iwl_tx_info {
177 * struct iwl_tx_queue - Tx Queue for DMA 202 * struct iwl_tx_queue - Tx Queue for DMA
178 * @q: generic Rx/Tx queue descriptor 203 * @q: generic Rx/Tx queue descriptor
179 * @bd: base of circular buffer of TFDs 204 * @bd: base of circular buffer of TFDs
180 * @cmd: array of command/Tx buffers 205 * @cmd: array of command/TX buffer pointers
206 * @meta: array of meta data for each command/tx buffer
181 * @dma_addr_cmd: physical address of cmd/tx buffer array 207 * @dma_addr_cmd: physical address of cmd/tx buffer array
182 * @txb: array of per-TFD driver data 208 * @txb: array of per-TFD driver data
183 * @need_update: indicates need to update read/write index 209 * @need_update: indicates need to update read/write index
@@ -192,7 +218,8 @@ struct iwl_tx_info {
192struct iwl_tx_queue { 218struct iwl_tx_queue {
193 struct iwl_queue q; 219 struct iwl_queue q;
194 void *tfds; 220 void *tfds;
195 struct iwl_cmd *cmd[TFD_TX_CMD_SLOTS]; 221 struct iwl_device_cmd **cmd;
222 struct iwl_cmd_meta *meta;
196 struct iwl_tx_info *txb; 223 struct iwl_tx_info *txb;
197 u8 need_update; 224 u8 need_update;
198 u8 sched_retry; 225 u8 sched_retry;
@@ -329,35 +356,16 @@ enum {
329 CMD_WANT_SKB = (1 << 2), 356 CMD_WANT_SKB = (1 << 2),
330}; 357};
331 358
332struct iwl_cmd;
333struct iwl_priv;
334
335struct iwl_cmd_meta {
336 struct iwl_cmd_meta *source;
337 union {
338 struct sk_buff *skb;
339 int (*callback)(struct iwl_priv *priv,
340 struct iwl_cmd *cmd, struct sk_buff *skb);
341 } __attribute__ ((packed)) u;
342
343 /* The CMD_SIZE_HUGE flag bit indicates that the command
344 * structure is stored at the end of the shared queue memory. */
345 u32 flags;
346 DECLARE_PCI_UNMAP_ADDR(mapping)
347 DECLARE_PCI_UNMAP_LEN(len)
348} __attribute__ ((packed));
349
350#define IWL_CMD_MAX_PAYLOAD 320 359#define IWL_CMD_MAX_PAYLOAD 320
351 360
352/** 361/**
353 * struct iwl_cmd 362 * struct iwl_device_cmd
354 * 363 *
355 * For allocation of the command and tx queues, this establishes the overall 364 * For allocation of the command and tx queues, this establishes the overall
356 * size of the largest command we send to uCode, except for a scan command 365 * size of the largest command we send to uCode, except for a scan command
357 * (which is relatively huge; space is allocated separately). 366 * (which is relatively huge; space is allocated separately).
358 */ 367 */
359struct iwl_cmd { 368struct iwl_device_cmd {
360 struct iwl_cmd_meta meta; /* driver data */
361 struct iwl_cmd_header hdr; /* uCode API */ 369 struct iwl_cmd_header hdr; /* uCode API */
362 union { 370 union {
363 u32 flags; 371 u32 flags;
@@ -369,17 +377,20 @@ struct iwl_cmd {
369 } __attribute__ ((packed)) cmd; 377 } __attribute__ ((packed)) cmd;
370} __attribute__ ((packed)); 378} __attribute__ ((packed));
371 379
380#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
381
372 382
373struct iwl_host_cmd { 383struct iwl_host_cmd {
374 u8 id;
375 u16 len;
376 struct iwl_cmd_meta meta;
377 const void *data; 384 const void *data;
385 struct sk_buff *reply_skb;
386 int (*callback)(struct iwl_priv *priv,
387 struct iwl_device_cmd *cmd,
388 struct sk_buff *skb);
389 u32 flags;
390 u16 len;
391 u8 id;
378}; 392};
379 393
380#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
381 sizeof(struct iwl_cmd_meta))
382
383/* 394/*
384 * RX related structures and functions 395 * RX related structures and functions
385 */ 396 */