aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/tcm_fc
diff options
context:
space:
mode:
authorKiran Patil <kiran.patil@intel.com>2011-08-26 12:25:25 -0400
committerNicholas A. Bellinger <nab@linux-iscsi.org>2011-09-16 05:29:27 -0400
commit079587b4eb4d3b78a4d65d142f662aa9d7eedab4 (patch)
tree1316ea524dac4cfd2979f040b3908699c02df840 /drivers/target/tcm_fc
parentbcac364a24c894c4cf8cf219b7863c192cd34079 (diff)
tcm_fc: Invalidation of DDP context for FCoE target in error conditions
Problem: HW DDP context wasn;t invalidated in case of ABORTS, etc... This leads to the problem where memory pages which are used for DDP as user descriptor could get reused for some other purpose (such as to satisfy new memory allocation request either by kernel or user mode threads) and since HW DDP context was not invalidated, HW continue to write to those pages, hence causing memory corruption. Fix: Either on incoming ABORTS or due to exchange time out, allowed the target to cleanup HW DDP context if it was setup for respective ft_cmd. Added new function to perform this cleanup, furthur it can be enhanced for other cleanup activity. Additinal Notes: To avoid calling ddp_done from multiple places, composed the functionality in helper function "ft_invl_hw_context" and it is being called from multiple places. Cleaned up code in function "ft_recv_write_data" w.r.t DDP. Signed-off-by: Kiran Patil <kiran.patil@intel.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/tcm_fc')
-rw-r--r--drivers/target/tcm_fc/tfc_io.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index c37f4cd96452..d35ea5a3d56c 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -219,43 +219,41 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
219 if (cmd->was_ddp_setup) { 219 if (cmd->was_ddp_setup) {
220 BUG_ON(!ep); 220 BUG_ON(!ep);
221 BUG_ON(!lport); 221 BUG_ON(!lport);
222 } 222 /*
223 223 * Since DDP (Large Rx offload) was setup for this request,
224 /* 224 * payload is expected to be copied directly to user buffers.
225 * Doesn't expect payload if DDP is setup. Payload 225 */
226 * is expected to be copied directly to user buffers 226 buf = fc_frame_payload_get(fp, 1);
227 * due to DDP (Large Rx offload), 227 if (buf)
228 */ 228 pr_err("%s: xid 0x%x, f_ctl 0x%x, cmd->sg %p, "
229 buf = fc_frame_payload_get(fp, 1);
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" 229 "cmd->sg_cnt 0x%x. DDP was setup"
233 " hence not expected to receive frame with " 230 " hence not expected to receive frame with "
234 "payload, Frame will be dropped if " 231 "payload, Frame will be dropped if"
235 "'Sequence Initiative' bit in f_ctl is " 232 "'Sequence Initiative' bit in f_ctl is"
236 "not set\n", __func__, ep->xid, f_ctl, 233 "not set\n", __func__, ep->xid, f_ctl,
237 cmd->sg, cmd->sg_cnt); 234 cmd->sg, cmd->sg_cnt);
238 /* 235 /*
239 * Invalidate HW DDP context if it was setup for respective 236 * Invalidate HW DDP context if it was setup for respective
240 * command. Invalidation of HW DDP context is requited in both 237 * command. Invalidation of HW DDP context is requited in both
241 * situation (success and error). 238 * situation (success and error).
242 */ 239 */
243 ft_invl_hw_context(cmd); 240 ft_invl_hw_context(cmd);
244 241
245 /* 242 /*
246 * If "Sequence Initiative (TSI)" bit set in f_ctl, means last 243 * If "Sequence Initiative (TSI)" bit set in f_ctl, means last
247 * write data frame is received successfully where payload is 244 * write data frame is received successfully where payload is
248 * posted directly to user buffer and only the last frame's 245 * posted directly to user buffer and only the last frame's
249 * header is posted in receive queue. 246 * header is posted in receive queue.
250 * 247 *
251 * If "Sequence Initiative (TSI)" bit is not set, means error 248 * If "Sequence Initiative (TSI)" bit is not set, means error
252 * condition w.r.t. DDP, hence drop the packet and let explict 249 * condition w.r.t. DDP, hence drop the packet and let explict
253 * ABORTS from other end of exchange timer trigger the recovery. 250 * ABORTS from other end of exchange timer trigger the recovery.
254 */ 251 */
255 if (f_ctl & FC_FC_SEQ_INIT) 252 if (f_ctl & FC_FC_SEQ_INIT)
256 goto last_frame; 253 goto last_frame;
257 else 254 else
258 goto drop; 255 goto drop;
256 }
259 257
260 rel_off = ntohl(fh->fh_parm_offset); 258 rel_off = ntohl(fh->fh_parm_offset);
261 frame_len = fr_len(fp); 259 frame_len = fr_len(fp);