The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/hptrr/ldm.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) HighPoint Technologies, Inc.
    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
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/6.4/sys/dev/hptrr/ldm.h 174614 2007-12-15 06:03:44Z scottl $
   27  */
   28 #include <dev/hptrr/hptrr_config.h>
   29 /*
   30  * $Id: ldm.h,v 1.59 2007/04/17 07:00:06 mah Exp $
   31  * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved.
   32  */
   33 #ifndef _HPT_LDM_H_
   34 #define _HPT_LDM_H_
   35 
   36 #define VERMAGIC_LDM 57
   37 
   38 #if defined(__cplusplus)
   39 extern "C" {
   40 #endif
   41 
   42 
   43 #define __hpt_set_ver(x, v1, v2, v3, v4, v5) x ## _R_ ## v1 ## _ ## v2 ## _ ## v3 ## _ ## v4 ## _ ## v5
   44 #define _hpt_set_ver(x, v1, v2, v3, v4, v5)  __hpt_set_ver(x, v1, v2, v3, v4, v5)
   45 #define hpt_set_ver(x)               _hpt_set_ver(x, VERMAGIC_OSM, VERMAGIC_HIM, VERMAGIC_LDM, VERMAGIC_ARRAY, MAX_MEMBERS)
   46 
   47 #define ldm_register_him        hpt_set_ver(ldm_register_him)
   48 #define ldm_register_vdev_class hpt_set_ver(ldm_register_vdev_class)
   49 #define ldm_alloc_cmds          hpt_set_ver(ldm_alloc_cmds)
   50 
   51 
   52 #ifndef HPT_INTERFACE_VERSION
   53 #define HPT_INTERFACE_VERSION 0x02000001
   54 #endif
   55 
   56 #define MAX_PARTITIONS_PER_DISK 4
   57 #if defined(__MAX_PARTITIONS_PER_DISK) && MAX_PARTITIONS_PER_DISK > __MAX_PARTITIONS_PER_DISK
   58 #error "Please redefine MAX_PARTITIONS_PER_DISK!!!"
   59 #endif
   60 
   61 #define MAX(a,b) (((a)>(b))?(a):(b))
   62 #define MIN(a,b) (((a)<(b))?(a):(b))
   63 
   64 
   65 struct freelist {
   66         int dma;
   67         HPT_UINT alignment;
   68         HPT_UINT count;
   69         HPT_UINT size;
   70         void * head;
   71         struct freelist *next;
   72 #ifdef DBG
   73         char *tag;
   74         HPT_UINT reserved_count; 
   75         #define freelist_debug_tag(list, _tag) (list)->tag = _tag
   76 #else 
   77         #define freelist_debug_tag(list, _tag)
   78 #endif
   79 };
   80 
   81 
   82 void freelist_reserve(struct freelist *list, void *osext, HPT_UINT size, HPT_UINT count);
   83 
   84 void *freelist_get(struct freelist *);
   85 void freelist_put(struct freelist *, void *p);
   86 
   87 void freelist_reserve_dma(struct freelist *list, void *osext, HPT_UINT size, HPT_UINT alignment, HPT_UINT count);
   88 void *freelist_get_dma(struct freelist *, BUS_ADDRESS *busaddr);
   89 void freelist_put_dma(struct freelist *, void *p, BUS_ADDRESS busaddr);
   90 
   91 
   92 #define freelist_reserve_with_tag(list, osext, size, count) \
   93         do {\
   94                 freelist_debug_tag(list, #list  " at " __FILE__);\
   95                 freelist_reserve(list, osext, size, count);\
   96         }while(0)
   97 
   98 #define freelist_reserve_dma_with_tag(list, osext, size, alignment, count) \
   99         do {\
  100                 freelist_debug_tag(list, #list " at " __FILE__);\
  101                 freelist_reserve_dma(list, osext, size, alignment, count);\
  102         }while(0)
  103 
  104 struct lock_request {
  105         HPT_U64 start, end;
  106         struct lock_request *next;
  107         struct list_head waiters; /* blocked commands */
  108         struct tq_item callback;
  109 };
  110 
  111 #define INIT_LOCK_REQUEST(req, _start, _end, _cb, _arg) \
  112         do {\
  113                 (req)->next = 0;\
  114                 (req)->start = _start;\
  115                 (req)->end = _end;\
  116                 INIT_TQ_ITEM(&(req)->callback, _cb, _arg);\
  117                 INIT_LIST_HEAD(&(req)->waiters);\
  118         } while (0)
  119 
  120 struct task_queue {
  121         struct tq_item *head, *tail;
  122 };
  123 
  124 #define TQ_EMPTY(tq) ((tq)->head==0)
  125 
  126 struct dmapool_order {
  127         HPT_UINT npages;
  128         struct tq_item wakeup_fn;
  129         struct dmapool_order *next;
  130 };
  131 
  132 struct dmapool_client {
  133         void * handle;
  134         HPT_UINT (*shrink)(void *handle, HPT_UINT npages);
  135         void (*resume)(void *handle);
  136         struct dmapool_client *next;
  137 };
  138 
  139 typedef struct _VBUS * PVBUS;
  140 typedef struct _VDEV * PVDEV;
  141 
  142 
  143 void dmapool_register_client(PVBUS vbus, struct dmapool_client *client);
  144 
  145 
  146 void dmapool_active(PVBUS vbus);
  147 
  148 /* return 0 if the request is immediately satisfied, non-zero otherwise. */
  149 int dmapool_make_order(PVBUS vbus, struct dmapool_order *order);
  150 
  151 
  152 void *dmapool_get_page(PVBUS vbus, BUS_ADDRESS *busaddr);
  153 void *dmapool_get_page_at(PVBUS vbus, void *p, BUS_ADDRESS *busaddr);
  154 void dmapool_put_page(PVBUS vbus, void *p, BUS_ADDRESS busaddr);
  155 void dmapool_init(PVBUS vbus);
  156 HPT_UINT dmapool_max_class_pages(PVBUS vbus);
  157 
  158 
  159 struct timer_call {
  160         HPT_U32 interval; /*microseconds*/
  161         HPT_TIME expire_time; /*microseconds*/
  162         void (*proc)(void * arg);
  163         void * arg;
  164         struct timer_call ** pprev;
  165         struct timer_call * next;
  166 };
  167 
  168 #define ldm_init_timer(timer) do { (timer)->next=0; (timer)->pprev=0; } while (0)
  169 
  170 #define INIT_TIMER_CALL(timer, _interval, _proc, _arg) \
  171         do { \
  172                 HPT_ASSERT((timer)->next==0 && (timer)->pprev==0);\
  173                 (timer)->interval = _interval;\
  174                 (timer)->proc = _proc;\
  175                 (timer)->arg = _arg;\
  176         } while(0)
  177 
  178 void ldm_request_timer(PVBUS vbus, struct timer_call * tc);
  179 void ldm_remove_timer(PVBUS vbus, struct timer_call * tc);
  180 void ldm_on_timer(PVBUS vbus);
  181 
  182 
  183 typedef struct _LDM_ADAPTER
  184 {
  185         struct _LDM_ADAPTER *next;
  186         HIM  *him;
  187         void *him_handle;
  188         PVBUS vbus;
  189         struct freelist freelist_dev;
  190         struct freelist freelist_plugged_dpc;
  191         HPT_BOOL master;
  192 }
  193 LDM_ADAPTER, *PLDM_ADAPTER;
  194 
  195 typedef struct _IOCTL_ARG
  196 {
  197         struct list_head link;
  198         PVBUS vbus;
  199         HPT_U32 dwIoControlCode;
  200         HPT_U32 nInBufferSize;
  201         HPT_U32 nOutBufferSize;
  202         void *  lpInBuffer;
  203         void *  lpOutBuffer;
  204         HPT_U32 *lpBytesReturned;
  205         void *  ioctl_cmnd;
  206         void (* done)(struct _IOCTL_ARG *);
  207         int     result; /* HPT_IOCTL_RESULT_ */
  208         struct tq_item dpc;
  209 } IOCTL_ARG;
  210 
  211 #define HPT_IOCTL_RESULT_OK          0
  212 #define HPT_IOCTL_RESULT_FAILED     (-1)
  213 #define HPT_IOCTL_RESULT_INVALID    (-2)
  214 #define HPT_IOCTL_RESULT_RETRY      (-3)
  215 #define HPT_IOCTL_RESULT_WRONG_VBUS (-4)
  216 
  217 void ldm_ioctl( PVBUS vbus,     IOCTL_ARG *IAPnt);
  218 HPT_U32 ldm_get_device_id(PVDEV vd); /* for ioctl */
  219 void ldm_set_rebuild_priority(PVBUS vbus, int priority);
  220 void ldm_set_autorebuild(PVBUS vbus, int enable);
  221 
  222 #include <dev/hptrr/array.h>
  223 
  224 typedef struct hpt_raw_disk
  225 {
  226 #ifdef SUPPORT_ARRAY
  227         PRAW_PARTITION raw_part_list;
  228         HPT_RAW_LBA max_available_capacity; 
  229         HPT_RAW_LBA total_available_capacity;
  230 #endif
  231         HPT_RAW_LBA real_capacity;
  232         HPT_RAW_LBA head_position;
  233 
  234         HPT_U16 max_sectors_per_cmd;
  235         HPT_U8  user_select_mode;
  236 
  237         HPT_U8  uninitialized : 1;
  238         HPT_U8  legacy_disk : 1;
  239         HPT_U8  is_spare : 1;
  240         HPT_U8  v3_format : 1;
  241         HPT_U8  need_sync : 1;
  242         HPT_U8  temp_spare : 1;
  243         HPT_U8  need_check_array : 1;
  244         HPT_U8  df_user_mode_set: 1;
  245 
  246         HPT_U8  df_read_ahead_set: 1;
  247         HPT_U8  enable_read_ahead : 1;
  248         HPT_U8  df_write_cache_set: 1;
  249         HPT_U8  enable_write_cache : 1;
  250         HPT_U8  df_tcq_set: 1;
  251         HPT_U8  enable_tcq : 1;
  252         HPT_U8  df_ncq_set: 1;
  253         HPT_U8  enable_ncq : 1;
  254 
  255         HIM  *                          him;
  256         int                             index;
  257         PLDM_ADAPTER            adapter;
  258         void *                          phy_dev;
  259         PIDENTIFY_DATA2         identify_data;
  260         char    model[40];
  261 
  262         struct tq_item reset_dpc;
  263         int reset_pending;
  264 
  265         struct tq_item fail_dpc;
  266         int fail_pending;
  267 }
  268 HPT_RAW_DISK, *PHPT_RAW_DISK;
  269 
  270 struct vdev_class
  271 {
  272         struct vdev_class *next;
  273 
  274         HPT_U8   type;
  275         HPT_U8   stripped;        /* RAID0,3,5,6 */
  276         HPT_U8   redundancy;      /* RAID1-1, RAID3/5-1, RAID6-2 */
  277         HPT_U8   must_init;       /* RAID3,5,6 */
  278 
  279         HPT_UINT vbus_ext_size;
  280         HPT_UINT vbus_ext_offset; /* used by LDM */
  281         HPT_UINT dev_ext_size;
  282         HPT_UINT cmd_ext_size;
  283 
  284         
  285         void (*get_mem_info)(PVBUS vbus, void *osext, int phydev_count);
  286         void (*queue_cmd)(PCOMMAND cmd);
  287         void (*member_failed)(struct _VDEV * vd); 
  288 
  289         
  290         void (*initialize)(PVBUS vbus);
  291         void (*release)(PVBUS vbus); 
  292         int  (*add)(PVDEV vd); 
  293         void (*remove)(PVDEV vd); 
  294         void (*reset)(PVDEV vd); 
  295         void (*sync_stamp)(PVDEV vd);
  296 };
  297 
  298 
  299 #define VDEV_CLASS_CONSTRUCTOR(type, prefix) { \
  300         0, \
  301         type, \
  302         prefix ## _stripped, \
  303         prefix ## _redundancy, \
  304         prefix ## _must_init, \
  305         prefix ## _vbus_ext_size, \
  306         0, \
  307         prefix ## _dev_ext_size, \
  308         prefix ## _cmd_ext_size, \
  309         prefix ## _get_mem_info, \
  310         prefix ## _queue_cmd, \
  311         prefix ## _member_failed, \
  312         prefix ## _initialize, \
  313         prefix ## _release, \
  314         prefix ## _add, \
  315         prefix ## _remove, \
  316         prefix ## _reset, \
  317         prefix ## _sync_stamp, \
  318 }
  319 
  320 #define VD_RAW       1
  321 #define VD_PARTITION 4
  322 
  323 #define mIsArray(vdev_type) ((vdev_type)>VD_PARTITION)
  324 
  325 #define VD_RAID0     5
  326 #define VD_RAID1     6
  327 #define VD_JBOD      7
  328 #define VD_RAID5     8
  329 #define VD_RAID6     9
  330 
  331 #define MAX_VD_TYPE_ID  9
  332 
  333 struct vdev_class *ldm_find_vdev_class(HPT_U8 type);
  334 
  335 typedef struct _VDEV {
  336         PVBUS vbus;
  337         PVDEV parent;
  338         void * ext;
  339         HPT_U64 capacity;
  340         int     target_id;
  341         HPT_UINT cmds_per_request;
  342 
  343         union {
  344 #ifdef SUPPORT_ARRAY
  345                 HPT_ARRAY array;
  346                 HPT_PARTITION partition;
  347 #endif
  348                 HPT_RAW_DISK raw;
  349         } u;
  350 
  351         HPT_U8 vf_online : 1;
  352         HPT_U8 vf_bootmark : 1;
  353         HPT_U8 vf_bootable : 1;
  354         HPT_U8 vf_resetting: 1;
  355         HPT_U8 vf_quiesced: 1;
  356 
  357         HPT_U8 cache_policy; /* see CACHE_POLICY_* */
  358 
  359         HPT_UINT cq_len;
  360         HPT_UINT cmds_sent;
  361         HPT_UINT max_queue_depth;
  362 
  363         struct list_head link;
  364         struct vdev_class *Class;
  365 
  366         struct list_head cq_wait_send;
  367         struct list_head cq_sent;
  368 
  369         int cq_priority;
  370         struct list_head cq_wait_lock;
  371         struct lock_request *locks_granted;
  372         struct lock_request *locks_wait;
  373         HPT_U32 ioctl_id; 
  374         void * cc_ext;
  375 }
  376 VDEV;
  377 
  378 #define CACHE_POLICY_NONE 0
  379 #define CACHE_POLICY_WRITE_THROUGH 1
  380 #define CACHE_POLICY_WRITE_BACK 2
  381 
  382 
  383 extern HIM *him_list;
  384 
  385 
  386 void ldm_register_him(PHIM him);
  387 
  388 
  389 void ldm_register_vdev_class(struct vdev_class *Class);
  390 
  391 
  392 HPT_BOOL ldm_register_adapter(PLDM_ADAPTER adapter);
  393 
  394 
  395 int init_config(void);
  396 
  397 HPT_UINT ldm_get_vbus_size(void);
  398 
  399 
  400 void ldm_create_vbus(PVBUS vbus, void *osext);
  401 
  402 
  403 void ldm_get_mem_info(PVBUS vbus, void *osext);
  404 
  405 
  406 void *ldm_get_vbus_ext(PVBUS vbus, struct vdev_class *Class);
  407 
  408 
  409 PVBUS ldm_get_next_vbus(PVBUS vbus, void **posext);
  410 
  411 #define ldm_for_each_vbus(vbus, vbus_ext) \
  412         for (vbus = ldm_get_next_vbus(0, (void **)(void *)&vbus_ext); vbus; \
  413                 vbus = ldm_get_next_vbus(vbus, (void **)(void *)&vbus_ext))
  414 
  415 
  416 void ldm_initialize_vbus_async(PVBUS vbus, PLDM_ADAPTER master_adapter, void (*done)(void *osext));
  417 
  418 /* ldm_initialize_vbus is deprecated since it will hold the CPU too long. */
  419 #define ldm_initialize_vbus(vbus, adapter) ldm_initialize_vbus_async(vbus, adapter, 0)
  420 
  421 
  422 void ldm_release_vbus(PVBUS vbus);
  423 
  424 PVDEV ldm_create_vdev(PVBUS vbus, HPT_U8 type);
  425 void ldm_release_vdev(PVDEV vd);
  426 
  427 PVDEV ldm_find_target(PVBUS vbus, int id);
  428 PVDEV ldm_find_stamp(PVBUS vbus, HPT_U32 stamp, int seq);
  429 
  430 
  431 PCOMMAND ldm_alloc_cmds(PVBUS vbus, HPT_UINT cnt);
  432 void ldm_free_cmds(PCOMMAND cmd);
  433 
  434 HPT_UINT ldm_get_cmd_size(void);
  435 PCOMMAND ldm_alloc_cmds_from_list(PVBUS vbus, struct freelist *list, HPT_UINT cnt);
  436 void ldm_free_cmds_to_list(struct freelist *list, PCOMMAND cmd);
  437 
  438 
  439 PCOMMAND __ldm_alloc_cmd(struct freelist *list);
  440 
  441 #ifdef OS_SUPPORT_TASK
  442 #define CMD_SET_PRIORITY(cmd, pri) cmd->priority = (pri)
  443 #else 
  444 #define CMD_SET_PRIORITY(cmd, pri)
  445 #endif
  446 
  447 #define CMD_GROUP_GET(grp, cmd) \
  448         do {\
  449                 grp->grplist->count++;\
  450                 cmd = __ldm_alloc_cmd(grp->grplist);\
  451                 cmd->vbus = grp->vbus;\
  452                 cmd->grplist = grp->grplist;\
  453                 CMD_SET_PRIORITY(cmd, grp->priority);\
  454         } while(0)
  455 
  456 #define CMD_GROUP_PUT(grp, cmd) \
  457         do {\
  458                 freelist_put(grp->grplist, cmd);\
  459                 grp->grplist->count--;\
  460         } while (0)
  461 
  462 
  463 void ldm_queue_cmd(PCOMMAND cmd);
  464 void vdev_queue_cmd(PCOMMAND cmd);
  465 void ldm_finish_cmd(PCOMMAND cmd);
  466 
  467 
  468 int  ldm_acquire_lock(PVDEV vd, struct lock_request *req);
  469 void ldm_release_lock(PVDEV vd, struct lock_request *req);
  470 
  471 void ldm_queue_task(struct task_queue *tq, struct tq_item *t);
  472 void ldm_queue_vbus_dpc(PVBUS vbus, struct tq_item *t);
  473 
  474 HPT_BOOL ldm_intr(PVBUS vbus);
  475 void ldm_run(PVBUS vbus);
  476 int ldm_idle(PVBUS vbus);
  477 
  478 
  479 int ldm_reset_vbus(PVBUS vbus);
  480 
  481 
  482 void ldm_suspend(PVBUS vbus);
  483 void ldm_resume(PVBUS vbus);
  484 void ldm_shutdown(PVBUS vbus);/*shutdown all the controllers*/
  485 
  486 
  487 #define HIM_EVENT_DEVICE_REMOVED 1
  488 #define HIM_EVENT_DEVICE_PLUGGED 2
  489 #define HIM_EVENT_DEVICE_ERROR   3
  490 #define HIM_EVENT_RESET_REQUIRED 4
  491 #define HIM_EVENT_QUIESCE_DEVICE 5
  492 #define HIM_EVENT_UNQUIESCE_DEVICE 6
  493 #define HIM_EVENT_CONFIG_CHANGED 7
  494 
  495 void ldm_event_notify(HPT_U32 event, void *arg1, void *arg2);
  496 
  497 void log_sector_repair(PVDEV vd, int success, HPT_LBA lba, HPT_U16 nsectors);
  498 
  499 void ldm_register_device(PVDEV vd);
  500 void ldm_unregister_device(PVDEV vd);
  501 
  502 PVBUS him_handle_to_vbus(void * him_handle);
  503 
  504 #if defined(__cplusplus)
  505 }
  506 #endif
  507 #endif

Cache object: 91f482daab886eb2c42e61da90fdf069


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.