iwlwifi: pcie: tx: unify TFD unmapping
When anything fails, we unmap the whole TFD in three different places scattered throughout the code. Unify this to a single place. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
This commit is contained in:

committed by
Luca Coelho

parent
53f474e6a8
commit
7d50d76e30
@@ -1994,11 +1994,8 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
dma_addr_t tb2_phys = dma_map_single(trans->dev,
|
dma_addr_t tb2_phys = dma_map_single(trans->dev,
|
||||||
skb->data + hdr_len,
|
skb->data + hdr_len,
|
||||||
tb2_len, DMA_TO_DEVICE);
|
tb2_len, DMA_TO_DEVICE);
|
||||||
if (unlikely(dma_mapping_error(trans->dev, tb2_phys))) {
|
if (unlikely(dma_mapping_error(trans->dev, tb2_phys)))
|
||||||
iwl_pcie_tfd_unmap(trans, out_meta, txq,
|
|
||||||
txq->write_ptr);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, false);
|
iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2014,11 +2011,8 @@ static int iwl_fill_data_tbs(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
tb_phys = skb_frag_dma_map(trans->dev, frag, 0,
|
tb_phys = skb_frag_dma_map(trans->dev, frag, 0,
|
||||||
skb_frag_size(frag), DMA_TO_DEVICE);
|
skb_frag_size(frag), DMA_TO_DEVICE);
|
||||||
|
|
||||||
if (unlikely(dma_mapping_error(trans->dev, tb_phys))) {
|
if (unlikely(dma_mapping_error(trans->dev, tb_phys)))
|
||||||
iwl_pcie_tfd_unmap(trans, out_meta, txq,
|
|
||||||
txq->write_ptr);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
tb_idx = iwl_pcie_txq_build_tfd(trans, txq, tb_phys,
|
tb_idx = iwl_pcie_txq_build_tfd(trans, txq, tb_phys,
|
||||||
skb_frag_size(frag), false);
|
skb_frag_size(frag), false);
|
||||||
|
|
||||||
@@ -2091,7 +2085,6 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
u8 *start_hdr;
|
u8 *start_hdr;
|
||||||
struct iwl_tso_hdr_page *hdr_page;
|
struct iwl_tso_hdr_page *hdr_page;
|
||||||
struct page **page_ptr;
|
struct page **page_ptr;
|
||||||
int ret;
|
|
||||||
struct tso_t tso;
|
struct tso_t tso;
|
||||||
|
|
||||||
/* if the packet is protected, then it must be CCMP or GCMP */
|
/* if the packet is protected, then it must be CCMP or GCMP */
|
||||||
@@ -2177,10 +2170,8 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
if (trans_pcie->sw_csum_tx) {
|
if (trans_pcie->sw_csum_tx) {
|
||||||
csum_skb = alloc_skb(data_left + tcp_hdrlen(skb),
|
csum_skb = alloc_skb(data_left + tcp_hdrlen(skb),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (!csum_skb) {
|
if (!csum_skb)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out_unmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
iwl_compute_pseudo_hdr_csum(iph, tcph,
|
iwl_compute_pseudo_hdr_csum(iph, tcph,
|
||||||
skb->protocol ==
|
skb->protocol ==
|
||||||
@@ -2201,8 +2192,7 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
hdr_tb_len, DMA_TO_DEVICE);
|
hdr_tb_len, DMA_TO_DEVICE);
|
||||||
if (unlikely(dma_mapping_error(trans->dev, hdr_tb_phys))) {
|
if (unlikely(dma_mapping_error(trans->dev, hdr_tb_phys))) {
|
||||||
dev_kfree_skb(csum_skb);
|
dev_kfree_skb(csum_skb);
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto out_unmap;
|
|
||||||
}
|
}
|
||||||
iwl_pcie_txq_build_tfd(trans, txq, hdr_tb_phys,
|
iwl_pcie_txq_build_tfd(trans, txq, hdr_tb_phys,
|
||||||
hdr_tb_len, false);
|
hdr_tb_len, false);
|
||||||
@@ -2227,8 +2217,7 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
size, DMA_TO_DEVICE);
|
size, DMA_TO_DEVICE);
|
||||||
if (unlikely(dma_mapping_error(trans->dev, tb_phys))) {
|
if (unlikely(dma_mapping_error(trans->dev, tb_phys))) {
|
||||||
dev_kfree_skb(csum_skb);
|
dev_kfree_skb(csum_skb);
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto out_unmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iwl_pcie_txq_build_tfd(trans, txq, tb_phys,
|
iwl_pcie_txq_build_tfd(trans, txq, tb_phys,
|
||||||
@@ -2262,10 +2251,6 @@ static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
skb_push(skb, hdr_len + iv_len);
|
skb_push(skb, hdr_len + iv_len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unmap:
|
|
||||||
iwl_pcie_tfd_unmap(trans, out_meta, txq, txq->write_ptr);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#else /* CONFIG_INET */
|
#else /* CONFIG_INET */
|
||||||
static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb,
|
||||||
@@ -2477,6 +2462,7 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
|
|||||||
spin_unlock(&txq->lock);
|
spin_unlock(&txq->lock);
|
||||||
return 0;
|
return 0;
|
||||||
out_err:
|
out_err:
|
||||||
|
iwl_pcie_tfd_unmap(trans, out_meta, txq, txq->write_ptr);
|
||||||
spin_unlock(&txq->lock);
|
spin_unlock(&txq->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user