isp.c (291502) | isp.c (291503) |
---|---|
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 * --- 33 unchanged lines hidden (view full) --- 42 */ 43#ifdef __NetBSD__ 44#include <sys/cdefs.h> 45__KERNEL_RCSID(0, "$NetBSD$"); 46#include <dev/ic/isp_netbsd.h> 47#endif 48#ifdef __FreeBSD__ 49#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 * --- 33 unchanged lines hidden (view full) --- 42 */ 43#ifdef __NetBSD__ 44#include <sys/cdefs.h> 45__KERNEL_RCSID(0, "$NetBSD$"); 46#include <dev/ic/isp_netbsd.h> 47#endif 48#ifdef __FreeBSD__ 49#include <sys/cdefs.h> |
50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 291502 2015-11-30 21:31:34Z mav $"); | 50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 291503 2015-11-30 21:32:12Z mav $"); |
51#include <dev/isp/isp_freebsd.h> 52#endif 53#ifdef __OpenBSD__ 54#include <dev/ic/isp_openbsd.h> 55#endif 56#ifdef __linux__ 57#include "isp_linux.h" 58#endif --- 2692 unchanged lines hidden (view full) --- 2751/* 2752 * Make sure we have good FC link. 2753 */ 2754 2755static int 2756isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay) 2757{ 2758 mbreg_t mbs; | 51#include <dev/isp/isp_freebsd.h> 52#endif 53#ifdef __OpenBSD__ 54#include <dev/ic/isp_openbsd.h> 55#endif 56#ifdef __linux__ 57#include "isp_linux.h" 58#endif --- 2692 unchanged lines hidden (view full) --- 2751/* 2752 * Make sure we have good FC link. 2753 */ 2754 2755static int 2756isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay) 2757{ 2758 mbreg_t mbs; |
2759 int count, check_for_fabric, r; | 2759 int check_for_fabric, r; |
2760 uint8_t lwfs; 2761 int loopid; 2762 fcparam *fcp; 2763 fcportdb_t *lp; 2764 isp_pdb_t pdb; | 2760 uint8_t lwfs; 2761 int loopid; 2762 fcparam *fcp; 2763 fcportdb_t *lp; 2764 isp_pdb_t pdb; |
2765 NANOTIME_T hra, hrb; |
|
2765 2766 fcp = FCPARAM(isp, chan); 2767 2768 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Entry", chan); 2769 ISP_MARK_PORTDB(isp, chan, 1); 2770 2771 /* 2772 * Wait up to N microseconds for F/W to go to a ready state. 2773 */ 2774 lwfs = FW_CONFIG_WAIT; | 2766 2767 fcp = FCPARAM(isp, chan); 2768 2769 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Entry", chan); 2770 ISP_MARK_PORTDB(isp, chan, 1); 2771 2772 /* 2773 * Wait up to N microseconds for F/W to go to a ready state. 2774 */ 2775 lwfs = FW_CONFIG_WAIT; |
2775 count = 0; 2776 while (count < usdelay) { 2777 uint64_t enano; 2778 uint32_t wrk; 2779 NANOTIME_T hra, hrb; 2780 2781 GET_NANOTIME(&hra); | 2776 GET_NANOTIME(&hra); 2777 do { |
2782 isp_fw_state(isp, chan); 2783 if (lwfs != fcp->isp_fwstate) { 2784 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), isp_fc_fw_statename((int)fcp->isp_fwstate)); 2785 lwfs = fcp->isp_fwstate; 2786 } 2787 if (fcp->isp_fwstate == FW_READY) { 2788 break; 2789 } | 2778 isp_fw_state(isp, chan); 2779 if (lwfs != fcp->isp_fwstate) { 2780 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), isp_fc_fw_statename((int)fcp->isp_fwstate)); 2781 lwfs = fcp->isp_fwstate; 2782 } 2783 if (fcp->isp_fwstate == FW_READY) { 2784 break; 2785 } |
2786 ISP_SLEEP(isp, 1000); |
|
2790 GET_NANOTIME(&hrb); | 2787 GET_NANOTIME(&hrb); |
2788 } while (NANOTIME_SUB(&hrb, &hra) / 1000 < usdelay); |
|
2791 | 2789 |
2792 /* 2793 * Get the elapsed time in nanoseconds. 2794 * Always guaranteed to be non-zero. 2795 */ 2796 enano = NANOTIME_SUB(&hrb, &hra); 2797 2798 isp_prt(isp, ISP_LOGDEBUG1, "usec%d: 0x%lx->0x%lx enano 0x%x%08x", count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb), (uint32_t)(enano >> 32), (uint32_t)(enano)); 2799 2800 /* 2801 * If the elapsed time is less than 1 millisecond, 2802 * delay a period of time up to that millisecond of 2803 * waiting. 2804 * 2805 * This peculiar code is an attempt to try and avoid 2806 * invoking uint64_t math support functions for some 2807 * platforms where linkage is a problem. 2808 */ 2809 if (enano < (1000 * 1000)) { 2810 count += 1000; 2811 enano = (1000 * 1000) - enano; 2812 while (enano > (uint64_t) 4000000000U) { 2813 ISP_SLEEP(isp, 4000000); 2814 enano -= (uint64_t) 4000000000U; 2815 } 2816 wrk = enano; 2817 wrk /= 1000; 2818 ISP_SLEEP(isp, wrk); 2819 } else { 2820 while (enano > (uint64_t) 4000000000U) { 2821 count += 4000000; 2822 enano -= (uint64_t) 4000000000U; 2823 } 2824 wrk = enano; 2825 count += (wrk / 1000); 2826 } 2827 } 2828 2829 2830 | |
2831 /* 2832 * If we haven't gone to 'ready' state, return. 2833 */ 2834 if (fcp->isp_fwstate != FW_READY) { 2835 isp_prt(isp, ISP_LOG_SANCFG, "%s: chan %d not at FW_READY state", __func__, chan); 2836 return (-1); 2837 } 2838 --- 5750 unchanged lines hidden --- | 2790 /* 2791 * If we haven't gone to 'ready' state, return. 2792 */ 2793 if (fcp->isp_fwstate != FW_READY) { 2794 isp_prt(isp, ISP_LOG_SANCFG, "%s: chan %d not at FW_READY state", __func__, chan); 2795 return (-1); 2796 } 2797 --- 5750 unchanged lines hidden --- |