11fdeb165SXin LI /* $Id: ldm.h,v 1.78 2010/05/10 10:08:46 lcn Exp $ */ 21fdeb165SXin LI /*- 3*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 4718cf2ccSPedro F. Giffuni * 51fdeb165SXin LI * Copyright (C) 2005-2011 HighPoint Technologies, Inc. 61fdeb165SXin LI * All rights reserved. 71fdeb165SXin LI * 81fdeb165SXin LI * Redistribution and use in source and binary forms, with or without 91fdeb165SXin LI * modification, are permitted provided that the following conditions 101fdeb165SXin LI * are met: 111fdeb165SXin LI * 1. Redistributions of source code must retain the above copyright 121fdeb165SXin LI * notice, this list of conditions and the following disclaimer. 131fdeb165SXin LI * 2. Redistributions in binary form must reproduce the above copyright 141fdeb165SXin LI * notice, this list of conditions and the following disclaimer in the 151fdeb165SXin LI * documentation and/or other materials provided with the distribution. 161fdeb165SXin LI * 171fdeb165SXin LI * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 181fdeb165SXin LI * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191fdeb165SXin LI * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201fdeb165SXin LI * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 211fdeb165SXin LI * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221fdeb165SXin LI * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231fdeb165SXin LI * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241fdeb165SXin LI * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251fdeb165SXin LI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261fdeb165SXin LI * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271fdeb165SXin LI * SUCH DAMAGE. 281fdeb165SXin LI */ 291fdeb165SXin LI #include <dev/hptnr/hptnr_config.h> 301fdeb165SXin LI #ifndef _HPT_LDM_H_ 311fdeb165SXin LI #define _HPT_LDM_H_ 321fdeb165SXin LI 331fdeb165SXin LI #define VERMAGIC_LDM 75 341fdeb165SXin LI 351fdeb165SXin LI #if defined(__cplusplus) 361fdeb165SXin LI extern "C" { 371fdeb165SXin LI #endif 381fdeb165SXin LI 391fdeb165SXin LI 401fdeb165SXin LI #define __hpt_set_ver(x, v1, v2, v3, v4, v5) x ## _R_ ## v1 ## _ ## v2 ## _ ## v3 ## _ ## v4 ## _ ## v5 411fdeb165SXin LI #define _hpt_set_ver(x, v1, v2, v3, v4, v5) __hpt_set_ver(x, v1, v2, v3, v4, v5) 421fdeb165SXin LI #define hpt_set_ver(x) _hpt_set_ver(x, VERMAGIC_OSM, VERMAGIC_HIM, VERMAGIC_LDM, VERMAGIC_ARRAY, MAX_MEMBERS) 431fdeb165SXin LI 441fdeb165SXin LI #define ldm_register_him hpt_set_ver(ldm_register_him) 451fdeb165SXin LI #define ldm_register_vdev_class hpt_set_ver(ldm_register_vdev_class) 461fdeb165SXin LI #define ldm_alloc_cmds hpt_set_ver(ldm_alloc_cmds) 471fdeb165SXin LI 481fdeb165SXin LI 491fdeb165SXin LI #ifndef HPT_INTERFACE_VERSION 501fdeb165SXin LI #define HPT_INTERFACE_VERSION 0x02010000 511fdeb165SXin LI #endif 521fdeb165SXin LI 531fdeb165SXin LI #ifndef MAX_PARTITIONS_PER_DISK 541fdeb165SXin LI #define MAX_PARTITIONS_PER_DISK 4 551fdeb165SXin LI #endif 561fdeb165SXin LI 571fdeb165SXin LI #if defined(__MAX_PARTITIONS_PER_DISK) && MAX_PARTITIONS_PER_DISK > __MAX_PARTITIONS_PER_DISK 581fdeb165SXin LI #error "Please redefine MAX_PARTITIONS_PER_DISK!!!" 591fdeb165SXin LI #endif 601fdeb165SXin LI 611fdeb165SXin LI 621fdeb165SXin LI typedef char check_HPT_TIME_is_unsigned[ (HPT_TIME)(-1) > 0 ? 1 : -1 ]; 631fdeb165SXin LI 641fdeb165SXin LI #define hpt_time_after_eq(a, b) ((int)(a) - (int)(b) >= 0) 651fdeb165SXin LI #define hpt_time_after(a, b) ((int)(a) - (int)(b) > 0) 661fdeb165SXin LI 671fdeb165SXin LI 681fdeb165SXin LI 691fdeb165SXin LI struct freelist { 701fdeb165SXin LI int dma; 711fdeb165SXin LI HPT_UINT alignment; 721fdeb165SXin LI HPT_UINT count; 731fdeb165SXin LI HPT_UINT size; 741fdeb165SXin LI void * head; 751fdeb165SXin LI struct freelist *next; 761fdeb165SXin LI #if DBG 771fdeb165SXin LI char *tag; 781fdeb165SXin LI HPT_UINT reserved_count; 791fdeb165SXin LI #define freelist_debug_tag(list, _tag) (list)->tag = _tag 801fdeb165SXin LI #else 811fdeb165SXin LI #define freelist_debug_tag(list, _tag) 821fdeb165SXin LI #endif 831fdeb165SXin LI }; 841fdeb165SXin LI 851fdeb165SXin LI 861fdeb165SXin LI void freelist_reserve(struct freelist *list, void *osext, HPT_UINT size, HPT_UINT count); 871fdeb165SXin LI 881fdeb165SXin LI void *freelist_get(struct freelist *); 891fdeb165SXin LI void freelist_put(struct freelist *, void *p); 901fdeb165SXin LI 911fdeb165SXin LI void freelist_reserve_dma(struct freelist *list, void *osext, HPT_UINT size, HPT_UINT alignment, HPT_UINT count); 921fdeb165SXin LI void *freelist_get_dma(struct freelist *, BUS_ADDRESS *busaddr); 931fdeb165SXin LI void freelist_put_dma(struct freelist *, void *p, BUS_ADDRESS busaddr); 941fdeb165SXin LI 951fdeb165SXin LI 961fdeb165SXin LI #define freelist_reserve_with_tag(list, osext, size, count) \ 971fdeb165SXin LI do {\ 981fdeb165SXin LI freelist_debug_tag(list, #list " at " __FILE__);\ 991fdeb165SXin LI freelist_reserve(list, osext, (HPT_UINT)(size), (HPT_UINT)(count));\ 1001fdeb165SXin LI }while(0) 1011fdeb165SXin LI 1021fdeb165SXin LI #define freelist_reserve_dma_with_tag(list, osext, size, alignment, count) \ 1031fdeb165SXin LI do {\ 1041fdeb165SXin LI freelist_debug_tag(list, #list " at " __FILE__);\ 1051fdeb165SXin LI freelist_reserve_dma(list, osext, (HPT_UINT)(size), (HPT_UINT)(alignment), (HPT_UINT)(count));\ 1061fdeb165SXin LI }while(0) 1071fdeb165SXin LI 1081fdeb165SXin LI struct lock_request { 1091fdeb165SXin LI HPT_U64 start, end; 1101fdeb165SXin LI struct lock_request *next; 1111fdeb165SXin LI struct list_head waiters; /* blocked commands */ 1121fdeb165SXin LI struct tq_item callback; 1131fdeb165SXin LI int lock_cc; 1141fdeb165SXin LI }; 1151fdeb165SXin LI 1161fdeb165SXin LI #define INIT_LOCK_REQUEST(req, _start, _end, _cb, _arg, _cc) \ 1171fdeb165SXin LI do {\ 1181fdeb165SXin LI (req)->next = 0;\ 1191fdeb165SXin LI (req)->start = _start;\ 1201fdeb165SXin LI (req)->end = _end;\ 1211fdeb165SXin LI INIT_TQ_ITEM(&(req)->callback, _cb, _arg);\ 1221fdeb165SXin LI INIT_LIST_HEAD(&(req)->waiters);\ 1231fdeb165SXin LI (req)->lock_cc = _cc;\ 1241fdeb165SXin LI } while (0) 1251fdeb165SXin LI 1261fdeb165SXin LI struct task_queue { 1271fdeb165SXin LI struct tq_item *head, *tail; 1281fdeb165SXin LI }; 1291fdeb165SXin LI 1301fdeb165SXin LI #define TQ_EMPTY(tq) ((tq)->head==0) 1311fdeb165SXin LI 1321fdeb165SXin LI struct dmapool_order { 1331fdeb165SXin LI HPT_UINT npages; 1341fdeb165SXin LI struct tq_item wakeup_fn; 1351fdeb165SXin LI struct dmapool_order *next; 1361fdeb165SXin LI }; 1371fdeb165SXin LI 1381fdeb165SXin LI struct dmapool_client { 1391fdeb165SXin LI void * handle; 1401fdeb165SXin LI HPT_UINT (*shrink)(void *handle, HPT_UINT npages); 1411fdeb165SXin LI int (*resume)(void *handle); 1421fdeb165SXin LI struct dmapool_client *next; 1431fdeb165SXin LI }; 1441fdeb165SXin LI 1451fdeb165SXin LI typedef struct _VBUS * PVBUS; 1461fdeb165SXin LI typedef struct _VDEV * PVDEV; 1471fdeb165SXin LI 1481fdeb165SXin LI 1491fdeb165SXin LI void dmapool_register_client(PVBUS vbus, struct dmapool_client *client); 1501fdeb165SXin LI 1511fdeb165SXin LI 1521fdeb165SXin LI void dmapool_active(PVBUS vbus); 1531fdeb165SXin LI 1541fdeb165SXin LI /* return 0 if the request is immediately satisfied, non-zero otherwise. */ 1551fdeb165SXin LI int dmapool_make_order(PVBUS vbus, struct dmapool_order *order); 1561fdeb165SXin LI 1571fdeb165SXin LI 1581fdeb165SXin LI void *dmapool_get_page(PVBUS vbus, BUS_ADDRESS *busaddr); 1591fdeb165SXin LI void *dmapool_get_page_at(PVBUS vbus, void *p, BUS_ADDRESS *busaddr); 1601fdeb165SXin LI void dmapool_put_page(PVBUS vbus, void *p, BUS_ADDRESS busaddr); 1611fdeb165SXin LI void dmapool_init(PVBUS vbus); 1621fdeb165SXin LI HPT_UINT dmapool_max_class_pages(PVBUS vbus); 1631fdeb165SXin LI 1641fdeb165SXin LI 1651fdeb165SXin LI struct timer_call { 1661fdeb165SXin LI HPT_U32 interval; /*microseconds*/ 1671fdeb165SXin LI HPT_TIME expire_time; /*microseconds*/ 1681fdeb165SXin LI void (*proc)(void * arg); 1691fdeb165SXin LI void * arg; 1701fdeb165SXin LI struct timer_call ** pprev; 1711fdeb165SXin LI struct timer_call * next; 1721fdeb165SXin LI }; 1731fdeb165SXin LI 1741fdeb165SXin LI #define ldm_init_timer(timer) do { (timer)->next=0; (timer)->pprev=0; } while (0) 1751fdeb165SXin LI 1761fdeb165SXin LI #define INIT_TIMER_CALL(timer, _interval, _proc, _arg) \ 1771fdeb165SXin LI do { \ 1781fdeb165SXin LI HPT_ASSERT((timer)->next==0 && (timer)->pprev==0);\ 1791fdeb165SXin LI (timer)->interval = _interval;\ 1801fdeb165SXin LI (timer)->proc = _proc;\ 1811fdeb165SXin LI (timer)->arg = _arg;\ 1821fdeb165SXin LI } while(0) 1831fdeb165SXin LI 1841fdeb165SXin LI void ldm_request_timer(PVBUS vbus, struct timer_call * tc); 1851fdeb165SXin LI void ldm_remove_timer(PVBUS vbus, struct timer_call * tc); 1861fdeb165SXin LI void ldm_on_timer(PVBUS vbus); 1871fdeb165SXin LI 1881fdeb165SXin LI 1891fdeb165SXin LI typedef struct _LDM_ADAPTER 1901fdeb165SXin LI { 1911fdeb165SXin LI struct _LDM_ADAPTER *next; 1921fdeb165SXin LI HIM *him; 1931fdeb165SXin LI void *him_handle; 1941fdeb165SXin LI PVBUS vbus; 1951fdeb165SXin LI struct freelist freelist_dev; 1961fdeb165SXin LI int devid_start; 1971fdeb165SXin LI struct freelist freelist_plugged_dpc; 1981fdeb165SXin LI HPT_BOOL master; 1991fdeb165SXin LI } 2001fdeb165SXin LI LDM_ADAPTER, *PLDM_ADAPTER; 2011fdeb165SXin LI 2021fdeb165SXin LI typedef struct _IOCTL_ARG 2031fdeb165SXin LI { 2041fdeb165SXin LI struct list_head link; 2051fdeb165SXin LI PVBUS vbus; 2061fdeb165SXin LI HPT_U32 dwIoControlCode; 2071fdeb165SXin LI HPT_U32 nInBufferSize; 2081fdeb165SXin LI HPT_U32 nOutBufferSize; 2091fdeb165SXin LI void * lpInBuffer; 2101fdeb165SXin LI void * lpOutBuffer; 2111fdeb165SXin LI HPT_U32 *lpBytesReturned; 2121fdeb165SXin LI void * ioctl_cmnd; 2131fdeb165SXin LI void (* done)(struct _IOCTL_ARG *); 2141fdeb165SXin LI int result; /* HPT_IOCTL_RESULT_ */ 2151fdeb165SXin LI struct tq_item dpc; 2161fdeb165SXin LI } IOCTL_ARG; 2171fdeb165SXin LI 2181fdeb165SXin LI #define HPT_IOCTL_RESULT_OK 0 2191fdeb165SXin LI #define HPT_IOCTL_RESULT_FAILED (-1) 2201fdeb165SXin LI #define HPT_IOCTL_RESULT_INVALID (-2) 2211fdeb165SXin LI #define HPT_IOCTL_RESULT_RETRY (-3) 2221fdeb165SXin LI #define HPT_IOCTL_RESULT_WRONG_VBUS (-4) 2231fdeb165SXin LI 2241fdeb165SXin LI void ldm_ioctl( PVBUS vbus, IOCTL_ARG *IAPnt); 2251fdeb165SXin LI void ldm_set_autorebuild(PVBUS vbus, int enable); 2261fdeb165SXin LI HPT_U32 ldm_get_device_id(PVDEV vd); /* for ioctl */ 2271fdeb165SXin LI 2281fdeb165SXin LI #ifndef __HPT_RAW_LBA 2291fdeb165SXin LI #define __HPT_RAW_LBA HPT_RAW_LBA 2301fdeb165SXin LI #endif 2311fdeb165SXin LI 2321fdeb165SXin LI #include <dev/hptnr/array.h> 2331fdeb165SXin LI 2341fdeb165SXin LI typedef struct hpt_raw_disk 2351fdeb165SXin LI { 2361fdeb165SXin LI #ifdef SUPPORT_ARRAY 2371fdeb165SXin LI PRAW_PARTITION raw_part_list; 2381fdeb165SXin LI __HPT_RAW_LBA max_available_capacity; 2391fdeb165SXin LI __HPT_RAW_LBA total_available_capacity; 2401fdeb165SXin LI #endif 2411fdeb165SXin LI __HPT_RAW_LBA real_capacity; 2421fdeb165SXin LI __HPT_RAW_LBA head_position; 243e157d597SXin LI HPT_U32 logical_sector_size; 2447d379626SXin LI HPT_U8 logicalsectors_per_physicalsector; 2457d379626SXin LI HPT_U16 lowest_aligned; 2461fdeb165SXin LI HPT_U16 max_sectors_per_cmd; 2471fdeb165SXin LI HPT_U8 max_queue_depth; 2481fdeb165SXin LI HPT_U8 user_select_mode; 2491fdeb165SXin LI 2501fdeb165SXin LI HPT_UINT uninitialized : 1; 2511fdeb165SXin LI HPT_UINT legacy_disk : 1; 2521fdeb165SXin LI HPT_UINT is_spare : 1; 2531fdeb165SXin LI HPT_UINT v3_format : 1; 2541fdeb165SXin LI HPT_UINT need_sync : 1; 2551fdeb165SXin LI HPT_UINT temp_spare : 1; 2561fdeb165SXin LI HPT_UINT need_check_array : 1; 2571fdeb165SXin LI HPT_UINT df_user_mode_set: 1; 2581fdeb165SXin LI 2591fdeb165SXin LI HPT_UINT df_read_ahead_set: 1; 2601fdeb165SXin LI HPT_UINT enable_read_ahead : 1; 2611fdeb165SXin LI HPT_UINT df_write_cache_set: 1; 2621fdeb165SXin LI HPT_UINT enable_write_cache : 1; 2631fdeb165SXin LI HPT_UINT df_tcq_set: 1; 2641fdeb165SXin LI HPT_UINT enable_tcq : 1; 2651fdeb165SXin LI HPT_UINT df_ncq_set: 1; 2661fdeb165SXin LI HPT_UINT enable_ncq : 1; 2671fdeb165SXin LI 2681fdeb165SXin LI HPT_UINT bad_sector : 1; 2691fdeb165SXin LI HPT_UINT df_sas : 1; 2701fdeb165SXin LI 2711fdeb165SXin LI HIM * him; 2721fdeb165SXin LI int index; 2731fdeb165SXin LI PLDM_ADAPTER adapter; 2741fdeb165SXin LI void * phy_dev; 2751fdeb165SXin LI 2761fdeb165SXin LI char model[40]; 2771fdeb165SXin LI 2781fdeb165SXin LI struct tq_item reset_dpc; 2791fdeb165SXin LI int reset_pending; 2801fdeb165SXin LI 2811fdeb165SXin LI struct tq_item fail_dpc; 2821fdeb165SXin LI int fail_pending; 2831fdeb165SXin LI } 2841fdeb165SXin LI HPT_RAW_DISK, *PHPT_RAW_DISK; 2851fdeb165SXin LI 2861fdeb165SXin LI struct vdev_class 2871fdeb165SXin LI { 2881fdeb165SXin LI struct vdev_class *next; 2891fdeb165SXin LI 2901fdeb165SXin LI HPT_U8 __type; 2911fdeb165SXin LI HPT_U8 stripped; /* RAID0,3,5,6 */ 2921fdeb165SXin LI HPT_U8 redundancy; /* RAID1-1, RAID3/5-1, RAID6-2 */ 2931fdeb165SXin LI HPT_U8 must_init; /* RAID3,5,6 */ 2941fdeb165SXin LI HPT_U8 docache; 2951fdeb165SXin LI 2961fdeb165SXin LI HPT_UINT vbus_ext_size; 2971fdeb165SXin LI HPT_UINT vbus_ext_offset; /* used by LDM */ 2981fdeb165SXin LI HPT_UINT dev_ext_size; 2991fdeb165SXin LI HPT_UINT cmd_ext_size; 3001fdeb165SXin LI 3011fdeb165SXin LI 3021fdeb165SXin LI void (*get_mem_info)(PVBUS vbus, void *osext, int phydev_count); 3031fdeb165SXin LI void (*queue_cmd)(PCOMMAND cmd); 3041fdeb165SXin LI void (*member_failed)(struct _VDEV * vd); 3051fdeb165SXin LI 3061fdeb165SXin LI 3071fdeb165SXin LI void (*initialize)(PVBUS vbus); 3081fdeb165SXin LI void (*release)(PVBUS vbus); 3091fdeb165SXin LI int (*add)(PVDEV vd); 3101fdeb165SXin LI void (*remove)(PVDEV vd); 3111fdeb165SXin LI void (*reset)(PVDEV vd); 3121fdeb165SXin LI void (*sync_stamp)(PVDEV vd); 3131fdeb165SXin LI int (*support_type)(int type); 3141fdeb165SXin LI }; 3151fdeb165SXin LI 3161fdeb165SXin LI 3171fdeb165SXin LI #define VDEV_CLASS_CONSTRUCTOR(type, prefix) { \ 3181fdeb165SXin LI 0, \ 3191fdeb165SXin LI type, \ 3201fdeb165SXin LI prefix ## _stripped, \ 3211fdeb165SXin LI prefix ## _redundancy, \ 3221fdeb165SXin LI prefix ## _must_init, \ 3231fdeb165SXin LI 0, \ 3241fdeb165SXin LI (HPT_UINT)(prefix ## _vbus_ext_size), \ 3251fdeb165SXin LI 0, \ 3261fdeb165SXin LI (HPT_UINT)(prefix ## _dev_ext_size), \ 3271fdeb165SXin LI (HPT_UINT)(prefix ## _cmd_ext_size), \ 3281fdeb165SXin LI prefix ## _get_mem_info, \ 3291fdeb165SXin LI prefix ## _queue_cmd, \ 3301fdeb165SXin LI prefix ## _member_failed, \ 3311fdeb165SXin LI prefix ## _initialize, \ 3321fdeb165SXin LI prefix ## _release, \ 3331fdeb165SXin LI prefix ## _add, \ 3341fdeb165SXin LI prefix ## _remove, \ 3351fdeb165SXin LI prefix ## _reset, \ 3361fdeb165SXin LI prefix ## _sync_stamp, \ 3371fdeb165SXin LI 0 \ 3381fdeb165SXin LI } 3391fdeb165SXin LI 3401fdeb165SXin LI #define VD_RAW 1 3411fdeb165SXin LI #define VD_PARTITION 4 3421fdeb165SXin LI 3431fdeb165SXin LI #define mIsArray(vdev_type) ((vdev_type)>VD_PARTITION) 3441fdeb165SXin LI 3451fdeb165SXin LI #define VD_RAID0 5 3461fdeb165SXin LI #define VD_RAID1 6 3471fdeb165SXin LI #define VD_JBOD 7 3481fdeb165SXin LI #define VD_RAID5 8 3491fdeb165SXin LI #define VD_RAID6 9 3501fdeb165SXin LI #define VD_RAID3 10 3511fdeb165SXin LI #define VD_RAID4 11 3521fdeb165SXin LI #define VD_RAID1E 12 3531fdeb165SXin LI 3541fdeb165SXin LI #define MAX_VD_TYPE_ID 12 3551fdeb165SXin LI 3561fdeb165SXin LI struct vdev_class *ldm_find_vdev_class(HPT_U8 type); 3571fdeb165SXin LI 3581fdeb165SXin LI typedef struct _VDEV { 3591fdeb165SXin LI PVBUS vbus; 3601fdeb165SXin LI struct vdev_class *Class; 3611fdeb165SXin LI HPT_U8 type; 3621fdeb165SXin LI PVDEV parent; 3631fdeb165SXin LI void * ext; 3641fdeb165SXin LI HPT_U64 capacity; 3651fdeb165SXin LI int target_id; 3661fdeb165SXin LI HPT_UINT cmds_per_request; 3671fdeb165SXin LI 3681fdeb165SXin LI union { 3691fdeb165SXin LI #ifdef SUPPORT_ARRAY 3701fdeb165SXin LI HPT_ARRAY array; 3711fdeb165SXin LI HPT_PARTITION partition; 3721fdeb165SXin LI #endif 3731fdeb165SXin LI HPT_RAW_DISK raw; 3741fdeb165SXin LI } u; 3751fdeb165SXin LI 3761fdeb165SXin LI HPT_U8 vf_online : 1; 3771fdeb165SXin LI HPT_U8 vf_bootmark : 1; 3781fdeb165SXin LI HPT_U8 vf_bootable : 1; 3791fdeb165SXin LI HPT_U8 vf_resetting: 1; 3801fdeb165SXin LI HPT_U8 vf_quiesced: 1; 3811fdeb165SXin LI HPT_U8 vf_clslock: 1; 3821fdeb165SXin LI 3831fdeb165SXin LI HPT_U8 cache_policy; /* see CACHE_POLICY_* */ 3841fdeb165SXin LI 3851fdeb165SXin LI HPT_UINT cq_len; 3861fdeb165SXin LI HPT_UINT cmds_sent; 3871fdeb165SXin LI 3881fdeb165SXin LI struct list_head link; 3891fdeb165SXin LI struct list_head cq_wait_send; 3901fdeb165SXin LI struct list_head cq_sent; 3911fdeb165SXin LI 3921fdeb165SXin LI HPT_U32 last_active; 3931fdeb165SXin LI int cq_priority; 3941fdeb165SXin LI struct list_head cq_wait_lock; 3951fdeb165SXin LI struct lock_request *locks_granted; 3961fdeb165SXin LI struct lock_request *locks_wait; 3971fdeb165SXin LI HPT_U32 ioctl_id; 3981fdeb165SXin LI void * cc_ext; 3991fdeb165SXin LI } 4001fdeb165SXin LI VDEV; 4011fdeb165SXin LI 4021fdeb165SXin LI #define CACHE_POLICY_NONE 0 4031fdeb165SXin LI #define CACHE_POLICY_WRITE_THROUGH 1 4041fdeb165SXin LI #define CACHE_POLICY_WRITE_BACK 2 4051fdeb165SXin LI 4061fdeb165SXin LI 4071fdeb165SXin LI extern HIM *him_list; 4081fdeb165SXin LI 4091fdeb165SXin LI 4101fdeb165SXin LI void ldm_register_him(PHIM him); 4111fdeb165SXin LI 4121fdeb165SXin LI 4131fdeb165SXin LI void ldm_register_vdev_class(struct vdev_class *Class); 4141fdeb165SXin LI 4151fdeb165SXin LI 4161fdeb165SXin LI HPT_BOOL ldm_register_adapter(PLDM_ADAPTER adapter); 4171fdeb165SXin LI 4181fdeb165SXin LI 4191fdeb165SXin LI int init_config(void); 4201fdeb165SXin LI 4211fdeb165SXin LI HPT_UINT ldm_get_vbus_size(void); 4221fdeb165SXin LI 4231fdeb165SXin LI 4241fdeb165SXin LI void ldm_create_vbus(PVBUS vbus, void *osext); 4251fdeb165SXin LI 4261fdeb165SXin LI 4271fdeb165SXin LI void ldm_get_mem_info(PVBUS vbus, void *osext); 4281fdeb165SXin LI 4291fdeb165SXin LI 4301fdeb165SXin LI void *ldm_get_vbus_ext(PVBUS vbus, struct vdev_class *Class); 4311fdeb165SXin LI 4321fdeb165SXin LI 4331fdeb165SXin LI PVBUS ldm_get_next_vbus(PVBUS vbus, void **posext); 4341fdeb165SXin LI 4351fdeb165SXin LI #define ldm_for_each_vbus(vbus, vbus_ext) \ 4361fdeb165SXin LI for (vbus = ldm_get_next_vbus(0, (void **)(void *)&vbus_ext); vbus; \ 4371fdeb165SXin LI vbus = ldm_get_next_vbus(vbus, (void **)(void *)&vbus_ext)) 4381fdeb165SXin LI 4391fdeb165SXin LI 4401fdeb165SXin LI void ldm_initialize_vbus_async(PVBUS vbus, PLDM_ADAPTER master_adapter, void (*done)(void *osext)); 4411fdeb165SXin LI 4421fdeb165SXin LI /* ldm_initialize_vbus is deprecated since it will hold the CPU too long. */ 4431fdeb165SXin LI #define ldm_initialize_vbus(vbus, adapter) ldm_initialize_vbus_async(vbus, adapter, 0) 4441fdeb165SXin LI 4451fdeb165SXin LI 4461fdeb165SXin LI void ldm_release_vbus(PVBUS vbus); 4471fdeb165SXin LI 4481fdeb165SXin LI PVDEV ldm_create_vdev(PVBUS vbus, HPT_U8 type); 4491fdeb165SXin LI void ldm_release_vdev(PVDEV vd); 4501fdeb165SXin LI 4511fdeb165SXin LI PVDEV ldm_find_target(PVBUS vbus, int id); 4521fdeb165SXin LI PVDEV ldm_find_stamp(PVBUS vbus, HPT_U32 stamp, int seq); 4531fdeb165SXin LI 4541fdeb165SXin LI 4551fdeb165SXin LI PCOMMAND ldm_alloc_cmds(PVBUS vbus, HPT_UINT cnt); 4561fdeb165SXin LI void ldm_free_cmds(PCOMMAND cmd); 4571fdeb165SXin LI 4581fdeb165SXin LI HPT_UINT ldm_get_cmd_size(void); 4591fdeb165SXin LI PCOMMAND ldm_alloc_cmds_from_list(PVBUS vbus, struct freelist *list, HPT_UINT cnt); 4601fdeb165SXin LI void ldm_free_cmds_to_list(struct freelist *list, PCOMMAND cmd); 4611fdeb165SXin LI 4621fdeb165SXin LI 4631fdeb165SXin LI PCOMMAND __ldm_alloc_cmd(struct freelist *list); 4641fdeb165SXin LI 4651fdeb165SXin LI #ifdef OS_SUPPORT_TASK 4661fdeb165SXin LI #define CMD_SET_PRIORITY(cmd, pri) cmd->priority = (pri) 4671fdeb165SXin LI #else 4681fdeb165SXin LI #define CMD_SET_PRIORITY(cmd, pri) 4691fdeb165SXin LI #endif 4701fdeb165SXin LI 4711fdeb165SXin LI 4721fdeb165SXin LI #define CMD_GROUP_GET(grp, cmd) \ 4731fdeb165SXin LI do {\ 4741fdeb165SXin LI grp->grplist->count++;\ 4751fdeb165SXin LI cmd = __ldm_alloc_cmd(grp->grplist);\ 4761fdeb165SXin LI cmd->vbus = grp->vbus;\ 4771fdeb165SXin LI cmd->grplist = grp->grplist;\ 4781fdeb165SXin LI CMD_SET_PRIORITY(cmd, grp->priority);\ 4791fdeb165SXin LI } while(0) 4801fdeb165SXin LI 4811fdeb165SXin LI #define CMD_GROUP_PUT(grp, cmd) \ 4821fdeb165SXin LI do {\ 4831fdeb165SXin LI freelist_put(grp->grplist, cmd);\ 4841fdeb165SXin LI grp->grplist->count--;\ 4851fdeb165SXin LI } while (0) 4861fdeb165SXin LI 4871fdeb165SXin LI 4881fdeb165SXin LI 4891fdeb165SXin LI 4901fdeb165SXin LI void ldm_queue_cmd(PCOMMAND cmd); 4911fdeb165SXin LI void vdev_queue_cmd(PCOMMAND cmd); 4921fdeb165SXin LI void ldm_finish_cmd(PCOMMAND cmd); 4931fdeb165SXin LI 4941fdeb165SXin LI 4951fdeb165SXin LI int ldm_acquire_lock(PVDEV vd, struct lock_request *req); 4961fdeb165SXin LI void ldm_release_lock(PVDEV vd, struct lock_request *req); 4971fdeb165SXin LI 4981fdeb165SXin LI void ldm_queue_task(struct task_queue *tq, struct tq_item *t); 4991fdeb165SXin LI void ldm_queue_vbus_dpc(PVBUS vbus, struct tq_item *t); 5001fdeb165SXin LI 5011fdeb165SXin LI HPT_BOOL ldm_intr(PVBUS vbus); 5021fdeb165SXin LI void ldm_run(PVBUS vbus); 5031fdeb165SXin LI int ldm_idle(PVBUS vbus); 5041fdeb165SXin LI 5051fdeb165SXin LI 5061fdeb165SXin LI int ldm_reset_vbus(PVBUS vbus); 5071fdeb165SXin LI 5081fdeb165SXin LI 5091fdeb165SXin LI void ldm_suspend(PVBUS vbus); 5101fdeb165SXin LI void ldm_resume(PVBUS vbus); 5111fdeb165SXin LI LDM_ADAPTER *ldm_resume_adapter(PVBUS vbus, PLDM_ADAPTER ldm_adapter); 5121fdeb165SXin LI void ldm_shutdown(PVBUS vbus);/*shutdown all the controllers*/ 5131fdeb165SXin LI 5141fdeb165SXin LI 5151fdeb165SXin LI #define HIM_EVENT_DEVICE_REMOVED 1 5161fdeb165SXin LI #define HIM_EVENT_DEVICE_PLUGGED 2 5171fdeb165SXin LI #define HIM_EVENT_DEVICE_ERROR 3 5181fdeb165SXin LI #define HIM_EVENT_RESET_REQUIRED 4 5191fdeb165SXin LI #define HIM_EVENT_QUIESCE_DEVICE 5 5201fdeb165SXin LI #define HIM_EVENT_UNQUIESCE_DEVICE 6 5211fdeb165SXin LI #define HIM_EVENT_CONFIG_CHANGED 7 5221fdeb165SXin LI 5231fdeb165SXin LI void ldm_event_notify(HPT_U32 event, void *arg1, void *arg2); 5241fdeb165SXin LI 5251fdeb165SXin LI void log_sector_repair(PVDEV vd, int success, HPT_LBA lba, HPT_U16 nsectors); 5261fdeb165SXin LI 5271fdeb165SXin LI void ldm_register_device(PVDEV vd); 5281fdeb165SXin LI void ldm_unregister_device(PVDEV vd); 5291fdeb165SXin LI 5301fdeb165SXin LI PVBUS him_handle_to_vbus(void * him_handle); 5311fdeb165SXin LI void ldm_ide_fixstring (HPT_U8 *s, const int bytecount); 5321fdeb165SXin LI #if defined(__cplusplus) 5331fdeb165SXin LI } 5341fdeb165SXin LI #endif 5351fdeb165SXin LI #endif 536