Deleted Added
full compact
sbp.c (110195) sbp.c (110269)
1/*
2 * Copyright (c) 1998,1999,2000,2001 Katsushi Kobayashi and Hidetosh Shimokawa
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

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

25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
1/*
2 * Copyright (c) 1998,1999,2000,2001 Katsushi Kobayashi and Hidetosh Shimokawa
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

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

25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sys/dev/firewire/sbp.c 110195 2003-02-01 15:04:33Z simokawa $
33 * $FreeBSD: head/sys/dev/firewire/sbp.c 110269 2003-02-03 07:33:31Z simokawa $
34 *
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/module.h>
40#include <sys/bus.h>
41#include <sys/mbuf.h>

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

762 return;
763}
764
765static void
766sbp_cam_callback(struct cam_periph *periph, union ccb *ccb)
767{
768 struct sbp_dev *sdev;
769 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
34 *
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/module.h>
40#include <sys/bus.h>
41#include <sys/mbuf.h>

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

762 return;
763}
764
765static void
766sbp_cam_callback(struct cam_periph *periph, union ccb *ccb)
767{
768 struct sbp_dev *sdev;
769 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
770SBP_DEBUG(1)
770SBP_DEBUG(0)
771 sbp_show_sdev_info(sdev, 2);
772 printf("sbp_cam_callback\n");
773END_DEBUG
774 sdev->status = SBP_DEV_ATTACHED;
775 free(ccb, M_SBP);
776}
777
778static void

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

795}
796
797
798static void
799sbp_ping_unit_callback(struct cam_periph *periph, union ccb *ccb)
800{
801 struct sbp_dev *sdev;
802 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
771 sbp_show_sdev_info(sdev, 2);
772 printf("sbp_cam_callback\n");
773END_DEBUG
774 sdev->status = SBP_DEV_ATTACHED;
775 free(ccb, M_SBP);
776}
777
778static void

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

795}
796
797
798static void
799sbp_ping_unit_callback(struct cam_periph *periph, union ccb *ccb)
800{
801 struct sbp_dev *sdev;
802 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
803SBP_DEBUG(1)
803SBP_DEBUG(0)
804 sbp_show_sdev_info(sdev, 2);
805 printf("sbp_ping_unit_callback\n");
806END_DEBUG
807 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
808 if (--ccb->ccb_h.retry_count == 0) {
809 sbp_show_sdev_info(sdev, 2);
810 printf("sbp_tur_callback: retry count exceeded\n");
811 sdev->status = SBP_DEV_RETRY;

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

836{
837 union ccb *ccb;
838 struct scsi_inquiry_data *inq_buf;
839
840 ccb = malloc(sizeof(union ccb), M_SBP, M_ZERO);
841 inq_buf = (struct scsi_inquiry_data *)
842 malloc(sizeof(*inq_buf), M_SBP, 0);
843
804 sbp_show_sdev_info(sdev, 2);
805 printf("sbp_ping_unit_callback\n");
806END_DEBUG
807 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
808 if (--ccb->ccb_h.retry_count == 0) {
809 sbp_show_sdev_info(sdev, 2);
810 printf("sbp_tur_callback: retry count exceeded\n");
811 sdev->status = SBP_DEV_RETRY;

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

836{
837 union ccb *ccb;
838 struct scsi_inquiry_data *inq_buf;
839
840 ccb = malloc(sizeof(union ccb), M_SBP, M_ZERO);
841 inq_buf = (struct scsi_inquiry_data *)
842 malloc(sizeof(*inq_buf), M_SBP, 0);
843
844SBP_DEBUG(1)
844SBP_DEBUG(0)
845 sbp_show_sdev_info(sdev, 2);
846 printf("sbp_ping_unit\n");
847END_DEBUG
848
849 /*
850 * We need to execute this command before any other queued command.
851 * Make priority 0 and freeze queue after execution for retry.
852 * cam's scan_lun command doesn't provide this feature.

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

1039}
1040
1041static struct fw_xfer *
1042sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
1043{
1044 struct fw_xfer *xfer;
1045 struct fw_pkt *fp;
1046
845 sbp_show_sdev_info(sdev, 2);
846 printf("sbp_ping_unit\n");
847END_DEBUG
848
849 /*
850 * We need to execute this command before any other queued command.
851 * Make priority 0 and freeze queue after execution for retry.
852 * cam's scan_lun command doesn't provide this feature.

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

1039}
1040
1041static struct fw_xfer *
1042sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
1043{
1044 struct fw_xfer *xfer;
1045 struct fw_pkt *fp;
1046
1047 xfer = fw_xfer_alloc();
1047 xfer = fw_xfer_alloc(M_SBP);
1048 if(xfer == NULL){
1049 return NULL;
1050 }
1051 if (tcode == FWTCODE_WREQQ)
1052 xfer->send.len = 16;
1053 else
1054 xfer->send.len = 24;
1055

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

1439 printf("unknown respose code %d\n", sbp_status->resp);
1440 }
1441 }
1442
1443 /* we have to reset the fetch agent if it's dead */
1444 if (sbp_status->dead) {
1445 if (sdev->path)
1446 xpt_freeze_devq(sdev->path, 1);
1048 if(xfer == NULL){
1049 return NULL;
1050 }
1051 if (tcode == FWTCODE_WREQQ)
1052 xfer->send.len = 16;
1053 else
1054 xfer->send.len = 24;
1055

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

1439 printf("unknown respose code %d\n", sbp_status->resp);
1440 }
1441 }
1442
1443 /* we have to reset the fetch agent if it's dead */
1444 if (sbp_status->dead) {
1445 if (sdev->path)
1446 xpt_freeze_devq(sdev->path, 1);
1447 sbp_show_sdev_info(sdev, 2);
1448 printf("reset agent\n");
1449 sbp_agent_reset(sdev, 0);
1450 }
1451
1452 if (ocb == NULL) {
1453 fw_xfer_free(xfer);
1454 return;
1455 }
1456

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

1670
1671 if (xpt_bus_register(sbp->sim, /*bus*/0) != CAM_SUCCESS) {
1672 cam_sim_free(sbp->sim, /*free_devq*/TRUE);
1673 contigfree(sbp->ocb, sizeof (struct sbp_ocb) * SBP_NUM_OCB,
1674 M_SBP);
1675 return (ENXIO);
1676 }
1677
1447 sbp_agent_reset(sdev, 0);
1448 }
1449
1450 if (ocb == NULL) {
1451 fw_xfer_free(xfer);
1452 return;
1453 }
1454

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

1668
1669 if (xpt_bus_register(sbp->sim, /*bus*/0) != CAM_SUCCESS) {
1670 cam_sim_free(sbp->sim, /*free_devq*/TRUE);
1671 contigfree(sbp->ocb, sizeof (struct sbp_ocb) * SBP_NUM_OCB,
1672 M_SBP);
1673 return (ENXIO);
1674 }
1675
1678 xfer = fw_xfer_alloc();
1676 xfer = fw_xfer_alloc(M_SBP);
1679 xfer->act.hand = sbp_recv;
1680 xfer->act_type = FWACT_XFER;
1681#if NEED_RESPONSE
1682 xfer->fc = sbp->fd.fc;
1683#endif
1684 xfer->sc = (caddr_t)sbp;
1685
1686 sbp->fwb.start_hi = SBP_BIND_HI;

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

1709 printf("sbp_logout_all\n");
1710END_DEBUG
1711 for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
1712 target = &sbp->targets[i];
1713 if (target->luns == NULL)
1714 continue;
1715 for (j = 0; j < target->num_lun; j++) {
1716 sdev = &target->luns[j];
1677 xfer->act.hand = sbp_recv;
1678 xfer->act_type = FWACT_XFER;
1679#if NEED_RESPONSE
1680 xfer->fc = sbp->fd.fc;
1681#endif
1682 xfer->sc = (caddr_t)sbp;
1683
1684 sbp->fwb.start_hi = SBP_BIND_HI;

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

1707 printf("sbp_logout_all\n");
1708END_DEBUG
1709 for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
1710 target = &sbp->targets[i];
1711 if (target->luns == NULL)
1712 continue;
1713 for (j = 0; j < target->num_lun; j++) {
1714 sdev = &target->luns[j];
1717 if (sdev->status == SBP_DEV_ATTACHED) {
1718 sbp_show_sdev_info(sdev, 2);
1719 printf("logout\n");
1715 if (sdev->status == SBP_DEV_ATTACHED)
1720 sbp_mgm_orb(sdev, ORB_FUN_LGO);
1716 sbp_mgm_orb(sdev, ORB_FUN_LGO);
1721 }
1722 }
1723 }
1724 return 0;
1725}
1726
1727static int
1728sbp_shutdown(device_t dev)
1729{

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

1792 }
1793}
1794
1795static void
1796sbp_timeout(void *arg)
1797{
1798 struct sbp_ocb *ocb = (struct sbp_ocb *)arg;
1799 struct sbp_dev *sdev = ocb->sdev;
1717 }
1718 }
1719 return 0;
1720}
1721
1722static int
1723sbp_shutdown(device_t dev)
1724{

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

1787 }
1788}
1789
1790static void
1791sbp_timeout(void *arg)
1792{
1793 struct sbp_ocb *ocb = (struct sbp_ocb *)arg;
1794 struct sbp_dev *sdev = ocb->sdev;
1795#if 0
1800 int s;
1796 int s;
1797#endif
1801
1802 sbp_show_sdev_info(sdev, 2);
1803 printf("request timeout ... requeue\n");
1804
1798
1799 sbp_show_sdev_info(sdev, 2);
1800 printf("request timeout ... requeue\n");
1801
1805 /* XXX need reset? */
1806
1802 /* XXX need bus reset? */
1803#if 0
1807 s = splfw();
1808 sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT);
1809 splx(s);
1804 s = splfw();
1805 sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT);
1806 splx(s);
1807#else
1808 sbp_agent_reset(sdev, 0);
1809#endif
1810 return;
1811}
1812
1813static void
1814sbp_action1(struct cam_sim *sim, union ccb *ccb)
1815{
1816
1817 struct sbp_softc *sbp = (struct sbp_softc *)sim->softc;

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

2302}
2303
2304static void
2305sbp_abort_ocb(struct sbp_ocb *ocb, int status)
2306{
2307 struct sbp_dev *sdev;
2308
2309 sdev = ocb->sdev;
1810 return;
1811}
1812
1813static void
1814sbp_action1(struct cam_sim *sim, union ccb *ccb)
1815{
1816
1817 struct sbp_softc *sbp = (struct sbp_softc *)sim->softc;

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

2302}
2303
2304static void
2305sbp_abort_ocb(struct sbp_ocb *ocb, int status)
2306{
2307 struct sbp_dev *sdev;
2308
2309 sdev = ocb->sdev;
2310SBP_DEBUG(0)
2310SBP_DEBUG(1)
2311 sbp_show_sdev_info(sdev, 2);
2312 printf("sbp_abort_ocb 0x%x\n", status);
2313 if (ocb->ccb != NULL)
2314 sbp_print_scsi_cmd(ocb);
2315END_DEBUG
2316 if (ocb->ccb != NULL && !(ocb->flags & OCB_DONE)) {
2317 if (status != CAM_CMD_TIMEOUT)
2318 untimeout(sbp_timeout, (caddr_t)ocb,

--- 52 unchanged lines hidden ---
2311 sbp_show_sdev_info(sdev, 2);
2312 printf("sbp_abort_ocb 0x%x\n", status);
2313 if (ocb->ccb != NULL)
2314 sbp_print_scsi_cmd(ocb);
2315END_DEBUG
2316 if (ocb->ccb != NULL && !(ocb->flags & OCB_DONE)) {
2317 if (status != CAM_CMD_TIMEOUT)
2318 untimeout(sbp_timeout, (caddr_t)ocb,

--- 52 unchanged lines hidden ---