aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet/be_main.c
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2010-11-21 18:25:50 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-27 20:43:20 -0500
commitfe6d2a38b2076cba515dc95b5dc1589a7ab51c17 (patch)
treeb1d6268d43a051e31579984f98d65aa8ad341e8d /drivers/net/benet/be_main.c
parent1d24eb4815d1e0e8b451ecc546645f8ef1176d4f (diff)
be2net: adding support for Lancer family of CNAs
Key changes are: - EQ ids are not assigned consecutively in Lancer. So, fix mapping of MSIx vector to EQ-id. - BAR mapping and some req locations different for Lancer. - TCP,UDP,IP checksum fields must be compulsorily set in TX wrb for TSO in Lancer. - CEV_IST reg not present in Lancer; so, peek into event queue to check for new entries - cq_create and mcc_create cmd interface is different for Lancer; handle accordingly Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com> Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_main.c')
-rw-r--r--drivers/net/benet/be_main.c181
1 files changed, 131 insertions, 50 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 93354eee2cfd..102567ee68c2 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -41,6 +41,7 @@ static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = {
41 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, 41 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) },
42 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) }, 42 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) },
43 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) }, 43 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) },
44 { PCI_DEVICE(EMULEX_VENDOR_ID, OC_DEVICE_ID3)},
44 { 0 } 45 { 0 }
45}; 46};
46MODULE_DEVICE_TABLE(pci, be_dev_ids); 47MODULE_DEVICE_TABLE(pci, be_dev_ids);
@@ -188,6 +189,8 @@ static void be_eq_notify(struct be_adapter *adapter, u16 qid,
188{ 189{
189 u32 val = 0; 190 u32 val = 0;
190 val |= qid & DB_EQ_RING_ID_MASK; 191 val |= qid & DB_EQ_RING_ID_MASK;
192 val |= ((qid & DB_EQ_RING_ID_EXT_MASK) <<
193 DB_EQ_RING_ID_EXT_MASK_SHIFT);
191 194
192 if (adapter->eeh_err) 195 if (adapter->eeh_err)
193 return; 196 return;
@@ -205,6 +208,8 @@ void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped)
205{ 208{
206 u32 val = 0; 209 u32 val = 0;
207 val |= qid & DB_CQ_RING_ID_MASK; 210 val |= qid & DB_CQ_RING_ID_MASK;
211 val |= ((qid & DB_CQ_RING_ID_EXT_MASK) <<
212 DB_CQ_RING_ID_EXT_MASK_SHIFT);
208 213
209 if (adapter->eeh_err) 214 if (adapter->eeh_err)
210 return; 215 return;
@@ -404,7 +409,8 @@ static void be_tx_stats_update(struct be_adapter *adapter,
404} 409}
405 410
406/* Determine number of WRB entries needed to xmit data in an skb */ 411/* Determine number of WRB entries needed to xmit data in an skb */
407static u32 wrb_cnt_for_skb(struct sk_buff *skb, bool *dummy) 412static u32 wrb_cnt_for_skb(struct be_adapter *adapter, struct sk_buff *skb,
413 bool *dummy)
408{ 414{
409 int cnt = (skb->len > skb->data_len); 415 int cnt = (skb->len > skb->data_len);
410 416
@@ -412,12 +418,13 @@ static u32 wrb_cnt_for_skb(struct sk_buff *skb, bool *dummy)
412 418
413 /* to account for hdr wrb */ 419 /* to account for hdr wrb */
414 cnt++; 420 cnt++;
415 if (cnt & 1) { 421 if (lancer_chip(adapter) || !(cnt & 1)) {
422 *dummy = false;
423 } else {
416 /* add a dummy to make it an even num */ 424 /* add a dummy to make it an even num */
417 cnt++; 425 cnt++;
418 *dummy = true; 426 *dummy = true;
419 } else 427 }
420 *dummy = false;
421 BUG_ON(cnt > BE_MAX_TX_FRAG_COUNT); 428 BUG_ON(cnt > BE_MAX_TX_FRAG_COUNT);
422 return cnt; 429 return cnt;
423} 430}
@@ -443,8 +450,18 @@ static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
443 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso, hdr, 1); 450 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso, hdr, 1);
444 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso_mss, 451 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso_mss,
445 hdr, skb_shinfo(skb)->gso_size); 452 hdr, skb_shinfo(skb)->gso_size);
446 if (skb_is_gso_v6(skb)) 453 if (skb_is_gso_v6(skb) && !lancer_chip(adapter))
447 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso6, hdr, 1); 454 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso6, hdr, 1);
455 if (lancer_chip(adapter) && adapter->sli_family ==
456 LANCER_A0_SLI_FAMILY) {
457 AMAP_SET_BITS(struct amap_eth_hdr_wrb, ipcs, hdr, 1);
458 if (is_tcp_pkt(skb))
459 AMAP_SET_BITS(struct amap_eth_hdr_wrb,
460 tcpcs, hdr, 1);
461 else if (is_udp_pkt(skb))
462 AMAP_SET_BITS(struct amap_eth_hdr_wrb,
463 udpcs, hdr, 1);
464 }
448 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 465 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
449 if (is_tcp_pkt(skb)) 466 if (is_tcp_pkt(skb))
450 AMAP_SET_BITS(struct amap_eth_hdr_wrb, tcpcs, hdr, 1); 467 AMAP_SET_BITS(struct amap_eth_hdr_wrb, tcpcs, hdr, 1);
@@ -566,7 +583,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb,
566 u32 start = txq->head; 583 u32 start = txq->head;
567 bool dummy_wrb, stopped = false; 584 bool dummy_wrb, stopped = false;
568 585
569 wrb_cnt = wrb_cnt_for_skb(skb, &dummy_wrb); 586 wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb);
570 587
571 copied = make_tx_wrbs(adapter, skb, wrb_cnt, dummy_wrb); 588 copied = make_tx_wrbs(adapter, skb, wrb_cnt, dummy_wrb);
572 if (copied) { 589 if (copied) {
@@ -1035,7 +1052,8 @@ static void be_rx_compl_process(struct be_adapter *adapter,
1035 return; 1052 return;
1036 } 1053 }
1037 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp); 1054 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
1038 vid = swab16(vid); 1055 if (!lancer_chip(adapter))
1056 vid = swab16(vid);
1039 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, vid); 1057 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, vid);
1040 } else { 1058 } else {
1041 netif_receive_skb(skb); 1059 netif_receive_skb(skb);
@@ -1113,7 +1131,8 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter,
1113 napi_gro_frags(&eq_obj->napi); 1131 napi_gro_frags(&eq_obj->napi);
1114 } else { 1132 } else {
1115 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp); 1133 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
1116 vid = swab16(vid); 1134 if (!lancer_chip(adapter))
1135 vid = swab16(vid);
1117 1136
1118 if (!adapter->vlan_grp || adapter->vlans_added == 0) 1137 if (!adapter->vlan_grp || adapter->vlans_added == 0)
1119 return; 1138 return;
@@ -1381,7 +1400,8 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
1381 sent_skb = sent_skbs[txq->tail]; 1400 sent_skb = sent_skbs[txq->tail];
1382 end_idx = txq->tail; 1401 end_idx = txq->tail;
1383 index_adv(&end_idx, 1402 index_adv(&end_idx,
1384 wrb_cnt_for_skb(sent_skb, &dummy_wrb) - 1, txq->len); 1403 wrb_cnt_for_skb(adapter, sent_skb, &dummy_wrb) - 1,
1404 txq->len);
1385 be_tx_compl_process(adapter, end_idx); 1405 be_tx_compl_process(adapter, end_idx);
1386 } 1406 }
1387} 1407}
@@ -1476,7 +1496,9 @@ static int be_tx_queues_create(struct be_adapter *adapter)
1476 /* Ask BE to create Tx Event queue */ 1496 /* Ask BE to create Tx Event queue */
1477 if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) 1497 if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd))
1478 goto tx_eq_free; 1498 goto tx_eq_free;
1479 adapter->base_eq_id = adapter->tx_eq.q.id; 1499
1500 adapter->tx_eq.msix_vec_idx = adapter->msix_vec_next_idx++;
1501
1480 1502
1481 /* Alloc TX eth compl queue */ 1503 /* Alloc TX eth compl queue */
1482 cq = &adapter->tx_obj.cq; 1504 cq = &adapter->tx_obj.cq;
@@ -1568,6 +1590,8 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1568 if (rc) 1590 if (rc)
1569 goto err; 1591 goto err;
1570 1592
1593 rxo->rx_eq.msix_vec_idx = adapter->msix_vec_next_idx++;
1594
1571 /* CQ */ 1595 /* CQ */
1572 cq = &rxo->cq; 1596 cq = &rxo->cq;
1573 rc = be_queue_alloc(adapter, cq, RX_CQ_LEN, 1597 rc = be_queue_alloc(adapter, cq, RX_CQ_LEN,
@@ -1578,7 +1602,6 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1578 rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3); 1602 rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3);
1579 if (rc) 1603 if (rc)
1580 goto err; 1604 goto err;
1581
1582 /* Rx Q */ 1605 /* Rx Q */
1583 q = &rxo->q; 1606 q = &rxo->q;
1584 rc = be_queue_alloc(adapter, q, RX_Q_LEN, 1607 rc = be_queue_alloc(adapter, q, RX_Q_LEN,
@@ -1611,29 +1634,45 @@ err:
1611 return -1; 1634 return -1;
1612} 1635}
1613 1636
1614/* There are 8 evt ids per func. Retruns the evt id's bit number */ 1637static bool event_peek(struct be_eq_obj *eq_obj)
1615static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id)
1616{ 1638{
1617 return eq_id - adapter->base_eq_id; 1639 struct be_eq_entry *eqe = queue_tail_node(&eq_obj->q);
1640 if (!eqe->evt)
1641 return false;
1642 else
1643 return true;
1618} 1644}
1619 1645
1620static irqreturn_t be_intx(int irq, void *dev) 1646static irqreturn_t be_intx(int irq, void *dev)
1621{ 1647{
1622 struct be_adapter *adapter = dev; 1648 struct be_adapter *adapter = dev;
1623 struct be_rx_obj *rxo; 1649 struct be_rx_obj *rxo;
1624 int isr, i; 1650 int isr, i, tx = 0 , rx = 0;
1625 1651
1626 isr = ioread32(adapter->csr + CEV_ISR0_OFFSET + 1652 if (lancer_chip(adapter)) {
1627 (adapter->tx_eq.q.id/ 8) * CEV_ISR_SIZE); 1653 if (event_peek(&adapter->tx_eq))
1628 if (!isr) 1654 tx = event_handle(adapter, &adapter->tx_eq);
1629 return IRQ_NONE; 1655 for_all_rx_queues(adapter, rxo, i) {
1656 if (event_peek(&rxo->rx_eq))
1657 rx |= event_handle(adapter, &rxo->rx_eq);
1658 }
1630 1659
1631 if ((1 << be_evt_bit_get(adapter, adapter->tx_eq.q.id) & isr)) 1660 if (!(tx || rx))
1632 event_handle(adapter, &adapter->tx_eq); 1661 return IRQ_NONE;
1633 1662
1634 for_all_rx_queues(adapter, rxo, i) { 1663 } else {
1635 if ((1 << be_evt_bit_get(adapter, rxo->rx_eq.q.id) & isr)) 1664 isr = ioread32(adapter->csr + CEV_ISR0_OFFSET +
1636 event_handle(adapter, &rxo->rx_eq); 1665 (adapter->tx_eq.q.id / 8) * CEV_ISR_SIZE);
1666 if (!isr)
1667 return IRQ_NONE;
1668
1669 if ((1 << adapter->tx_eq.msix_vec_idx & isr))
1670 event_handle(adapter, &adapter->tx_eq);
1671
1672 for_all_rx_queues(adapter, rxo, i) {
1673 if ((1 << rxo->rx_eq.msix_vec_idx & isr))
1674 event_handle(adapter, &rxo->rx_eq);
1675 }
1637 } 1676 }
1638 1677
1639 return IRQ_HANDLED; 1678 return IRQ_HANDLED;
@@ -1830,8 +1869,7 @@ static void be_worker(struct work_struct *work)
1830 be_post_rx_frags(rxo); 1869 be_post_rx_frags(rxo);
1831 } 1870 }
1832 } 1871 }
1833 1872 if (!adapter->ue_detected && !lancer_chip(adapter))
1834 if (!adapter->ue_detected)
1835 be_detect_dump_ue(adapter); 1873 be_detect_dump_ue(adapter);
1836 1874
1837reschedule: 1875reschedule:
@@ -1910,10 +1948,10 @@ static void be_sriov_disable(struct be_adapter *adapter)
1910#endif 1948#endif
1911} 1949}
1912 1950
1913static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) 1951static inline int be_msix_vec_get(struct be_adapter *adapter,
1952 struct be_eq_obj *eq_obj)
1914{ 1953{
1915 return adapter->msix_entries[ 1954 return adapter->msix_entries[eq_obj->msix_vec_idx].vector;
1916 be_evt_bit_get(adapter, eq_id)].vector;
1917} 1955}
1918 1956
1919static int be_request_irq(struct be_adapter *adapter, 1957static int be_request_irq(struct be_adapter *adapter,
@@ -1924,14 +1962,14 @@ static int be_request_irq(struct be_adapter *adapter,
1924 int vec; 1962 int vec;
1925 1963
1926 sprintf(eq_obj->desc, "%s-%s", netdev->name, desc); 1964 sprintf(eq_obj->desc, "%s-%s", netdev->name, desc);
1927 vec = be_msix_vec_get(adapter, eq_obj->q.id); 1965 vec = be_msix_vec_get(adapter, eq_obj);
1928 return request_irq(vec, handler, 0, eq_obj->desc, context); 1966 return request_irq(vec, handler, 0, eq_obj->desc, context);
1929} 1967}
1930 1968
1931static void be_free_irq(struct be_adapter *adapter, struct be_eq_obj *eq_obj, 1969static void be_free_irq(struct be_adapter *adapter, struct be_eq_obj *eq_obj,
1932 void *context) 1970 void *context)
1933{ 1971{
1934 int vec = be_msix_vec_get(adapter, eq_obj->q.id); 1972 int vec = be_msix_vec_get(adapter, eq_obj);
1935 free_irq(vec, context); 1973 free_irq(vec, context);
1936} 1974}
1937 1975
@@ -2036,14 +2074,15 @@ static int be_close(struct net_device *netdev)
2036 netif_carrier_off(netdev); 2074 netif_carrier_off(netdev);
2037 adapter->link_up = false; 2075 adapter->link_up = false;
2038 2076
2039 be_intr_set(adapter, false); 2077 if (!lancer_chip(adapter))
2078 be_intr_set(adapter, false);
2040 2079
2041 if (adapter->msix_enabled) { 2080 if (adapter->msix_enabled) {
2042 vec = be_msix_vec_get(adapter, tx_eq->q.id); 2081 vec = be_msix_vec_get(adapter, tx_eq);
2043 synchronize_irq(vec); 2082 synchronize_irq(vec);
2044 2083
2045 for_all_rx_queues(adapter, rxo, i) { 2084 for_all_rx_queues(adapter, rxo, i) {
2046 vec = be_msix_vec_get(adapter, rxo->rx_eq.q.id); 2085 vec = be_msix_vec_get(adapter, &rxo->rx_eq);
2047 synchronize_irq(vec); 2086 synchronize_irq(vec);
2048 } 2087 }
2049 } else { 2088 } else {
@@ -2082,7 +2121,8 @@ static int be_open(struct net_device *netdev)
2082 2121
2083 be_irq_register(adapter); 2122 be_irq_register(adapter);
2084 2123
2085 be_intr_set(adapter, true); 2124 if (!lancer_chip(adapter))
2125 be_intr_set(adapter, true);
2086 2126
2087 /* The evt queues are created in unarmed state; arm them */ 2127 /* The evt queues are created in unarmed state; arm them */
2088 for_all_rx_queues(adapter, rxo, i) { 2128 for_all_rx_queues(adapter, rxo, i) {
@@ -2548,6 +2588,9 @@ static void be_netdev_init(struct net_device *netdev)
2548 2588
2549 netdev->vlan_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_HW_CSUM; 2589 netdev->vlan_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_HW_CSUM;
2550 2590
2591 if (lancer_chip(adapter))
2592 netdev->vlan_features |= NETIF_F_TSO6;
2593
2551 netdev->flags |= IFF_MULTICAST; 2594 netdev->flags |= IFF_MULTICAST;
2552 2595
2553 adapter->rx_csum = true; 2596 adapter->rx_csum = true;
@@ -2587,6 +2630,15 @@ static int be_map_pci_bars(struct be_adapter *adapter)
2587 u8 __iomem *addr; 2630 u8 __iomem *addr;
2588 int pcicfg_reg, db_reg; 2631 int pcicfg_reg, db_reg;
2589 2632
2633 if (lancer_chip(adapter)) {
2634 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 0),
2635 pci_resource_len(adapter->pdev, 0));
2636 if (addr == NULL)
2637 return -ENOMEM;
2638 adapter->db = addr;
2639 return 0;
2640 }
2641
2590 if (be_physfn(adapter)) { 2642 if (be_physfn(adapter)) {
2591 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2), 2643 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2),
2592 pci_resource_len(adapter->pdev, 2)); 2644 pci_resource_len(adapter->pdev, 2));
@@ -2783,6 +2835,44 @@ static int be_get_config(struct be_adapter *adapter)
2783 return 0; 2835 return 0;
2784} 2836}
2785 2837
2838static int be_dev_family_check(struct be_adapter *adapter)
2839{
2840 struct pci_dev *pdev = adapter->pdev;
2841 u32 sli_intf = 0, if_type;
2842
2843 switch (pdev->device) {
2844 case BE_DEVICE_ID1:
2845 case OC_DEVICE_ID1:
2846 adapter->generation = BE_GEN2;
2847 break;
2848 case BE_DEVICE_ID2:
2849 case OC_DEVICE_ID2:
2850 adapter->generation = BE_GEN3;
2851 break;
2852 case OC_DEVICE_ID3:
2853 pci_read_config_dword(pdev, SLI_INTF_REG_OFFSET, &sli_intf);
2854 if_type = (sli_intf & SLI_INTF_IF_TYPE_MASK) >>
2855 SLI_INTF_IF_TYPE_SHIFT;
2856
2857 if (((sli_intf & SLI_INTF_VALID_MASK) != SLI_INTF_VALID) ||
2858 if_type != 0x02) {
2859 dev_err(&pdev->dev, "SLI_INTF reg val is not valid\n");
2860 return -EINVAL;
2861 }
2862 if (num_vfs > 0) {
2863 dev_err(&pdev->dev, "VFs not supported\n");
2864 return -EINVAL;
2865 }
2866 adapter->sli_family = ((sli_intf & SLI_INTF_FAMILY_MASK) >>
2867 SLI_INTF_FAMILY_SHIFT);
2868 adapter->generation = BE_GEN3;
2869 break;
2870 default:
2871 adapter->generation = 0;
2872 }
2873 return 0;
2874}
2875
2786static int __devinit be_probe(struct pci_dev *pdev, 2876static int __devinit be_probe(struct pci_dev *pdev,
2787 const struct pci_device_id *pdev_id) 2877 const struct pci_device_id *pdev_id)
2788{ 2878{
@@ -2805,22 +2895,13 @@ static int __devinit be_probe(struct pci_dev *pdev,
2805 goto rel_reg; 2895 goto rel_reg;
2806 } 2896 }
2807 adapter = netdev_priv(netdev); 2897 adapter = netdev_priv(netdev);
2808
2809 switch (pdev->device) {
2810 case BE_DEVICE_ID1:
2811 case OC_DEVICE_ID1:
2812 adapter->generation = BE_GEN2;
2813 break;
2814 case BE_DEVICE_ID2:
2815 case OC_DEVICE_ID2:
2816 adapter->generation = BE_GEN3;
2817 break;
2818 default:
2819 adapter->generation = 0;
2820 }
2821
2822 adapter->pdev = pdev; 2898 adapter->pdev = pdev;
2823 pci_set_drvdata(pdev, adapter); 2899 pci_set_drvdata(pdev, adapter);
2900
2901 status = be_dev_family_check(adapter);
2902 if (!status)
2903 goto free_netdev;
2904
2824 adapter->netdev = netdev; 2905 adapter->netdev = netdev;
2825 SET_NETDEV_DEV(netdev, &pdev->dev); 2906 SET_NETDEV_DEV(netdev, &pdev->dev);
2826 2907
@@ -2895,7 +2976,7 @@ ctrl_clean:
2895 be_ctrl_cleanup(adapter); 2976 be_ctrl_cleanup(adapter);
2896free_netdev: 2977free_netdev:
2897 be_sriov_disable(adapter); 2978 be_sriov_disable(adapter);
2898 free_netdev(adapter->netdev); 2979 free_netdev(netdev);
2899 pci_set_drvdata(pdev, NULL); 2980 pci_set_drvdata(pdev, NULL);
2900rel_reg: 2981rel_reg:
2901 pci_release_regions(pdev); 2982 pci_release_regions(pdev);