@@ -21,24 +21,76 @@ static void enic_intr_update_pkt_size(struct vnic_rx_bytes_counter *pkt_size,
2121 pkt_size -> small_pkt_bytes_cnt += pkt_len ;
2222}
2323
24- static void enic_rq_cq_desc_dec (struct cq_enet_rq_desc * desc , u8 * type ,
24+ static void enic_rq_cq_desc_dec (void * cq_desc , u8 cq_desc_size , u8 * type ,
2525 u8 * color , u16 * q_number , u16 * completed_index )
2626{
2727 /* type_color is the last field for all cq structs */
28- u8 type_color = desc -> type_color ;
28+ u8 type_color ;
29+
30+ switch (cq_desc_size ) {
31+ case VNIC_RQ_CQ_ENTRY_SIZE_16 : {
32+ struct cq_enet_rq_desc * desc =
33+ (struct cq_enet_rq_desc * )cq_desc ;
34+ type_color = desc -> type_color ;
35+
36+ /* Make sure color bit is read from desc *before* other fields
37+ * are read from desc. Hardware guarantees color bit is last
38+ * bit (byte) written. Adding the rmb() prevents the compiler
39+ * and/or CPU from reordering the reads which would potentially
40+ * result in reading stale values.
41+ */
42+ rmb ();
2943
30- /* Make sure color bit is read from desc *before* other fields
31- * are read from desc. Hardware guarantees color bit is last
32- * bit (byte) written. Adding the rmb() prevents the compiler
33- * and/or CPU from reordering the reads which would potentially
34- * result in reading stale values.
35- */
36- rmb ();
44+ * q_number = le16_to_cpu (desc -> q_number_rss_type_flags ) &
45+ CQ_DESC_Q_NUM_MASK ;
46+ * completed_index = le16_to_cpu (desc -> completed_index_flags ) &
47+ CQ_DESC_COMP_NDX_MASK ;
48+ break ;
49+ }
50+ case VNIC_RQ_CQ_ENTRY_SIZE_32 : {
51+ struct cq_enet_rq_desc_32 * desc =
52+ (struct cq_enet_rq_desc_32 * )cq_desc ;
53+ type_color = desc -> type_color ;
54+
55+ /* Make sure color bit is read from desc *before* other fields
56+ * are read from desc. Hardware guarantees color bit is last
57+ * bit (byte) written. Adding the rmb() prevents the compiler
58+ * and/or CPU from reordering the reads which would potentially
59+ * result in reading stale values.
60+ */
61+ rmb ();
62+
63+ * q_number = le16_to_cpu (desc -> q_number_rss_type_flags ) &
64+ CQ_DESC_Q_NUM_MASK ;
65+ * completed_index = le16_to_cpu (desc -> completed_index_flags ) &
66+ CQ_DESC_COMP_NDX_MASK ;
67+ * completed_index |= (desc -> fetch_index_flags & CQ_DESC_32_FI_MASK ) <<
68+ CQ_DESC_COMP_NDX_BITS ;
69+ break ;
70+ }
71+ case VNIC_RQ_CQ_ENTRY_SIZE_64 : {
72+ struct cq_enet_rq_desc_64 * desc =
73+ (struct cq_enet_rq_desc_64 * )cq_desc ;
74+ type_color = desc -> type_color ;
75+
76+ /* Make sure color bit is read from desc *before* other fields
77+ * are read from desc. Hardware guarantees color bit is last
78+ * bit (byte) written. Adding the rmb() prevents the compiler
79+ * and/or CPU from reordering the reads which would potentially
80+ * result in reading stale values.
81+ */
82+ rmb ();
83+
84+ * q_number = le16_to_cpu (desc -> q_number_rss_type_flags ) &
85+ CQ_DESC_Q_NUM_MASK ;
86+ * completed_index = le16_to_cpu (desc -> completed_index_flags ) &
87+ CQ_DESC_COMP_NDX_MASK ;
88+ * completed_index |= (desc -> fetch_index_flags & CQ_DESC_64_FI_MASK ) <<
89+ CQ_DESC_COMP_NDX_BITS ;
90+ break ;
91+ }
92+ }
3793
38- * q_number = le16_to_cpu (desc -> q_number_rss_type_flags ) &
39- CQ_DESC_Q_NUM_MASK ;
40- * completed_index = le16_to_cpu (desc -> completed_index_flags ) &
41- CQ_DESC_COMP_NDX_MASK ;
4294 * color = (type_color >> CQ_DESC_COLOR_SHIFT ) & CQ_DESC_COLOR_MASK ;
4395 * type = type_color & CQ_DESC_TYPE_MASK ;
4496}
@@ -113,6 +165,10 @@ static void enic_rq_set_skb_flags(struct vnic_rq *vrq, u8 type, u32 rss_hash,
113165 }
114166}
115167
168+ /*
169+ * cq_enet_rq_desc accesses section uses only the 1st 15 bytes of the cq which
170+ * is identical for all type (16,32 and 64 byte) of cqs.
171+ */
116172static void cq_enet_rq_desc_dec (struct cq_enet_rq_desc * desc , u8 * ingress_port ,
117173 u8 * fcoe , u8 * eop , u8 * sop , u8 * rss_type ,
118174 u8 * csum_not_calc , u32 * rss_hash ,
@@ -258,9 +314,8 @@ void enic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
258314}
259315
260316static void enic_rq_indicate_buf (struct enic * enic , struct vnic_rq * rq ,
261- struct vnic_rq_buf * buf ,
262- struct cq_enet_rq_desc * cq_desc , u8 type ,
263- u16 q_number , u16 completed_index )
317+ struct vnic_rq_buf * buf , void * cq_desc ,
318+ u8 type , u16 q_number , u16 completed_index )
264319{
265320 struct sk_buff * skb ;
266321 struct vnic_cq * cq = & enic -> cq [enic_cq_rq (enic , rq -> index )];
@@ -277,7 +332,7 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,
277332
278333 rqstats -> packets ++ ;
279334
280- cq_enet_rq_desc_dec (cq_desc , & ingress_port ,
335+ cq_enet_rq_desc_dec (( struct cq_enet_rq_desc * ) cq_desc , & ingress_port ,
281336 & fcoe , & eop , & sop , & rss_type , & csum_not_calc ,
282337 & rss_hash , & bytes_written , & packet_error ,
283338 & vlan_stripped , & vlan_tci , & checksum , & fcoe_sof ,
@@ -329,8 +384,8 @@ static void enic_rq_indicate_buf(struct enic *enic, struct vnic_rq *rq,
329384 }
330385}
331386
332- static void enic_rq_service (struct enic * enic , struct cq_enet_rq_desc * cq_desc ,
333- u8 type , u16 q_number , u16 completed_index )
387+ static void enic_rq_service (struct enic * enic , void * cq_desc , u8 type ,
388+ u16 q_number , u16 completed_index )
334389{
335390 struct enic_rq_stats * rqstats = & enic -> rq [q_number ].stats ;
336391 struct vnic_rq * vrq = & enic -> rq [q_number ].vrq ;
@@ -357,14 +412,12 @@ unsigned int enic_rq_cq_service(struct enic *enic, unsigned int cq_index,
357412 unsigned int work_to_do )
358413{
359414 struct vnic_cq * cq = & enic -> cq [cq_index ];
360- struct cq_enet_rq_desc * cq_desc ;
415+ void * cq_desc = vnic_cq_to_clean ( cq ) ;
361416 u16 q_number , completed_index ;
362417 unsigned int work_done = 0 ;
363418 u8 type , color ;
364419
365- cq_desc = (struct cq_enet_rq_desc * )vnic_cq_to_clean (cq );
366-
367- enic_rq_cq_desc_dec (cq_desc , & type , & color , & q_number ,
420+ enic_rq_cq_desc_dec (cq_desc , enic -> ext_cq , & type , & color , & q_number ,
368421 & completed_index );
369422
370423 while (color != cq -> last_color ) {
@@ -374,9 +427,9 @@ unsigned int enic_rq_cq_service(struct enic *enic, unsigned int cq_index,
374427 if (++ work_done >= work_to_do )
375428 break ;
376429
377- cq_desc = ( struct cq_enet_rq_desc * ) vnic_cq_to_clean (cq );
378- enic_rq_cq_desc_dec (cq_desc , & type , & color , & q_number ,
379- & completed_index );
430+ cq_desc = vnic_cq_to_clean (cq );
431+ enic_rq_cq_desc_dec (cq_desc , enic -> ext_cq , & type , & color ,
432+ & q_number , & completed_index );
380433 }
381434
382435 return work_done ;
0 commit comments