@@ -213,62 +213,49 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
213213 if (!(ntoh24 (fh -> fh_f_ctl ) & FC_FC_REL_OFF ))
214214 goto drop ;
215215
216+ f_ctl = ntoh24 (fh -> fh_f_ctl );
217+ ep = fc_seq_exch (seq );
218+ lport = ep -> lp ;
219+ if (cmd -> was_ddp_setup ) {
220+ BUG_ON (!ep );
221+ BUG_ON (!lport );
222+ }
223+
216224 /*
217- * Doesn't expect even single byte of payload . Payload
225+ * Doesn't expect payload if DDP is setup . Payload
218226 * is expected to be copied directly to user buffers
219- * due to DDP (Large Rx offload) feature, hence
220- * BUG_ON if BUF is non-NULL
227+ * due to DDP (Large Rx offload),
221228 */
222229 buf = fc_frame_payload_get (fp , 1 );
223- if (cmd -> was_ddp_setup && buf ) {
224- pr_debug ("%s: When DDP was setup, not expected to"
225- "receive frame with payload, Payload shall be"
226- "copied directly to buffer instead of coming "
227- "via. legacy receive queues\n" , __func__ );
228- BUG_ON (buf );
229- }
230+ if (buf )
231+ pr_err ("%s: xid 0x%x, f_ctl 0x%x, cmd->sg %p, "
232+ "cmd->sg_cnt 0x%x. DDP was setup"
233+ " hence not expected to receive frame with "
234+ "payload, Frame will be dropped if "
235+ "'Sequence Initiative' bit in f_ctl is "
236+ "not set\n" , __func__ , ep -> xid , f_ctl ,
237+ cmd -> sg , cmd -> sg_cnt );
238+ /*
239+ * Invalidate HW DDP context if it was setup for respective
240+ * command. Invalidation of HW DDP context is requited in both
241+ * situation (success and error).
242+ */
243+ ft_invl_hw_context (cmd );
230244
231245 /*
232- * If ft_cmd indicated 'ddp_setup', in that case only the last frame
233- * should come with 'TSI bit being set'. If 'TSI bit is not set and if
234- * data frame appears here, means error condition. In both the cases
235- * release the DDP context (ddp_put) and in error case, as well
236- * initiate error recovery mechanism.
246+ * If "Sequence Initiative (TSI)" bit set in f_ctl, means last
247+ * write data frame is received successfully where payload is
248+ * posted directly to user buffer and only the last frame's
249+ * header is posted in receive queue.
250+ *
251+ * If "Sequence Initiative (TSI)" bit is not set, means error
252+ * condition w.r.t. DDP, hence drop the packet and let explict
253+ * ABORTS from other end of exchange timer trigger the recovery.
237254 */
238- ep = fc_seq_exch (seq );
239- if (cmd -> was_ddp_setup ) {
240- BUG_ON (!ep );
241- lport = ep -> lp ;
242- BUG_ON (!lport );
243- }
244- if (cmd -> was_ddp_setup && ep -> xid != FC_XID_UNKNOWN ) {
245- f_ctl = ntoh24 (fh -> fh_f_ctl );
246- /*
247- * If TSI bit set in f_ctl, means last write data frame is
248- * received successfully where payload is posted directly
249- * to user buffer and only the last frame's header is posted
250- * in legacy receive queue
251- */
252- if (f_ctl & FC_FC_SEQ_INIT ) { /* TSI bit set in FC frame */
253- cmd -> write_data_len = lport -> tt .ddp_done (lport ,
254- ep -> xid );
255- goto last_frame ;
256- } else {
257- /*
258- * Updating the write_data_len may be meaningless at
259- * this point, but just in case if required in future
260- * for debugging or any other purpose
261- */
262- pr_err ("%s: Received frame with TSI bit not"
263- " being SET, dropping the frame, "
264- "cmd->sg <%p>, cmd->sg_cnt <0x%x>\n" ,
265- __func__ , cmd -> sg , cmd -> sg_cnt );
266- cmd -> write_data_len = lport -> tt .ddp_done (lport ,
267- ep -> xid );
268- lport -> tt .seq_exch_abort (cmd -> seq , 0 );
269- goto drop ;
270- }
271- }
255+ if (f_ctl & FC_FC_SEQ_INIT )
256+ goto last_frame ;
257+ else
258+ goto drop ;
272259
273260 rel_off = ntohl (fh -> fh_parm_offset );
274261 frame_len = fr_len (fp );
@@ -331,3 +318,39 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
331318drop :
332319 fc_frame_free (fp );
333320}
321+
322+ /*
323+ * Handle and cleanup any HW specific resources if
324+ * received ABORTS, errors, timeouts.
325+ */
326+ void ft_invl_hw_context (struct ft_cmd * cmd )
327+ {
328+ struct fc_seq * seq = cmd -> seq ;
329+ struct fc_exch * ep = NULL ;
330+ struct fc_lport * lport = NULL ;
331+
332+ BUG_ON (!cmd );
333+
334+ /* Cleanup the DDP context in HW if DDP was setup */
335+ if (cmd -> was_ddp_setup && seq ) {
336+ ep = fc_seq_exch (seq );
337+ if (ep ) {
338+ lport = ep -> lp ;
339+ if (lport && (ep -> xid <= lport -> lro_xid ))
340+ /*
341+ * "ddp_done" trigger invalidation of HW
342+ * specific DDP context
343+ */
344+ cmd -> write_data_len = lport -> tt .ddp_done (lport ,
345+ ep -> xid );
346+
347+ /*
348+ * Resetting same variable to indicate HW's
349+ * DDP context has been invalidated to avoid
350+ * re_invalidation of same context (context is
351+ * identified using ep->xid)
352+ */
353+ cmd -> was_ddp_setup = 0 ;
354+ }
355+ }
356+ }
0 commit comments