iSCSI/luns/check-condition

Danny Braniss danny at cs.huji.ac.il
Sun Aug 27 13:37:10 UTC 2006


> Danny Braniss wrote:
> > [...]
> > 
> >>>sorry to barge in :-)
> >>>but my initial problem was that the driver went into a loop.
> >>>	0- cam starts lun discovery
> >>>	1- cam sends inq
> >>>	2- target replies 'condition check'
> >>>	3- cam ignores,
> >>>	4- back to 1
> >>
> >>This is only going to happen if the SIM is returning CAM_REQ_CMP.
> >>You should be returning CAM_REQ_CMP_ERROR.  An ASC of 0x24 will set
> >>SS_FATAL, which will cause probedone() to break out of the probe
> >>sequence.
> > 
> > 
> > I was returning CAM_SCSI_STATUS_ERROR. now im returning CAM_REQ_CMP_ERR
> > and the loop is broken, thanks. Couldn't figure out how to
> > deal with 'ASC of 0x24' - maybe after coffee.
> > 
> 
> Actually, CAM_SCSI_STATUS_ERROR should have worked.  Did you set 
> CAM_AUTOSNS_VALID?  If not, then that probably caused the loop.

i do!, here is the relevant code:
/*
 | under construction ...
 */
static void
getSenseData(u_int status, union ccb *ccb, pduq_t *pq)
{
     pdu_t		*pp = &pq->pdu;
     struct		ccb_scsiio *scsi = (struct ccb_scsiio *)ccb;
     struct		scsi_sense_data *sense = &scsi->sense_data;
     struct		ccb_hdr	*ccb_h = &ccb->ccb_h;
     caddr_t		bp = mtod(pq->mp, caddr_t);
     struct mbuf	*m = pq->mp;
     scsi_rsp_t		*cmd = &pp->ipdu.scsi_rsp;
     int		sense_len, mustfree = 0;

     sense_len = scsi_2btoul(bp);
     /*
      | according to the specs, the sense data cannot
      | be larger than 252 ...
      */
     if(sense_len > m->m_len) {
	  bp = malloc(sense_len, M_ISCSI, M_WAITOK);
	  debug(3, "calling i_mbufcopy(len=%d)", sense_len);
	  i_mbufcopy(pq->mp, bp, sense_len);
	  mustfree++;
     }
     scsi->scsi_status = status;

     bcopy(bp+2, sense, min(sense_len, scsi->sense_len));
     scsi->sense_resid = 0;
     if(cmd->flag & (BIT(1)|BIT(2)))
	  scsi->sense_resid = ntohl(pp->ipdu.scsi_rsp.rcnt);
     debug(3, "sense_len=%d rcnt=%d sense_resid=%d dsl=%d error_code=%x 
flags=%x",
	   sense_len,
	   ntohl(pp->ipdu.scsi_rsp.rcnt), scsi->sense_resid,
	   pp->ds_len, sense->error_code, sense->flags);

     ccb_h->status |= CAM_AUTOSNS_VALID;

     if(mustfree)
	  free(bp, M_ISCSI);
}

and
...
	  case 0x02: 	// Check Condition
	       if(pq != NULL) // XXX: check for data ...
		    getSenseData(status, ccb, pq);

	  case 0x14:	// Intermediate-Condition Met
	  case 0x10:	// Intermediate
	  case 0x04:	// Condition Met
	       ccb_h->status = CAM_REQ_CMP_ERR; //CAM_SCSI_STATUS_ERROR;
	       break;
...

danny




More information about the freebsd-scsi mailing list