Lines Matching defs:reqp

131 nack_message(SC_REQ *reqp, u_char msg)
135 reqp->msgout = msg;
139 finish_req(SC_REQ *reqp)
142 struct scsipi_xfer *xs = reqp->xs;
148 if (reqp->dr_flag & DRIVER_BOUNCING)
149 free_bounceb(reqp->bounceb);
152 if (dbg_target_mask & (1 << reqp->targ_id))
153 show_request(reqp, "DONE");
156 if ((dbg_target_mask & (1 << reqp->targ_id)) && (reqp->xs->error != 0))
157 show_request(reqp, "ERR_RET");
163 reqp->next = free_head;
164 free_head = reqp;
167 if ((reqp->dr_flag & DRIVER_LINKCHK) == 0)
271 SC_REQ *reqp, *link, *tmp;
294 if ((reqp = free_head) == 0) {
300 free_head = reqp->next;
301 reqp->next = NULL;
307 reqp->dr_flag = (flags & XS_CTL_POLL) ? DRIVER_NOINT : 0;
308 reqp->phase = NR_PHASE;
309 reqp->msgout = MSG_NOOP;
310 reqp->status = SCSGOOD;
311 reqp->message = 0xff;
312 reqp->link = NULL;
313 reqp->xs = xs;
314 reqp->targ_id = xs->xs_periph->periph_target;
315 reqp->targ_lun = xs->xs_periph->periph_lun;
316 reqp->xdata_ptr = (u_char*)xs->data;
317 reqp->xdata_len = xs->datalen;
318 memcpy(&reqp->xcmd, xs->cmd, xs->cmdlen);
319 reqp->xcmd_len = xs->cmdlen;
320 reqp->xcmd.bytes[0] |= reqp->targ_lun << 5;
326 if (scsi_dmaok(reqp))
327 reqp->dr_flag |= DRIVER_DMAOK;
343 (reqp->xcmd.opcode == SCSI_REQUEST_SENSE)) {
344 reqp->next = issue_q;
345 issue_q = reqp;
349 if (!link && (tmp->targ_id == reqp->targ_id) &&
353 tmp->next = reqp;
355 if (link && (ncr_will_link & (1<<reqp->targ_id))) {
356 link->link = reqp;
371 if (!link && (ncr_test_link & (1 << reqp->targ_id)) == 0 &&
372 (tmp = free_head) && (reqp->dr_flag & DRIVER_NOINT) == 0) {
374 tmp->dr_flag = (reqp->dr_flag & ~DRIVER_DMAOK) |
379 tmp->xs = reqp->xs;
380 tmp->targ_id = reqp->targ_id;
381 tmp->targ_lun = reqp->targ_lun;
387 tmp->link = reqp;
400 if (dbg_target_mask & (1 << reqp->targ_id))
401 show_request(reqp,
402 (reqp->xcmd.opcode == SCSI_REQUEST_SENSE) ?
642 SC_REQ *reqp;
646 if ((reqp = connected) && (reqp->dr_flag & DRIVER_IN_DMA)) {
649 transfer_dma(reqp, reqp->phase, 0);
708 scsi_select(SC_REQ *reqp, int code)
719 reqp->xs->xs_periph->periph_channel->chan_adapter->adapt_dev);
812 targ_bit = 1 << reqp->targ_id;
862 reqp->xs->error = code ? code : XS_SELTIMEOUT;
864 reqp->targ_id);
865 if (reqp->dr_flag & DRIVER_LINKCHK)
866 ncr_test_link &= ~(1<<reqp->targ_id);
867 finish_req(reqp);
874 DBG_SELPRINT ("Target %d responding to select.\n", reqp->targ_id);
885 reqp->phase = PH_CMD;
893 tmp[0] = MSG_IDENTIFY(reqp->targ_lun,
894 (reqp->dr_flag & DRIVER_NOINT) ? 0 : 1);
912 reqp->targ_id);
914 reqp->phase = PH_CMD;
919 reqp->targ_id);
935 reqp->xs->error = code ? code : XS_DRIVER_STUFFUP;
936 finish_req(reqp);
940 reqp->phase = PH_MSGOUT;
952 connected = reqp;
966 SC_REQ *reqp = connected;
990 busy &= ~(1 << reqp->targ_id);
992 reqp->xs->error = XS_TIMEOUT;
993 finish_req(reqp);
1002 if (phase != reqp->phase) {
1003 reqp->phase = phase;
1005 if (dbg_target_mask & (1 << reqp->targ_id))
1006 DBG_INFPRINT(show_phase, reqp, phase);
1012 if ((reqp->msgout == MSG_ABORT) &&
1014 busy &= ~(1 << reqp->targ_id);
1016 reqp->xs->error = XS_TIMEOUT;
1017 finish_req(reqp);
1026 ncr_tprint(reqp, "NOWRITE set -- write attempt aborted.");
1027 reqp->msgout = MSG_ABORT;
1035 if (reqp->xdata_ptr == reqp->xs->data) { /* XXX */
1036 if (reqp->dr_flag & DRIVER_BOUNCING)
1037 memcpy(reqp->bounceb, reqp->xdata_ptr,
1038 reqp->xdata_len);
1042 if (reqp->xdata_len <= 0) {
1047 ncr_tprint(reqp, "Target requests too much data\n");
1048 reqp->msgout = MSG_ABORT;
1054 if (reqp->dr_flag & DRIVER_DMAOK) {
1055 int poll = REAL_DMA_POLL|(reqp->dr_flag & DRIVER_NOINT);
1056 transfer_dma(reqp, phase, poll);
1063 len = reqp->xdata_len;
1065 if (transfer_pdma(&phase, reqp->xdata_ptr, &len) == 0)
1068 transfer_pio(&phase, reqp->xdata_ptr, &len, 0);
1070 reqp->xdata_ptr += reqp->xdata_len - len;
1071 reqp->xdata_len = len;
1080 reqp->message = tmp;
1081 return handle_message(reqp, tmp);
1084 transfer_pio(&phase, &reqp->msgout, &len, 0);
1085 if (reqp->msgout == MSG_ABORT) {
1086 busy &= ~(1 << reqp->targ_id);
1088 if (!reqp->xs->error)
1089 reqp->xs->error = XS_DRIVER_STUFFUP;
1090 finish_req(reqp);
1094 reqp->msgout = MSG_NOOP;
1097 len = reqp->xcmd_len;
1098 transfer_pio(&phase, (uint8_t *)&reqp->xcmd, &len, 0);
1104 reqp->status = tmp;
1108 ncr_tprint(reqp, "Unknown phase\n");
1121 handle_message(SC_REQ *reqp, u_int msg)
1137 if (reqp->link == NULL) {
1138 ncr_tprint(reqp, "No link for linked command");
1139 nack_message(reqp, MSG_ABORT);
1144 if ((reqp->dr_flag & DRIVER_AUTOSEN) == 0) {
1145 reqp->xs->resid = reqp->xdata_len;
1146 reqp->xs->error = 0;
1150 if (check_autosense(reqp, 1) == -1)
1155 if (dbg_target_mask & (1 << reqp->targ_id))
1156 show_request(reqp->link, "LINK");
1158 connected = reqp->link;
1178 finish_req(reqp);
1185 busy &= ~(1 << reqp->targ_id);
1186 if ((reqp->dr_flag & DRIVER_AUTOSEN) == 0) {
1187 reqp->xs->resid = reqp->xdata_len;
1188 reqp->xs->error = 0;
1192 if (check_autosense(reqp, 0) == -1) {
1198 finish_req(reqp);
1208 if (dbg_target_mask & (1 << reqp->targ_id))
1209 show_request(reqp, "DISCON");
1213 reqp->next = discon_q;
1214 discon_q = reqp;
1228 nack_message(reqp, MSG_MESSAGE_REJECT);
1237 ncr_tprint(reqp, "Unknown message %x. Rejecting.\n",
1239 nack_message(reqp, MSG_MESSAGE_REJECT);
1434 transfer_dma(SC_REQ *reqp, u_int phase, int poll)
1465 reqp->dr_flag |= DRIVER_IN_DMA;
1470 scsi_dma_setup(reqp, phase, mbase);
1479 poll_edma(reqp);
1492 SC_REQ *reqp = connected;
1496 is_edma = get_dma_result(reqp, &bytes_left);
1506 ncr_tprint(reqp, "dma_ready: spurious call "
1524 bytes_done = reqp->dm_cur->dm_count - bytes_left;
1526 if ((reqp->dr_flag & DRIVER_BOUNCING) && (PH_IN(reqp->phase))) {
1533 memcpy(reqp->xdata_ptr, reqp->bouncerp, bytes_done);
1534 reqp->bouncerp += bytes_done;
1537 reqp->xdata_ptr = &reqp->xdata_ptr[bytes_done]; /* XXX */
1538 reqp->xdata_len -= bytes_done; /* XXX */
1539 if ((reqp->dm_cur->dm_count -= bytes_done) == 0)
1540 reqp->dm_cur++;
1542 reqp->dm_cur->dm_addr += bytes_done;
1544 if (PH_IN(reqp->phase) && (dmstat & SC_PAR_ERR)) {
1545 if ((ncr5380_no_parchk & (1 << reqp->targ_id)) == 0) {
1546 ncr_tprint(reqp, "parity error in data-phase\n");
1547 reqp->xs->error = XS_TIMEOUT;
1561 (reqp->dm_cur > reqp->dm_last) || reqp->xs->error != 0) {
1566 reqp->dr_flag &= ~DRIVER_IN_DMA;
1575 if (reqp->xs->error == 0)
1576 reqp->xs->error = XS_TIMEOUT;
1577 finish_req(reqp);
1582 if (reqp->xs->error != 0) {
1583 ncr_tprint(reqp, "dma-ready: code = %d\n",
1584 reqp->xs->error); /* LWP */
1585 reqp->msgout = MSG_ABORT;
1596 check_autosense(SC_REQ *reqp, int linked)
1606 if (reqp->dr_flag & DRIVER_LINKCHK) {
1608 ncr_will_link |= 1<<reqp->targ_id;
1610 ncr_tprint(reqp, "Does not support linked commands\n");
1619 if ((reqp->dr_flag & DRIVER_AUTOSEN) == 0) {
1620 switch (reqp->status & SCSMASK) {
1622 memcpy(&reqp->xcmd, sense_cmd, sizeof(sense_cmd));
1623 reqp->xcmd_len = sizeof(sense_cmd);
1624 reqp->xdata_ptr = (u_char *)&reqp->xs->sense.scsi_sense;
1625 reqp->xdata_len = sizeof(reqp->xs->sense.scsi_sense);
1626 reqp->dr_flag |= DRIVER_AUTOSEN;
1627 reqp->dr_flag &= ~DRIVER_DMAOK;
1630 reqp->next = issue_q;
1631 issue_q = reqp;
1634 reqp->xcmd.bytes[sizeof(sense_cmd)-2] |= 1;
1637 memset(reqp->xdata_ptr, 0, reqp->xdata_len);
1638 if (dbg_target_mask & (1 << reqp->targ_id))
1639 show_request(reqp, "AUTO-SENSE");
1644 reqp->xs->error = XS_BUSY;
1651 if ((reqp->status & SCSMASK) != SCSGOOD)
1652 reqp->xs->error = XS_DRIVER_STUFFUP; /* SC_E_AUTOSEN; */
1654 reqp->xs->error = XS_SENSE;
1655 reqp->status = SCSCHKC;
1780 SC_REQ *reqp;
1786 if ((reqp = connected) && (reqp->dr_flag & DRIVER_IN_DMA)){
1787 reqp->dr_flag &= ~DRIVER_IN_DMA;
1804 scsi_dmaok(SC_REQ *reqp)
1821 req_len = reqp->xdata_len;
1822 req_addr = (uint8_t *)reqp->xdata_ptr;
1823 dm = reqp->dm_cur = reqp->dm_last = reqp->dm_chain;
1825 reqp->dr_flag &= ~DRIVER_BOUNCING;
1867 if (wrong_dma_range(reqp, dm)) {
1868 if (reqp->dr_flag & DRIVER_BOUNCING)
1873 if (++dm >= &reqp->dm_chain[MAXDMAIO]) {
1874 ncr_tprint(reqp,
1884 if (wrong_dma_range(reqp, dm)) {
1885 if (reqp->dr_flag & DRIVER_BOUNCING)
1889 reqp->dm_last = dm;
1893 if ((reqp->bounceb = alloc_bounceb(reqp->xdata_len)) == NULL) {
1897 reqp->dr_flag &= ~DRIVER_BOUNCING;
1903 dm = reqp->dm_cur = reqp->dm_last = reqp->dm_chain;
1904 dm->dm_addr = kvtop(reqp->bounceb);
1905 dm->dm_count = reqp->xdata_len;
1906 reqp->bouncerp = reqp->bounceb;
1939 ncr_tprint(SC_REQ *reqp, const char *fmt, ...)
1944 scsipi_printaddr(reqp->xs->xs_periph);
1973 show_phase(SC_REQ *reqp, int phase)
1976 printf("INFTRANS: %d Phase = %s\n", reqp->targ_id, phase_names[phase]);
1999 show_request(SC_REQ *reqp, const char *qtxt)
2004 qtxt, reqp->targ_id, reqp->xdata_ptr, reqp->xdata_len,
2005 reqp->xcmd.opcode, reqp->status, reqp->message,
2006 reqp->xs->error, reqp->xs->resid, reqp->dr_flag,
2007 reqp->link ? "L":"");
2008 if (reqp->status == SCSCHKC)
2009 show_data_sense(reqp->xs);