aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/nes/nes_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/nes/nes_hw.c')
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c99
1 files changed, 66 insertions, 33 deletions
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index be36cbeae630..7c0ff19ce382 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -110,6 +110,14 @@ static unsigned char *nes_tcp_state_str[] = {
110}; 110};
111#endif 111#endif
112 112
113static inline void print_ip(struct nes_cm_node *cm_node)
114{
115 unsigned char *rem_addr;
116 if (cm_node) {
117 rem_addr = (unsigned char *)&cm_node->rem_addr;
118 printk(KERN_ERR PFX "Remote IP addr: %pI4\n", rem_addr);
119 }
120}
113 121
114/** 122/**
115 * nes_nic_init_timer_defaults 123 * nes_nic_init_timer_defaults
@@ -1555,6 +1563,7 @@ static void nes_replenish_nic_rq(struct nes_vnic *nesvnic)
1555 struct nes_hw_nic_rq_wqe *nic_rqe; 1563 struct nes_hw_nic_rq_wqe *nic_rqe;
1556 struct nes_hw_nic *nesnic; 1564 struct nes_hw_nic *nesnic;
1557 struct nes_device *nesdev; 1565 struct nes_device *nesdev;
1566 struct nes_rskb_cb *cb;
1558 u32 rx_wqes_posted = 0; 1567 u32 rx_wqes_posted = 0;
1559 1568
1560 nesnic = &nesvnic->nic; 1569 nesnic = &nesvnic->nic;
@@ -1580,6 +1589,9 @@ static void nes_replenish_nic_rq(struct nes_vnic *nesvnic)
1580 1589
1581 bus_address = pci_map_single(nesdev->pcidev, 1590 bus_address = pci_map_single(nesdev->pcidev,
1582 skb->data, nesvnic->max_frame_size, PCI_DMA_FROMDEVICE); 1591 skb->data, nesvnic->max_frame_size, PCI_DMA_FROMDEVICE);
1592 cb = (struct nes_rskb_cb *)&skb->cb[0];
1593 cb->busaddr = bus_address;
1594 cb->maplen = nesvnic->max_frame_size;
1583 1595
1584 nic_rqe = &nesnic->rq_vbase[nesvnic->nic.rq_head]; 1596 nic_rqe = &nesnic->rq_vbase[nesvnic->nic.rq_head];
1585 nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_1_0_IDX] = 1597 nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_1_0_IDX] =
@@ -1669,6 +1681,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
1669 u32 cqp_head; 1681 u32 cqp_head;
1670 u32 counter; 1682 u32 counter;
1671 u32 wqe_count; 1683 u32 wqe_count;
1684 struct nes_rskb_cb *cb;
1672 u8 jumbomode=0; 1685 u8 jumbomode=0;
1673 1686
1674 /* Allocate fragment, SQ, RQ, and CQ; Reuse CEQ based on the PCI function */ 1687 /* Allocate fragment, SQ, RQ, and CQ; Reuse CEQ based on the PCI function */
@@ -1845,6 +1858,9 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
1845 1858
1846 pmem = pci_map_single(nesdev->pcidev, skb->data, 1859 pmem = pci_map_single(nesdev->pcidev, skb->data,
1847 nesvnic->max_frame_size, PCI_DMA_FROMDEVICE); 1860 nesvnic->max_frame_size, PCI_DMA_FROMDEVICE);
1861 cb = (struct nes_rskb_cb *)&skb->cb[0];
1862 cb->busaddr = pmem;
1863 cb->maplen = nesvnic->max_frame_size;
1848 1864
1849 nic_rqe = &nesvnic->nic.rq_vbase[counter]; 1865 nic_rqe = &nesvnic->nic.rq_vbase[counter];
1850 nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_1_0_IDX] = cpu_to_le32(nesvnic->max_frame_size); 1866 nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_1_0_IDX] = cpu_to_le32(nesvnic->max_frame_size);
@@ -1873,6 +1889,13 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
1873 jumbomode = 1; 1889 jumbomode = 1;
1874 nes_nic_init_timer_defaults(nesdev, jumbomode); 1890 nes_nic_init_timer_defaults(nesdev, jumbomode);
1875 } 1891 }
1892 if ((nesdev->nesadapter->allow_unaligned_fpdus) &&
1893 (nes_init_mgt_qp(nesdev, netdev, nesvnic))) {
1894 nes_debug(NES_DBG_INIT, "%s: Out of memory for pau nic\n", netdev->name);
1895 nes_destroy_nic_qp(nesvnic);
1896 return -ENOMEM;
1897 }
1898
1876 nesvnic->lro_mgr.max_aggr = nes_lro_max_aggr; 1899 nesvnic->lro_mgr.max_aggr = nes_lro_max_aggr;
1877 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS; 1900 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS;
1878 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc; 1901 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc;
@@ -1895,28 +1918,29 @@ void nes_destroy_nic_qp(struct nes_vnic *nesvnic)
1895 struct nes_device *nesdev = nesvnic->nesdev; 1918 struct nes_device *nesdev = nesvnic->nesdev;
1896 struct nes_hw_cqp_wqe *cqp_wqe; 1919 struct nes_hw_cqp_wqe *cqp_wqe;
1897 struct nes_hw_nic_sq_wqe *nic_sqe; 1920 struct nes_hw_nic_sq_wqe *nic_sqe;
1898 struct nes_hw_nic_rq_wqe *nic_rqe;
1899 __le16 *wqe_fragment_length; 1921 __le16 *wqe_fragment_length;
1900 u16 wqe_fragment_index; 1922 u16 wqe_fragment_index;
1901 u64 wqe_frag;
1902 u32 cqp_head; 1923 u32 cqp_head;
1903 u32 wqm_cfg0; 1924 u32 wqm_cfg0;
1904 unsigned long flags; 1925 unsigned long flags;
1926 struct sk_buff *rx_skb;
1927 struct nes_rskb_cb *cb;
1905 int ret; 1928 int ret;
1906 1929
1930 if (nesdev->nesadapter->allow_unaligned_fpdus)
1931 nes_destroy_mgt(nesvnic);
1932
1907 /* clear wqe stall before destroying NIC QP */ 1933 /* clear wqe stall before destroying NIC QP */
1908 wqm_cfg0 = nes_read_indexed(nesdev, NES_IDX_WQM_CONFIG0); 1934 wqm_cfg0 = nes_read_indexed(nesdev, NES_IDX_WQM_CONFIG0);
1909 nes_write_indexed(nesdev, NES_IDX_WQM_CONFIG0, wqm_cfg0 & 0xFFFF7FFF); 1935 nes_write_indexed(nesdev, NES_IDX_WQM_CONFIG0, wqm_cfg0 & 0xFFFF7FFF);
1910 1936
1911 /* Free remaining NIC receive buffers */ 1937 /* Free remaining NIC receive buffers */
1912 while (nesvnic->nic.rq_head != nesvnic->nic.rq_tail) { 1938 while (nesvnic->nic.rq_head != nesvnic->nic.rq_tail) {
1913 nic_rqe = &nesvnic->nic.rq_vbase[nesvnic->nic.rq_tail]; 1939 rx_skb = nesvnic->nic.rx_skb[nesvnic->nic.rq_tail];
1914 wqe_frag = (u64)le32_to_cpu( 1940 cb = (struct nes_rskb_cb *)&rx_skb->cb[0];
1915 nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_LOW_IDX]); 1941 pci_unmap_single(nesdev->pcidev, cb->busaddr, cb->maplen,
1916 wqe_frag |= ((u64)le32_to_cpu( 1942 PCI_DMA_FROMDEVICE);
1917 nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_HIGH_IDX]))<<32; 1943
1918 pci_unmap_single(nesdev->pcidev, (dma_addr_t)wqe_frag,
1919 nesvnic->max_frame_size, PCI_DMA_FROMDEVICE);
1920 dev_kfree_skb(nesvnic->nic.rx_skb[nesvnic->nic.rq_tail++]); 1944 dev_kfree_skb(nesvnic->nic.rx_skb[nesvnic->nic.rq_tail++]);
1921 nesvnic->nic.rq_tail &= (nesvnic->nic.rq_size - 1); 1945 nesvnic->nic.rq_tail &= (nesvnic->nic.rq_size - 1);
1922 } 1946 }
@@ -2775,6 +2799,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
2775 struct nes_hw_nic_sq_wqe *nic_sqe; 2799 struct nes_hw_nic_sq_wqe *nic_sqe;
2776 struct sk_buff *skb; 2800 struct sk_buff *skb;
2777 struct sk_buff *rx_skb; 2801 struct sk_buff *rx_skb;
2802 struct nes_rskb_cb *cb;
2778 __le16 *wqe_fragment_length; 2803 __le16 *wqe_fragment_length;
2779 u32 head; 2804 u32 head;
2780 u32 cq_size; 2805 u32 cq_size;
@@ -2859,6 +2884,8 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
2859 bus_address += ((u64)le32_to_cpu(nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_HIGH_IDX])) << 32; 2884 bus_address += ((u64)le32_to_cpu(nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_HIGH_IDX])) << 32;
2860 pci_unmap_single(nesdev->pcidev, bus_address, 2885 pci_unmap_single(nesdev->pcidev, bus_address,
2861 nesvnic->max_frame_size, PCI_DMA_FROMDEVICE); 2886 nesvnic->max_frame_size, PCI_DMA_FROMDEVICE);
2887 cb = (struct nes_rskb_cb *)&rx_skb->cb[0];
2888 cb->busaddr = 0;
2862 /* rx_skb->tail = rx_skb->data + rx_pkt_size; */ 2889 /* rx_skb->tail = rx_skb->data + rx_pkt_size; */
2863 /* rx_skb->len = rx_pkt_size; */ 2890 /* rx_skb->len = rx_pkt_size; */
2864 rx_skb->len = 0; /* TODO: see if this is necessary */ 2891 rx_skb->len = 0; /* TODO: see if this is necessary */
@@ -2983,6 +3010,7 @@ skip_rx_indicate0:
2983} 3010}
2984 3011
2985 3012
3013
2986/** 3014/**
2987 * nes_cqp_ce_handler 3015 * nes_cqp_ce_handler
2988 */ 3016 */
@@ -2997,6 +3025,8 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
2997 u32 cq_size; 3025 u32 cq_size;
2998 u32 cqe_count=0; 3026 u32 cqe_count=0;
2999 u32 error_code; 3027 u32 error_code;
3028 u32 opcode;
3029 u32 ctx_index;
3000 /* u32 counter; */ 3030 /* u32 counter; */
3001 3031
3002 head = cq->cq_head; 3032 head = cq->cq_head;
@@ -3007,12 +3037,9 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
3007 /* nes_debug(NES_DBG_CQP, "head=%u cqe_words=%08X\n", head, 3037 /* nes_debug(NES_DBG_CQP, "head=%u cqe_words=%08X\n", head,
3008 le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX])); */ 3038 le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX])); */
3009 3039
3010 if (le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_VALID) { 3040 opcode = le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX]);
3011 u64temp = (((u64)(le32_to_cpu(cq->cq_vbase[head]. 3041 if (opcode & NES_CQE_VALID) {
3012 cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX]))) << 32) | 3042 cqp = &nesdev->cqp;
3013 ((u64)(le32_to_cpu(cq->cq_vbase[head].
3014 cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX])));
3015 cqp = *((struct nes_hw_cqp **)&u64temp);
3016 3043
3017 error_code = le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_ERROR_CODE_IDX]); 3044 error_code = le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_ERROR_CODE_IDX]);
3018 if (error_code) { 3045 if (error_code) {
@@ -3021,15 +3048,14 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
3021 le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX])&0x3f, 3048 le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX])&0x3f,
3022 (u16)(error_code >> 16), 3049 (u16)(error_code >> 16),
3023 (u16)error_code); 3050 (u16)error_code);
3024 nes_debug(NES_DBG_CQP, "cqp: qp_id=%u, sq_head=%u, sq_tail=%u\n",
3025 cqp->qp_id, cqp->sq_head, cqp->sq_tail);
3026 } 3051 }
3027 3052
3028 u64temp = (((u64)(le32_to_cpu(nesdev->cqp.sq_vbase[cqp->sq_tail]. 3053 u64temp = (((u64)(le32_to_cpu(cq->cq_vbase[head].
3029 wqe_words[NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX]))) << 32) | 3054 cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX]))) << 32) |
3030 ((u64)(le32_to_cpu(nesdev->cqp.sq_vbase[cqp->sq_tail]. 3055 ((u64)(le32_to_cpu(cq->cq_vbase[head].
3031 wqe_words[NES_CQP_WQE_COMP_SCRATCH_LOW_IDX]))); 3056 cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX])));
3032 cqp_request = *((struct nes_cqp_request **)&u64temp); 3057
3058 cqp_request = (struct nes_cqp_request *)(unsigned long)u64temp;
3033 if (cqp_request) { 3059 if (cqp_request) {
3034 if (cqp_request->waiting) { 3060 if (cqp_request->waiting) {
3035 /* nes_debug(NES_DBG_CQP, "%s: Waking up requestor\n"); */ 3061 /* nes_debug(NES_DBG_CQP, "%s: Waking up requestor\n"); */
@@ -3075,9 +3101,15 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
3075 cqp_wqe = &nesdev->cqp.sq_vbase[head]; 3101 cqp_wqe = &nesdev->cqp.sq_vbase[head];
3076 memcpy(cqp_wqe, &cqp_request->cqp_wqe, sizeof(*cqp_wqe)); 3102 memcpy(cqp_wqe, &cqp_request->cqp_wqe, sizeof(*cqp_wqe));
3077 barrier(); 3103 barrier();
3078 cqp_wqe->wqe_words[NES_CQP_WQE_COMP_SCRATCH_LOW_IDX] = 3104
3105 opcode = cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX];
3106 if ((opcode & NES_CQP_OPCODE_MASK) == NES_CQP_DOWNLOAD_SEGMENT)
3107 ctx_index = NES_CQP_WQE_DL_COMP_CTX_LOW_IDX;
3108 else
3109 ctx_index = NES_CQP_WQE_COMP_CTX_LOW_IDX;
3110 cqp_wqe->wqe_words[ctx_index] =
3079 cpu_to_le32((u32)((unsigned long)cqp_request)); 3111 cpu_to_le32((u32)((unsigned long)cqp_request));
3080 cqp_wqe->wqe_words[NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX] = 3112 cqp_wqe->wqe_words[ctx_index + 1] =
3081 cpu_to_le32((u32)(upper_32_bits((unsigned long)cqp_request))); 3113 cpu_to_le32((u32)(upper_32_bits((unsigned long)cqp_request)));
3082 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) put on CQPs SQ wqe%u.\n", 3114 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) put on CQPs SQ wqe%u.\n",
3083 cqp_request, le32_to_cpu(cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f, head); 3115 cqp_request, le32_to_cpu(cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f, head);
@@ -3093,7 +3125,6 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
3093 nes_read32(nesdev->regs+NES_CQE_ALLOC); 3125 nes_read32(nesdev->regs+NES_CQE_ALLOC);
3094} 3126}
3095 3127
3096
3097static u8 *locate_mpa(u8 *pkt, u32 aeq_info) 3128static u8 *locate_mpa(u8 *pkt, u32 aeq_info)
3098{ 3129{
3099 if (aeq_info & NES_AEQE_Q2_DATA_ETHERNET) { 3130 if (aeq_info & NES_AEQE_Q2_DATA_ETHERNET) {
@@ -3553,9 +3584,9 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3553 3584
3554 aeqe_cq_id = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]); 3585 aeqe_cq_id = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]);
3555 if (aeq_info & NES_AEQE_QP) { 3586 if (aeq_info & NES_AEQE_QP) {
3556 if ((!nes_is_resource_allocated(nesadapter, nesadapter->allocated_qps, 3587 if (!nes_is_resource_allocated(nesadapter,
3557 aeqe_cq_id)) || 3588 nesadapter->allocated_qps,
3558 (atomic_read(&nesqp->close_timer_started))) 3589 aeqe_cq_id))
3559 return; 3590 return;
3560 } 3591 }
3561 3592
@@ -3566,8 +3597,7 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3566 3597
3567 if (atomic_inc_return(&nesqp->close_timer_started) == 1) { 3598 if (atomic_inc_return(&nesqp->close_timer_started) == 1) {
3568 if ((tcp_state == NES_AEQE_TCP_STATE_CLOSE_WAIT) && 3599 if ((tcp_state == NES_AEQE_TCP_STATE_CLOSE_WAIT) &&
3569 (nesqp->ibqp_state == IB_QPS_RTS) && 3600 (nesqp->ibqp_state == IB_QPS_RTS)) {
3570 ((nesadapter->eeprom_version >> 16) != NES_A0)) {
3571 spin_lock_irqsave(&nesqp->lock, flags); 3601 spin_lock_irqsave(&nesqp->lock, flags);
3572 nesqp->hw_iwarp_state = iwarp_state; 3602 nesqp->hw_iwarp_state = iwarp_state;
3573 nesqp->hw_tcp_state = tcp_state; 3603 nesqp->hw_tcp_state = tcp_state;
@@ -3594,9 +3624,10 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3594 return; 3624 return;
3595 } 3625 }
3596 spin_lock_irqsave(&nesqp->lock, flags); 3626 spin_lock_irqsave(&nesqp->lock, flags);
3597 nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_CLOSING; 3627 nesqp->hw_iwarp_state = iwarp_state;
3628 nesqp->hw_tcp_state = tcp_state;
3629 nesqp->last_aeq = async_event_id;
3598 spin_unlock_irqrestore(&nesqp->lock, flags); 3630 spin_unlock_irqrestore(&nesqp->lock, flags);
3599 nes_hw_modify_qp(nesdev, nesqp, NES_CQP_QP_IWARP_STATE_CLOSING, 0, 0);
3600 nes_cm_disconn(nesqp); 3631 nes_cm_disconn(nesqp);
3601 break; 3632 break;
3602 3633
@@ -3694,7 +3725,9 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3694 case NES_AEQE_AEID_ROE_INVALID_RDMA_WRITE_OR_READ_RESP: 3725 case NES_AEQE_AEID_ROE_INVALID_RDMA_WRITE_OR_READ_RESP:
3695 printk(KERN_ERR PFX "QP[%u] async_event_id=0x%04X IB_EVENT_QP_FATAL\n", 3726 printk(KERN_ERR PFX "QP[%u] async_event_id=0x%04X IB_EVENT_QP_FATAL\n",
3696 nesqp->hwqp.qp_id, async_event_id); 3727 nesqp->hwqp.qp_id, async_event_id);
3697 nes_terminate_connection(nesdev, nesqp, aeqe, IB_EVENT_QP_FATAL); 3728 print_ip(nesqp->cm_node);
3729 if (!atomic_read(&nesqp->close_timer_started))
3730 nes_terminate_connection(nesdev, nesqp, aeqe, IB_EVENT_QP_FATAL);
3698 break; 3731 break;
3699 3732
3700 case NES_AEQE_AEID_CQ_OPERATION_ERROR: 3733 case NES_AEQE_AEID_CQ_OPERATION_ERROR: