aac.c (81154) | aac.c (81189) |
---|---|
1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2001 Scott Long 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 Adaptec, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2001 Scott Long 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 Adaptec, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/aac/aac.c 81154 2001-08-05 07:26:31Z scottl $ | 29 * $FreeBSD: head/sys/dev/aac/aac.c 81189 2001-08-06 04:34:47Z scottl $ |
30 */ 31 32/* 33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 34 */ 35 36#include "opt_aac.h" 37 --- 114 unchanged lines hidden (view full) --- 152 153/* Management Interface */ 154static d_open_t aac_open; 155static d_close_t aac_close; 156static d_ioctl_t aac_ioctl; 157static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib); 158static void aac_handle_aif(struct aac_softc *sc, 159 struct aac_aif_command *aif); | 30 */ 31 32/* 33 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 34 */ 35 36#include "opt_aac.h" 37 --- 114 unchanged lines hidden (view full) --- 152 153/* Management Interface */ 154static d_open_t aac_open; 155static d_close_t aac_close; 156static d_ioctl_t aac_ioctl; 157static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib); 158static void aac_handle_aif(struct aac_softc *sc, 159 struct aac_aif_command *aif); |
160#ifdef AAC_COMPAT_LINUX 161static int aac_linux_rev_check(struct aac_softc *sc, 162 caddr_t udata); 163static int aac_linux_getnext_aif(struct aac_softc *sc, 164 caddr_t arg); 165static int aac_linux_return_aif(struct aac_softc *sc, 166 caddr_t uptr); 167#endif | 160static int aac_rev_check(struct aac_softc *sc, caddr_t udata); 161static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg); 162static int aac_return_aif(struct aac_softc *sc, caddr_t uptr); |
168 169#define AAC_CDEV_MAJOR 150 170 171static struct cdevsw aac_cdevsw = { 172 aac_open, /* open */ 173 aac_close, /* close */ 174 noread, /* read */ 175 nowrite, /* write */ --- 1594 unchanged lines hidden (view full) --- 1770} 1771 1772static int 1773aac_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) 1774{ 1775 union aac_statrequest *as = (union aac_statrequest *)arg; 1776 struct aac_softc *sc = dev->si_drv1; 1777 int error = 0; | 163 164#define AAC_CDEV_MAJOR 150 165 166static struct cdevsw aac_cdevsw = { 167 aac_open, /* open */ 168 aac_close, /* close */ 169 noread, /* read */ 170 nowrite, /* write */ --- 1594 unchanged lines hidden (view full) --- 1765} 1766 1767static int 1768aac_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) 1769{ 1770 union aac_statrequest *as = (union aac_statrequest *)arg; 1771 struct aac_softc *sc = dev->si_drv1; 1772 int error = 0; |
1778#ifdef AAC_COMPAT_LINUX | |
1779 int i; | 1773 int i; |
1780#endif | |
1781 1782 debug_called(2); 1783 1784 switch (cmd) { 1785 case AACIO_STATS: 1786 switch (as->as_item) { 1787 case AACQ_FREE: 1788 case AACQ_BIO: --- 4 unchanged lines hidden (view full) --- 1793 sizeof(struct aac_qstat)); 1794 break; 1795 default: 1796 error = ENOENT; 1797 break; 1798 } 1799 break; 1800 | 1774 1775 debug_called(2); 1776 1777 switch (cmd) { 1778 case AACIO_STATS: 1779 switch (as->as_item) { 1780 case AACQ_FREE: 1781 case AACQ_BIO: --- 4 unchanged lines hidden (view full) --- 1786 sizeof(struct aac_qstat)); 1787 break; 1788 default: 1789 error = ENOENT; 1790 break; 1791 } 1792 break; 1793 |
1801#ifdef AAC_COMPAT_LINUX | |
1802 case FSACTL_SENDFIB: | 1794 case FSACTL_SENDFIB: |
1795 arg = *(caddr_t *)arg; 1796 case FSACTL_LNX_SENDFIB: |
|
1803 debug(1, "FSACTL_SENDFIB"); 1804 error = aac_ioctl_sendfib(sc, arg); 1805 break; 1806 case FSACTL_AIF_THREAD: | 1797 debug(1, "FSACTL_SENDFIB"); 1798 error = aac_ioctl_sendfib(sc, arg); 1799 break; 1800 case FSACTL_AIF_THREAD: |
1801 case FSACTL_LNX_AIF_THREAD: |
|
1807 debug(1, "FSACTL_AIF_THREAD"); 1808 error = EINVAL; 1809 break; 1810 case FSACTL_OPEN_GET_ADAPTER_FIB: | 1802 debug(1, "FSACTL_AIF_THREAD"); 1803 error = EINVAL; 1804 break; 1805 case FSACTL_OPEN_GET_ADAPTER_FIB: |
1806 arg = *(caddr_t *)arg; 1807 case FSACTL_LNX_OPEN_GET_ADAPTER_FIB: |
|
1811 debug(1, "FSACTL_OPEN_GET_ADAPTER_FIB"); 1812 /* 1813 * Pass the caller out an AdapterFibContext. 1814 * 1815 * Note that because we only support one opener, we 1816 * basically ignore this. Set the caller's context to a magic 1817 * number just in case. 1818 * 1819 * The Linux code hands the driver a pointer into kernel space, 1820 * and then trusts it when the caller hands it back. Aiee! 1821 */ 1822 i = AAC_AIF_SILLYMAGIC; 1823 error = copyout(&i, arg, sizeof(i)); 1824 break; 1825 case FSACTL_GET_NEXT_ADAPTER_FIB: | 1808 debug(1, "FSACTL_OPEN_GET_ADAPTER_FIB"); 1809 /* 1810 * Pass the caller out an AdapterFibContext. 1811 * 1812 * Note that because we only support one opener, we 1813 * basically ignore this. Set the caller's context to a magic 1814 * number just in case. 1815 * 1816 * The Linux code hands the driver a pointer into kernel space, 1817 * and then trusts it when the caller hands it back. Aiee! 1818 */ 1819 i = AAC_AIF_SILLYMAGIC; 1820 error = copyout(&i, arg, sizeof(i)); 1821 break; 1822 case FSACTL_GET_NEXT_ADAPTER_FIB: |
1823 arg = *(caddr_t *)arg; 1824 case FSACTL_LNX_GET_NEXT_ADAPTER_FIB: |
|
1826 debug(1, "FSACTL_GET_NEXT_ADAPTER_FIB"); | 1825 debug(1, "FSACTL_GET_NEXT_ADAPTER_FIB"); |
1827 error = aac_linux_getnext_aif(sc, arg); | 1826 error = aac_getnext_aif(sc, arg); |
1828 break; 1829 case FSACTL_CLOSE_GET_ADAPTER_FIB: | 1827 break; 1828 case FSACTL_CLOSE_GET_ADAPTER_FIB: |
1829 case FSACTL_LNX_CLOSE_GET_ADAPTER_FIB: |
|
1830 debug(1, "FSACTL_CLOSE_GET_ADAPTER_FIB"); 1831 /* don't do anything here */ 1832 break; 1833 case FSACTL_MINIPORT_REV_CHECK: | 1830 debug(1, "FSACTL_CLOSE_GET_ADAPTER_FIB"); 1831 /* don't do anything here */ 1832 break; 1833 case FSACTL_MINIPORT_REV_CHECK: |
1834 arg = *(caddr_t *)arg; 1835 case FSACTL_LNX_MINIPORT_REV_CHECK: |
|
1834 debug(1, "FSACTL_MINIPORT_REV_CHECK"); | 1836 debug(1, "FSACTL_MINIPORT_REV_CHECK"); |
1835 error = aac_linux_rev_check(sc, arg); | 1837 error = aac_rev_check(sc, arg); |
1836 break; | 1838 break; |
1837#endif | |
1838 default: 1839 device_printf(sc->aac_dev, "unsupported cmd 0x%lx\n", cmd); 1840 error = EINVAL; 1841 break; 1842 } 1843 return(error); 1844} 1845 --- 118 unchanged lines hidden (view full) --- 1964 u_long cmd = args->cmd; 1965 1966 /* 1967 * Pass the ioctl off to our standard handler. 1968 */ 1969 return(fo_ioctl(fp, cmd, (caddr_t)args->arg, p)); 1970} 1971 | 1839 default: 1840 device_printf(sc->aac_dev, "unsupported cmd 0x%lx\n", cmd); 1841 error = EINVAL; 1842 break; 1843 } 1844 return(error); 1845} 1846 --- 118 unchanged lines hidden (view full) --- 1965 u_long cmd = args->cmd; 1966 1967 /* 1968 * Pass the ioctl off to our standard handler. 1969 */ 1970 return(fo_ioctl(fp, cmd, (caddr_t)args->arg, p)); 1971} 1972 |
1973#endif 1974 |
|
1972/****************************************************************************** 1973 * Return the Revision of the driver to userspace and check to see if the 1974 * userspace app is possibly compatible. This is extremely bogus right now 1975 * because I have no idea how to handle the versioning of this driver. It is 1976 * needed, though, to get aaccli working. 1977 */ 1978static int | 1975/****************************************************************************** 1976 * Return the Revision of the driver to userspace and check to see if the 1977 * userspace app is possibly compatible. This is extremely bogus right now 1978 * because I have no idea how to handle the versioning of this driver. It is 1979 * needed, though, to get aaccli working. 1980 */ 1981static int |
1979aac_linux_rev_check(struct aac_softc *sc, caddr_t udata) | 1982aac_rev_check(struct aac_softc *sc, caddr_t udata) |
1980{ 1981 struct aac_rev_check rev_check; 1982 struct aac_rev_check_resp rev_check_resp; 1983 int error = 0; 1984 1985 debug_called(2); 1986 1987 /* --- 16 unchanged lines hidden (view full) --- 2004 return(copyout((caddr_t)&rev_check_resp, udata, 2005 sizeof(struct aac_rev_check_resp))); 2006} 2007 2008/****************************************************************************** 2009 * Pass the caller the next AIF in their queue 2010 */ 2011static int | 1983{ 1984 struct aac_rev_check rev_check; 1985 struct aac_rev_check_resp rev_check_resp; 1986 int error = 0; 1987 1988 debug_called(2); 1989 1990 /* --- 16 unchanged lines hidden (view full) --- 2007 return(copyout((caddr_t)&rev_check_resp, udata, 2008 sizeof(struct aac_rev_check_resp))); 2009} 2010 2011/****************************************************************************** 2012 * Pass the caller the next AIF in their queue 2013 */ 2014static int |
2012aac_linux_getnext_aif(struct aac_softc *sc, caddr_t arg) | 2015aac_getnext_aif(struct aac_softc *sc, caddr_t arg) |
2013{ 2014 struct get_adapter_fib_ioctl agf; 2015 int error, s; 2016 2017 debug_called(2); 2018 2019 if ((error = copyin(arg, &agf, sizeof(agf))) == 0) { 2020 2021 /* 2022 * Check the magic number that we gave the caller. 2023 */ 2024 if (agf.AdapterFibContext != AAC_AIF_SILLYMAGIC) { 2025 error = EFAULT; 2026 } else { 2027 2028 s = splbio(); | 2016{ 2017 struct get_adapter_fib_ioctl agf; 2018 int error, s; 2019 2020 debug_called(2); 2021 2022 if ((error = copyin(arg, &agf, sizeof(agf))) == 0) { 2023 2024 /* 2025 * Check the magic number that we gave the caller. 2026 */ 2027 if (agf.AdapterFibContext != AAC_AIF_SILLYMAGIC) { 2028 error = EFAULT; 2029 } else { 2030 2031 s = splbio(); |
2029 error = aac_linux_return_aif(sc, agf.AifFib); | 2032 error = aac_return_aif(sc, agf.AifFib); |
2030 2031 if ((error == EAGAIN) && (agf.Wait)) { 2032 sc->aac_state |= AAC_STATE_AIF_SLEEPER; 2033 while (error == EAGAIN) { 2034 error = tsleep(sc->aac_aifq, PRIBIO | PCATCH, "aacaif", 0); 2035 if (error == 0) | 2033 2034 if ((error == EAGAIN) && (agf.Wait)) { 2035 sc->aac_state |= AAC_STATE_AIF_SLEEPER; 2036 while (error == EAGAIN) { 2037 error = tsleep(sc->aac_aifq, PRIBIO | PCATCH, "aacaif", 0); 2038 if (error == 0) |
2036 error = aac_linux_return_aif(sc, agf.AifFib); | 2039 error = aac_return_aif(sc, agf.AifFib); |
2037 } 2038 sc->aac_state &= ~AAC_STATE_AIF_SLEEPER; 2039 } 2040 splx(s); 2041 } 2042 } 2043 return(error); 2044} 2045 2046/****************************************************************************** 2047 * Hand the next AIF off the top of the queue out to userspace. 2048 */ 2049static int | 2040 } 2041 sc->aac_state &= ~AAC_STATE_AIF_SLEEPER; 2042 } 2043 splx(s); 2044 } 2045 } 2046 return(error); 2047} 2048 2049/****************************************************************************** 2050 * Hand the next AIF off the top of the queue out to userspace. 2051 */ 2052static int |
2050aac_linux_return_aif(struct aac_softc *sc, caddr_t uptr) | 2053aac_return_aif(struct aac_softc *sc, caddr_t uptr) |
2051{ 2052 int error, s; 2053 2054 debug_called(2); 2055 2056 s = splbio(); 2057 if (sc->aac_aifq_tail == sc->aac_aifq_head) { 2058 error = EAGAIN; 2059 } else { 2060 error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, 2061 sizeof(struct aac_aif_command)); 2062 if (!error) 2063 sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % AAC_AIFQ_LENGTH; 2064 } 2065 splx(s); 2066 return(error); 2067} | 2054{ 2055 int error, s; 2056 2057 debug_called(2); 2058 2059 s = splbio(); 2060 if (sc->aac_aifq_tail == sc->aac_aifq_head) { 2061 error = EAGAIN; 2062 } else { 2063 error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, 2064 sizeof(struct aac_aif_command)); 2065 if (!error) 2066 sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % AAC_AIFQ_LENGTH; 2067 } 2068 splx(s); 2069 return(error); 2070} |
2068 2069 2070#endif /* AAC_COMPAT_LINUX */ | |