提交 d87c771f 编写于 作者: S Stanislaw Gruszka 提交者: John W. Linville

iwlegacy: small queue initializations cleanup

Signed-off-by: NStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 3976b451
......@@ -790,7 +790,6 @@ il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq)
static int
il3945_tx_reset(struct il_priv *il)
{
/* bypass mode */
il_wr_prph(il, ALM_SCD_MODE_REG, 0x2);
......@@ -827,8 +826,7 @@ il3945_tx_reset(struct il_priv *il)
static int
il3945_txq_ctx_reset(struct il_priv *il)
{
int rc;
int txq_id, slots_num;
int rc, txq_id;
il3945_hw_txq_ctx_free(il);
......@@ -844,10 +842,7 @@ il3945_txq_ctx_reset(struct il_priv *il)
/* Tx queue(s) */
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
slots_num =
(txq_id ==
IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id);
rc = il_tx_queue_init(il, txq_id);
if (rc) {
IL_ERR("Tx %d queue init failed\n", txq_id);
goto error;
......
......@@ -1952,8 +1952,7 @@ il4965_hw_txq_ctx_free(struct il_priv *il)
int
il4965_txq_ctx_alloc(struct il_priv *il)
{
int ret;
int txq_id, slots_num;
int ret, txq_id;
unsigned long flags;
/* Free all tx/cmd queues and keep-warm buffer */
......@@ -1990,10 +1989,7 @@ il4965_txq_ctx_alloc(struct il_priv *il)
/* Alloc and init all Tx queues, including the command queue (#4/#9) */
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
slots_num =
(txq_id ==
il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
ret = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id);
ret = il_tx_queue_init(il, txq_id);
if (ret) {
IL_ERR("Tx %d queue init failed\n", txq_id);
goto error;
......@@ -2014,25 +2010,21 @@ il4965_txq_ctx_alloc(struct il_priv *il)
void
il4965_txq_ctx_reset(struct il_priv *il)
{
int txq_id, slots_num;
int txq_id;
unsigned long flags;
spin_lock_irqsave(&il->lock, flags);
/* Turn off all Tx DMA fifos */
il4965_txq_set_sched(il, 0);
/* Tell NIC where to find the "keep warm" buffer */
il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4);
spin_unlock_irqrestore(&il->lock, flags);
/* Alloc and init all Tx queues, including the command queue (#4) */
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
slots_num =
txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id);
}
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++)
il_tx_queue_reset(il, txq_id);
}
void
......
......@@ -2887,20 +2887,22 @@ EXPORT_SYMBOL(il_queue_space);
* il_queue_init - Initialize queue's high/low-water and read/write idxes
*/
static int
il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num,
u32 id)
il_queue_init(struct il_priv *il, struct il_queue *q, int slots, u32 id)
{
q->n_bd = count;
q->n_win = slots_num;
q->id = id;
/*
* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
* il_queue_inc_wrap and il_queue_dec_wrap are broken.
*/
BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
/* FIXME: remove q->n_bd */
q->n_bd = TFD_QUEUE_SIZE_MAX;
/* count must be power-of-two size, otherwise il_queue_inc_wrap
* and il_queue_dec_wrap are broken. */
BUG_ON(!is_power_of_2(count));
q->n_win = slots;
q->id = id;
/* slots_num must be power-of-two size, otherwise
/* slots_must be power-of-two size, otherwise
* il_get_cmd_idx is broken. */
BUG_ON(!is_power_of_2(slots_num));
BUG_ON(!is_power_of_2(slots));
q->low_mark = q->n_win / 4;
if (q->low_mark < 4)
......@@ -2959,12 +2961,11 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id)
* il_tx_queue_init - Allocate and initialize one tx/cmd queue
*/
int
il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
u32 txq_id)
il_tx_queue_init(struct il_priv *il, u32 txq_id)
{
int i, len;
int ret;
int actual_slots = slots_num;
int i, len, ret;
int slots, actual_slots;
struct il_tx_queue *txq = &il->txq[txq_id];
/*
* Alloc buffer array for commands (Tx or other types of commands).
......@@ -2974,8 +2975,13 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
* For normal Tx queues (all other queues), no super-size command
* space is needed.
*/
if (txq_id == il->cmd_queue)
actual_slots++;
if (txq_id == il->cmd_queue) {
slots = TFD_CMD_SLOTS;
actual_slots = slots + 1;
} else {
slots = TFD_TX_CMD_SLOTS;
actual_slots = slots;
}
txq->meta =
kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL);
......@@ -2988,7 +2994,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
len = sizeof(struct il_device_cmd);
for (i = 0; i < actual_slots; i++) {
/* only happens for cmd queue */
if (i == slots_num)
if (i == slots)
len = IL_MAX_CMD_SIZE;
txq->cmd[i] = kmalloc(len, GFP_KERNEL);
......@@ -3011,12 +3017,8 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
if (txq_id < 4)
il_set_swq_id(txq, txq_id, txq_id);
/* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
* il_queue_inc_wrap and il_queue_dec_wrap are broken. */
BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
/* Initialize queue's high/low-water marks, and head/tail idxes */
il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
il_queue_init(il, &txq->q, slots, txq_id);
/* Tell device where to find queue */
il->ops->txq_init(il, txq);
......@@ -3034,20 +3036,24 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
EXPORT_SYMBOL(il_tx_queue_init);
void
il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
u32 txq_id)
il_tx_queue_reset(struct il_priv *il, u32 txq_id)
{
int actual_slots = slots_num;
int slots, actual_slots;
struct il_tx_queue *txq = &il->txq[txq_id];
if (txq_id == il->cmd_queue)
actual_slots++;
if (txq_id == il->cmd_queue) {
slots = TFD_CMD_SLOTS;
actual_slots = TFD_CMD_SLOTS + 1;
} else {
slots = TFD_TX_CMD_SLOTS;
actual_slots = TFD_TX_CMD_SLOTS;
}
memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots);
txq->need_update = 0;
/* Initialize queue's high/low-water marks, and head/tail idxes */
il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
il_queue_init(il, &txq->q, slots, txq_id);
/* Tell device where to find queue */
il->ops->txq_init(il, txq);
......
......@@ -1783,14 +1783,12 @@ void il_chswitch_done(struct il_priv *il, bool is_success);
/*****************************************************
* TX
******************************************************/
void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq);
int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
u32 txq_id);
void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq,
int slots_num, u32 txq_id);
void il_tx_queue_unmap(struct il_priv *il, int txq_id);
void il_tx_queue_free(struct il_priv *il, int txq_id);
void il_setup_watchdog(struct il_priv *il);
extern void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq);
extern int il_tx_queue_init(struct il_priv *il, u32 txq_id);
extern void il_tx_queue_reset(struct il_priv *il, u32 txq_id);
extern void il_tx_queue_unmap(struct il_priv *il, int txq_id);
extern void il_tx_queue_free(struct il_priv *il, int txq_id);
extern void il_setup_watchdog(struct il_priv *il);
/*****************************************************
* TX power
****************************************************/
......@@ -2405,10 +2403,10 @@ struct il_rb_status {
__le32 __unused; /* 3945 only */
} __packed;
#define TFD_QUEUE_SIZE_MAX (256)
#define TFD_QUEUE_SIZE_BC_DUP (64)
#define TFD_QUEUE_SIZE_MAX 256
#define TFD_QUEUE_SIZE_BC_DUP 64
#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
#define IL_TX_DMA_MASK DMA_BIT_MASK(36)
#define IL_TX_DMA_MASK DMA_BIT_MASK(36)
#define IL_NUM_OF_TBS 20
static inline u8
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册