@@ -1563,6 +1563,7 @@ static void nes_replenish_nic_rq(struct nes_vnic *nesvnic)
15631563 struct nes_hw_nic_rq_wqe * nic_rqe ;
15641564 struct nes_hw_nic * nesnic ;
15651565 struct nes_device * nesdev ;
1566+ struct nes_rskb_cb * cb ;
15661567 u32 rx_wqes_posted = 0 ;
15671568
15681569 nesnic = & nesvnic -> nic ;
@@ -1588,6 +1589,9 @@ static void nes_replenish_nic_rq(struct nes_vnic *nesvnic)
15881589
15891590 bus_address = pci_map_single (nesdev -> pcidev ,
15901591 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 ;
15911595
15921596 nic_rqe = & nesnic -> rq_vbase [nesvnic -> nic .rq_head ];
15931597 nic_rqe -> wqe_words [NES_NIC_RQ_WQE_LENGTH_1_0_IDX ] =
@@ -1677,6 +1681,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
16771681 u32 cqp_head ;
16781682 u32 counter ;
16791683 u32 wqe_count ;
1684+ struct nes_rskb_cb * cb ;
16801685 u8 jumbomode = 0 ;
16811686
16821687 /* Allocate fragment, SQ, RQ, and CQ; Reuse CEQ based on the PCI function */
@@ -1853,6 +1858,9 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
18531858
18541859 pmem = pci_map_single (nesdev -> pcidev , skb -> data ,
18551860 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 ;
18561864
18571865 nic_rqe = & nesvnic -> nic .rq_vbase [counter ];
18581866 nic_rqe -> wqe_words [NES_NIC_RQ_WQE_LENGTH_1_0_IDX ] = cpu_to_le32 (nesvnic -> max_frame_size );
@@ -1881,6 +1889,13 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
18811889 jumbomode = 1 ;
18821890 nes_nic_init_timer_defaults (nesdev , jumbomode );
18831891 }
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+
18841899 nesvnic -> lro_mgr .max_aggr = nes_lro_max_aggr ;
18851900 nesvnic -> lro_mgr .max_desc = NES_MAX_LRO_DESCRIPTORS ;
18861901 nesvnic -> lro_mgr .lro_arr = nesvnic -> lro_desc ;
@@ -1903,28 +1918,29 @@ void nes_destroy_nic_qp(struct nes_vnic *nesvnic)
19031918 struct nes_device * nesdev = nesvnic -> nesdev ;
19041919 struct nes_hw_cqp_wqe * cqp_wqe ;
19051920 struct nes_hw_nic_sq_wqe * nic_sqe ;
1906- struct nes_hw_nic_rq_wqe * nic_rqe ;
19071921 __le16 * wqe_fragment_length ;
19081922 u16 wqe_fragment_index ;
1909- u64 wqe_frag ;
19101923 u32 cqp_head ;
19111924 u32 wqm_cfg0 ;
19121925 unsigned long flags ;
1926+ struct sk_buff * rx_skb ;
1927+ struct nes_rskb_cb * cb ;
19131928 int ret ;
19141929
1930+ if (nesdev -> nesadapter -> allow_unaligned_fpdus )
1931+ nes_destroy_mgt (nesvnic );
1932+
19151933 /* clear wqe stall before destroying NIC QP */
19161934 wqm_cfg0 = nes_read_indexed (nesdev , NES_IDX_WQM_CONFIG0 );
19171935 nes_write_indexed (nesdev , NES_IDX_WQM_CONFIG0 , wqm_cfg0 & 0xFFFF7FFF );
19181936
19191937 /* Free remaining NIC receive buffers */
19201938 while (nesvnic -> nic .rq_head != nesvnic -> nic .rq_tail ) {
1921- nic_rqe = & nesvnic -> nic .rq_vbase [nesvnic -> nic .rq_tail ];
1922- wqe_frag = (u64 )le32_to_cpu (
1923- nic_rqe -> wqe_words [NES_NIC_RQ_WQE_FRAG0_LOW_IDX ]);
1924- wqe_frag |= ((u64 )le32_to_cpu (
1925- nic_rqe -> wqe_words [NES_NIC_RQ_WQE_FRAG0_HIGH_IDX ]))<<32 ;
1926- pci_unmap_single (nesdev -> pcidev , (dma_addr_t )wqe_frag ,
1927- nesvnic -> max_frame_size , PCI_DMA_FROMDEVICE );
1939+ rx_skb = nesvnic -> nic .rx_skb [nesvnic -> nic .rq_tail ];
1940+ cb = (struct nes_rskb_cb * )& rx_skb -> cb [0 ];
1941+ pci_unmap_single (nesdev -> pcidev , cb -> busaddr , cb -> maplen ,
1942+ PCI_DMA_FROMDEVICE );
1943+
19281944 dev_kfree_skb (nesvnic -> nic .rx_skb [nesvnic -> nic .rq_tail ++ ]);
19291945 nesvnic -> nic .rq_tail &= (nesvnic -> nic .rq_size - 1 );
19301946 }
@@ -2783,6 +2799,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
27832799 struct nes_hw_nic_sq_wqe * nic_sqe ;
27842800 struct sk_buff * skb ;
27852801 struct sk_buff * rx_skb ;
2802+ struct nes_rskb_cb * cb ;
27862803 __le16 * wqe_fragment_length ;
27872804 u32 head ;
27882805 u32 cq_size ;
@@ -2867,6 +2884,8 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
28672884 bus_address += ((u64 )le32_to_cpu (nic_rqe -> wqe_words [NES_NIC_RQ_WQE_FRAG0_HIGH_IDX ])) << 32 ;
28682885 pci_unmap_single (nesdev -> pcidev , bus_address ,
28692886 nesvnic -> max_frame_size , PCI_DMA_FROMDEVICE );
2887+ cb = (struct nes_rskb_cb * )& rx_skb -> cb [0 ];
2888+ cb -> busaddr = 0 ;
28702889 /* rx_skb->tail = rx_skb->data + rx_pkt_size; */
28712890 /* rx_skb->len = rx_pkt_size; */
28722891 rx_skb -> len = 0 ; /* TODO: see if this is necessary */
@@ -2991,6 +3010,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
29913010}
29923011
29933012
3013+
29943014/**
29953015 * nes_cqp_ce_handler
29963016 */
@@ -3005,6 +3025,8 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
30053025 u32 cq_size ;
30063026 u32 cqe_count = 0 ;
30073027 u32 error_code ;
3028+ u32 opcode ;
3029+ u32 ctx_index ;
30083030 /* u32 counter; */
30093031
30103032 head = cq -> cq_head ;
@@ -3015,12 +3037,9 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
30153037 /* nes_debug(NES_DBG_CQP, "head=%u cqe_words=%08X\n", head,
30163038 le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX])); */
30173039
3018- if (le32_to_cpu (cq -> cq_vbase [head ].cqe_words [NES_CQE_OPCODE_IDX ]) & NES_CQE_VALID ) {
3019- u64temp = (((u64 )(le32_to_cpu (cq -> cq_vbase [head ].
3020- cqe_words [NES_CQE_COMP_COMP_CTX_HIGH_IDX ]))) << 32 ) |
3021- ((u64 )(le32_to_cpu (cq -> cq_vbase [head ].
3022- cqe_words [NES_CQE_COMP_COMP_CTX_LOW_IDX ])));
3023- cqp = * ((struct nes_hw_cqp * * )& u64temp );
3040+ opcode = le32_to_cpu (cq -> cq_vbase [head ].cqe_words [NES_CQE_OPCODE_IDX ]);
3041+ if (opcode & NES_CQE_VALID ) {
3042+ cqp = & nesdev -> cqp ;
30243043
30253044 error_code = le32_to_cpu (cq -> cq_vbase [head ].cqe_words [NES_CQE_ERROR_CODE_IDX ]);
30263045 if (error_code ) {
@@ -3029,15 +3048,14 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
30293048 le32_to_cpu (cq -> cq_vbase [head ].cqe_words [NES_CQE_OPCODE_IDX ])& 0x3f ,
30303049 (u16 )(error_code >> 16 ),
30313050 (u16 )error_code );
3032- nes_debug (NES_DBG_CQP , "cqp: qp_id=%u, sq_head=%u, sq_tail=%u\n" ,
3033- cqp -> qp_id , cqp -> sq_head , cqp -> sq_tail );
30343051 }
30353052
3036- u64temp = (((u64 )(le32_to_cpu (nesdev -> cqp .sq_vbase [cqp -> sq_tail ].
3037- wqe_words [NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX ]))) << 32 ) |
3038- ((u64 )(le32_to_cpu (nesdev -> cqp .sq_vbase [cqp -> sq_tail ].
3039- wqe_words [NES_CQP_WQE_COMP_SCRATCH_LOW_IDX ])));
3040- cqp_request = * ((struct nes_cqp_request * * )& u64temp );
3053+ u64temp = (((u64 )(le32_to_cpu (cq -> cq_vbase [head ].
3054+ cqe_words [NES_CQE_COMP_COMP_CTX_HIGH_IDX ]))) << 32 ) |
3055+ ((u64 )(le32_to_cpu (cq -> cq_vbase [head ].
3056+ cqe_words [NES_CQE_COMP_COMP_CTX_LOW_IDX ])));
3057+
3058+ cqp_request = (struct nes_cqp_request * )(unsigned long )u64temp ;
30413059 if (cqp_request ) {
30423060 if (cqp_request -> waiting ) {
30433061 /* nes_debug(NES_DBG_CQP, "%s: Waking up requestor\n"); */
@@ -3083,9 +3101,15 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
30833101 cqp_wqe = & nesdev -> cqp .sq_vbase [head ];
30843102 memcpy (cqp_wqe , & cqp_request -> cqp_wqe , sizeof (* cqp_wqe ));
30853103 barrier ();
3086- 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 ] =
30873111 cpu_to_le32 ((u32 )((unsigned long )cqp_request ));
3088- cqp_wqe -> wqe_words [NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX ] =
3112+ cqp_wqe -> wqe_words [ctx_index + 1 ] =
30893113 cpu_to_le32 ((u32 )(upper_32_bits ((unsigned long )cqp_request )));
30903114 nes_debug (NES_DBG_CQP , "CQP request %p (opcode 0x%02X) put on CQPs SQ wqe%u.\n" ,
30913115 cqp_request , le32_to_cpu (cqp_wqe -> wqe_words [NES_CQP_WQE_OPCODE_IDX ])& 0x3f , head );
@@ -3101,7 +3125,6 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
31013125 nes_read32 (nesdev -> regs + NES_CQE_ALLOC );
31023126}
31033127
3104-
31053128static u8 * locate_mpa (u8 * pkt , u32 aeq_info )
31063129{
31073130 if (aeq_info & NES_AEQE_Q2_DATA_ETHERNET ) {
0 commit comments