Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 159263
b: refs/heads/master
c: c2acea8
h: refs/heads/master
i:
  159261: 994f481
  159259: dcefab0
  159255: f4f7893
  159247: 09cb940
  159231: 040bb7e
v: v3
  • Loading branch information
Johannes Berg authored and John W. Linville committed Jul 27, 2009
1 parent 840df17 commit e9b0d19
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 143 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fbf3a2af3834e8e93e9c2876de62c5b49988e352
refs/heads/master: c2acea8e9b86ba5a5469ff477445676a223af4e2
6 changes: 3 additions & 3 deletions trunk/drivers/net/wireless/iwlwifi/iwl-3945-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static const struct {
#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)

static int iwl3945_led_cmd_callback(struct iwl_priv *priv,
struct iwl_cmd *cmd,
struct iwl_device_cmd *cmd,
struct sk_buff *skb)
{
return 1;
Expand All @@ -99,8 +99,8 @@ static int iwl_send_led_cmd(struct iwl_priv *priv,
.id = REPLY_LEDS_CMD,
.len = sizeof(struct iwl_led_cmd),
.data = led_cmd,
.meta.flags = CMD_ASYNC,
.meta.u.callback = iwl3945_led_cmd_callback,
.flags = CMD_ASYNC,
.callback = iwl3945_led_cmd_callback,
};

return iwl_send_cmd(priv, &cmd);
Expand Down
18 changes: 10 additions & 8 deletions trunk/drivers/net/wireless/iwlwifi/iwl-3945.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
/* Unmap tx_cmd */
if (counter)
pci_unmap_single(dev,
pci_unmap_addr(&txq->cmd[index]->meta, mapping),
pci_unmap_len(&txq->cmd[index]->meta, len),
pci_unmap_addr(&txq->meta[index], mapping),
pci_unmap_len(&txq->meta[index], len),
PCI_DMA_TODEVICE);

/* unmap chunks if any */
Expand All @@ -774,9 +774,11 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
* iwl3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD:
*
*/
void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct iwl_cmd *cmd,
struct ieee80211_tx_info *info,
struct ieee80211_hdr *hdr, int sta_id, int tx_id)
void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
struct iwl_device_cmd *cmd,
struct ieee80211_tx_info *info,
struct ieee80211_hdr *hdr,
int sta_id, int tx_id)
{
u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value;
u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT - 1);
Expand Down Expand Up @@ -1858,7 +1860,7 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
struct iwl_host_cmd cmd = {
.id = REPLY_RXON_ASSOC,
.len = sizeof(rxon_assoc),
.meta.flags = CMD_WANT_SKB,
.flags = CMD_WANT_SKB,
.data = &rxon_assoc,
};
const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
Expand All @@ -1882,14 +1884,14 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
if (rc)
return rc;

res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
res = (struct iwl_rx_packet *)cmd.reply_skb->data;
if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
IWL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n");
rc = -EIO;
}

priv->alloc_rxb_skb--;
dev_kfree_skb_any(cmd.meta.u.skb);
dev_kfree_skb_any(cmd.reply_skb);

return rc;
}
Expand Down
9 changes: 5 additions & 4 deletions trunk/drivers/net/wireless/iwlwifi/iwl-3945.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,11 @@ extern int iwl3945_hw_tx_queue_init(struct iwl_priv *priv,
struct iwl_tx_queue *txq);
extern unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv,
struct iwl3945_frame *frame, u8 rate);
void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct iwl_cmd *cmd,
struct ieee80211_tx_info *info,
struct ieee80211_hdr *hdr,
int sta_id, int tx_id);
void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
struct iwl_device_cmd *cmd,
struct ieee80211_tx_info *info,
struct ieee80211_hdr *hdr,
int sta_id, int tx_id);
extern int iwl3945_hw_reg_send_txpower(struct iwl_priv *priv);
extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
/* Unmap tx_cmd */
if (num_tbs)
pci_unmap_single(dev,
pci_unmap_addr(&txq->cmd[index]->meta, mapping),
pci_unmap_len(&txq->cmd[index]->meta, len),
pci_unmap_addr(&txq->meta[index], mapping),
pci_unmap_len(&txq->meta[index], len),
PCI_DMA_BIDIRECTIONAL);

/* Unmap chunks, if any. */
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-calib.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int iwl_send_calib_results(struct iwl_priv *priv)

struct iwl_host_cmd hcmd = {
.id = REPLY_PHY_CALIBRATION_CMD,
.meta.flags = CMD_SIZE_HUGE,
.flags = CMD_SIZE_HUGE,
};

for (i = 0; i < IWL_CALIB_MAX; i++) {
Expand Down Expand Up @@ -419,7 +419,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
struct iwl_host_cmd cmd_out = {
.id = SENSITIVITY_CMD,
.len = sizeof(struct iwl_sensitivity_cmd),
.meta.flags = CMD_ASYNC,
.flags = CMD_ASYNC,
.data = &cmd,
};

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags)
u32 stat_flags = 0;
struct iwl_host_cmd cmd = {
.id = REPLY_STATISTICS_CMD,
.meta.flags = flags,
.flags = flags,
.len = sizeof(stat_flags),
.data = (u8 *) &stat_flags,
};
Expand Down Expand Up @@ -2282,7 +2282,7 @@ int iwl_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag)
.id = REPLY_CARD_STATE_CMD,
.len = sizeof(u32),
.data = &flags,
.meta.flags = meta_flag,
.flags = meta_flag,
};

return iwl_send_cmd(priv, &cmd);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/wireless/iwlwifi/iwl-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id,
int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
const void *data,
int (*callback)(struct iwl_priv *priv,
struct iwl_cmd *cmd,
struct iwl_device_cmd *cmd,
struct sk_buff *skb));

int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
Expand Down
69 changes: 40 additions & 29 deletions trunk/drivers/net/wireless/iwlwifi/iwl-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,31 @@ struct iwl_rx_mem_buffer {
struct list_head list;
};

/* defined below */
struct iwl_device_cmd;

struct iwl_cmd_meta {
/* only for SYNC commands, iff the reply skb is wanted */
struct iwl_host_cmd *source;
/*
* only for ASYNC commands
* (which is somewhat stupid -- look at iwl-sta.c for instance
* which duplicates a bunch of code because the callback isn't
* invoked for SYNC commands, if it were and its result passed
* through it would be simpler...)
*/
int (*callback)(struct iwl_priv *priv,
struct iwl_device_cmd *cmd,
struct sk_buff *skb);

/* The CMD_SIZE_HUGE flag bit indicates that the command
* structure is stored at the end of the shared queue memory. */
u32 flags;

DECLARE_PCI_UNMAP_ADDR(mapping)
DECLARE_PCI_UNMAP_LEN(len)
};

/*
* Generic queue structure
*
Expand Down Expand Up @@ -177,7 +202,8 @@ struct iwl_tx_info {
* struct iwl_tx_queue - Tx Queue for DMA
* @q: generic Rx/Tx queue descriptor
* @bd: base of circular buffer of TFDs
* @cmd: array of command/Tx buffers
* @cmd: array of command/TX buffer pointers
* @meta: array of meta data for each command/tx buffer
* @dma_addr_cmd: physical address of cmd/tx buffer array
* @txb: array of per-TFD driver data
* @need_update: indicates need to update read/write index
Expand All @@ -192,7 +218,8 @@ struct iwl_tx_info {
struct iwl_tx_queue {
struct iwl_queue q;
void *tfds;
struct iwl_cmd *cmd[TFD_TX_CMD_SLOTS];
struct iwl_device_cmd **cmd;
struct iwl_cmd_meta *meta;
struct iwl_tx_info *txb;
u8 need_update;
u8 sched_retry;
Expand Down Expand Up @@ -329,35 +356,16 @@ enum {
CMD_WANT_SKB = (1 << 2),
};

struct iwl_cmd;
struct iwl_priv;

struct iwl_cmd_meta {
struct iwl_cmd_meta *source;
union {
struct sk_buff *skb;
int (*callback)(struct iwl_priv *priv,
struct iwl_cmd *cmd, struct sk_buff *skb);
} __attribute__ ((packed)) u;

/* The CMD_SIZE_HUGE flag bit indicates that the command
* structure is stored at the end of the shared queue memory. */
u32 flags;
DECLARE_PCI_UNMAP_ADDR(mapping)
DECLARE_PCI_UNMAP_LEN(len)
} __attribute__ ((packed));

#define IWL_CMD_MAX_PAYLOAD 320

/**
* struct iwl_cmd
* struct iwl_device_cmd
*
* For allocation of the command and tx queues, this establishes the overall
* size of the largest command we send to uCode, except for a scan command
* (which is relatively huge; space is allocated separately).
*/
struct iwl_cmd {
struct iwl_cmd_meta meta; /* driver data */
struct iwl_device_cmd {
struct iwl_cmd_header hdr; /* uCode API */
union {
u32 flags;
Expand All @@ -369,17 +377,20 @@ struct iwl_cmd {
} __attribute__ ((packed)) cmd;
} __attribute__ ((packed));

#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))


struct iwl_host_cmd {
u8 id;
u16 len;
struct iwl_cmd_meta meta;
const void *data;
struct sk_buff *reply_skb;
int (*callback)(struct iwl_priv *priv,
struct iwl_device_cmd *cmd,
struct sk_buff *skb);
u32 flags;
u16 len;
u8 id;
};

#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
sizeof(struct iwl_cmd_meta))

/*
* RX related structures and functions
*/
Expand Down
48 changes: 23 additions & 25 deletions trunk/drivers/net/wireless/iwlwifi/iwl-hcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ EXPORT_SYMBOL(get_cmd_string);
#define HOST_COMPLETE_TIMEOUT (HZ / 2)

static int iwl_generic_cmd_callback(struct iwl_priv *priv,
struct iwl_cmd *cmd, struct sk_buff *skb)
struct iwl_device_cmd *cmd,
struct sk_buff *skb)
{
struct iwl_rx_packet *pkt = NULL;

Expand Down Expand Up @@ -142,14 +143,14 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
{
int ret;

BUG_ON(!(cmd->meta.flags & CMD_ASYNC));
BUG_ON(!(cmd->flags & CMD_ASYNC));

/* An asynchronous command can not expect an SKB to be set. */
BUG_ON(cmd->meta.flags & CMD_WANT_SKB);
BUG_ON(cmd->flags & CMD_WANT_SKB);

/* Assign a generic callback if one is not provided */
if (!cmd->meta.u.callback)
cmd->meta.u.callback = iwl_generic_cmd_callback;
if (!cmd->callback)
cmd->callback = iwl_generic_cmd_callback;

if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return -EBUSY;
Expand All @@ -168,10 +169,10 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
int cmd_idx;
int ret;

BUG_ON(cmd->meta.flags & CMD_ASYNC);
BUG_ON(cmd->flags & CMD_ASYNC);

/* A synchronous command can not have a callback set. */
BUG_ON(cmd->meta.u.callback != NULL);
BUG_ON(cmd->callback);

if (test_and_set_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status)) {
IWL_ERR(priv,
Expand All @@ -183,9 +184,6 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)

set_bit(STATUS_HCMD_ACTIVE, &priv->status);

if (cmd->meta.flags & CMD_WANT_SKB)
cmd->meta.source = &cmd->meta;

cmd_idx = iwl_enqueue_hcmd(priv, cmd);
if (cmd_idx < 0) {
ret = cmd_idx;
Expand Down Expand Up @@ -222,7 +220,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
ret = -EIO;
goto fail;
}
if ((cmd->meta.flags & CMD_WANT_SKB) && !cmd->meta.u.skb) {
if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_skb) {
IWL_ERR(priv, "Error: Response NULL in '%s'\n",
get_cmd_string(cmd->id));
ret = -EIO;
Expand All @@ -233,20 +231,20 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
goto out;

cancel:
if (cmd->meta.flags & CMD_WANT_SKB) {
struct iwl_cmd *qcmd;

/* Cancel the CMD_WANT_SKB flag for the cmd in the
if (cmd->flags & CMD_WANT_SKB) {
/*
* Cancel the CMD_WANT_SKB flag for the cmd in the
* TX cmd queue. Otherwise in case the cmd comes
* in later, it will possibly set an invalid
* address (cmd->meta.source). */
qcmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_idx];
qcmd->meta.flags &= ~CMD_WANT_SKB;
* address (cmd->meta.source).
*/
priv->txq[IWL_CMD_QUEUE_NUM].meta[cmd_idx].flags &=
~CMD_WANT_SKB;
}
fail:
if (cmd->meta.u.skb) {
dev_kfree_skb_any(cmd->meta.u.skb);
cmd->meta.u.skb = NULL;
if (cmd->reply_skb) {
dev_kfree_skb_any(cmd->reply_skb);
cmd->reply_skb = NULL;
}
out:
clear_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status);
Expand All @@ -256,7 +254,7 @@ EXPORT_SYMBOL(iwl_send_cmd_sync);

int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
{
if (cmd->meta.flags & CMD_ASYNC)
if (cmd->flags & CMD_ASYNC)
return iwl_send_cmd_async(priv, cmd);

return iwl_send_cmd_sync(priv, cmd);
Expand All @@ -278,7 +276,7 @@ EXPORT_SYMBOL(iwl_send_cmd_pdu);
int iwl_send_cmd_pdu_async(struct iwl_priv *priv,
u8 id, u16 len, const void *data,
int (*callback)(struct iwl_priv *priv,
struct iwl_cmd *cmd,
struct iwl_device_cmd *cmd,
struct sk_buff *skb))
{
struct iwl_host_cmd cmd = {
Expand All @@ -287,8 +285,8 @@ int iwl_send_cmd_pdu_async(struct iwl_priv *priv,
.data = data,
};

cmd.meta.flags |= CMD_ASYNC;
cmd.meta.u.callback = callback;
cmd.flags |= CMD_ASYNC;
cmd.callback = callback;

return iwl_send_cmd_async(priv, &cmd);
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/wireless/iwlwifi/iwl-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
.id = REPLY_LEDS_CMD,
.len = sizeof(struct iwl_led_cmd),
.data = led_cmd,
.meta.flags = CMD_ASYNC,
.meta.u.callback = NULL,
.flags = CMD_ASYNC,
.callback = NULL,
};
u32 reg;

Expand Down
Loading

0 comments on commit e9b0d19

Please sign in to comment.