iwlegacy: small queue initializations cleanup
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
3976b45194
commit
d87c771f47
|
@ -790,7 +790,6 @@ il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq)
|
||||||
static int
|
static int
|
||||||
il3945_tx_reset(struct il_priv *il)
|
il3945_tx_reset(struct il_priv *il)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* bypass mode */
|
/* bypass mode */
|
||||||
il_wr_prph(il, ALM_SCD_MODE_REG, 0x2);
|
il_wr_prph(il, ALM_SCD_MODE_REG, 0x2);
|
||||||
|
|
||||||
|
@ -827,8 +826,7 @@ il3945_tx_reset(struct il_priv *il)
|
||||||
static int
|
static int
|
||||||
il3945_txq_ctx_reset(struct il_priv *il)
|
il3945_txq_ctx_reset(struct il_priv *il)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc, txq_id;
|
||||||
int txq_id, slots_num;
|
|
||||||
|
|
||||||
il3945_hw_txq_ctx_free(il);
|
il3945_hw_txq_ctx_free(il);
|
||||||
|
|
||||||
|
@ -844,10 +842,7 @@ il3945_txq_ctx_reset(struct il_priv *il)
|
||||||
|
|
||||||
/* Tx queue(s) */
|
/* Tx queue(s) */
|
||||||
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
|
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
|
||||||
slots_num =
|
rc = il_tx_queue_init(il, txq_id);
|
||||||
(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);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
IL_ERR("Tx %d queue init failed\n", txq_id);
|
IL_ERR("Tx %d queue init failed\n", txq_id);
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -1952,8 +1952,7 @@ il4965_hw_txq_ctx_free(struct il_priv *il)
|
||||||
int
|
int
|
||||||
il4965_txq_ctx_alloc(struct il_priv *il)
|
il4965_txq_ctx_alloc(struct il_priv *il)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, txq_id;
|
||||||
int txq_id, slots_num;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
/* Free all tx/cmd queues and keep-warm buffer */
|
/* 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) */
|
/* 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++) {
|
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
|
||||||
slots_num =
|
ret = il_tx_queue_init(il, txq_id);
|
||||||
(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);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
IL_ERR("Tx %d queue init failed\n", txq_id);
|
IL_ERR("Tx %d queue init failed\n", txq_id);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -2014,25 +2010,21 @@ error_bc_tbls:
|
||||||
void
|
void
|
||||||
il4965_txq_ctx_reset(struct il_priv *il)
|
il4965_txq_ctx_reset(struct il_priv *il)
|
||||||
{
|
{
|
||||||
int txq_id, slots_num;
|
int txq_id;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&il->lock, flags);
|
spin_lock_irqsave(&il->lock, flags);
|
||||||
|
|
||||||
/* Turn off all Tx DMA fifos */
|
/* Turn off all Tx DMA fifos */
|
||||||
il4965_txq_set_sched(il, 0);
|
il4965_txq_set_sched(il, 0);
|
||||||
|
|
||||||
/* Tell NIC where to find the "keep warm" buffer */
|
/* Tell NIC where to find the "keep warm" buffer */
|
||||||
il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4);
|
il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&il->lock, flags);
|
spin_unlock_irqrestore(&il->lock, flags);
|
||||||
|
|
||||||
/* Alloc and init all Tx queues, including the command queue (#4) */
|
/* 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++) {
|
for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++)
|
||||||
slots_num =
|
il_tx_queue_reset(il, txq_id);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -2887,20 +2887,22 @@ EXPORT_SYMBOL(il_queue_space);
|
||||||
* il_queue_init - Initialize queue's high/low-water and read/write idxes
|
* il_queue_init - Initialize queue's high/low-water and read/write idxes
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num,
|
il_queue_init(struct il_priv *il, struct il_queue *q, int slots, u32 id)
|
||||||
u32 id)
|
|
||||||
{
|
{
|
||||||
q->n_bd = count;
|
/*
|
||||||
q->n_win = slots_num;
|
* 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;
|
||||||
|
|
||||||
|
q->n_win = slots;
|
||||||
q->id = id;
|
q->id = id;
|
||||||
|
|
||||||
/* count must be power-of-two size, otherwise il_queue_inc_wrap
|
/* slots_must be power-of-two size, otherwise
|
||||||
* and il_queue_dec_wrap are broken. */
|
|
||||||
BUG_ON(!is_power_of_2(count));
|
|
||||||
|
|
||||||
/* slots_num must be power-of-two size, otherwise
|
|
||||||
* il_get_cmd_idx is broken. */
|
* 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;
|
q->low_mark = q->n_win / 4;
|
||||||
if (q->low_mark < 4)
|
if (q->low_mark < 4)
|
||||||
|
@ -2959,12 +2961,11 @@ error:
|
||||||
* il_tx_queue_init - Allocate and initialize one tx/cmd queue
|
* il_tx_queue_init - Allocate and initialize one tx/cmd queue
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
|
il_tx_queue_init(struct il_priv *il, u32 txq_id)
|
||||||
u32 txq_id)
|
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len, ret;
|
||||||
int ret;
|
int slots, actual_slots;
|
||||||
int actual_slots = slots_num;
|
struct il_tx_queue *txq = &il->txq[txq_id];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alloc buffer array for commands (Tx or other types of commands).
|
* 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
|
* For normal Tx queues (all other queues), no super-size command
|
||||||
* space is needed.
|
* space is needed.
|
||||||
*/
|
*/
|
||||||
if (txq_id == il->cmd_queue)
|
if (txq_id == il->cmd_queue) {
|
||||||
actual_slots++;
|
slots = TFD_CMD_SLOTS;
|
||||||
|
actual_slots = slots + 1;
|
||||||
|
} else {
|
||||||
|
slots = TFD_TX_CMD_SLOTS;
|
||||||
|
actual_slots = slots;
|
||||||
|
}
|
||||||
|
|
||||||
txq->meta =
|
txq->meta =
|
||||||
kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL);
|
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);
|
len = sizeof(struct il_device_cmd);
|
||||||
for (i = 0; i < actual_slots; i++) {
|
for (i = 0; i < actual_slots; i++) {
|
||||||
/* only happens for cmd queue */
|
/* only happens for cmd queue */
|
||||||
if (i == slots_num)
|
if (i == slots)
|
||||||
len = IL_MAX_CMD_SIZE;
|
len = IL_MAX_CMD_SIZE;
|
||||||
|
|
||||||
txq->cmd[i] = kmalloc(len, GFP_KERNEL);
|
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)
|
if (txq_id < 4)
|
||||||
il_set_swq_id(txq, txq_id, txq_id);
|
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 */
|
/* 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 */
|
/* Tell device where to find queue */
|
||||||
il->ops->txq_init(il, txq);
|
il->ops->txq_init(il, txq);
|
||||||
|
@ -3034,20 +3036,24 @@ out_free_arrays:
|
||||||
EXPORT_SYMBOL(il_tx_queue_init);
|
EXPORT_SYMBOL(il_tx_queue_init);
|
||||||
|
|
||||||
void
|
void
|
||||||
il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
|
il_tx_queue_reset(struct il_priv *il, u32 txq_id)
|
||||||
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)
|
if (txq_id == il->cmd_queue) {
|
||||||
actual_slots++;
|
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);
|
memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots);
|
||||||
|
|
||||||
txq->need_update = 0;
|
txq->need_update = 0;
|
||||||
|
|
||||||
/* Initialize queue's high/low-water marks, and head/tail idxes */
|
/* 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 */
|
/* Tell device where to find queue */
|
||||||
il->ops->txq_init(il, txq);
|
il->ops->txq_init(il, txq);
|
||||||
|
|
|
@ -1783,14 +1783,12 @@ void il_chswitch_done(struct il_priv *il, bool is_success);
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* TX
|
* TX
|
||||||
******************************************************/
|
******************************************************/
|
||||||
void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq);
|
extern 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,
|
extern int il_tx_queue_init(struct il_priv *il, u32 txq_id);
|
||||||
u32 txq_id);
|
extern void il_tx_queue_reset(struct il_priv *il, u32 txq_id);
|
||||||
void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq,
|
extern void il_tx_queue_unmap(struct il_priv *il, int txq_id);
|
||||||
int slots_num, u32 txq_id);
|
extern void il_tx_queue_free(struct il_priv *il, int txq_id);
|
||||||
void il_tx_queue_unmap(struct il_priv *il, int txq_id);
|
extern void il_setup_watchdog(struct il_priv *il);
|
||||||
void il_tx_queue_free(struct il_priv *il, int txq_id);
|
|
||||||
void il_setup_watchdog(struct il_priv *il);
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* TX power
|
* TX power
|
||||||
****************************************************/
|
****************************************************/
|
||||||
|
@ -2405,10 +2403,10 @@ struct il_rb_status {
|
||||||
__le32 __unused; /* 3945 only */
|
__le32 __unused; /* 3945 only */
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
#define TFD_QUEUE_SIZE_MAX (256)
|
#define TFD_QUEUE_SIZE_MAX 256
|
||||||
#define TFD_QUEUE_SIZE_BC_DUP (64)
|
#define TFD_QUEUE_SIZE_BC_DUP 64
|
||||||
#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
|
#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
|
#define IL_NUM_OF_TBS 20
|
||||||
|
|
||||||
static inline u8
|
static inline u8
|
||||||
|
|
Loading…
Reference in New Issue