]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/ixgbe/ixgbe_main.c
ixgbe: select FCoE Tx queue in ndo_select_queue
[karo-tx-linux.git] / drivers / net / ixgbe / ixgbe_main.c
index 5c56f2a741f39db94f037ce27a1ce786bcfa1349..e3dc68ba4b70374c3ee726eed2a835f2b60bbfb7 100644 (file)
@@ -218,10 +218,20 @@ static void ixgbe_unmap_and_free_tx_resource(struct ixgbe_adapter *adapter,
                                              struct ixgbe_tx_buffer
                                              *tx_buffer_info)
 {
-       tx_buffer_info->dma = 0;
+       if (tx_buffer_info->dma) {
+               if (tx_buffer_info->mapped_as_page)
+                       pci_unmap_page(adapter->pdev,
+                                      tx_buffer_info->dma,
+                                      tx_buffer_info->length,
+                                      PCI_DMA_TODEVICE);
+               else
+                       pci_unmap_single(adapter->pdev,
+                                        tx_buffer_info->dma,
+                                        tx_buffer_info->length,
+                                        PCI_DMA_TODEVICE);
+               tx_buffer_info->dma = 0;
+       }
        if (tx_buffer_info->skb) {
-               skb_dma_unmap(&adapter->pdev->dev, tx_buffer_info->skb,
-                             DMA_TO_DEVICE);
                dev_kfree_skb_any(tx_buffer_info->skb);
                tx_buffer_info->skb = NULL;
        }
@@ -3948,8 +3958,10 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
                adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE;
                adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
                adapter->ring_feature[RING_F_FCOE].indices = 0;
+#ifdef CONFIG_IXGBE_DCB
                /* Default traffic class to use for FCoE */
                adapter->fcoe.tc = IXGBE_FCOE_DEFTC;
+#endif
 #endif /* IXGBE_FCOE */
        }
 
@@ -5024,23 +5036,16 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
                         struct sk_buff *skb, u32 tx_flags,
                         unsigned int first)
 {
+       struct pci_dev *pdev = adapter->pdev;
        struct ixgbe_tx_buffer *tx_buffer_info;
        unsigned int len;
        unsigned int total = skb->len;
        unsigned int offset = 0, size, count = 0, i;
        unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
        unsigned int f;
-       dma_addr_t *map;
 
        i = tx_ring->next_to_use;
 
-       if (skb_dma_map(&adapter->pdev->dev, skb, DMA_TO_DEVICE)) {
-               dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
-               return 0;
-       }
-
-       map = skb_shinfo(skb)->dma_maps;
-
        if (tx_flags & IXGBE_TX_FLAGS_FCOE)
                /* excluding fcoe_crc_eof for FCoE */
                total -= sizeof(struct fcoe_crc_eof);
@@ -5051,7 +5056,12 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
                size = min(len, (uint)IXGBE_MAX_DATA_PER_TXD);
 
                tx_buffer_info->length = size;
-               tx_buffer_info->dma = skb_shinfo(skb)->dma_head + offset;
+               tx_buffer_info->mapped_as_page = false;
+               tx_buffer_info->dma = pci_map_single(pdev,
+                                                    skb->data + offset,
+                                                    size, PCI_DMA_TODEVICE);
+               if (pci_dma_mapping_error(pdev, tx_buffer_info->dma))
+                       goto dma_error;
                tx_buffer_info->time_stamp = jiffies;
                tx_buffer_info->next_to_watch = i;
 
@@ -5072,7 +5082,7 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
 
                frag = &skb_shinfo(skb)->frags[f];
                len = min((unsigned int)frag->size, total);
-               offset = 0;
+               offset = frag->page_offset;
 
                while (len) {
                        i++;
@@ -5083,7 +5093,13 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
                        size = min(len, (uint)IXGBE_MAX_DATA_PER_TXD);
 
                        tx_buffer_info->length = size;
-                       tx_buffer_info->dma = map[f] + offset;
+                       tx_buffer_info->dma = pci_map_page(adapter->pdev,
+                                                          frag->page,
+                                                          offset, size,
+                                                          PCI_DMA_TODEVICE);
+                       tx_buffer_info->mapped_as_page = true;
+                       if (pci_dma_mapping_error(pdev, tx_buffer_info->dma))
+                               goto dma_error;
                        tx_buffer_info->time_stamp = jiffies;
                        tx_buffer_info->next_to_watch = i;
 
@@ -5099,6 +5115,27 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter,
        tx_ring->tx_buffer_info[i].skb = skb;
        tx_ring->tx_buffer_info[first].next_to_watch = i;
 
+       return count;
+
+dma_error:
+       dev_err(&pdev->dev, "TX DMA map failed\n");
+
+       /* clear timestamp and dma mappings for failed tx_buffer_info map */
+       tx_buffer_info->dma = 0;
+       tx_buffer_info->time_stamp = 0;
+       tx_buffer_info->next_to_watch = 0;
+       count--;
+
+       /* clear timestamp and dma mappings for remaining portion of packet */
+       while (count >= 0) {
+               count--;
+               i--;
+               if (i < 0)
+                       i += tx_ring->count;
+               tx_buffer_info = &tx_ring->tx_buffer_info[i];
+               ixgbe_unmap_and_free_tx_resource(adapter, tx_buffer_info);
+       }
+
        return count;
 }
 
@@ -5249,10 +5286,19 @@ static int ixgbe_maybe_stop_tx(struct net_device *netdev,
 static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
 {
        struct ixgbe_adapter *adapter = netdev_priv(dev);
+       int txq = smp_processor_id();
 
        if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)
-               return smp_processor_id();
+               return txq;
 
+#ifdef IXGBE_FCOE
+       if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
+           (skb->protocol == htons(ETH_P_FCOE))) {
+               txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
+               txq += adapter->ring_feature[RING_F_FCOE].mask;
+               return txq;
+       }
+#endif
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
                return (skb->vlan_tci & IXGBE_TX_FLAGS_VLAN_PRIO_MASK) >> 13;
 
@@ -5267,7 +5313,7 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
        unsigned int first;
        unsigned int tx_flags = 0;
        u8 hdr_len = 0;
-       int r_idx = 0, tso;
+       int tso;
        int count = 0;
        unsigned int f;
 
@@ -5275,13 +5321,13 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
                tx_flags |= vlan_tx_tag_get(skb);
                if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
                        tx_flags &= ~IXGBE_TX_FLAGS_VLAN_PRIO_MASK;
-                       tx_flags |= (skb->queue_mapping << 13);
+                       tx_flags |= ((skb->queue_mapping & 0x7) << 13);
                }
                tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
                tx_flags |= IXGBE_TX_FLAGS_VLAN;
        } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
                if (skb->priority != TC_PRIO_CONTROL) {
-                       tx_flags |= (skb->queue_mapping << 13);
+                       tx_flags |= ((skb->queue_mapping & 0x7) << 13);
                        tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
                        tx_flags |= IXGBE_TX_FLAGS_VLAN;
                } else {
@@ -5290,17 +5336,18 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
                }
        }
 
-       r_idx = skb->queue_mapping;
-       tx_ring = &adapter->tx_ring[r_idx];
+       tx_ring = &adapter->tx_ring[skb->queue_mapping];
 
        if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
            (skb->protocol == htons(ETH_P_FCOE))) {
                tx_flags |= IXGBE_TX_FLAGS_FCOE;
 #ifdef IXGBE_FCOE
-               r_idx = smp_processor_id();
-               r_idx &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
-               r_idx += adapter->ring_feature[RING_F_FCOE].mask;
-               tx_ring = &adapter->tx_ring[r_idx];
+#ifdef CONFIG_IXGBE_DCB
+               tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
+                             << IXGBE_TX_FLAGS_VLAN_SHIFT);
+               tx_flags |= ((adapter->fcoe.up << 13)
+                             << IXGBE_TX_FLAGS_VLAN_SHIFT);
+#endif
 #endif
        }
        /* four things can cause us to need a context descriptor */