iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)&ctask->hdr, (u8 *)ctask->hdrext); 
iscsi_buf_init_virt(&ctask->headbuf, (char*)&ctask->hdr, sizeof(struct iscsi_hdr)); 
iscsi_cmd_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,		struct scsi_cmnd *sc){	struct iscsi_session *session = conn->session;	BUG_ON(__kfifo_len(ctask->r2tqueue));	ctask->sc = sc;	ctask->conn = conn;	ctask->hdr.opcode = ISCSI_OP_SCSI_CMD;	ctask->hdr.flags = ISCSI_ATTR_SIMPLE;	int_to_scsilun(sc->device->lun, (struct scsi_lun *)ctask->hdr.lun);	ctask->hdr.itt = ctask->itt | (conn->id << CID_SHIFT) |			 (session->age << AGE_SHIFT);	ctask->hdr.data_length = cpu_to_be32(sc->request_bufflen);	ctask->hdr.cmdsn = cpu_to_be32(session->cmdsn); session->cmdsn++;	ctask->hdr.exp_statsn = cpu_to_be32(conn->exp_statsn);	memcpy(ctask->hdr.cdb, sc->cmnd, sc->cmd_len);	memset(&ctask->hdr.cdb[sc->cmd_len], 0, MAX_COMMAND_SIZE - sc->cmd_len);	ctask->mtask = NULL;	ctask->sent = 0;	ctask->sg_count = 0;	ctask->total_length = sc->request_bufflen;	if (sc->sc_data_direction == DMA_TO_DEVICE) {		ctask->exp_r2tsn = 0;		ctask->hdr.flags |= ISCSI_FLAG_CMD_WRITE;		BUG_ON(ctask->total_length == 0);		if (sc->use_sg) {			struct scatterlist *sg = sc->request_buffer;			iscsi_buf_init_sg(&ctask->sendbuf,					  &sg[ctask->sg_count++]);			ctask->sg = sg;			ctask->bad_sg = sg + sc->use_sg;		} else {			iscsi_buf_init_iov(&ctask->sendbuf, sc->request_buffer,					sc->request_bufflen);		}		/*		 * Write counters:		 *		 *	imm_count	bytes to be sent right after		 *			SCSI PDU Header		 *		 *	unsol_count	bytes(as Data-Out) to be sent		 *			without	R2T ack right after		 *			immediate data		 *		 *	r2t_data_count	bytes to be sent via R2T ack's		 *		 *      pad_count       bytes to be sent as zero-padding		 */		ctask->imm_count = 0;		ctask->unsol_count = 0;		ctask->unsol_datasn = 0;		ctask->xmstate = XMSTATE_W_HDR;		/* calculate write padding */		ctask->pad_count = ctask->total_length & (ISCSI_PAD_LEN-1);		if (ctask->pad_count) {			ctask->pad_count = ISCSI_PAD_LEN - ctask->pad_count;			debug_scsi("write padding %d bytes\n",				ctask->pad_count);			ctask->xmstate |= XMSTATE_W_PAD;		}		if (session->imm_data_en) {			if (ctask->total_length >= session->first_burst)				ctask->imm_count = min(session->first_burst,							conn->max_xmit_dlength);			else				ctask->imm_count = min(ctask->total_length,							conn->max_xmit_dlength);			hton24(ctask->hdr.dlength, ctask->imm_count);			ctask->xmstate |= XMSTATE_IMM_DATA;		} else			zero_data(ctask->hdr.dlength);		if (!session->initial_r2t_en)			ctask->unsol_count = min(session->first_burst,				ctask->total_length) - ctask->imm_count;		if (!ctask->unsol_count)			/* No unsolicit Data-Out's */			ctask->hdr.flags |= ISCSI_FLAG_CMD_FINAL;		else			ctask->xmstate |= XMSTATE_UNS_HDR | XMSTATE_UNS_INIT;		ctask->r2t_data_count = ctask->total_length -				    ctask->imm_count -				    ctask->unsol_count;		debug_scsi("cmd [itt %x total %d imm %d imm_data %d "			   "r2t_data %d]\n",			   ctask->itt, ctask->total_length, ctask->imm_count,			   ctask->unsol_count, ctask->r2t_data_count);	} else {		ctask->hdr.flags |= ISCSI_FLAG_CMD_FINAL;		if (sc->sc_data_direction == DMA_FROM_DEVICE)			ctask->hdr.flags |= ISCSI_FLAG_CMD_READ;		ctask->datasn = 0;		ctask->xmstate = XMSTATE_R_HDR;		zero_data(ctask->hdr.dlength);	}	iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)&ctask->hdr,			    (u8 *)ctask->hdrext);	conn->scsicmd_pdus_cnt++;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/af973481f4a0902ad35726636c290f4794704948/iscsi_tcp.c/clean/drivers/scsi/iscsi_tcp.c