Deleted Added
full compact
sbp.c (110839) sbp.c (111040)
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 110839 2003-02-14 03:09:59Z simokawa $
33 * $FreeBSD: head/sys/dev/firewire/sbp.c 111040 2003-02-17 14:24:06Z 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>

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

75#define SBP_INITIATOR 7
76#define SBP_ESELECT_TIMEOUT 1
77#define SBP_BIND_HI 0x1
78#define SBP_DEV2ADDR(u, t, l) \
79 ((((u) & 0xff) << 16) | (((l) & 0xff) << 8) | (((t) & 0x3f) << 2))
80#define SBP_ADDR2TRG(a) (((a) >> 2) & 0x3f)
81#define SBP_ADDR2LUN(a) (((a) >> 8) & 0xff)
82
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>

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

75#define SBP_INITIATOR 7
76#define SBP_ESELECT_TIMEOUT 1
77#define SBP_BIND_HI 0x1
78#define SBP_DEV2ADDR(u, t, l) \
79 ((((u) & 0xff) << 16) | (((l) & 0xff) << 8) | (((t) & 0x3f) << 2))
80#define SBP_ADDR2TRG(a) (((a) >> 2) & 0x3f)
81#define SBP_ADDR2LUN(a) (((a) >> 8) & 0xff)
82
83#define MAX_FREEZE 10
84
83#define ORB_NOTIFY (1 << 31)
84#define ORB_FMT_STD (0 << 29)
85#define ORB_FMT_VED (2 << 29)
86#define ORB_FMT_NOP (3 << 29)
87#define ORB_FMT_MSK (3 << 29)
88#define ORB_EXV (1 << 28)
89/* */
90#define ORB_CMD_IN (1 << 27)

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

625 case SBP_DEV_RESET:
626 case SBP_DEV_DEAD:
627 break;
628 }
629 }
630 }
631}
632
85#define ORB_NOTIFY (1 << 31)
86#define ORB_FMT_STD (0 << 29)
87#define ORB_FMT_VED (2 << 29)
88#define ORB_FMT_NOP (3 << 29)
89#define ORB_FMT_MSK (3 << 29)
90#define ORB_EXV (1 << 28)
91/* */
92#define ORB_CMD_IN (1 << 27)

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

627 case SBP_DEV_RESET:
628 case SBP_DEV_DEAD:
629 break;
630 }
631 }
632 }
633}
634
633#if 0
634static void
635static void
635sbp_release_queue(void *arg)
636{
637 struct sbp_softc *sbp;
638
639SBP_DEBUG(0)
640 printf("sbp_release_queue\n");
641END_DEBUG
642 sbp = (struct sbp_softc *)arg;
643 xpt_release_simq(sbp->sim, 1);
644}
645
646static void
647sbp_release_devq(void *arg)
648{
649 struct sbp_dev *sdev;
650 int s;
651
652 sdev = (struct sbp_dev *)arg;
653SBP_DEBUG(0)
654 sbp_show_sdev_info(sdev, 2);
655 printf("sbp_release_devq\n");
656END_DEBUG
657 s = splcam();
658 xpt_release_devq(sdev->path, 1, TRUE);
659 splx(s);
660}
661#endif
662
663static void
664sbp_post_explore(void *arg)
665{
666 struct sbp_softc *sbp = (struct sbp_softc *)arg;
667 struct sbp_target *target;
668 struct fw_device *fwdev;
669 int i, alive;
670
671SBP_DEBUG(1)

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

798 sbp_show_sdev_info(sdev, 2);
799 printf("sbp_cam_scan_lun\n");
800END_DEBUG
801 xpt_setup_ccb(&ccb->ccb_h, sdev->path, 5/*priority (low)*/);
802 ccb->ccb_h.func_code = XPT_SCAN_LUN;
803 ccb->ccb_h.cbfcnp = sbp_cam_callback;
804 ccb->crcn.flags = CAM_FLAG_NONE;
805 ccb->ccb_h.ccb_sdev_ptr = sdev;
636sbp_post_explore(void *arg)
637{
638 struct sbp_softc *sbp = (struct sbp_softc *)arg;
639 struct sbp_target *target;
640 struct fw_device *fwdev;
641 int i, alive;
642
643SBP_DEBUG(1)

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

770 sbp_show_sdev_info(sdev, 2);
771 printf("sbp_cam_scan_lun\n");
772END_DEBUG
773 xpt_setup_ccb(&ccb->ccb_h, sdev->path, 5/*priority (low)*/);
774 ccb->ccb_h.func_code = XPT_SCAN_LUN;
775 ccb->ccb_h.cbfcnp = sbp_cam_callback;
776 ccb->crcn.flags = CAM_FLAG_NONE;
777 ccb->ccb_h.ccb_sdev_ptr = sdev;
806 xpt_action(ccb);
807
808 /* The scan is in progress now. */
778
779 /* The scan is in progress now. */
780 sdev->status = SBP_DEV_PROBE;
781 xpt_action(ccb);
809}
810
811
812static void
813sbp_ping_unit_callback(struct cam_periph *periph, union ccb *ccb)
814{
815 struct sbp_dev *sdev;
816 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;

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

823 sbp_show_sdev_info(sdev, 2);
824 printf("sbp_ping_unit_callback: "
825 "retry count exceeded\n");
826 sdev->status = SBP_DEV_RETRY;
827 free(ccb, M_SBP);
828 } else {
829 /* requeue */
830 xpt_action(ccb);
782}
783
784
785static void
786sbp_ping_unit_callback(struct cam_periph *periph, union ccb *ccb)
787{
788 struct sbp_dev *sdev;
789 sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;

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

796 sbp_show_sdev_info(sdev, 2);
797 printf("sbp_ping_unit_callback: "
798 "retry count exceeded\n");
799 sdev->status = SBP_DEV_RETRY;
800 free(ccb, M_SBP);
801 } else {
802 /* requeue */
803 xpt_action(ccb);
831 xpt_release_devq(sdev->path, 1, TRUE);
804 xpt_release_devq(sdev->path, MAX_FREEZE, TRUE);
832 }
833 } else {
834 free(ccb->csio.data_ptr, M_SBP);
835 free(ccb, M_SBP);
836 sdev->status = SBP_DEV_ATTACHED;
805 }
806 } else {
807 free(ccb->csio.data_ptr, M_SBP);
808 free(ccb, M_SBP);
809 sdev->status = SBP_DEV_ATTACHED;
837 xpt_release_devq(sdev->path, 1, TRUE);
810 xpt_release_devq(sdev->path, MAX_FREEZE, TRUE);
838 }
839}
840
841/*
842 * XXX Some devices need to execute inquiry or read_capacity
843 * after bus_rest during busy transfer.
844 * Otherwise they return incorrect result for READ(and WRITE?)
845 * command without any SBP-II/SCSI error.

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

887 SHORT_INQUIRY_LENGTH,
888 /*evpd*/FALSE,
889 /*page_code*/0,
890 SSD_MIN_SIZE,
891 /*timeout*/60000
892 );
893 ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
894 xpt_action(ccb);
811 }
812}
813
814/*
815 * XXX Some devices need to execute inquiry or read_capacity
816 * after bus_rest during busy transfer.
817 * Otherwise they return incorrect result for READ(and WRITE?)
818 * command without any SBP-II/SCSI error.

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

860 SHORT_INQUIRY_LENGTH,
861 /*evpd*/FALSE,
862 /*page_code*/0,
863 SSD_MIN_SIZE,
864 /*timeout*/60000
865 );
866 ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
867 xpt_action(ccb);
895
896 if (sdev->status == SBP_DEV_RETRY)
897 /* freezed twice */
898 xpt_release_devq(sdev->path, 1, TRUE);
868 sdev->status = SBP_DEV_PROBE;
899}
900
901static void
902sbp_do_attach(struct fw_xfer *xfer)
903{
904 struct sbp_dev *sdev;
905
906 sdev = (struct sbp_dev *)xfer->sc;
907SBP_DEBUG(0)
908 sbp_show_sdev_info(sdev, 2);
909 printf("sbp_do_attach\n");
910END_DEBUG
911 fw_xfer_free(xfer);
912 if (sdev->path == NULL)
913 xpt_create_path(&sdev->path, xpt_periph,
914 cam_sim_path(sdev->target->sbp->sim),
915 sdev->target->target_id, sdev->lun_id);
916
869}
870
871static void
872sbp_do_attach(struct fw_xfer *xfer)
873{
874 struct sbp_dev *sdev;
875
876 sdev = (struct sbp_dev *)xfer->sc;
877SBP_DEBUG(0)
878 sbp_show_sdev_info(sdev, 2);
879 printf("sbp_do_attach\n");
880END_DEBUG
881 fw_xfer_free(xfer);
882 if (sdev->path == NULL)
883 xpt_create_path(&sdev->path, xpt_periph,
884 cam_sim_path(sdev->target->sbp->sim),
885 sdev->target->target_id, sdev->lun_id);
886
917 if (sdev->status == SBP_DEV_RETRY) {
887 if (sdev->status == SBP_DEV_RETRY)
918 sbp_ping_unit(sdev);
888 sbp_ping_unit(sdev);
919 sdev->status = SBP_DEV_PROBE;
920 } else {
921 sdev->status = SBP_DEV_PROBE;
889 else
922 sbp_cam_scan_lun(sdev);
890 sbp_cam_scan_lun(sdev);
923 }
924 xpt_release_devq(sdev->path, 1, TRUE);
891 xpt_release_devq(sdev->path, MAX_FREEZE, TRUE);
925 return;
926}
927
928static void
929sbp_agent_reset_callback(struct fw_xfer *xfer)
930{
931 struct sbp_dev *sdev;
932
933 sdev = (struct sbp_dev *)xfer->sc;
934SBP_DEBUG(1)
935 sbp_show_sdev_info(sdev, 2);
936 printf("sbp_cmd_callback\n");
937END_DEBUG
938 fw_xfer_free(xfer);
939 sbp_abort_all_ocbs(sdev, CAM_REQUEUE_REQ);
940 if (sdev->path)
892 return;
893}
894
895static void
896sbp_agent_reset_callback(struct fw_xfer *xfer)
897{
898 struct sbp_dev *sdev;
899
900 sdev = (struct sbp_dev *)xfer->sc;
901SBP_DEBUG(1)
902 sbp_show_sdev_info(sdev, 2);
903 printf("sbp_cmd_callback\n");
904END_DEBUG
905 fw_xfer_free(xfer);
906 sbp_abort_all_ocbs(sdev, CAM_REQUEUE_REQ);
907 if (sdev->path)
941 xpt_release_devq(sdev->path, 1, TRUE);
908 xpt_release_devq(sdev->path, MAX_FREEZE, TRUE);
942}
943
944static void
945sbp_agent_reset(struct sbp_dev *sdev)
946{
947 struct fw_xfer *xfer;
948 struct fw_pkt *fp;
949

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

1522 login_res = &sdev->login;
1523 if (status_valid) {
1524SBP_DEBUG(0)
1525sbp_show_sdev_info(sdev, 2);
1526printf("reconnect: len %d, ID %d, cmd %08x%08x\n", login_res->len, login_res->id, login_res->cmd_hi, login_res->cmd_lo);
1527END_DEBUG
1528#if 1
1529 sbp_ping_unit(sdev);
909}
910
911static void
912sbp_agent_reset(struct sbp_dev *sdev)
913{
914 struct fw_xfer *xfer;
915 struct fw_pkt *fp;
916

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

1489 login_res = &sdev->login;
1490 if (status_valid) {
1491SBP_DEBUG(0)
1492sbp_show_sdev_info(sdev, 2);
1493printf("reconnect: len %d, ID %d, cmd %08x%08x\n", login_res->len, login_res->id, login_res->cmd_hi, login_res->cmd_lo);
1494END_DEBUG
1495#if 1
1496 sbp_ping_unit(sdev);
1530 sdev->status = SBP_DEV_ATTACHED;
1531 xpt_release_devq(sdev->path, 1, TRUE);
1497 xpt_release_devq(sdev->path,
1498 MAX_FREEZE, TRUE);
1532#else
1533 sdev->status = SBP_DEV_ATTACHED;
1534 sbp_mgm_orb(sdev, ORB_FUN_ATS, 0, 0);
1535#endif
1536 } else {
1537 /* reconnection hold time exceed? */
1538SBP_DEBUG(0)
1539 sbp_show_sdev_info(sdev, 2);

--- 876 unchanged lines hidden ---
1499#else
1500 sdev->status = SBP_DEV_ATTACHED;
1501 sbp_mgm_orb(sdev, ORB_FUN_ATS, 0, 0);
1502#endif
1503 } else {
1504 /* reconnection hold time exceed? */
1505SBP_DEBUG(0)
1506 sbp_show_sdev_info(sdev, 2);

--- 876 unchanged lines hidden ---