Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[deliverable/linux.git] / drivers / net / benet / be_main.c
index 88d4c8038be4c89c83b7fec01405aeb485a7117a..2c3685389485e1d754c4b57b9989bfdb45130164 100644 (file)
@@ -1101,8 +1101,12 @@ static void be_parse_rx_compl_v1(struct be_adapter *adapter,
                AMAP_GET_BITS(struct amap_eth_rx_compl_v1, numfrags, compl);
        rxcp->pkt_type =
                AMAP_GET_BITS(struct amap_eth_rx_compl_v1, cast_enc, compl);
-       rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm, compl);
-       rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag, compl);
+       if (rxcp->vlanf) {
+               rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm,
+                               compl);
+               rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag,
+                               compl);
+       }
 }
 
 static void be_parse_rx_compl_v0(struct be_adapter *adapter,
@@ -1127,8 +1131,12 @@ static void be_parse_rx_compl_v0(struct be_adapter *adapter,
                AMAP_GET_BITS(struct amap_eth_rx_compl_v0, numfrags, compl);
        rxcp->pkt_type =
                AMAP_GET_BITS(struct amap_eth_rx_compl_v0, cast_enc, compl);
-       rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm, compl);
-       rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag, compl);
+       if (rxcp->vlanf) {
+               rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm,
+                               compl);
+               rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag,
+                               compl);
+       }
 }
 
 static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
@@ -1150,15 +1158,19 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
        else
                be_parse_rx_compl_v0(adapter, compl, rxcp);
 
-       /* vlanf could be wrongly set in some cards. ignore if vtm is not set */
-       if ((adapter->function_mode & 0x400) && !rxcp->vtm)
-               rxcp->vlanf = 0;
+       if (rxcp->vlanf) {
+               /* vlanf could be wrongly set in some cards.
+                * ignore if vtm is not set */
+               if ((adapter->function_mode & 0x400) && !rxcp->vtm)
+                       rxcp->vlanf = 0;
 
-       if (!lancer_chip(adapter))
-               rxcp->vid = swab16(rxcp->vid);
+               if (!lancer_chip(adapter))
+                       rxcp->vid = swab16(rxcp->vid);
 
-       if ((adapter->pvid == rxcp->vid) && !adapter->vlan_tag[rxcp->vid])
-               rxcp->vlanf = 0;
+               if ((adapter->pvid == rxcp->vid) &&
+                       !adapter->vlan_tag[rxcp->vid])
+                       rxcp->vlanf = 0;
+       }
 
        /* As the compl has been parsed, reset it; we wont touch it again */
        compl->dw[offsetof(struct amap_eth_rx_compl_v1, valid) / 32] = 0;
@@ -1567,12 +1579,31 @@ static void be_rx_queues_destroy(struct be_adapter *adapter)
        }
 }
 
+static u32 be_num_rxqs_want(struct be_adapter *adapter)
+{
+       if (multi_rxq && (adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
+               !adapter->sriov_enabled && !(adapter->function_mode & 0x400)) {
+               return 1 + MAX_RSS_QS; /* one default non-RSS queue */
+       } else {
+               dev_warn(&adapter->pdev->dev,
+                       "No support for multiple RX queues\n");
+               return 1;
+       }
+}
+
 static int be_rx_queues_create(struct be_adapter *adapter)
 {
        struct be_queue_info *eq, *q, *cq;
        struct be_rx_obj *rxo;
        int rc, i;
 
+       adapter->num_rx_qs = min(be_num_rxqs_want(adapter),
+                               msix_enabled(adapter) ?
+                                       adapter->num_msix_vec - 1 : 1);
+       if (adapter->num_rx_qs != MAX_RX_QS)
+               dev_warn(&adapter->pdev->dev,
+                       "Can create only %d RX queues", adapter->num_rx_qs);
+
        adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
        for_all_rx_queues(adapter, rxo, i) {
                rxo->adapter = adapter;
@@ -1837,6 +1868,9 @@ static void be_worker(struct work_struct *work)
        struct be_rx_obj *rxo;
        int i;
 
+       if (!adapter->ue_detected && !lancer_chip(adapter))
+               be_detect_dump_ue(adapter);
+
        /* when interrupts are not yet enabled, just reap any pending
        * mcc completions */
        if (!netif_running(adapter->netdev)) {
@@ -1849,9 +1883,6 @@ static void be_worker(struct work_struct *work)
                        be_cq_notify(adapter, mcc_obj->cq.id, false, mcc_compl);
                }
 
-               if (!adapter->ue_detected && !lancer_chip(adapter))
-                       be_detect_dump_ue(adapter);
-
                goto reschedule;
        }
 
@@ -1869,8 +1900,6 @@ static void be_worker(struct work_struct *work)
                        be_post_rx_frags(rxo, GFP_KERNEL);
                }
        }
-       if (!adapter->ue_detected && !lancer_chip(adapter))
-               be_detect_dump_ue(adapter);
 
 reschedule:
        schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
@@ -1878,51 +1907,35 @@ reschedule:
 
 static void be_msix_disable(struct be_adapter *adapter)
 {
-       if (adapter->msix_enabled) {
+       if (msix_enabled(adapter)) {
                pci_disable_msix(adapter->pdev);
-               adapter->msix_enabled = false;
-       }
-}
-
-static int be_num_rxqs_get(struct be_adapter *adapter)
-{
-       if (multi_rxq && (adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
-               !adapter->sriov_enabled && !(adapter->function_mode & 0x400)) {
-               return 1 + MAX_RSS_QS; /* one default non-RSS queue */
-       } else {
-               dev_warn(&adapter->pdev->dev,
-                       "No support for multiple RX queues\n");
-               return 1;
+               adapter->num_msix_vec = 0;
        }
 }
 
 static void be_msix_enable(struct be_adapter *adapter)
 {
 #define BE_MIN_MSIX_VECTORS    (1 + 1) /* Rx + Tx */
-       int i, status;
+       int i, status, num_vec;
 
-       adapter->num_rx_qs = be_num_rxqs_get(adapter);
+       num_vec = be_num_rxqs_want(adapter) + 1;
 
-       for (i = 0; i < (adapter->num_rx_qs + 1); i++)
+       for (i = 0; i < num_vec; i++)
                adapter->msix_entries[i].entry = i;
 
-       status = pci_enable_msix(adapter->pdev, adapter->msix_entries,
-                       adapter->num_rx_qs + 1);
+       status = pci_enable_msix(adapter->pdev, adapter->msix_entries, num_vec);
        if (status == 0) {
                goto done;
        } else if (status >= BE_MIN_MSIX_VECTORS) {
+               num_vec = status;
                if (pci_enable_msix(adapter->pdev, adapter->msix_entries,
-                               status) == 0) {
-                       adapter->num_rx_qs = status - 1;
-                       dev_warn(&adapter->pdev->dev,
-                               "Could alloc only %d MSIx vectors. "
-                               "Using %d RX Qs\n", status, adapter->num_rx_qs);
+                               num_vec) == 0)
                        goto done;
-               }
        }
        return;
 done:
-       adapter->msix_enabled = true;
+       adapter->num_msix_vec = num_vec;
+       return;
 }
 
 static void be_sriov_enable(struct be_adapter *adapter)
@@ -2003,8 +2016,7 @@ err_msix:
 err:
        dev_warn(&adapter->pdev->dev,
                "MSIX Request IRQ failed - err %d\n", status);
-       pci_disable_msix(adapter->pdev);
-       adapter->msix_enabled = false;
+       be_msix_disable(adapter);
        return status;
 }
 
@@ -2013,7 +2025,7 @@ static int be_irq_register(struct be_adapter *adapter)
        struct net_device *netdev = adapter->netdev;
        int status;
 
-       if (adapter->msix_enabled) {
+       if (msix_enabled(adapter)) {
                status = be_msix_register(adapter);
                if (status == 0)
                        goto done;
@@ -2046,7 +2058,7 @@ static void be_irq_unregister(struct be_adapter *adapter)
                return;
 
        /* INTx */
-       if (!adapter->msix_enabled) {
+       if (!msix_enabled(adapter)) {
                free_irq(netdev->irq, adapter);
                goto done;
        }
@@ -2088,7 +2100,7 @@ static int be_close(struct net_device *netdev)
                         be_cq_notify(adapter, rxo->cq.id, false, 0);
        }
 
-       if (adapter->msix_enabled) {
+       if (msix_enabled(adapter)) {
                vec = be_msix_vec_get(adapter, tx_eq);
                synchronize_irq(vec);
 
@@ -2261,7 +2273,7 @@ static int be_setup(struct be_adapter *adapter)
                                BE_IF_FLAGS_PASS_L3L4_ERRORS;
                en_flags |= BE_IF_FLAGS_PASS_L3L4_ERRORS;
 
-               if (be_multi_rxq(adapter)) {
+               if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) {
                        cap_flags |= BE_IF_FLAGS_RSS;
                        en_flags |= BE_IF_FLAGS_RSS;
                }
@@ -2318,7 +2330,6 @@ static int be_setup(struct be_adapter *adapter)
 
        return 0;
 
-       be_mcc_queues_destroy(adapter);
 rx_qs_destroy:
        be_rx_queues_destroy(adapter);
 tx_qs_destroy:
@@ -3146,8 +3157,7 @@ static void be_shutdown(struct pci_dev *pdev)
        if (!adapter)
                return;
 
-       if (netif_running(adapter->netdev))
-               cancel_delayed_work_sync(&adapter->work);
+       cancel_delayed_work_sync(&adapter->work);
 
        netif_device_detach(adapter->netdev);
 
This page took 0.028425 seconds and 5 git commands to generate.