diff options
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/queue')
| -rw-r--r-- | drivers/net/wireless/intel/iwlwifi/queue/tx.c | 22 | ||||
| -rw-r--r-- | drivers/net/wireless/intel/iwlwifi/queue/tx.h | 8 | 
2 files changed, 20 insertions, 10 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/queue/tx.c b/drivers/net/wireless/intel/iwlwifi/queue/tx.c index d1c39c214f95..5bb3cc3367c9 100644 --- a/drivers/net/wireless/intel/iwlwifi/queue/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/queue/tx.c @@ -1,6 +1,6 @@  // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause  /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation   */  #include <net/tso.h>  #include <linux/tcp.h> @@ -648,6 +648,13 @@ struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans,  	/* There must be data left over for TB1 or this code must be changed */  	BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen2) < IWL_FIRST_TB_SIZE); +	BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + +		     offsetofend(struct iwl_tx_cmd_gen2, dram_info) > +		     IWL_FIRST_TB_SIZE); +	BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen3) < IWL_FIRST_TB_SIZE); +	BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + +		     offsetofend(struct iwl_tx_cmd_gen3, dram_info) > +		     IWL_FIRST_TB_SIZE);  	memset(tfd, 0, sizeof(*tfd)); @@ -978,7 +985,7 @@ void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq)  	bool active;  	u8 fifo; -	if (trans->trans_cfg->use_tfh) { +	if (trans->trans_cfg->gen2) {  		IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id,  			txq->read_ptr, txq->write_ptr);  		/* TODO: access new SCD registers and dump them */ @@ -1027,10 +1034,13 @@ int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num,  	size_t tb0_buf_sz;  	int i; +	if (WARN_ONCE(slots_num <= 0, "Invalid slots num:%d\n", slots_num)) +		return -EINVAL; +  	if (WARN_ON(txq->entries || txq->tfds))  		return -EINVAL; -	if (trans->trans_cfg->use_tfh) +	if (trans->trans_cfg->gen2)  		tfd_sz = trans->txqs.tfd.size * slots_num;  	timer_setup(&txq->stuck_timer, iwl_txq_stuck_timer, 0); @@ -1337,7 +1347,7 @@ static inline dma_addr_t iwl_txq_gen1_tfd_tb_get_addr(struct iwl_trans *trans,  	dma_addr_t addr;  	dma_addr_t hi_len; -	if (trans->trans_cfg->use_tfh) { +	if (trans->trans_cfg->gen2) {  		struct iwl_tfh_tfd *tfh_tfd = _tfd;  		struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx]; @@ -1398,7 +1408,7 @@ void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans,  	meta->tbs = 0; -	if (trans->trans_cfg->use_tfh) { +	if (trans->trans_cfg->gen2) {  		struct iwl_tfh_tfd *tfd_fh = (void *)tfd;  		tfd_fh->num_tbs = 0; @@ -1615,7 +1625,7 @@ void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn,  		txq->entries[read_ptr].skb = NULL; -		if (!trans->trans_cfg->use_tfh) +		if (!trans->trans_cfg->gen2)  			iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq);  		iwl_txq_free_tfd(trans, txq); diff --git a/drivers/net/wireless/intel/iwlwifi/queue/tx.h b/drivers/net/wireless/intel/iwlwifi/queue/tx.h index eca53bfd326d..1e4a24ab9bab 100644 --- a/drivers/net/wireless/intel/iwlwifi/queue/tx.h +++ b/drivers/net/wireless/intel/iwlwifi/queue/tx.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */  /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation   */  #ifndef __iwl_trans_queue_tx_h__  #define __iwl_trans_queue_tx_h__ @@ -38,7 +38,7 @@ static inline void iwl_wake_queue(struct iwl_trans *trans,  static inline void *iwl_txq_get_tfd(struct iwl_trans *trans,  				    struct iwl_txq *txq, int idx)  { -	if (trans->trans_cfg->use_tfh) +	if (trans->trans_cfg->gen2)  		idx = iwl_txq_get_cmd_index(txq, idx);  	return (u8 *)txq->tfds + trans->txqs.tfd.size * idx; @@ -135,7 +135,7 @@ static inline u8 iwl_txq_gen1_tfd_get_num_tbs(struct iwl_trans *trans,  {  	struct iwl_tfd *tfd; -	if (trans->trans_cfg->use_tfh) { +	if (trans->trans_cfg->gen2) {  		struct iwl_tfh_tfd *tfh_tfd = _tfd;  		return le16_to_cpu(tfh_tfd->num_tbs) & 0x1f; @@ -151,7 +151,7 @@ static inline u16 iwl_txq_gen1_tfd_tb_get_len(struct iwl_trans *trans,  	struct iwl_tfd *tfd;  	struct iwl_tfd_tb *tb; -	if (trans->trans_cfg->use_tfh) { +	if (trans->trans_cfg->gen2) {  		struct iwl_tfh_tfd *tfh_tfd = _tfd;  		struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx];  | 
