aac.c (177184) | aac.c (177462) |
---|---|
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 --- 14 unchanged lines hidden (view full) --- 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 30#include <sys/cdefs.h> | 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 --- 14 unchanged lines hidden (view full) --- 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 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 177184 2008-03-14 21:59:11Z emaste $"); | 31__FBSDID("$FreeBSD: head/sys/dev/aac/aac.c 177462 2008-03-20 17:59:19Z emaste $"); |
32 33/* 34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 35 */ 36#define AAC_DRIVER_VERSION 0x02000000 37#define AAC_DRIVERNAME "aac" 38 39#include "opt_aac.h" --- 168 unchanged lines hidden (view full) --- 208 u_int32_t code); 209 210/* Management Interface */ 211static d_open_t aac_open; 212static d_close_t aac_close; 213static d_ioctl_t aac_ioctl; 214static d_poll_t aac_poll; 215static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib); | 32 33/* 34 * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. 35 */ 36#define AAC_DRIVER_VERSION 0x02000000 37#define AAC_DRIVERNAME "aac" 38 39#include "opt_aac.h" --- 168 unchanged lines hidden (view full) --- 208 u_int32_t code); 209 210/* Management Interface */ 211static d_open_t aac_open; 212static d_close_t aac_close; 213static d_ioctl_t aac_ioctl; 214static d_poll_t aac_poll; 215static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib); |
216static int aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg); |
|
216static void aac_handle_aif(struct aac_softc *sc, 217 struct aac_fib *fib); 218static int aac_rev_check(struct aac_softc *sc, caddr_t udata); 219static int aac_open_aif(struct aac_softc *sc, caddr_t arg); 220static int aac_close_aif(struct aac_softc *sc, caddr_t arg); 221static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg); 222static int aac_return_aif(struct aac_softc *sc, 223 struct aac_fib_context *ctx, caddr_t uptr); --- 1464 unchanged lines hidden (view full) --- 1688 sc->aac_sg_tablesize = (options >> 16); 1689 options = AAC_GET_MAILBOX(sc, 3); 1690 sc->aac_max_fibs = (options & 0xFFFF); 1691 } 1692 if (sc->aac_max_fib_size > PAGE_SIZE) 1693 sc->aac_max_fib_size = PAGE_SIZE; 1694 sc->aac_max_fibs_alloc = PAGE_SIZE / sc->aac_max_fib_size; 1695 | 217static void aac_handle_aif(struct aac_softc *sc, 218 struct aac_fib *fib); 219static int aac_rev_check(struct aac_softc *sc, caddr_t udata); 220static int aac_open_aif(struct aac_softc *sc, caddr_t arg); 221static int aac_close_aif(struct aac_softc *sc, caddr_t arg); 222static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg); 223static int aac_return_aif(struct aac_softc *sc, 224 struct aac_fib_context *ctx, caddr_t uptr); --- 1464 unchanged lines hidden (view full) --- 1689 sc->aac_sg_tablesize = (options >> 16); 1690 options = AAC_GET_MAILBOX(sc, 3); 1691 sc->aac_max_fibs = (options & 0xFFFF); 1692 } 1693 if (sc->aac_max_fib_size > PAGE_SIZE) 1694 sc->aac_max_fib_size = PAGE_SIZE; 1695 sc->aac_max_fibs_alloc = PAGE_SIZE / sc->aac_max_fib_size; 1696 |
1697 if (sc->aac_max_fib_size > sizeof(struct aac_fib)) { 1698 sc->flags |= AAC_FLAGS_RAW_IO; 1699 device_printf(sc->aac_dev, "Enable Raw I/O\n"); 1700 } 1701 |
|
1696 return (0); 1697} 1698 1699static int 1700aac_init(struct aac_softc *sc) 1701{ 1702 struct aac_adapter_init *ip; 1703 time_t then; --- 1178 unchanged lines hidden (view full) --- 2882 break; 2883 default: 2884 error = ENOENT; 2885 break; 2886 } 2887 break; 2888 2889 case FSACTL_SENDFIB: | 1702 return (0); 1703} 1704 1705static int 1706aac_init(struct aac_softc *sc) 1707{ 1708 struct aac_adapter_init *ip; 1709 time_t then; --- 1178 unchanged lines hidden (view full) --- 2888 break; 2889 default: 2890 error = ENOENT; 2891 break; 2892 } 2893 break; 2894 2895 case FSACTL_SENDFIB: |
2896 case FSACTL_SEND_LARGE_FIB: |
|
2890 arg = *(caddr_t*)arg; 2891 case FSACTL_LNX_SENDFIB: | 2897 arg = *(caddr_t*)arg; 2898 case FSACTL_LNX_SENDFIB: |
2899 case FSACTL_LNX_SEND_LARGE_FIB: |
|
2892 debug(1, "FSACTL_SENDFIB"); 2893 error = aac_ioctl_sendfib(sc, arg); 2894 break; | 2900 debug(1, "FSACTL_SENDFIB"); 2901 error = aac_ioctl_sendfib(sc, arg); 2902 break; |
2903 case FSACTL_SEND_RAW_SRB: 2904 arg = *(caddr_t*)arg; 2905 case FSACTL_LNX_SEND_RAW_SRB: 2906 debug(1, "FSACTL_SEND_RAW_SRB"); 2907 error = aac_ioctl_send_raw_srb(sc, arg); 2908 break; |
|
2895 case FSACTL_AIF_THREAD: 2896 case FSACTL_LNX_AIF_THREAD: 2897 debug(1, "FSACTL_AIF_THREAD"); 2898 error = EINVAL; 2899 break; 2900 case FSACTL_OPEN_GET_ADAPTER_FIB: 2901 arg = *(caddr_t*)arg; 2902 case FSACTL_LNX_OPEN_GET_ADAPTER_FIB: --- 127 unchanged lines hidden (view full) --- 3030 3031 /* 3032 * Fetch the FIB header, then re-copy to get data as well. 3033 */ 3034 if ((error = copyin(ufib, cm->cm_fib, 3035 sizeof(struct aac_fib_header))) != 0) 3036 goto out; 3037 size = cm->cm_fib->Header.Size + sizeof(struct aac_fib_header); | 2909 case FSACTL_AIF_THREAD: 2910 case FSACTL_LNX_AIF_THREAD: 2911 debug(1, "FSACTL_AIF_THREAD"); 2912 error = EINVAL; 2913 break; 2914 case FSACTL_OPEN_GET_ADAPTER_FIB: 2915 arg = *(caddr_t*)arg; 2916 case FSACTL_LNX_OPEN_GET_ADAPTER_FIB: --- 127 unchanged lines hidden (view full) --- 3044 3045 /* 3046 * Fetch the FIB header, then re-copy to get data as well. 3047 */ 3048 if ((error = copyin(ufib, cm->cm_fib, 3049 sizeof(struct aac_fib_header))) != 0) 3050 goto out; 3051 size = cm->cm_fib->Header.Size + sizeof(struct aac_fib_header); |
3038 if (size > sizeof(struct aac_fib)) { 3039 device_printf(sc->aac_dev, "incoming FIB oversized (%d > %zd)\n", 3040 size, sizeof(struct aac_fib)); 3041 size = sizeof(struct aac_fib); | 3052 if (size > sc->aac_max_fib_size) { 3053 device_printf(sc->aac_dev, "incoming FIB oversized (%d > %d)\n", 3054 size, sc->aac_max_fib_size); 3055 size = sc->aac_max_fib_size; |
3042 } 3043 if ((error = copyin(ufib, cm->cm_fib, size)) != 0) 3044 goto out; 3045 cm->cm_fib->Header.Size = size; 3046 cm->cm_timestamp = time_uptime; 3047 3048 /* 3049 * Pass the FIB to the controller, wait for it to complete. --- 6 unchanged lines hidden (view full) --- 3056 "aac_wait_command return %d\n", error); 3057 goto out; 3058 } 3059 3060 /* 3061 * Copy the FIB and data back out to the caller. 3062 */ 3063 size = cm->cm_fib->Header.Size; | 3056 } 3057 if ((error = copyin(ufib, cm->cm_fib, size)) != 0) 3058 goto out; 3059 cm->cm_fib->Header.Size = size; 3060 cm->cm_timestamp = time_uptime; 3061 3062 /* 3063 * Pass the FIB to the controller, wait for it to complete. --- 6 unchanged lines hidden (view full) --- 3070 "aac_wait_command return %d\n", error); 3071 goto out; 3072 } 3073 3074 /* 3075 * Copy the FIB and data back out to the caller. 3076 */ 3077 size = cm->cm_fib->Header.Size; |
3064 if (size > sizeof(struct aac_fib)) { 3065 device_printf(sc->aac_dev, "outbound FIB oversized (%d > %zd)\n", 3066 size, sizeof(struct aac_fib)); 3067 size = sizeof(struct aac_fib); | 3078 if (size > sc->aac_max_fib_size) { 3079 device_printf(sc->aac_dev, "outbound FIB oversized (%d > %d)\n", 3080 size, sc->aac_max_fib_size); 3081 size = sc->aac_max_fib_size; |
3068 } 3069 error = copyout(cm->cm_fib, ufib, size); 3070 3071out: 3072 if (cm != NULL) { 3073 mtx_lock(&sc->aac_io_lock); 3074 aac_release_command(cm); 3075 mtx_unlock(&sc->aac_io_lock); 3076 } 3077 return(error); 3078} 3079 3080/* | 3082 } 3083 error = copyout(cm->cm_fib, ufib, size); 3084 3085out: 3086 if (cm != NULL) { 3087 mtx_lock(&sc->aac_io_lock); 3088 aac_release_command(cm); 3089 mtx_unlock(&sc->aac_io_lock); 3090 } 3091 return(error); 3092} 3093 3094/* |
3095 * Send a passthrough FIB supplied from userspace 3096 */ 3097static int 3098aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg) 3099{ 3100 return (EINVAL); 3101} 3102 3103/* |
|
3081 * Handle an AIF sent to us by the controller; queue it for later reference. 3082 * If the queue fills up, then drop the older entries. 3083 */ 3084static void 3085aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib) 3086{ 3087 struct aac_aif_command *aif; 3088 struct aac_container *co, *co_next; --- 532 unchanged lines hidden --- | 3104 * Handle an AIF sent to us by the controller; queue it for later reference. 3105 * If the queue fills up, then drop the older entries. 3106 */ 3107static void 3108aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib) 3109{ 3110 struct aac_aif_command *aif; 3111 struct aac_container *co, *co_next; --- 532 unchanged lines hidden --- |