Deleted Added
full compact
scsi_ctl.c (236426) scsi_ctl.c (237601)
1/*-
2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 */
32/*
33 * Peripheral driver interface between CAM and CTL (CAM Target Layer).
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 */
32/*
33 * Peripheral driver interface between CAM and CTL (CAM Target Layer).
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/cam/ctl/scsi_ctl.c 236426 2012-06-01 23:24:56Z mjacob $");
39__FBSDID("$FreeBSD: head/sys/cam/ctl/scsi_ctl.c 237601 2012-06-26 14:51:35Z ken $");
40
41#include <sys/param.h>
42#include <sys/queue.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>
47#include <sys/condvar.h>

--- 505 unchanged lines hidden (view full) ---

553 int i;
554
555 softc = (struct ctlfe_lun_softc *)arg;
556 bus_softc = softc->parent_softc;
557 sim = xpt_path_sim(periph->path);
558
559 TAILQ_INIT(&softc->work_queue);
560 softc->periph = periph;
40
41#include <sys/param.h>
42#include <sys/queue.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>
47#include <sys/condvar.h>

--- 505 unchanged lines hidden (view full) ---

553 int i;
554
555 softc = (struct ctlfe_lun_softc *)arg;
556 bus_softc = softc->parent_softc;
557 sim = xpt_path_sim(periph->path);
558
559 TAILQ_INIT(&softc->work_queue);
560 softc->periph = periph;
561 softc->parent_softc = bus_softc;
562
563 callout_init_mtx(&softc->dma_callout, sim->mtx, /*flags*/ 0);
564 periph->softc = softc;
565
566 xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, /*priority*/ 1);
567 en_lun_ccb.ccb_h.func_code = XPT_EN_LUN;
568 en_lun_ccb.cel.grp6_len = 0;
569 en_lun_ccb.cel.grp7_len = 0;

--- 53 unchanged lines hidden (view full) ---

623 }
624
625 xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
626 new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY;
627 new_ccb->ccb_h.cbfcnp = ctlfedone;
628 xpt_action(new_ccb);
629 softc->inots_sent++;
630 status = new_ccb->ccb_h.status;
561
562 callout_init_mtx(&softc->dma_callout, sim->mtx, /*flags*/ 0);
563 periph->softc = softc;
564
565 xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, /*priority*/ 1);
566 en_lun_ccb.ccb_h.func_code = XPT_EN_LUN;
567 en_lun_ccb.cel.grp6_len = 0;
568 en_lun_ccb.cel.grp7_len = 0;

--- 53 unchanged lines hidden (view full) ---

622 }
623
624 xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
625 new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY;
626 new_ccb->ccb_h.cbfcnp = ctlfedone;
627 xpt_action(new_ccb);
628 softc->inots_sent++;
629 status = new_ccb->ccb_h.status;
631 if (status != CAM_REQ_INPROG) {
632 free(new_ccb, M_CTLFE);
630 if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
631 /*
632 * Note that we don't free the CCB here. If the
633 * status is not CAM_REQ_INPROG, then we're
634 * probably talking to a SIM that says it is
635 * target-capable but doesn't support the
636 * XPT_IMMEDIATE_NOTIFY CCB. i.e. it supports the
637 * older API. In that case, it'll call xpt_done()
638 * on the CCB, and we need to free it in our done
639 * routine as a result.
640 */
633 break;
634 }
635 }
641 break;
642 }
643 }
636 if (i == 0) {
644 if ((i == 0)
645 || (status != CAM_REQ_INPROG)) {
637 xpt_print(periph->path, "%s: could not allocate immediate "
638 "notify CCBs, status 0x%x\n", __func__, status);
639 return (CAM_REQ_CMP_ERR);
640 }
641 return (CAM_REQ_CMP);
642}
643
644static void

--- 810 unchanged lines hidden (view full) ---

1455 break;
1456 case CAM_REQ_ABORTED:
1457 /*
1458 * This request was sent back by the driver.
1459 * XXX KDM what do we do here?
1460 */
1461 send_ctl_io = 0;
1462 break;
646 xpt_print(periph->path, "%s: could not allocate immediate "
647 "notify CCBs, status 0x%x\n", __func__, status);
648 return (CAM_REQ_CMP_ERR);
649 }
650 return (CAM_REQ_CMP);
651}
652
653static void

--- 810 unchanged lines hidden (view full) ---

1464 break;
1465 case CAM_REQ_ABORTED:
1466 /*
1467 * This request was sent back by the driver.
1468 * XXX KDM what do we do here?
1469 */
1470 send_ctl_io = 0;
1471 break;
1472 case CAM_REQ_INVALID:
1473 case CAM_PROVIDE_FAIL:
1463 default:
1474 default:
1464 xpt_print(periph->path, "%s: "
1465 "unsupported CAM status 0x%x\n",
1466 __func__, status);
1467 send_ctl_io = 0;
1468 break;
1475 /*
1476 * We should only get here if we're talking
1477 * to a talking to a SIM that is target
1478 * capable but supports the old API. In
1479 * that case, we need to just free the CCB.
1480 * If we actually send a notify acknowledge,
1481 * it will send that back with an error as
1482 * well.
1483 */
1484
1485 if ((status != CAM_REQ_INVALID)
1486 && (status != CAM_PROVIDE_FAIL))
1487 xpt_print(periph->path, "%s: "
1488 "unsupported CAM status "
1489 "0x%x\n", __func__, status);
1490
1491 ctl_free_io(io);
1492 ctlfe_free_ccb(periph, done_ccb);
1493
1494 return;
1469 }
1470 if (send_ctl_io != 0) {
1471 ctl_queue(io);
1472 } else {
1473 ctl_free_io(io);
1474 done_ccb->ccb_h.status = CAM_REQ_INPROG;
1475 done_ccb->ccb_h.func_code =
1476 XPT_NOTIFY_ACKNOWLEDGE;

--- 577 unchanged lines hidden ---
1495 }
1496 if (send_ctl_io != 0) {
1497 ctl_queue(io);
1498 } else {
1499 ctl_free_io(io);
1500 done_ccb->ccb_h.status = CAM_REQ_INPROG;
1501 done_ccb->ccb_h.func_code =
1502 XPT_NOTIFY_ACKNOWLEDGE;

--- 577 unchanged lines hidden ---