aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2010-11-12 02:47:06 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-11-16 16:39:09 -0500
commit70f3876f09ccf1f2819aee6caee9266b2c4b1622 (patch)
tree985017d59f9ee04cb1bb6cb8c5294fc05e9b4c8f /drivers/net/wireless/iwlwifi/iwl-agn-tx.c
parent2cb7865648e44647a976875428c9dfd9d5553221 (diff)
iwlagn: simplify iwlagn_tx_skb
We can simplify length calculation in iwlagn_tx_skb, that function is enough complex, without fuzz it more than necessary. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-tx.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 2b078a995729..1205cecfcaf0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -522,7 +522,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
522 dma_addr_t phys_addr; 522 dma_addr_t phys_addr;
523 dma_addr_t txcmd_phys; 523 dma_addr_t txcmd_phys;
524 dma_addr_t scratch_phys; 524 dma_addr_t scratch_phys;
525 u16 len, len_org, firstlen, secondlen; 525 u16 len, firstlen, secondlen;
526 u16 seq_number = 0; 526 u16 seq_number = 0;
527 __le16 fc; 527 __le16 fc;
528 u8 hdr_len; 528 u8 hdr_len;
@@ -687,30 +687,23 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
687 */ 687 */
688 len = sizeof(struct iwl_tx_cmd) + 688 len = sizeof(struct iwl_tx_cmd) +
689 sizeof(struct iwl_cmd_header) + hdr_len; 689 sizeof(struct iwl_cmd_header) + hdr_len;
690 690 firstlen = (len + 3) & ~3;
691 len_org = len;
692 firstlen = len = (len + 3) & ~3;
693
694 if (len_org != len)
695 len_org = 1;
696 else
697 len_org = 0;
698 691
699 /* Tell NIC about any 2-byte padding after MAC header */ 692 /* Tell NIC about any 2-byte padding after MAC header */
700 if (len_org) 693 if (firstlen != len)
701 tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; 694 tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK;
702 695
703 /* Physical address of this Tx command's header (not MAC header!), 696 /* Physical address of this Tx command's header (not MAC header!),
704 * within command buffer array. */ 697 * within command buffer array. */
705 txcmd_phys = pci_map_single(priv->pci_dev, 698 txcmd_phys = pci_map_single(priv->pci_dev,
706 &out_cmd->hdr, len, 699 &out_cmd->hdr, firstlen,
707 PCI_DMA_BIDIRECTIONAL); 700 PCI_DMA_BIDIRECTIONAL);
708 dma_unmap_addr_set(out_meta, mapping, txcmd_phys); 701 dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
709 dma_unmap_len_set(out_meta, len, len); 702 dma_unmap_len_set(out_meta, len, firstlen);
710 /* Add buffer containing Tx command and MAC(!) header to TFD's 703 /* Add buffer containing Tx command and MAC(!) header to TFD's
711 * first entry */ 704 * first entry */
712 priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, 705 priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq,
713 txcmd_phys, len, 1, 0); 706 txcmd_phys, firstlen, 1, 0);
714 707
715 if (!ieee80211_has_morefrags(hdr->frame_control)) { 708 if (!ieee80211_has_morefrags(hdr->frame_control)) {
716 txq->need_update = 1; 709 txq->need_update = 1;
@@ -721,23 +714,21 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
721 714
722 /* Set up TFD's 2nd entry to point directly to remainder of skb, 715 /* Set up TFD's 2nd entry to point directly to remainder of skb,
723 * if any (802.11 null frames have no payload). */ 716 * if any (802.11 null frames have no payload). */
724 secondlen = len = skb->len - hdr_len; 717 secondlen = skb->len - hdr_len;
725 if (len) { 718 if (secondlen > 0) {
726 phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, 719 phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len,
727 len, PCI_DMA_TODEVICE); 720 secondlen, PCI_DMA_TODEVICE);
728 priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, 721 priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq,
729 phys_addr, len, 722 phys_addr, secondlen,
730 0, 0); 723 0, 0);
731 } 724 }
732 725
733 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + 726 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
734 offsetof(struct iwl_tx_cmd, scratch); 727 offsetof(struct iwl_tx_cmd, scratch);
735 728
736 len = sizeof(struct iwl_tx_cmd) +
737 sizeof(struct iwl_cmd_header) + hdr_len;
738 /* take back ownership of DMA buffer to enable update */ 729 /* take back ownership of DMA buffer to enable update */
739 pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, 730 pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys,
740 len, PCI_DMA_BIDIRECTIONAL); 731 firstlen, PCI_DMA_BIDIRECTIONAL);
741 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); 732 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
742 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys); 733 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
743 734
@@ -753,7 +744,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
753 le16_to_cpu(tx_cmd->len)); 744 le16_to_cpu(tx_cmd->len));
754 745
755 pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, 746 pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys,
756 len, PCI_DMA_BIDIRECTIONAL); 747 firstlen, PCI_DMA_BIDIRECTIONAL);
757 748
758 trace_iwlwifi_dev_tx(priv, 749 trace_iwlwifi_dev_tx(priv,
759 &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr], 750 &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],