Deleted Added
full compact
isp_freebsd.c (154704) isp_freebsd.c (155228)
1/*-
2 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
3 *
4 * Copyright (c) 1997-2006 by Matthew Jacob
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
3 *
4 * Copyright (c) 1997-2006 by Matthew Jacob
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 154704 2006-01-23 06:23:37Z mjacob $");
30__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 155228 2006-02-02 21:31:34Z mjacob $");
31
32#include <dev/isp/isp_freebsd.h>
33#include <sys/unistd.h>
34#include <sys/kthread.h>
35#include <machine/stdarg.h> /* for use by isp_prt below */
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>

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

218 while (tmp->isp_osinfo.next) {
219 tmp = tmp->isp_osinfo.next;
220 }
221 tmp->isp_osinfo.next = isp;
222 }
223
224}
225
31
32#include <dev/isp/isp_freebsd.h>
33#include <sys/unistd.h>
34#include <sys/kthread.h>
35#include <machine/stdarg.h> /* for use by isp_prt below */
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>

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

218 while (tmp->isp_osinfo.next) {
219 tmp = tmp->isp_osinfo.next;
220 }
221 tmp->isp_osinfo.next = isp;
222 }
223
224}
225
226static INLINE void
226static __inline void
227isp_freeze_loopdown(struct ispsoftc *isp, char *msg)
228{
229 if (isp->isp_osinfo.simqfrozen == 0) {
230 isp_prt(isp, ISP_LOGDEBUG0, "%s: freeze simq (loopdown)", msg);
231 isp->isp_osinfo.simqfrozen |= SIMQFRZ_LOOPDOWN;
232 ISPLOCK_2_CAMLOCK(isp);
233 xpt_freeze_simq(isp->isp_sim, 1);
234 CAMLOCK_2_ISPLOCK(isp);

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

588}
589
590/*
591 * Put the target mode functions here, because some are inlines
592 */
593
594#ifdef ISP_TARGET_MODE
595
227isp_freeze_loopdown(struct ispsoftc *isp, char *msg)
228{
229 if (isp->isp_osinfo.simqfrozen == 0) {
230 isp_prt(isp, ISP_LOGDEBUG0, "%s: freeze simq (loopdown)", msg);
231 isp->isp_osinfo.simqfrozen |= SIMQFRZ_LOOPDOWN;
232 ISPLOCK_2_CAMLOCK(isp);
233 xpt_freeze_simq(isp->isp_sim, 1);
234 CAMLOCK_2_ISPLOCK(isp);

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

588}
589
590/*
591 * Put the target mode functions here, because some are inlines
592 */
593
594#ifdef ISP_TARGET_MODE
595
596static INLINE int is_lun_enabled(struct ispsoftc *, int, lun_id_t);
597static INLINE int are_any_luns_enabled(struct ispsoftc *, int);
598static INLINE tstate_t *get_lun_statep(struct ispsoftc *, int, lun_id_t);
599static INLINE void rls_lun_statep(struct ispsoftc *, tstate_t *);
600static INLINE atio_private_data_t *isp_get_atpd(struct ispsoftc *, int);
596static __inline int is_lun_enabled(struct ispsoftc *, int, lun_id_t);
597static __inline int are_any_luns_enabled(struct ispsoftc *, int);
598static __inline tstate_t *get_lun_statep(struct ispsoftc *, int, lun_id_t);
599static __inline void rls_lun_statep(struct ispsoftc *, tstate_t *);
600static __inline atio_private_data_t *isp_get_atpd(struct ispsoftc *, int);
601static cam_status
602create_lun_state(struct ispsoftc *, int, struct cam_path *, tstate_t **);
603static void destroy_lun_state(struct ispsoftc *, tstate_t *);
604static int isp_en_lun(struct ispsoftc *, union ccb *);
605static void isp_ledone(struct ispsoftc *, lun_entry_t *);
606static cam_status isp_abort_tgt_ccb(struct ispsoftc *, union ccb *);
607static timeout_t isp_refire_putback_atio;
608static void isp_complete_ctio(union ccb *);
609static void isp_target_putback_atio(union ccb *);
610static cam_status isp_target_start_ctio(struct ispsoftc *, union ccb *);
611static int isp_handle_platform_atio(struct ispsoftc *, at_entry_t *);
612static int isp_handle_platform_atio2(struct ispsoftc *, at2_entry_t *);
613static int isp_handle_platform_ctio(struct ispsoftc *, void *);
614static int isp_handle_platform_notify_scsi(struct ispsoftc *, in_entry_t *);
615static int isp_handle_platform_notify_fc(struct ispsoftc *, in_fcentry_t *);
616
601static cam_status
602create_lun_state(struct ispsoftc *, int, struct cam_path *, tstate_t **);
603static void destroy_lun_state(struct ispsoftc *, tstate_t *);
604static int isp_en_lun(struct ispsoftc *, union ccb *);
605static void isp_ledone(struct ispsoftc *, lun_entry_t *);
606static cam_status isp_abort_tgt_ccb(struct ispsoftc *, union ccb *);
607static timeout_t isp_refire_putback_atio;
608static void isp_complete_ctio(union ccb *);
609static void isp_target_putback_atio(union ccb *);
610static cam_status isp_target_start_ctio(struct ispsoftc *, union ccb *);
611static int isp_handle_platform_atio(struct ispsoftc *, at_entry_t *);
612static int isp_handle_platform_atio2(struct ispsoftc *, at2_entry_t *);
613static int isp_handle_platform_ctio(struct ispsoftc *, void *);
614static int isp_handle_platform_notify_scsi(struct ispsoftc *, in_entry_t *);
615static int isp_handle_platform_notify_fc(struct ispsoftc *, in_fcentry_t *);
616
617static INLINE int
617static __inline int
618is_lun_enabled(struct ispsoftc *isp, int bus, lun_id_t lun)
619{
620 tstate_t *tptr;
621 tptr = isp->isp_osinfo.lun_hash[LUN_HASH_FUNC(isp, bus, lun)];
622 if (tptr == NULL) {
623 return (0);
624 }
625 do {
626 if (tptr->lun == (lun_id_t) lun && tptr->bus == bus) {
627 return (1);
628 }
629 } while ((tptr = tptr->next) != NULL);
630 return (0);
631}
632
618is_lun_enabled(struct ispsoftc *isp, int bus, lun_id_t lun)
619{
620 tstate_t *tptr;
621 tptr = isp->isp_osinfo.lun_hash[LUN_HASH_FUNC(isp, bus, lun)];
622 if (tptr == NULL) {
623 return (0);
624 }
625 do {
626 if (tptr->lun == (lun_id_t) lun && tptr->bus == bus) {
627 return (1);
628 }
629 } while ((tptr = tptr->next) != NULL);
630 return (0);
631}
632
633static INLINE int
633static __inline int
634are_any_luns_enabled(struct ispsoftc *isp, int port)
635{
636 int lo, hi;
637 if (IS_DUALBUS(isp)) {
638 lo = (port * (LUN_HASH_SIZE >> 1));
639 hi = lo + (LUN_HASH_SIZE >> 1);
640 } else {
641 lo = 0;
642 hi = LUN_HASH_SIZE;
643 }
644 for (lo = 0; lo < hi; lo++) {
645 if (isp->isp_osinfo.lun_hash[lo]) {
646 return (1);
647 }
648 }
649 return (0);
650}
651
634are_any_luns_enabled(struct ispsoftc *isp, int port)
635{
636 int lo, hi;
637 if (IS_DUALBUS(isp)) {
638 lo = (port * (LUN_HASH_SIZE >> 1));
639 hi = lo + (LUN_HASH_SIZE >> 1);
640 } else {
641 lo = 0;
642 hi = LUN_HASH_SIZE;
643 }
644 for (lo = 0; lo < hi; lo++) {
645 if (isp->isp_osinfo.lun_hash[lo]) {
646 return (1);
647 }
648 }
649 return (0);
650}
651
652static INLINE tstate_t *
652static __inline tstate_t *
653get_lun_statep(struct ispsoftc *isp, int bus, lun_id_t lun)
654{
655 tstate_t *tptr = NULL;
656
657 if (lun == CAM_LUN_WILDCARD) {
658 if (isp->isp_osinfo.tmflags[bus] & TM_WILDCARD_ENABLED) {
659 tptr = &isp->isp_osinfo.tsdflt[bus];
660 tptr->hold++;

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

672 if (tptr->lun == lun && tptr->bus == bus) {
673 tptr->hold++;
674 return (tptr);
675 }
676 } while ((tptr = tptr->next) != NULL);
677 return (tptr);
678}
679
653get_lun_statep(struct ispsoftc *isp, int bus, lun_id_t lun)
654{
655 tstate_t *tptr = NULL;
656
657 if (lun == CAM_LUN_WILDCARD) {
658 if (isp->isp_osinfo.tmflags[bus] & TM_WILDCARD_ENABLED) {
659 tptr = &isp->isp_osinfo.tsdflt[bus];
660 tptr->hold++;

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

672 if (tptr->lun == lun && tptr->bus == bus) {
673 tptr->hold++;
674 return (tptr);
675 }
676 } while ((tptr = tptr->next) != NULL);
677 return (tptr);
678}
679
680static INLINE void
680static __inline void
681rls_lun_statep(struct ispsoftc *isp, tstate_t *tptr)
682{
683 if (tptr->hold)
684 tptr->hold--;
685}
686
681rls_lun_statep(struct ispsoftc *isp, tstate_t *tptr)
682{
683 if (tptr->hold)
684 tptr->hold--;
685}
686
687static INLINE atio_private_data_t *
687static __inline atio_private_data_t *
688isp_get_atpd(struct ispsoftc *isp, int tag)
689{
690 atio_private_data_t *atp;
691 for (atp = isp->isp_osinfo.atpdp;
692 atp < &isp->isp_osinfo.atpdp[ATPDPSIZE]; atp++) {
693 if (atp->tag == tag)
694 return (atp);
695 }

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

737 while (tptr->next)
738 tptr = tptr->next;
739 tptr->next = new;
740 }
741 *rslt = new;
742 return (CAM_REQ_CMP);
743}
744
688isp_get_atpd(struct ispsoftc *isp, int tag)
689{
690 atio_private_data_t *atp;
691 for (atp = isp->isp_osinfo.atpdp;
692 atp < &isp->isp_osinfo.atpdp[ATPDPSIZE]; atp++) {
693 if (atp->tag == tag)
694 return (atp);
695 }

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

737 while (tptr->next)
738 tptr = tptr->next;
739 tptr->next = new;
740 }
741 *rslt = new;
742 return (CAM_REQ_CMP);
743}
744
745static INLINE void
745static __inline void
746destroy_lun_state(struct ispsoftc *isp, tstate_t *tptr)
747{
748 int hfx;
749 tstate_t *lw, *pw;
750
751 if (tptr->hold) {
752 return;
753 }

--- 2421 unchanged lines hidden ---
746destroy_lun_state(struct ispsoftc *isp, tstate_t *tptr)
747{
748 int hfx;
749 tstate_t *lw, *pw;
750
751 if (tptr->hold) {
752 return;
753 }

--- 2421 unchanged lines hidden ---