Deleted Added
full compact
isp_freebsd.c (316143) isp_freebsd.c (316145)
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
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

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

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/*
28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
29 */
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
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

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

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/*
28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
29 */
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: stable/11/sys/dev/isp/isp_freebsd.c 316143 2017-03-29 15:40:45Z mav $");
31__FBSDID("$FreeBSD: stable/11/sys/dev/isp/isp_freebsd.c 316145 2017-03-29 15:42:35Z mav $");
32
33#include <dev/isp/isp_freebsd.h>
34#include <sys/unistd.h>
35#include <sys/kthread.h>
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>
39#include <dev/isp/isp_ioctl.h>

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

507 ifc->node_wwn = lp->node_wwn;
508 ifc->port_wwn = lp->port_wwn;
509 retval = 0;
510 } else {
511 retval = ENODEV;
512 }
513 break;
514 }
32
33#include <dev/isp/isp_freebsd.h>
34#include <sys/unistd.h>
35#include <sys/kthread.h>
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>
39#include <dev/isp/isp_ioctl.h>

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

507 ifc->node_wwn = lp->node_wwn;
508 ifc->port_wwn = lp->port_wwn;
509 retval = 0;
510 } else {
511 retval = ENODEV;
512 }
513 break;
514 }
515 case ISP_GET_STATS:
516 {
517 isp_stats_t *sp = (isp_stats_t *) addr;
518
519 ISP_MEMZERO(sp, sizeof (*sp));
520 sp->isp_stat_version = ISP_STATS_VERSION;
521 sp->isp_type = isp->isp_type;
522 sp->isp_revision = isp->isp_revision;
523 ISP_LOCK(isp);
524 sp->isp_stats[ISP_INTCNT] = isp->isp_intcnt;
525 sp->isp_stats[ISP_INTBOGUS] = isp->isp_intbogus;
526 sp->isp_stats[ISP_INTMBOXC] = isp->isp_intmboxc;
527 sp->isp_stats[ISP_INGOASYNC] = isp->isp_intoasync;
528 sp->isp_stats[ISP_RSLTCCMPLT] = isp->isp_rsltccmplt;
529 sp->isp_stats[ISP_FPHCCMCPLT] = isp->isp_fphccmplt;
530 sp->isp_stats[ISP_RSCCHIWAT] = isp->isp_rscchiwater;
531 sp->isp_stats[ISP_FPCCHIWAT] = isp->isp_fpcchiwater;
532 ISP_UNLOCK(isp);
533 retval = 0;
534 break;
535 }
536 case ISP_CLR_STATS:
537 ISP_LOCK(isp);
538 isp->isp_intcnt = 0;
539 isp->isp_intbogus = 0;
540 isp->isp_intmboxc = 0;
541 isp->isp_intoasync = 0;
542 isp->isp_rsltccmplt = 0;
543 isp->isp_fphccmplt = 0;
544 isp->isp_rscchiwater = 0;
545 isp->isp_fpcchiwater = 0;
546 ISP_UNLOCK(isp);
547 retval = 0;
548 break;
549 case ISP_FC_GETHINFO:
550 {
551 struct isp_hba_device *hba = (struct isp_hba_device *) addr;
552 int chan = hba->fc_channel;
553
554 if (chan < 0 || chan >= isp->isp_nchan) {
555 retval = ENXIO;
556 break;

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

2824 break;
2825 }
2826}
2827
2828static void
2829isp_poll(struct cam_sim *sim)
2830{
2831 ispsoftc_t *isp = cam_sim_softc(sim);
515 case ISP_FC_GETHINFO:
516 {
517 struct isp_hba_device *hba = (struct isp_hba_device *) addr;
518 int chan = hba->fc_channel;
519
520 if (chan < 0 || chan >= isp->isp_nchan) {
521 retval = ENXIO;
522 break;

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

2790 break;
2791 }
2792}
2793
2794static void
2795isp_poll(struct cam_sim *sim)
2796{
2797 ispsoftc_t *isp = cam_sim_softc(sim);
2832 uint16_t isr, sema, info;
2833
2798
2834 if (ISP_READ_ISR(isp, &isr, &sema, &info))
2835 isp_intr(isp, isr, sema, info);
2799 ISP_RUN_ISR(isp);
2836}
2837
2838
2839static void
2840isp_watchdog(void *arg)
2841{
2842 struct ccb_scsiio *xs = arg;
2843 ispsoftc_t *isp;
2844 uint32_t ohandle = ISP_HANDLE_FREE, handle;
2845
2846 isp = XS_ISP(xs);
2847
2848 handle = isp_find_handle(isp, xs);
2849
2850 /*
2851 * Hand crank the interrupt code just to be sure the command isn't stuck somewhere.
2852 */
2853 if (handle != ISP_HANDLE_FREE) {
2800}
2801
2802
2803static void
2804isp_watchdog(void *arg)
2805{
2806 struct ccb_scsiio *xs = arg;
2807 ispsoftc_t *isp;
2808 uint32_t ohandle = ISP_HANDLE_FREE, handle;
2809
2810 isp = XS_ISP(xs);
2811
2812 handle = isp_find_handle(isp, xs);
2813
2814 /*
2815 * Hand crank the interrupt code just to be sure the command isn't stuck somewhere.
2816 */
2817 if (handle != ISP_HANDLE_FREE) {
2854 uint16_t isr, sema, info;
2855 if (ISP_READ_ISR(isp, &isr, &sema, &info) != 0)
2856 isp_intr(isp, isr, sema, info);
2818 ISP_RUN_ISR(isp);
2857 ohandle = handle;
2858 handle = isp_find_handle(isp, xs);
2859 }
2860 if (handle != ISP_HANDLE_FREE) {
2861 /*
2862 * Try and make sure the command is really dead before
2863 * we release the handle (and DMA resources) for reuse.
2864 *

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

4423 isp->isp_osinfo.mbox_sleep_ok = 0;
4424 isp->isp_osinfo.mbox_sleeping = 1;
4425 msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_osinfo.lock,
4426 PRIBIO, "ispmbx_sleep", to * SBT_1US, 0, 0);
4427 isp->isp_osinfo.mbox_sleep_ok = 1;
4428 isp->isp_osinfo.mbox_sleeping = 0;
4429 } else {
4430 for (t = 0; t < to; t += 100) {
2819 ohandle = handle;
2820 handle = isp_find_handle(isp, xs);
2821 }
2822 if (handle != ISP_HANDLE_FREE) {
2823 /*
2824 * Try and make sure the command is really dead before
2825 * we release the handle (and DMA resources) for reuse.
2826 *

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

4385 isp->isp_osinfo.mbox_sleep_ok = 0;
4386 isp->isp_osinfo.mbox_sleeping = 1;
4387 msleep_sbt(&isp->isp_osinfo.mboxcmd_done, &isp->isp_osinfo.lock,
4388 PRIBIO, "ispmbx_sleep", to * SBT_1US, 0, 0);
4389 isp->isp_osinfo.mbox_sleep_ok = 1;
4390 isp->isp_osinfo.mbox_sleeping = 0;
4391 } else {
4392 for (t = 0; t < to; t += 100) {
4431 uint16_t isr, sema, info;
4432 if (isp->isp_osinfo.mboxcmd_done)
4433 break;
4393 if (isp->isp_osinfo.mboxcmd_done)
4394 break;
4434 if (ISP_READ_ISR(isp, &isr, &sema, &info)) {
4435 isp_intr(isp, isr, sema, info);
4436 if (isp->isp_osinfo.mboxcmd_done)
4437 break;
4438 }
4395 ISP_RUN_ISR(isp);
4396 if (isp->isp_osinfo.mboxcmd_done)
4397 break;
4439 ISP_DELAY(100);
4440 }
4441 }
4442 if (isp->isp_osinfo.mboxcmd_done == 0) {
4443 isp_prt(isp, ISP_LOGWARN, "%s Mailbox Command (0x%x) Timeout (%uus) (%s:%d)",
4444 isp->isp_osinfo.mbox_sleep_ok? "Interrupting" : "Polled",
4445 isp->isp_lastmbxcmd, to, mbp->func, mbp->lineno);
4446 mbp->param[0] = MBOX_TIMEOUT;

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

4490 }
4491 return (hz);
4492}
4493
4494void
4495isp_platform_intr(void *arg)
4496{
4497 ispsoftc_t *isp = arg;
4398 ISP_DELAY(100);
4399 }
4400 }
4401 if (isp->isp_osinfo.mboxcmd_done == 0) {
4402 isp_prt(isp, ISP_LOGWARN, "%s Mailbox Command (0x%x) Timeout (%uus) (%s:%d)",
4403 isp->isp_osinfo.mbox_sleep_ok? "Interrupting" : "Polled",
4404 isp->isp_lastmbxcmd, to, mbp->func, mbp->lineno);
4405 mbp->param[0] = MBOX_TIMEOUT;

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

4449 }
4450 return (hz);
4451}
4452
4453void
4454isp_platform_intr(void *arg)
4455{
4456 ispsoftc_t *isp = arg;
4498 uint16_t isr, sema, info;
4499
4500 ISP_LOCK(isp);
4457
4458 ISP_LOCK(isp);
4501 isp->isp_intcnt++;
4502 if (ISP_READ_ISR(isp, &isr, &sema, &info))
4503 isp_intr(isp, isr, sema, info);
4504 else
4505 isp->isp_intbogus++;
4459 ISP_RUN_ISR(isp);
4506 ISP_UNLOCK(isp);
4507}
4508
4509void
4510isp_common_dmateardown(ispsoftc_t *isp, struct ccb_scsiio *csio, uint32_t hdl)
4511{
4512 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
4513 bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_POSTREAD);

--- 108 unchanged lines hidden ---
4460 ISP_UNLOCK(isp);
4461}
4462
4463void
4464isp_common_dmateardown(ispsoftc_t *isp, struct ccb_scsiio *csio, uint32_t hdl)
4465{
4466 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
4467 bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_POSTREAD);

--- 108 unchanged lines hidden ---