aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet/be_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/benet/be_main.c')
-rw-r--r--drivers/net/benet/be_main.c356
1 files changed, 140 insertions, 216 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index dea3155688bb..d20235b16800 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include "be.h" 18#include "be.h"
19#include "be_cmds.h"
19#include <asm/div64.h> 20#include <asm/div64.h>
20 21
21MODULE_VERSION(DRV_VER); 22MODULE_VERSION(DRV_VER);
@@ -60,40 +61,39 @@ static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q,
60 return 0; 61 return 0;
61} 62}
62 63
63static void be_intr_set(struct be_ctrl_info *ctrl, bool enable) 64static void be_intr_set(struct be_adapter *adapter, bool enable)
64{ 65{
65 u8 __iomem *addr = ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET; 66 u8 __iomem *addr = adapter->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET;
66 u32 reg = ioread32(addr); 67 u32 reg = ioread32(addr);
67 u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 68 u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
68 if (!enabled && enable) { 69
70 if (!enabled && enable)
69 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 71 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
70 } else if (enabled && !enable) { 72 else if (enabled && !enable)
71 reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 73 reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
72 } else { 74 else
73 printk(KERN_WARNING DRV_NAME
74 ": bad value in membar_int_ctrl reg=0x%x\n", reg);
75 return; 75 return;
76 } 76
77 iowrite32(reg, addr); 77 iowrite32(reg, addr);
78} 78}
79 79
80static void be_rxq_notify(struct be_ctrl_info *ctrl, u16 qid, u16 posted) 80static void be_rxq_notify(struct be_adapter *adapter, u16 qid, u16 posted)
81{ 81{
82 u32 val = 0; 82 u32 val = 0;
83 val |= qid & DB_RQ_RING_ID_MASK; 83 val |= qid & DB_RQ_RING_ID_MASK;
84 val |= posted << DB_RQ_NUM_POSTED_SHIFT; 84 val |= posted << DB_RQ_NUM_POSTED_SHIFT;
85 iowrite32(val, ctrl->db + DB_RQ_OFFSET); 85 iowrite32(val, adapter->db + DB_RQ_OFFSET);
86} 86}
87 87
88static void be_txq_notify(struct be_ctrl_info *ctrl, u16 qid, u16 posted) 88static void be_txq_notify(struct be_adapter *adapter, u16 qid, u16 posted)
89{ 89{
90 u32 val = 0; 90 u32 val = 0;
91 val |= qid & DB_TXULP_RING_ID_MASK; 91 val |= qid & DB_TXULP_RING_ID_MASK;
92 val |= (posted & DB_TXULP_NUM_POSTED_MASK) << DB_TXULP_NUM_POSTED_SHIFT; 92 val |= (posted & DB_TXULP_NUM_POSTED_MASK) << DB_TXULP_NUM_POSTED_SHIFT;
93 iowrite32(val, ctrl->db + DB_TXULP1_OFFSET); 93 iowrite32(val, adapter->db + DB_TXULP1_OFFSET);
94} 94}
95 95
96static void be_eq_notify(struct be_ctrl_info *ctrl, u16 qid, 96static void be_eq_notify(struct be_adapter *adapter, u16 qid,
97 bool arm, bool clear_int, u16 num_popped) 97 bool arm, bool clear_int, u16 num_popped)
98{ 98{
99 u32 val = 0; 99 u32 val = 0;
@@ -104,18 +104,17 @@ static void be_eq_notify(struct be_ctrl_info *ctrl, u16 qid,
104 val |= 1 << DB_EQ_CLR_SHIFT; 104 val |= 1 << DB_EQ_CLR_SHIFT;
105 val |= 1 << DB_EQ_EVNT_SHIFT; 105 val |= 1 << DB_EQ_EVNT_SHIFT;
106 val |= num_popped << DB_EQ_NUM_POPPED_SHIFT; 106 val |= num_popped << DB_EQ_NUM_POPPED_SHIFT;
107 iowrite32(val, ctrl->db + DB_EQ_OFFSET); 107 iowrite32(val, adapter->db + DB_EQ_OFFSET);
108} 108}
109 109
110void be_cq_notify(struct be_ctrl_info *ctrl, u16 qid, 110void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped)
111 bool arm, u16 num_popped)
112{ 111{
113 u32 val = 0; 112 u32 val = 0;
114 val |= qid & DB_CQ_RING_ID_MASK; 113 val |= qid & DB_CQ_RING_ID_MASK;
115 if (arm) 114 if (arm)
116 val |= 1 << DB_CQ_REARM_SHIFT; 115 val |= 1 << DB_CQ_REARM_SHIFT;
117 val |= num_popped << DB_CQ_NUM_POPPED_SHIFT; 116 val |= num_popped << DB_CQ_NUM_POPPED_SHIFT;
118 iowrite32(val, ctrl->db + DB_CQ_OFFSET); 117 iowrite32(val, adapter->db + DB_CQ_OFFSET);
119} 118}
120 119
121 120
@@ -126,12 +125,12 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
126 int status = 0; 125 int status = 0;
127 126
128 if (netif_running(netdev)) { 127 if (netif_running(netdev)) {
129 status = be_cmd_pmac_del(&adapter->ctrl, adapter->if_handle, 128 status = be_cmd_pmac_del(adapter, adapter->if_handle,
130 adapter->pmac_id); 129 adapter->pmac_id);
131 if (status) 130 if (status)
132 return status; 131 return status;
133 132
134 status = be_cmd_pmac_add(&adapter->ctrl, (u8 *)addr->sa_data, 133 status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
135 adapter->if_handle, &adapter->pmac_id); 134 adapter->if_handle, &adapter->pmac_id);
136 } 135 }
137 136
@@ -214,9 +213,8 @@ static void netdev_stats_update(struct be_adapter *adapter)
214 dev_stats->tx_window_errors = 0; 213 dev_stats->tx_window_errors = 0;
215} 214}
216 215
217void be_link_status_update(void *ctxt, bool link_up) 216void be_link_status_update(struct be_adapter *adapter, bool link_up)
218{ 217{
219 struct be_adapter *adapter = ctxt;
220 struct net_device *netdev = adapter->netdev; 218 struct net_device *netdev = adapter->netdev;
221 219
222 /* If link came up or went down */ 220 /* If link came up or went down */
@@ -237,7 +235,6 @@ void be_link_status_update(void *ctxt, bool link_up)
237/* Update the EQ delay n BE based on the RX frags consumed / sec */ 235/* Update the EQ delay n BE based on the RX frags consumed / sec */
238static void be_rx_eqd_update(struct be_adapter *adapter) 236static void be_rx_eqd_update(struct be_adapter *adapter)
239{ 237{
240 struct be_ctrl_info *ctrl = &adapter->ctrl;
241 struct be_eq_obj *rx_eq = &adapter->rx_eq; 238 struct be_eq_obj *rx_eq = &adapter->rx_eq;
242 struct be_drvr_stats *stats = &adapter->stats.drvr_stats; 239 struct be_drvr_stats *stats = &adapter->stats.drvr_stats;
243 ulong now = jiffies; 240 ulong now = jiffies;
@@ -270,7 +267,7 @@ static void be_rx_eqd_update(struct be_adapter *adapter)
270 if (eqd < 10) 267 if (eqd < 10)
271 eqd = 0; 268 eqd = 0;
272 if (eqd != rx_eq->cur_eqd) 269 if (eqd != rx_eq->cur_eqd)
273 be_cmd_modify_eqd(ctrl, rx_eq->q.id, eqd); 270 be_cmd_modify_eqd(adapter, rx_eq->q.id, eqd);
274 271
275 rx_eq->cur_eqd = eqd; 272 rx_eq->cur_eqd = eqd;
276} 273}
@@ -412,8 +409,8 @@ static int make_tx_wrbs(struct be_adapter *adapter,
412 struct skb_frag_struct *frag = 409 struct skb_frag_struct *frag =
413 &skb_shinfo(skb)->frags[i]; 410 &skb_shinfo(skb)->frags[i];
414 busaddr = pci_map_page(pdev, frag->page, 411 busaddr = pci_map_page(pdev, frag->page,
415 frag->page_offset, 412 frag->page_offset,
416 frag->size, PCI_DMA_TODEVICE); 413 frag->size, PCI_DMA_TODEVICE);
417 wrb = queue_head_node(txq); 414 wrb = queue_head_node(txq);
418 wrb_fill(wrb, busaddr, frag->size); 415 wrb_fill(wrb, busaddr, frag->size);
419 be_dws_cpu_to_le(wrb, sizeof(*wrb)); 416 be_dws_cpu_to_le(wrb, sizeof(*wrb));
@@ -461,7 +458,7 @@ static int be_xmit(struct sk_buff *skb, struct net_device *netdev)
461 stopped = true; 458 stopped = true;
462 } 459 }
463 460
464 be_txq_notify(&adapter->ctrl, txq->id, wrb_cnt); 461 be_txq_notify(adapter, txq->id, wrb_cnt);
465 462
466 be_tx_stats_update(adapter, wrb_cnt, copied, stopped); 463 be_tx_stats_update(adapter, wrb_cnt, copied, stopped);
467 return NETDEV_TX_OK; 464 return NETDEV_TX_OK;
@@ -502,10 +499,10 @@ static void be_vid_config(struct net_device *netdev)
502 ntags++; 499 ntags++;
503 } 500 }
504 } 501 }
505 be_cmd_vlan_config(&adapter->ctrl, adapter->if_handle, 502 be_cmd_vlan_config(adapter, adapter->if_handle,
506 vtag, ntags, 1, 0); 503 vtag, ntags, 1, 0);
507 } else { 504 } else {
508 be_cmd_vlan_config(&adapter->ctrl, adapter->if_handle, 505 be_cmd_vlan_config(adapter, adapter->if_handle,
509 NULL, 0, 1, 1); 506 NULL, 0, 1, 1);
510 } 507 }
511} 508}
@@ -515,13 +512,12 @@ static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp)
515 struct be_adapter *adapter = netdev_priv(netdev); 512 struct be_adapter *adapter = netdev_priv(netdev);
516 struct be_eq_obj *rx_eq = &adapter->rx_eq; 513 struct be_eq_obj *rx_eq = &adapter->rx_eq;
517 struct be_eq_obj *tx_eq = &adapter->tx_eq; 514 struct be_eq_obj *tx_eq = &adapter->tx_eq;
518 struct be_ctrl_info *ctrl = &adapter->ctrl;
519 515
520 be_eq_notify(ctrl, rx_eq->q.id, false, false, 0); 516 be_eq_notify(adapter, rx_eq->q.id, false, false, 0);
521 be_eq_notify(ctrl, tx_eq->q.id, false, false, 0); 517 be_eq_notify(adapter, tx_eq->q.id, false, false, 0);
522 adapter->vlan_grp = grp; 518 adapter->vlan_grp = grp;
523 be_eq_notify(ctrl, rx_eq->q.id, true, false, 0); 519 be_eq_notify(adapter, rx_eq->q.id, true, false, 0);
524 be_eq_notify(ctrl, tx_eq->q.id, true, false, 0); 520 be_eq_notify(adapter, tx_eq->q.id, true, false, 0);
525} 521}
526 522
527static void be_vlan_add_vid(struct net_device *netdev, u16 vid) 523static void be_vlan_add_vid(struct net_device *netdev, u16 vid)
@@ -548,10 +544,9 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
548static void be_set_multicast_list(struct net_device *netdev) 544static void be_set_multicast_list(struct net_device *netdev)
549{ 545{
550 struct be_adapter *adapter = netdev_priv(netdev); 546 struct be_adapter *adapter = netdev_priv(netdev);
551 struct be_ctrl_info *ctrl = &adapter->ctrl;
552 547
553 if (netdev->flags & IFF_PROMISC) { 548 if (netdev->flags & IFF_PROMISC) {
554 be_cmd_promiscuous_config(ctrl, adapter->port_num, 1); 549 be_cmd_promiscuous_config(adapter, adapter->port_num, 1);
555 adapter->promiscuous = true; 550 adapter->promiscuous = true;
556 goto done; 551 goto done;
557 } 552 }
@@ -559,15 +554,15 @@ static void be_set_multicast_list(struct net_device *netdev)
559 /* BE was previously in promiscous mode; disable it */ 554 /* BE was previously in promiscous mode; disable it */
560 if (adapter->promiscuous) { 555 if (adapter->promiscuous) {
561 adapter->promiscuous = false; 556 adapter->promiscuous = false;
562 be_cmd_promiscuous_config(ctrl, adapter->port_num, 0); 557 be_cmd_promiscuous_config(adapter, adapter->port_num, 0);
563 } 558 }
564 559
565 if (netdev->flags & IFF_ALLMULTI) { 560 if (netdev->flags & IFF_ALLMULTI) {
566 be_cmd_multicast_set(ctrl, adapter->if_handle, NULL, 0); 561 be_cmd_multicast_set(adapter, adapter->if_handle, NULL, 0);
567 goto done; 562 goto done;
568 } 563 }
569 564
570 be_cmd_multicast_set(ctrl, adapter->if_handle, netdev->mc_list, 565 be_cmd_multicast_set(adapter, adapter->if_handle, netdev->mc_list,
571 netdev->mc_count); 566 netdev->mc_count);
572done: 567done:
573 return; 568 return;
@@ -742,7 +737,7 @@ done:
742 return; 737 return;
743} 738}
744 739
745/* Process the RX completion indicated by rxcp when LRO is disabled */ 740/* Process the RX completion indicated by rxcp when GRO is disabled */
746static void be_rx_compl_process(struct be_adapter *adapter, 741static void be_rx_compl_process(struct be_adapter *adapter,
747 struct be_eth_rx_compl *rxcp) 742 struct be_eth_rx_compl *rxcp)
748{ 743{
@@ -789,13 +784,14 @@ static void be_rx_compl_process(struct be_adapter *adapter,
789 return; 784 return;
790} 785}
791 786
792/* Process the RX completion indicated by rxcp when LRO is enabled */ 787/* Process the RX completion indicated by rxcp when GRO is enabled */
793static void be_rx_compl_process_lro(struct be_adapter *adapter, 788static void be_rx_compl_process_gro(struct be_adapter *adapter,
794 struct be_eth_rx_compl *rxcp) 789 struct be_eth_rx_compl *rxcp)
795{ 790{
796 struct be_rx_page_info *page_info; 791 struct be_rx_page_info *page_info;
797 struct skb_frag_struct rx_frags[BE_MAX_FRAGS_PER_FRAME]; 792 struct sk_buff *skb = NULL;
798 struct be_queue_info *rxq = &adapter->rx_obj.q; 793 struct be_queue_info *rxq = &adapter->rx_obj.q;
794 struct be_eq_obj *eq_obj = &adapter->rx_eq;
799 u32 num_rcvd, pkt_size, remaining, vlanf, curr_frag_len; 795 u32 num_rcvd, pkt_size, remaining, vlanf, curr_frag_len;
800 u16 i, rxq_idx = 0, vid, j; 796 u16 i, rxq_idx = 0, vid, j;
801 797
@@ -804,6 +800,12 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
804 vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp); 800 vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp);
805 rxq_idx = AMAP_GET_BITS(struct amap_eth_rx_compl, fragndx, rxcp); 801 rxq_idx = AMAP_GET_BITS(struct amap_eth_rx_compl, fragndx, rxcp);
806 802
803 skb = napi_get_frags(&eq_obj->napi);
804 if (!skb) {
805 be_rx_compl_discard(adapter, rxcp);
806 return;
807 }
808
807 remaining = pkt_size; 809 remaining = pkt_size;
808 for (i = 0, j = -1; i < num_rcvd; i++) { 810 for (i = 0, j = -1; i < num_rcvd; i++) {
809 page_info = get_rx_page_info(adapter, rxq_idx); 811 page_info = get_rx_page_info(adapter, rxq_idx);
@@ -814,13 +816,14 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
814 if (i == 0 || page_info->page_offset == 0) { 816 if (i == 0 || page_info->page_offset == 0) {
815 /* First frag or Fresh page */ 817 /* First frag or Fresh page */
816 j++; 818 j++;
817 rx_frags[j].page = page_info->page; 819 skb_shinfo(skb)->frags[j].page = page_info->page;
818 rx_frags[j].page_offset = page_info->page_offset; 820 skb_shinfo(skb)->frags[j].page_offset =
819 rx_frags[j].size = 0; 821 page_info->page_offset;
822 skb_shinfo(skb)->frags[j].size = 0;
820 } else { 823 } else {
821 put_page(page_info->page); 824 put_page(page_info->page);
822 } 825 }
823 rx_frags[j].size += curr_frag_len; 826 skb_shinfo(skb)->frags[j].size += curr_frag_len;
824 827
825 remaining -= curr_frag_len; 828 remaining -= curr_frag_len;
826 index_inc(&rxq_idx, rxq->len); 829 index_inc(&rxq_idx, rxq->len);
@@ -828,9 +831,14 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
828 } 831 }
829 BUG_ON(j > MAX_SKB_FRAGS); 832 BUG_ON(j > MAX_SKB_FRAGS);
830 833
834 skb_shinfo(skb)->nr_frags = j + 1;
835 skb->len = pkt_size;
836 skb->data_len = pkt_size;
837 skb->truesize += pkt_size;
838 skb->ip_summed = CHECKSUM_UNNECESSARY;
839
831 if (likely(!vlanf)) { 840 if (likely(!vlanf)) {
832 lro_receive_frags(&adapter->rx_obj.lro_mgr, rx_frags, pkt_size, 841 napi_gro_frags(&eq_obj->napi);
833 pkt_size, NULL, 0);
834 } else { 842 } else {
835 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp); 843 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
836 vid = be16_to_cpu(vid); 844 vid = be16_to_cpu(vid);
@@ -838,9 +846,7 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
838 if (!adapter->vlan_grp || adapter->num_vlans == 0) 846 if (!adapter->vlan_grp || adapter->num_vlans == 0)
839 return; 847 return;
840 848
841 lro_vlan_hwaccel_receive_frags(&adapter->rx_obj.lro_mgr, 849 vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp, vid);
842 rx_frags, pkt_size, pkt_size, adapter->vlan_grp,
843 vid, NULL, 0);
844 } 850 }
845 851
846 be_rx_stats_update(adapter, pkt_size, num_rcvd); 852 be_rx_stats_update(adapter, pkt_size, num_rcvd);
@@ -931,7 +937,7 @@ static void be_post_rx_frags(struct be_adapter *adapter)
931 937
932 if (posted) { 938 if (posted) {
933 atomic_add(posted, &rxq->used); 939 atomic_add(posted, &rxq->used);
934 be_rxq_notify(&adapter->ctrl, rxq->id, posted); 940 be_rxq_notify(adapter, rxq->id, posted);
935 } else if (atomic_read(&rxq->used) == 0) { 941 } else if (atomic_read(&rxq->used) == 0) {
936 /* Let be_worker replenish when memory is available */ 942 /* Let be_worker replenish when memory is available */
937 adapter->rx_post_starved = true; 943 adapter->rx_post_starved = true;
@@ -999,7 +1005,7 @@ static void be_rx_q_clean(struct be_adapter *adapter)
999 while ((rxcp = be_rx_compl_get(adapter)) != NULL) { 1005 while ((rxcp = be_rx_compl_get(adapter)) != NULL) {
1000 be_rx_compl_discard(adapter, rxcp); 1006 be_rx_compl_discard(adapter, rxcp);
1001 be_rx_compl_reset(rxcp); 1007 be_rx_compl_reset(rxcp);
1002 be_cq_notify(&adapter->ctrl, rx_cq->id, true, 1); 1008 be_cq_notify(adapter, rx_cq->id, true, 1);
1003 } 1009 }
1004 1010
1005 /* Then free posted rx buffer that were not used */ 1011 /* Then free posted rx buffer that were not used */
@@ -1032,16 +1038,15 @@ static void be_tx_q_clean(struct be_adapter *adapter)
1032static void be_mcc_queues_destroy(struct be_adapter *adapter) 1038static void be_mcc_queues_destroy(struct be_adapter *adapter)
1033{ 1039{
1034 struct be_queue_info *q; 1040 struct be_queue_info *q;
1035 struct be_ctrl_info *ctrl = &adapter->ctrl;
1036 1041
1037 q = &ctrl->mcc_obj.q; 1042 q = &adapter->mcc_obj.q;
1038 if (q->created) 1043 if (q->created)
1039 be_cmd_q_destroy(ctrl, q, QTYPE_MCCQ); 1044 be_cmd_q_destroy(adapter, q, QTYPE_MCCQ);
1040 be_queue_free(adapter, q); 1045 be_queue_free(adapter, q);
1041 1046
1042 q = &ctrl->mcc_obj.cq; 1047 q = &adapter->mcc_obj.cq;
1043 if (q->created) 1048 if (q->created)
1044 be_cmd_q_destroy(ctrl, q, QTYPE_CQ); 1049 be_cmd_q_destroy(adapter, q, QTYPE_CQ);
1045 be_queue_free(adapter, q); 1050 be_queue_free(adapter, q);
1046} 1051}
1047 1052
@@ -1049,25 +1054,24 @@ static void be_mcc_queues_destroy(struct be_adapter *adapter)
1049static int be_mcc_queues_create(struct be_adapter *adapter) 1054static int be_mcc_queues_create(struct be_adapter *adapter)
1050{ 1055{
1051 struct be_queue_info *q, *cq; 1056 struct be_queue_info *q, *cq;
1052 struct be_ctrl_info *ctrl = &adapter->ctrl;
1053 1057
1054 /* Alloc MCC compl queue */ 1058 /* Alloc MCC compl queue */
1055 cq = &ctrl->mcc_obj.cq; 1059 cq = &adapter->mcc_obj.cq;
1056 if (be_queue_alloc(adapter, cq, MCC_CQ_LEN, 1060 if (be_queue_alloc(adapter, cq, MCC_CQ_LEN,
1057 sizeof(struct be_mcc_cq_entry))) 1061 sizeof(struct be_mcc_compl)))
1058 goto err; 1062 goto err;
1059 1063
1060 /* Ask BE to create MCC compl queue; share TX's eq */ 1064 /* Ask BE to create MCC compl queue; share TX's eq */
1061 if (be_cmd_cq_create(ctrl, cq, &adapter->tx_eq.q, false, true, 0)) 1065 if (be_cmd_cq_create(adapter, cq, &adapter->tx_eq.q, false, true, 0))
1062 goto mcc_cq_free; 1066 goto mcc_cq_free;
1063 1067
1064 /* Alloc MCC queue */ 1068 /* Alloc MCC queue */
1065 q = &ctrl->mcc_obj.q; 1069 q = &adapter->mcc_obj.q;
1066 if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) 1070 if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb)))
1067 goto mcc_cq_destroy; 1071 goto mcc_cq_destroy;
1068 1072
1069 /* Ask BE to create MCC queue */ 1073 /* Ask BE to create MCC queue */
1070 if (be_cmd_mccq_create(ctrl, q, cq)) 1074 if (be_cmd_mccq_create(adapter, q, cq))
1071 goto mcc_q_free; 1075 goto mcc_q_free;
1072 1076
1073 return 0; 1077 return 0;
@@ -1075,7 +1079,7 @@ static int be_mcc_queues_create(struct be_adapter *adapter)
1075mcc_q_free: 1079mcc_q_free:
1076 be_queue_free(adapter, q); 1080 be_queue_free(adapter, q);
1077mcc_cq_destroy: 1081mcc_cq_destroy:
1078 be_cmd_q_destroy(ctrl, cq, QTYPE_CQ); 1082 be_cmd_q_destroy(adapter, cq, QTYPE_CQ);
1079mcc_cq_free: 1083mcc_cq_free:
1080 be_queue_free(adapter, cq); 1084 be_queue_free(adapter, cq);
1081err: 1085err:
@@ -1088,7 +1092,7 @@ static void be_tx_queues_destroy(struct be_adapter *adapter)
1088 1092
1089 q = &adapter->tx_obj.q; 1093 q = &adapter->tx_obj.q;
1090 if (q->created) { 1094 if (q->created) {
1091 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_TXQ); 1095 be_cmd_q_destroy(adapter, q, QTYPE_TXQ);
1092 1096
1093 /* No more tx completions can be rcvd now; clean up if there 1097 /* No more tx completions can be rcvd now; clean up if there
1094 * are any pending completions or pending tx requests */ 1098 * are any pending completions or pending tx requests */
@@ -1098,12 +1102,12 @@ static void be_tx_queues_destroy(struct be_adapter *adapter)
1098 1102
1099 q = &adapter->tx_obj.cq; 1103 q = &adapter->tx_obj.cq;
1100 if (q->created) 1104 if (q->created)
1101 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_CQ); 1105 be_cmd_q_destroy(adapter, q, QTYPE_CQ);
1102 be_queue_free(adapter, q); 1106 be_queue_free(adapter, q);
1103 1107
1104 q = &adapter->tx_eq.q; 1108 q = &adapter->tx_eq.q;
1105 if (q->created) 1109 if (q->created)
1106 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_EQ); 1110 be_cmd_q_destroy(adapter, q, QTYPE_EQ);
1107 be_queue_free(adapter, q); 1111 be_queue_free(adapter, q);
1108} 1112}
1109 1113
@@ -1121,7 +1125,7 @@ static int be_tx_queues_create(struct be_adapter *adapter)
1121 return -1; 1125 return -1;
1122 1126
1123 /* Ask BE to create Tx Event queue */ 1127 /* Ask BE to create Tx Event queue */
1124 if (be_cmd_eq_create(&adapter->ctrl, eq, adapter->tx_eq.cur_eqd)) 1128 if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd))
1125 goto tx_eq_free; 1129 goto tx_eq_free;
1126 /* Alloc TX eth compl queue */ 1130 /* Alloc TX eth compl queue */
1127 cq = &adapter->tx_obj.cq; 1131 cq = &adapter->tx_obj.cq;
@@ -1130,7 +1134,7 @@ static int be_tx_queues_create(struct be_adapter *adapter)
1130 goto tx_eq_destroy; 1134 goto tx_eq_destroy;
1131 1135
1132 /* Ask BE to create Tx eth compl queue */ 1136 /* Ask BE to create Tx eth compl queue */
1133 if (be_cmd_cq_create(&adapter->ctrl, cq, eq, false, false, 3)) 1137 if (be_cmd_cq_create(adapter, cq, eq, false, false, 3))
1134 goto tx_cq_free; 1138 goto tx_cq_free;
1135 1139
1136 /* Alloc TX eth queue */ 1140 /* Alloc TX eth queue */
@@ -1139,18 +1143,18 @@ static int be_tx_queues_create(struct be_adapter *adapter)
1139 goto tx_cq_destroy; 1143 goto tx_cq_destroy;
1140 1144
1141 /* Ask BE to create Tx eth queue */ 1145 /* Ask BE to create Tx eth queue */
1142 if (be_cmd_txq_create(&adapter->ctrl, q, cq)) 1146 if (be_cmd_txq_create(adapter, q, cq))
1143 goto tx_q_free; 1147 goto tx_q_free;
1144 return 0; 1148 return 0;
1145 1149
1146tx_q_free: 1150tx_q_free:
1147 be_queue_free(adapter, q); 1151 be_queue_free(adapter, q);
1148tx_cq_destroy: 1152tx_cq_destroy:
1149 be_cmd_q_destroy(&adapter->ctrl, cq, QTYPE_CQ); 1153 be_cmd_q_destroy(adapter, cq, QTYPE_CQ);
1150tx_cq_free: 1154tx_cq_free:
1151 be_queue_free(adapter, cq); 1155 be_queue_free(adapter, cq);
1152tx_eq_destroy: 1156tx_eq_destroy:
1153 be_cmd_q_destroy(&adapter->ctrl, eq, QTYPE_EQ); 1157 be_cmd_q_destroy(adapter, eq, QTYPE_EQ);
1154tx_eq_free: 1158tx_eq_free:
1155 be_queue_free(adapter, eq); 1159 be_queue_free(adapter, eq);
1156 return -1; 1160 return -1;
@@ -1162,19 +1166,19 @@ static void be_rx_queues_destroy(struct be_adapter *adapter)
1162 1166
1163 q = &adapter->rx_obj.q; 1167 q = &adapter->rx_obj.q;
1164 if (q->created) { 1168 if (q->created) {
1165 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_RXQ); 1169 be_cmd_q_destroy(adapter, q, QTYPE_RXQ);
1166 be_rx_q_clean(adapter); 1170 be_rx_q_clean(adapter);
1167 } 1171 }
1168 be_queue_free(adapter, q); 1172 be_queue_free(adapter, q);
1169 1173
1170 q = &adapter->rx_obj.cq; 1174 q = &adapter->rx_obj.cq;
1171 if (q->created) 1175 if (q->created)
1172 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_CQ); 1176 be_cmd_q_destroy(adapter, q, QTYPE_CQ);
1173 be_queue_free(adapter, q); 1177 be_queue_free(adapter, q);
1174 1178
1175 q = &adapter->rx_eq.q; 1179 q = &adapter->rx_eq.q;
1176 if (q->created) 1180 if (q->created)
1177 be_cmd_q_destroy(&adapter->ctrl, q, QTYPE_EQ); 1181 be_cmd_q_destroy(adapter, q, QTYPE_EQ);
1178 be_queue_free(adapter, q); 1182 be_queue_free(adapter, q);
1179} 1183}
1180 1184
@@ -1183,7 +1187,6 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1183 struct be_queue_info *eq, *q, *cq; 1187 struct be_queue_info *eq, *q, *cq;
1184 int rc; 1188 int rc;
1185 1189
1186 adapter->max_rx_coal = BE_MAX_FRAGS_PER_FRAME;
1187 adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; 1190 adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
1188 adapter->rx_eq.max_eqd = BE_MAX_EQD; 1191 adapter->rx_eq.max_eqd = BE_MAX_EQD;
1189 adapter->rx_eq.min_eqd = 0; 1192 adapter->rx_eq.min_eqd = 0;
@@ -1198,7 +1201,7 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1198 return rc; 1201 return rc;
1199 1202
1200 /* Ask BE to create Rx Event queue */ 1203 /* Ask BE to create Rx Event queue */
1201 rc = be_cmd_eq_create(&adapter->ctrl, eq, adapter->rx_eq.cur_eqd); 1204 rc = be_cmd_eq_create(adapter, eq, adapter->rx_eq.cur_eqd);
1202 if (rc) 1205 if (rc)
1203 goto rx_eq_free; 1206 goto rx_eq_free;
1204 1207
@@ -1210,7 +1213,7 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1210 goto rx_eq_destroy; 1213 goto rx_eq_destroy;
1211 1214
1212 /* Ask BE to create Rx eth compl queue */ 1215 /* Ask BE to create Rx eth compl queue */
1213 rc = be_cmd_cq_create(&adapter->ctrl, cq, eq, false, false, 3); 1216 rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3);
1214 if (rc) 1217 if (rc)
1215 goto rx_cq_free; 1218 goto rx_cq_free;
1216 1219
@@ -1221,7 +1224,7 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1221 goto rx_cq_destroy; 1224 goto rx_cq_destroy;
1222 1225
1223 /* Ask BE to create Rx eth queue */ 1226 /* Ask BE to create Rx eth queue */
1224 rc = be_cmd_rxq_create(&adapter->ctrl, q, cq->id, rx_frag_size, 1227 rc = be_cmd_rxq_create(adapter, q, cq->id, rx_frag_size,
1225 BE_MAX_JUMBO_FRAME_SIZE, adapter->if_handle, false); 1228 BE_MAX_JUMBO_FRAME_SIZE, adapter->if_handle, false);
1226 if (rc) 1229 if (rc)
1227 goto rx_q_free; 1230 goto rx_q_free;
@@ -1230,11 +1233,11 @@ static int be_rx_queues_create(struct be_adapter *adapter)
1230rx_q_free: 1233rx_q_free:
1231 be_queue_free(adapter, q); 1234 be_queue_free(adapter, q);
1232rx_cq_destroy: 1235rx_cq_destroy:
1233 be_cmd_q_destroy(&adapter->ctrl, cq, QTYPE_CQ); 1236 be_cmd_q_destroy(adapter, cq, QTYPE_CQ);
1234rx_cq_free: 1237rx_cq_free:
1235 be_queue_free(adapter, cq); 1238 be_queue_free(adapter, cq);
1236rx_eq_destroy: 1239rx_eq_destroy:
1237 be_cmd_q_destroy(&adapter->ctrl, eq, QTYPE_EQ); 1240 be_cmd_q_destroy(adapter, eq, QTYPE_EQ);
1238rx_eq_free: 1241rx_eq_free:
1239 be_queue_free(adapter, eq); 1242 be_queue_free(adapter, eq);
1240 return rc; 1243 return rc;
@@ -1254,8 +1257,7 @@ static bool event_get(struct be_eq_obj *eq_obj, u16 *rid)
1254 return true; 1257 return true;
1255} 1258}
1256 1259
1257static int event_handle(struct be_ctrl_info *ctrl, 1260static int event_handle(struct be_adapter *adapter, struct be_eq_obj *eq_obj)
1258 struct be_eq_obj *eq_obj)
1259{ 1261{
1260 u16 rid = 0, num = 0; 1262 u16 rid = 0, num = 0;
1261 1263
@@ -1263,7 +1265,7 @@ static int event_handle(struct be_ctrl_info *ctrl,
1263 num++; 1265 num++;
1264 1266
1265 /* We can see an interrupt and no event */ 1267 /* We can see an interrupt and no event */
1266 be_eq_notify(ctrl, eq_obj->q.id, true, true, num); 1268 be_eq_notify(adapter, eq_obj->q.id, true, true, num);
1267 if (num) 1269 if (num)
1268 napi_schedule(&eq_obj->napi); 1270 napi_schedule(&eq_obj->napi);
1269 1271
@@ -1273,25 +1275,24 @@ static int event_handle(struct be_ctrl_info *ctrl,
1273static irqreturn_t be_intx(int irq, void *dev) 1275static irqreturn_t be_intx(int irq, void *dev)
1274{ 1276{
1275 struct be_adapter *adapter = dev; 1277 struct be_adapter *adapter = dev;
1276 struct be_ctrl_info *ctrl = &adapter->ctrl; 1278 int isr;
1277 int isr;
1278 1279
1279 isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET + 1280 isr = ioread32(adapter->csr + CEV_ISR0_OFFSET +
1280 ctrl->pci_func * CEV_ISR_SIZE); 1281 be_pci_func(adapter) * CEV_ISR_SIZE);
1281 if (!isr) 1282 if (!isr)
1282 return IRQ_NONE; 1283 return IRQ_NONE;
1283 1284
1284 event_handle(ctrl, &adapter->tx_eq); 1285 event_handle(adapter, &adapter->tx_eq);
1285 event_handle(ctrl, &adapter->rx_eq); 1286 event_handle(adapter, &adapter->rx_eq);
1286 1287
1287 return IRQ_HANDLED; 1288 return IRQ_HANDLED;
1288} 1289}
1289 1290
1290static irqreturn_t be_msix_rx(int irq, void *dev) 1291static irqreturn_t be_msix_rx(int irq, void *dev)
1291{ 1292{
1292 struct be_adapter *adapter = dev; 1293 struct be_adapter *adapter = dev;
1293 1294
1294 event_handle(&adapter->ctrl, &adapter->rx_eq); 1295 event_handle(adapter, &adapter->rx_eq);
1295 1296
1296 return IRQ_HANDLED; 1297 return IRQ_HANDLED;
1297} 1298}
@@ -1300,12 +1301,12 @@ static irqreturn_t be_msix_tx_mcc(int irq, void *dev)
1300{ 1301{
1301 struct be_adapter *adapter = dev; 1302 struct be_adapter *adapter = dev;
1302 1303
1303 event_handle(&adapter->ctrl, &adapter->tx_eq); 1304 event_handle(adapter, &adapter->tx_eq);
1304 1305
1305 return IRQ_HANDLED; 1306 return IRQ_HANDLED;
1306} 1307}
1307 1308
1308static inline bool do_lro(struct be_adapter *adapter, 1309static inline bool do_gro(struct be_adapter *adapter,
1309 struct be_eth_rx_compl *rxcp) 1310 struct be_eth_rx_compl *rxcp)
1310{ 1311{
1311 int err = AMAP_GET_BITS(struct amap_eth_rx_compl, err, rxcp); 1312 int err = AMAP_GET_BITS(struct amap_eth_rx_compl, err, rxcp);
@@ -1314,8 +1315,7 @@ static inline bool do_lro(struct be_adapter *adapter,
1314 if (err) 1315 if (err)
1315 drvr_stats(adapter)->be_rxcp_err++; 1316 drvr_stats(adapter)->be_rxcp_err++;
1316 1317
1317 return (!tcp_frame || err || (adapter->max_rx_coal <= 1)) ? 1318 return (tcp_frame && !err) ? true : false;
1318 false : true;
1319} 1319}
1320 1320
1321int be_poll_rx(struct napi_struct *napi, int budget) 1321int be_poll_rx(struct napi_struct *napi, int budget)
@@ -1332,16 +1332,14 @@ int be_poll_rx(struct napi_struct *napi, int budget)
1332 if (!rxcp) 1332 if (!rxcp)
1333 break; 1333 break;
1334 1334
1335 if (do_lro(adapter, rxcp)) 1335 if (do_gro(adapter, rxcp))
1336 be_rx_compl_process_lro(adapter, rxcp); 1336 be_rx_compl_process_gro(adapter, rxcp);
1337 else 1337 else
1338 be_rx_compl_process(adapter, rxcp); 1338 be_rx_compl_process(adapter, rxcp);
1339 1339
1340 be_rx_compl_reset(rxcp); 1340 be_rx_compl_reset(rxcp);
1341 } 1341 }
1342 1342
1343 lro_flush_all(&adapter->rx_obj.lro_mgr);
1344
1345 /* Refill the queue */ 1343 /* Refill the queue */
1346 if (atomic_read(&adapter->rx_obj.q.used) < RX_FRAGS_REFILL_WM) 1344 if (atomic_read(&adapter->rx_obj.q.used) < RX_FRAGS_REFILL_WM)
1347 be_post_rx_frags(adapter); 1345 be_post_rx_frags(adapter);
@@ -1349,10 +1347,10 @@ int be_poll_rx(struct napi_struct *napi, int budget)
1349 /* All consumed */ 1347 /* All consumed */
1350 if (work_done < budget) { 1348 if (work_done < budget) {
1351 napi_complete(napi); 1349 napi_complete(napi);
1352 be_cq_notify(&adapter->ctrl, rx_cq->id, true, work_done); 1350 be_cq_notify(adapter, rx_cq->id, true, work_done);
1353 } else { 1351 } else {
1354 /* More to be consumed; continue with interrupts disabled */ 1352 /* More to be consumed; continue with interrupts disabled */
1355 be_cq_notify(&adapter->ctrl, rx_cq->id, false, work_done); 1353 be_cq_notify(adapter, rx_cq->id, false, work_done);
1356 } 1354 }
1357 return work_done; 1355 return work_done;
1358} 1356}
@@ -1373,7 +1371,7 @@ void be_process_tx(struct be_adapter *adapter)
1373 } 1371 }
1374 1372
1375 if (num_cmpl) { 1373 if (num_cmpl) {
1376 be_cq_notify(&adapter->ctrl, tx_cq->id, true, num_cmpl); 1374 be_cq_notify(adapter, tx_cq->id, true, num_cmpl);
1377 1375
1378 /* As Tx wrbs have been freed up, wake up netdev queue if 1376 /* As Tx wrbs have been freed up, wake up netdev queue if
1379 * it was stopped due to lack of tx wrbs. 1377 * it was stopped due to lack of tx wrbs.
@@ -1401,7 +1399,7 @@ static int be_poll_tx_mcc(struct napi_struct *napi, int budget)
1401 1399
1402 be_process_tx(adapter); 1400 be_process_tx(adapter);
1403 1401
1404 be_process_mcc(&adapter->ctrl); 1402 be_process_mcc(adapter);
1405 1403
1406 return 1; 1404 return 1;
1407} 1405}
@@ -1413,7 +1411,7 @@ static void be_worker(struct work_struct *work)
1413 int status; 1411 int status;
1414 1412
1415 /* Get Stats */ 1413 /* Get Stats */
1416 status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd); 1414 status = be_cmd_get_stats(adapter, &adapter->stats.cmd);
1417 if (!status) 1415 if (!status)
1418 netdev_stats_update(adapter); 1416 netdev_stats_update(adapter);
1419 1417
@@ -1447,8 +1445,7 @@ static void be_msix_enable(struct be_adapter *adapter)
1447 1445
1448static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) 1446static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id)
1449{ 1447{
1450 return adapter->msix_entries[eq_id - 1448 return adapter->msix_entries[eq_id - 8 * be_pci_func(adapter)].vector;
1451 8 * adapter->ctrl.pci_func].vector;
1452} 1449}
1453 1450
1454static int be_msix_register(struct be_adapter *adapter) 1451static int be_msix_register(struct be_adapter *adapter)
@@ -1533,7 +1530,6 @@ done:
1533static int be_open(struct net_device *netdev) 1530static int be_open(struct net_device *netdev)
1534{ 1531{
1535 struct be_adapter *adapter = netdev_priv(netdev); 1532 struct be_adapter *adapter = netdev_priv(netdev);
1536 struct be_ctrl_info *ctrl = &adapter->ctrl;
1537 struct be_eq_obj *rx_eq = &adapter->rx_eq; 1533 struct be_eq_obj *rx_eq = &adapter->rx_eq;
1538 struct be_eq_obj *tx_eq = &adapter->tx_eq; 1534 struct be_eq_obj *tx_eq = &adapter->tx_eq;
1539 bool link_up; 1535 bool link_up;
@@ -1547,16 +1543,16 @@ static int be_open(struct net_device *netdev)
1547 1543
1548 be_irq_register(adapter); 1544 be_irq_register(adapter);
1549 1545
1550 be_intr_set(ctrl, true); 1546 be_intr_set(adapter, true);
1551 1547
1552 /* The evt queues are created in unarmed state; arm them */ 1548 /* The evt queues are created in unarmed state; arm them */
1553 be_eq_notify(ctrl, rx_eq->q.id, true, false, 0); 1549 be_eq_notify(adapter, rx_eq->q.id, true, false, 0);
1554 be_eq_notify(ctrl, tx_eq->q.id, true, false, 0); 1550 be_eq_notify(adapter, tx_eq->q.id, true, false, 0);
1555 1551
1556 /* Rx compl queue may be in unarmed state; rearm it */ 1552 /* Rx compl queue may be in unarmed state; rearm it */
1557 be_cq_notify(ctrl, adapter->rx_obj.cq.id, true, 0); 1553 be_cq_notify(adapter, adapter->rx_obj.cq.id, true, 0);
1558 1554
1559 status = be_cmd_link_status_query(ctrl, &link_up); 1555 status = be_cmd_link_status_query(adapter, &link_up);
1560 if (status) 1556 if (status)
1561 return status; 1557 return status;
1562 be_link_status_update(adapter, link_up); 1558 be_link_status_update(adapter, link_up);
@@ -1567,7 +1563,6 @@ static int be_open(struct net_device *netdev)
1567 1563
1568static int be_setup(struct be_adapter *adapter) 1564static int be_setup(struct be_adapter *adapter)
1569{ 1565{
1570 struct be_ctrl_info *ctrl = &adapter->ctrl;
1571 struct net_device *netdev = adapter->netdev; 1566 struct net_device *netdev = adapter->netdev;
1572 u32 if_flags; 1567 u32 if_flags;
1573 int status; 1568 int status;
@@ -1575,7 +1570,7 @@ static int be_setup(struct be_adapter *adapter)
1575 if_flags = BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PROMISCUOUS | 1570 if_flags = BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PROMISCUOUS |
1576 BE_IF_FLAGS_MCAST_PROMISCUOUS | BE_IF_FLAGS_UNTAGGED | 1571 BE_IF_FLAGS_MCAST_PROMISCUOUS | BE_IF_FLAGS_UNTAGGED |
1577 BE_IF_FLAGS_PASS_L3L4_ERRORS; 1572 BE_IF_FLAGS_PASS_L3L4_ERRORS;
1578 status = be_cmd_if_create(ctrl, if_flags, netdev->dev_addr, 1573 status = be_cmd_if_create(adapter, if_flags, netdev->dev_addr,
1579 false/* pmac_invalid */, &adapter->if_handle, 1574 false/* pmac_invalid */, &adapter->if_handle,
1580 &adapter->pmac_id); 1575 &adapter->pmac_id);
1581 if (status != 0) 1576 if (status != 0)
@@ -1583,7 +1578,7 @@ static int be_setup(struct be_adapter *adapter)
1583 1578
1584 be_vid_config(netdev); 1579 be_vid_config(netdev);
1585 1580
1586 status = be_cmd_set_flow_control(ctrl, true, true); 1581 status = be_cmd_set_flow_control(adapter, true, true);
1587 if (status != 0) 1582 if (status != 0)
1588 goto if_destroy; 1583 goto if_destroy;
1589 1584
@@ -1606,19 +1601,17 @@ rx_qs_destroy:
1606tx_qs_destroy: 1601tx_qs_destroy:
1607 be_tx_queues_destroy(adapter); 1602 be_tx_queues_destroy(adapter);
1608if_destroy: 1603if_destroy:
1609 be_cmd_if_destroy(ctrl, adapter->if_handle); 1604 be_cmd_if_destroy(adapter, adapter->if_handle);
1610do_none: 1605do_none:
1611 return status; 1606 return status;
1612} 1607}
1613 1608
1614static int be_clear(struct be_adapter *adapter) 1609static int be_clear(struct be_adapter *adapter)
1615{ 1610{
1616 struct be_ctrl_info *ctrl = &adapter->ctrl;
1617
1618 be_rx_queues_destroy(adapter); 1611 be_rx_queues_destroy(adapter);
1619 be_tx_queues_destroy(adapter); 1612 be_tx_queues_destroy(adapter);
1620 1613
1621 be_cmd_if_destroy(ctrl, adapter->if_handle); 1614 be_cmd_if_destroy(adapter, adapter->if_handle);
1622 1615
1623 be_mcc_queues_destroy(adapter); 1616 be_mcc_queues_destroy(adapter);
1624 return 0; 1617 return 0;
@@ -1627,7 +1620,6 @@ static int be_clear(struct be_adapter *adapter)
1627static int be_close(struct net_device *netdev) 1620static int be_close(struct net_device *netdev)
1628{ 1621{
1629 struct be_adapter *adapter = netdev_priv(netdev); 1622 struct be_adapter *adapter = netdev_priv(netdev);
1630 struct be_ctrl_info *ctrl = &adapter->ctrl;
1631 struct be_eq_obj *rx_eq = &adapter->rx_eq; 1623 struct be_eq_obj *rx_eq = &adapter->rx_eq;
1632 struct be_eq_obj *tx_eq = &adapter->tx_eq; 1624 struct be_eq_obj *tx_eq = &adapter->tx_eq;
1633 int vec; 1625 int vec;
@@ -1638,7 +1630,7 @@ static int be_close(struct net_device *netdev)
1638 netif_carrier_off(netdev); 1630 netif_carrier_off(netdev);
1639 adapter->link_up = false; 1631 adapter->link_up = false;
1640 1632
1641 be_intr_set(ctrl, false); 1633 be_intr_set(adapter, false);
1642 1634
1643 if (adapter->msix_enabled) { 1635 if (adapter->msix_enabled) {
1644 vec = be_msix_vec_get(adapter, tx_eq->q.id); 1636 vec = be_msix_vec_get(adapter, tx_eq->q.id);
@@ -1656,57 +1648,6 @@ static int be_close(struct net_device *netdev)
1656 return 0; 1648 return 0;
1657} 1649}
1658 1650
1659static int be_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
1660 void **ip_hdr, void **tcpudp_hdr,
1661 u64 *hdr_flags, void *priv)
1662{
1663 struct ethhdr *eh;
1664 struct vlan_ethhdr *veh;
1665 struct iphdr *iph;
1666 u8 *va = page_address(frag->page) + frag->page_offset;
1667 unsigned long ll_hlen;
1668
1669 prefetch(va);
1670 eh = (struct ethhdr *)va;
1671 *mac_hdr = eh;
1672 ll_hlen = ETH_HLEN;
1673 if (eh->h_proto != htons(ETH_P_IP)) {
1674 if (eh->h_proto == htons(ETH_P_8021Q)) {
1675 veh = (struct vlan_ethhdr *)va;
1676 if (veh->h_vlan_encapsulated_proto != htons(ETH_P_IP))
1677 return -1;
1678
1679 ll_hlen += VLAN_HLEN;
1680 } else {
1681 return -1;
1682 }
1683 }
1684 *hdr_flags = LRO_IPV4;
1685 iph = (struct iphdr *)(va + ll_hlen);
1686 *ip_hdr = iph;
1687 if (iph->protocol != IPPROTO_TCP)
1688 return -1;
1689 *hdr_flags |= LRO_TCP;
1690 *tcpudp_hdr = (u8 *) (*ip_hdr) + (iph->ihl << 2);
1691
1692 return 0;
1693}
1694
1695static void be_lro_init(struct be_adapter *adapter, struct net_device *netdev)
1696{
1697 struct net_lro_mgr *lro_mgr;
1698
1699 lro_mgr = &adapter->rx_obj.lro_mgr;
1700 lro_mgr->dev = netdev;
1701 lro_mgr->features = LRO_F_NAPI;
1702 lro_mgr->ip_summed = CHECKSUM_UNNECESSARY;
1703 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
1704 lro_mgr->max_desc = BE_MAX_LRO_DESCRIPTORS;
1705 lro_mgr->lro_arr = adapter->rx_obj.lro_desc;
1706 lro_mgr->get_frag_header = be_get_frag_header;
1707 lro_mgr->max_aggr = BE_MAX_FRAGS_PER_FRAME;
1708}
1709
1710static struct net_device_ops be_netdev_ops = { 1651static struct net_device_ops be_netdev_ops = {
1711 .ndo_open = be_open, 1652 .ndo_open = be_open,
1712 .ndo_stop = be_close, 1653 .ndo_stop = be_close,
@@ -1727,7 +1668,7 @@ static void be_netdev_init(struct net_device *netdev)
1727 1668
1728 netdev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_RX | NETIF_F_TSO | 1669 netdev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_RX | NETIF_F_TSO |
1729 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_IP_CSUM | 1670 NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER | NETIF_F_IP_CSUM |
1730 NETIF_F_IPV6_CSUM; 1671 NETIF_F_IPV6_CSUM | NETIF_F_GRO;
1731 1672
1732 netdev->flags |= IFF_MULTICAST; 1673 netdev->flags |= IFF_MULTICAST;
1733 1674
@@ -1737,8 +1678,6 @@ static void be_netdev_init(struct net_device *netdev)
1737 1678
1738 SET_ETHTOOL_OPS(netdev, &be_ethtool_ops); 1679 SET_ETHTOOL_OPS(netdev, &be_ethtool_ops);
1739 1680
1740 be_lro_init(adapter, netdev);
1741
1742 netif_napi_add(netdev, &adapter->rx_eq.napi, be_poll_rx, 1681 netif_napi_add(netdev, &adapter->rx_eq.napi, be_poll_rx,
1743 BE_NAPI_WEIGHT); 1682 BE_NAPI_WEIGHT);
1744 netif_napi_add(netdev, &adapter->tx_eq.napi, be_poll_tx_mcc, 1683 netif_napi_add(netdev, &adapter->tx_eq.napi, be_poll_tx_mcc,
@@ -1750,13 +1689,12 @@ static void be_netdev_init(struct net_device *netdev)
1750 1689
1751static void be_unmap_pci_bars(struct be_adapter *adapter) 1690static void be_unmap_pci_bars(struct be_adapter *adapter)
1752{ 1691{
1753 struct be_ctrl_info *ctrl = &adapter->ctrl; 1692 if (adapter->csr)
1754 if (ctrl->csr) 1693 iounmap(adapter->csr);
1755 iounmap(ctrl->csr); 1694 if (adapter->db)
1756 if (ctrl->db) 1695 iounmap(adapter->db);
1757 iounmap(ctrl->db); 1696 if (adapter->pcicfg)
1758 if (ctrl->pcicfg) 1697 iounmap(adapter->pcicfg);
1759 iounmap(ctrl->pcicfg);
1760} 1698}
1761 1699
1762static int be_map_pci_bars(struct be_adapter *adapter) 1700static int be_map_pci_bars(struct be_adapter *adapter)
@@ -1767,19 +1705,19 @@ static int be_map_pci_bars(struct be_adapter *adapter)
1767 pci_resource_len(adapter->pdev, 2)); 1705 pci_resource_len(adapter->pdev, 2));
1768 if (addr == NULL) 1706 if (addr == NULL)
1769 return -ENOMEM; 1707 return -ENOMEM;
1770 adapter->ctrl.csr = addr; 1708 adapter->csr = addr;
1771 1709
1772 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4), 1710 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4),
1773 128 * 1024); 1711 128 * 1024);
1774 if (addr == NULL) 1712 if (addr == NULL)
1775 goto pci_map_err; 1713 goto pci_map_err;
1776 adapter->ctrl.db = addr; 1714 adapter->db = addr;
1777 1715
1778 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 1), 1716 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 1),
1779 pci_resource_len(adapter->pdev, 1)); 1717 pci_resource_len(adapter->pdev, 1));
1780 if (addr == NULL) 1718 if (addr == NULL)
1781 goto pci_map_err; 1719 goto pci_map_err;
1782 adapter->ctrl.pcicfg = addr; 1720 adapter->pcicfg = addr;
1783 1721
1784 return 0; 1722 return 0;
1785pci_map_err: 1723pci_map_err:
@@ -1790,7 +1728,7 @@ pci_map_err:
1790 1728
1791static void be_ctrl_cleanup(struct be_adapter *adapter) 1729static void be_ctrl_cleanup(struct be_adapter *adapter)
1792{ 1730{
1793 struct be_dma_mem *mem = &adapter->ctrl.mbox_mem_alloced; 1731 struct be_dma_mem *mem = &adapter->mbox_mem_alloced;
1794 1732
1795 be_unmap_pci_bars(adapter); 1733 be_unmap_pci_bars(adapter);
1796 1734
@@ -1799,14 +1737,11 @@ static void be_ctrl_cleanup(struct be_adapter *adapter)
1799 mem->va, mem->dma); 1737 mem->va, mem->dma);
1800} 1738}
1801 1739
1802/* Initialize the mbox required to send cmds to BE */
1803static int be_ctrl_init(struct be_adapter *adapter) 1740static int be_ctrl_init(struct be_adapter *adapter)
1804{ 1741{
1805 struct be_ctrl_info *ctrl = &adapter->ctrl; 1742 struct be_dma_mem *mbox_mem_alloc = &adapter->mbox_mem_alloced;
1806 struct be_dma_mem *mbox_mem_alloc = &ctrl->mbox_mem_alloced; 1743 struct be_dma_mem *mbox_mem_align = &adapter->mbox_mem;
1807 struct be_dma_mem *mbox_mem_align = &ctrl->mbox_mem;
1808 int status; 1744 int status;
1809 u32 val;
1810 1745
1811 status = be_map_pci_bars(adapter); 1746 status = be_map_pci_bars(adapter);
1812 if (status) 1747 if (status)
@@ -1823,16 +1758,10 @@ static int be_ctrl_init(struct be_adapter *adapter)
1823 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); 1758 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16);
1824 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); 1759 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16);
1825 memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox)); 1760 memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox));
1826 spin_lock_init(&ctrl->mbox_lock); 1761 spin_lock_init(&adapter->mbox_lock);
1827 spin_lock_init(&ctrl->mcc_lock); 1762 spin_lock_init(&adapter->mcc_lock);
1828 spin_lock_init(&ctrl->mcc_cq_lock); 1763 spin_lock_init(&adapter->mcc_cq_lock);
1829 1764
1830 ctrl->async_cb = be_link_status_update;
1831 ctrl->adapter_ctxt = adapter;
1832
1833 val = ioread32(ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET);
1834 ctrl->pci_func = (val >> MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT) &
1835 MEMBAR_CTRL_INT_CTRL_PFUNC_MASK;
1836 return 0; 1765 return 0;
1837} 1766}
1838 1767
@@ -1886,18 +1815,17 @@ static void __devexit be_remove(struct pci_dev *pdev)
1886 1815
1887static int be_hw_up(struct be_adapter *adapter) 1816static int be_hw_up(struct be_adapter *adapter)
1888{ 1817{
1889 struct be_ctrl_info *ctrl = &adapter->ctrl;
1890 int status; 1818 int status;
1891 1819
1892 status = be_cmd_POST(ctrl); 1820 status = be_cmd_POST(adapter);
1893 if (status) 1821 if (status)
1894 return status; 1822 return status;
1895 1823
1896 status = be_cmd_get_fw_ver(ctrl, adapter->fw_ver); 1824 status = be_cmd_get_fw_ver(adapter, adapter->fw_ver);
1897 if (status) 1825 if (status)
1898 return status; 1826 return status;
1899 1827
1900 status = be_cmd_query_fw_cfg(ctrl, &adapter->port_num); 1828 status = be_cmd_query_fw_cfg(adapter, &adapter->port_num);
1901 return status; 1829 return status;
1902} 1830}
1903 1831
@@ -1907,7 +1835,6 @@ static int __devinit be_probe(struct pci_dev *pdev,
1907 int status = 0; 1835 int status = 0;
1908 struct be_adapter *adapter; 1836 struct be_adapter *adapter;
1909 struct net_device *netdev; 1837 struct net_device *netdev;
1910 struct be_ctrl_info *ctrl;
1911 u8 mac[ETH_ALEN]; 1838 u8 mac[ETH_ALEN];
1912 1839
1913 status = pci_enable_device(pdev); 1840 status = pci_enable_device(pdev);
@@ -1942,11 +1869,14 @@ static int __devinit be_probe(struct pci_dev *pdev,
1942 } 1869 }
1943 } 1870 }
1944 1871
1945 ctrl = &adapter->ctrl;
1946 status = be_ctrl_init(adapter); 1872 status = be_ctrl_init(adapter);
1947 if (status) 1873 if (status)
1948 goto free_netdev; 1874 goto free_netdev;
1949 1875
1876 status = be_cmd_reset_function(adapter);
1877 if (status)
1878 goto ctrl_clean;
1879
1950 status = be_stats_init(adapter); 1880 status = be_stats_init(adapter);
1951 if (status) 1881 if (status)
1952 goto ctrl_clean; 1882 goto ctrl_clean;
@@ -1955,7 +1885,7 @@ static int __devinit be_probe(struct pci_dev *pdev,
1955 if (status) 1885 if (status)
1956 goto stats_clean; 1886 goto stats_clean;
1957 1887
1958 status = be_cmd_mac_addr_query(ctrl, mac, MAC_ADDRESS_TYPE_NETWORK, 1888 status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK,
1959 true /* permanent */, 0); 1889 true /* permanent */, 0);
1960 if (status) 1890 if (status)
1961 goto stats_clean; 1891 goto stats_clean;
@@ -2054,12 +1984,6 @@ static int __init be_init_module(void)
2054 " Using 2048\n"); 1984 " Using 2048\n");
2055 rx_frag_size = 2048; 1985 rx_frag_size = 2048;
2056 } 1986 }
2057 /* Ensure rx_frag_size is aligned to chache line */
2058 if (SKB_DATA_ALIGN(rx_frag_size) != rx_frag_size) {
2059 printk(KERN_WARNING DRV_NAME
2060 " : Bad module param rx_frag_size. Using 2048\n");
2061 rx_frag_size = 2048;
2062 }
2063 1987
2064 return pci_register_driver(&be_driver); 1988 return pci_register_driver(&be_driver);
2065} 1989}