tw_cl_share.h revision 197409
1144966Svkashyap/* 2169400Sscottl * Copyright (c) 2004-07 Applied Micro Circuits Corporation. 3144966Svkashyap * Copyright (c) 2004-05 Vinod Kashyap 4144966Svkashyap * All rights reserved. 5144966Svkashyap * 6144966Svkashyap * Redistribution and use in source and binary forms, with or without 7144966Svkashyap * modification, are permitted provided that the following conditions 8144966Svkashyap * are met: 9144966Svkashyap * 1. Redistributions of source code must retain the above copyright 10144966Svkashyap * notice, this list of conditions and the following disclaimer. 11144966Svkashyap * 2. Redistributions in binary form must reproduce the above copyright 12144966Svkashyap * notice, this list of conditions and the following disclaimer in the 13144966Svkashyap * documentation and/or other materials provided with the distribution. 14144966Svkashyap * 15144966Svkashyap * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16144966Svkashyap * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17144966Svkashyap * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18144966Svkashyap * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19144966Svkashyap * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20144966Svkashyap * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21144966Svkashyap * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22144966Svkashyap * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23144966Svkashyap * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24144966Svkashyap * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25144966Svkashyap * SUCH DAMAGE. 26144966Svkashyap * 27144966Svkashyap * $FreeBSD: head/sys/dev/twa/tw_cl_share.h 197409 2009-09-22 16:28:07Z rdivacky $ 28144966Svkashyap */ 29144966Svkashyap 30144966Svkashyap/* 31144966Svkashyap * AMCC'S 3ware driver for 9000 series storage controllers. 32144966Svkashyap * 33144966Svkashyap * Author: Vinod Kashyap 34169400Sscottl * Modifications by: Adam Radford 35172496Sscottl * Modifications by: Manjunath Ranganathaiah 36144966Svkashyap */ 37144966Svkashyap 38144966Svkashyap 39144966Svkashyap 40144966Svkashyap#ifndef TW_CL_SHARE_H 41144966Svkashyap 42144966Svkashyap#define TW_CL_SHARE_H 43144966Svkashyap 44144966Svkashyap 45144966Svkashyap/* 46144966Svkashyap * Macros, structures and functions shared between OSL and CL, 47144966Svkashyap * and defined by CL. 48144966Svkashyap */ 49144966Svkashyap 50144966Svkashyap#define TW_CL_NULL ((TW_VOID *)0) 51144966Svkashyap#define TW_CL_TRUE 1 52144966Svkashyap#define TW_CL_FALSE 0 53144966Svkashyap 54144966Svkashyap#define TW_CL_VENDOR_ID 0x13C1 /* 3ware vendor id */ 55152213Svkashyap#define TW_CL_DEVICE_ID_9K 0x1002 /* 9000 PCI series device id */ 56152213Svkashyap#define TW_CL_DEVICE_ID_9K_X 0x1003 /* 9000 PCI-X series device id */ 57169400Sscottl#define TW_CL_DEVICE_ID_9K_E 0x1004 /* 9000 PCIe series device id */ 58172496Sscottl#define TW_CL_DEVICE_ID_9K_SA 0x1005 /* 9000 PCIe SAS series device id */ 59144966Svkashyap 60152213Svkashyap#define TW_CL_BAR_TYPE_IO 1 /* I/O base address */ 61152213Svkashyap#define TW_CL_BAR_TYPE_MEM 2 /* memory base address */ 62152213Svkashyap#define TW_CL_BAR_TYPE_SBUF 3 /* SBUF base address */ 63152213Svkashyap 64152213Svkashyap#ifdef TW_OSL_ENCLOSURE_SUPPORT 65152213Svkashyap#define TW_CL_MAX_NUM_UNITS 65 /* max # of units we support 66152213Svkashyap -- enclosure target id is 64 */ 67152213Svkashyap#else /* TW_OSL_ENCLOSURE_SUPPORT */ 68169400Sscottl#define TW_CL_MAX_NUM_UNITS 32 /* max # of units we support */ 69152213Svkashyap#endif /* TW_OSL_ENCLOSURE_SUPPORT */ 70152213Svkashyap 71144966Svkashyap#define TW_CL_MAX_NUM_LUNS 16 /* max # of LUN's we support */ 72144966Svkashyap#define TW_CL_MAX_IO_SIZE 0x20000 /* 128K */ 73144966Svkashyap 74144966Svkashyap/* 75144966Svkashyap * Though we can support 256 simultaneous requests, we advertise as capable 76144966Svkashyap * of supporting only 255, since we want to keep one CL internal request 77144966Svkashyap * context packet always available for internal requests. 78144966Svkashyap */ 79144966Svkashyap#define TW_CL_MAX_SIMULTANEOUS_REQUESTS 0xFF /* max simult reqs supported */ 80144966Svkashyap 81144966Svkashyap#define TW_CL_MAX_32BIT_SG_ELEMENTS 109 /* max 32-bit sg elements */ 82144966Svkashyap#define TW_CL_MAX_64BIT_SG_ELEMENTS 72 /* max 64-bit sg elements */ 83144966Svkashyap 84144966Svkashyap 85144966Svkashyap/* Possible values of ctlr->flags */ 86144966Svkashyap#define TW_CL_64BIT_ADDRESSES (1<<0) /* 64 bit cmdpkt & SG addresses */ 87144966Svkashyap#define TW_CL_64BIT_SG_LENGTH (1<<1) /* 64 bit SG length */ 88144966Svkashyap#define TW_CL_START_CTLR_ONLY (1<<2) /* Start ctlr only */ 89144966Svkashyap#define TW_CL_STOP_CTLR_ONLY (1<<3) /* Stop ctlr only */ 90152213Svkashyap#define TW_CL_DEFERRED_INTR_USED (1<<5) /* OS Layer uses deferred intr */ 91144966Svkashyap 92144966Svkashyap/* Possible error values from the Common Layer. */ 93144966Svkashyap#define TW_CL_ERR_REQ_SUCCESS 0 94144966Svkashyap#define TW_CL_ERR_REQ_GENERAL_FAILURE (1<<0) 95144966Svkashyap#define TW_CL_ERR_REQ_INVALID_TARGET (1<<1) 96144966Svkashyap#define TW_CL_ERR_REQ_INVALID_LUN (1<<2) 97144966Svkashyap#define TW_CL_ERR_REQ_SCSI_ERROR (1<<3) 98144966Svkashyap#define TW_CL_ERR_REQ_AUTO_SENSE_VALID (1<<4) 99144966Svkashyap#define TW_CL_ERR_REQ_BUS_RESET (1<<5) 100144966Svkashyap#define TW_CL_ERR_REQ_UNABLE_TO_SUBMIT_COMMAND (1<<6) 101144966Svkashyap 102144966Svkashyap 103144966Svkashyap/* Possible values of req_pkt->flags */ 104144966Svkashyap#define TW_CL_REQ_RETRY_ON_BUSY (1<<0) 105144966Svkashyap#define TW_CL_REQ_CALLBACK_FOR_SGLIST (1<<1) 106144966Svkashyap 107144966Svkashyap 108144966Svkashyap#define TW_CL_MESSAGE_SOURCE_CONTROLLER_ERROR 3 109144966Svkashyap#define TW_CL_MESSAGE_SOURCE_CONTROLLER_EVENT 4 110144966Svkashyap#define TW_CL_MESSAGE_SOURCE_COMMON_LAYER_ERROR 21 111144966Svkashyap#define TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT 22 112144966Svkashyap#define TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER 5 113144966Svkashyap#define TW_CL_MESSAGE_SOURCE_FREEBSD_OS 8 114144966Svkashyap#define TW_CL_MESSAGE_SOURCE_WINDOWS_DRIVER 7 115144966Svkashyap#define TW_CL_MESSAGE_SOURCE_WINDOWS_OS 10 116144966Svkashyap 117144966Svkashyap#define TW_CL_SEVERITY_ERROR 0x1 118144966Svkashyap#define TW_CL_SEVERITY_WARNING 0x2 119144966Svkashyap#define TW_CL_SEVERITY_INFO 0x3 120144966Svkashyap#define TW_CL_SEVERITY_DEBUG 0x4 121144966Svkashyap 122144966Svkashyap#define TW_CL_SEVERITY_ERROR_STRING "ERROR" 123144966Svkashyap#define TW_CL_SEVERITY_WARNING_STRING "WARNING" 124144966Svkashyap#define TW_CL_SEVERITY_INFO_STRING "INFO" 125144966Svkashyap#define TW_CL_SEVERITY_DEBUG_STRING "DEBUG" 126144966Svkashyap 127144966Svkashyap 128144966Svkashyap#pragma pack(1) 129144966Svkashyap 130144966Svkashyap/* 131144966Svkashyap * Structure, a pointer to which is used as the controller handle in 132144966Svkashyap * communications between the OS Layer and the Common Layer. 133144966Svkashyap */ 134144966Svkashyapstruct tw_cl_ctlr_handle { 135144966Svkashyap TW_VOID *osl_ctlr_ctxt; /* OSL's ctlr context */ 136144966Svkashyap TW_VOID *cl_ctlr_ctxt; /* CL's ctlr context */ 137144966Svkashyap}; 138144966Svkashyap 139144966Svkashyap 140144966Svkashyap/* 141144966Svkashyap * Structure, a pointer to which is used as the request handle in 142144966Svkashyap * communications between the OS Layer and the Common Layer. 143144966Svkashyap */ 144144966Svkashyapstruct tw_cl_req_handle { 145144966Svkashyap TW_VOID *osl_req_ctxt; /* OSL's request context */ 146144966Svkashyap TW_VOID *cl_req_ctxt; /* CL's request context */ 147144966Svkashyap}; 148144966Svkashyap 149144966Svkashyap 150144966Svkashyap/* Structure used to describe SCSI requests to CL. */ 151144966Svkashyapstruct tw_cl_scsi_req_packet { 152144966Svkashyap TW_UINT32 unit; /* unit # to send cmd to */ 153144966Svkashyap TW_UINT32 lun; /* LUN to send cmd to */ 154144966Svkashyap TW_UINT8 *cdb; /* ptr to SCSI cdb */ 155144966Svkashyap TW_UINT32 cdb_len; /* # of valid cdb bytes */ 156144966Svkashyap TW_UINT32 sense_len; /* # of bytes of valid sense info */ 157144966Svkashyap TW_UINT8 *sense_data; /* ptr to sense data, if any */ 158144966Svkashyap TW_UINT32 scsi_status; /* SCSI status returned by fw */ 159144966Svkashyap TW_UINT32 sgl_entries; /* # of SG descriptors */ 160144966Svkashyap TW_UINT8 *sg_list; /* ptr to SG list */ 161144966Svkashyap}; 162144966Svkashyap 163144966Svkashyap 164144966Svkashyap/* Structure used to describe pass through command packets to CL. */ 165144966Svkashyapstruct tw_cl_passthru_req_packet { 166144966Svkashyap TW_UINT8 *cmd_pkt; /* ptr to passthru cmd pkt */ 167144966Svkashyap TW_UINT32 cmd_pkt_length; /* size of cmd pkt */ 168144966Svkashyap TW_UINT32 sgl_entries; /* # of SG descriptors */ 169144966Svkashyap TW_UINT8 *sg_list; /* ptr to SG list */ 170144966Svkashyap}; 171144966Svkashyap 172144966Svkashyap 173144966Svkashyap/* Request packet submitted to the Common Layer, by the OS Layer. */ 174144966Svkashyapstruct tw_cl_req_packet { 175144966Svkashyap TW_UINT32 cmd; /* Common Layer cmd */ 176144966Svkashyap TW_UINT32 flags; /* flags describing request */ 177144966Svkashyap TW_UINT32 status; /* Common Layer returned status */ 178144966Svkashyap TW_VOID (*tw_osl_callback)(struct tw_cl_req_handle *req_handle); 179144966Svkashyap /* OSL routine to be called by CL on req completion */ 180144966Svkashyap TW_VOID (*tw_osl_sgl_callback)( 181144966Svkashyap struct tw_cl_req_handle *req_handle, TW_VOID *sg_list, 182144966Svkashyap TW_UINT32 *num_sgl_entries); 183144966Svkashyap /* OSL callback to get SG list. */ 184144966Svkashyap 185144966Svkashyap union { 186144966Svkashyap struct tw_cl_scsi_req_packet scsi_req; /* SCSI req */ 187144966Svkashyap struct tw_cl_passthru_req_packet pt_req;/*Passthru req*/ 188144966Svkashyap } gen_req_pkt; 189144966Svkashyap}; 190144966Svkashyap 191144966Svkashyap 192144966Svkashyap/* 193144966Svkashyap * Packet that describes an AEN/error generated by the controller, 194144966Svkashyap * Common Layer, or even the OS Layer. 195144966Svkashyap */ 196144966Svkashyapstruct tw_cl_event_packet { 197144966Svkashyap TW_UINT32 sequence_id; 198144966Svkashyap TW_UINT32 time_stamp_sec; 199144966Svkashyap TW_UINT16 aen_code; 200144966Svkashyap TW_UINT8 severity; 201144966Svkashyap TW_UINT8 retrieved; 202144966Svkashyap TW_UINT8 repeat_count; 203144966Svkashyap TW_UINT8 parameter_len; 204144966Svkashyap TW_UINT8 parameter_data[98]; 205144966Svkashyap TW_UINT32 event_src; 206144966Svkashyap TW_UINT8 severity_str[20]; 207144966Svkashyap}; 208144966Svkashyap 209144966Svkashyap 210144966Svkashyap/* Structure to link 2 adjacent elements in a list. */ 211144966Svkashyapstruct tw_cl_link { 212144966Svkashyap struct tw_cl_link *next; 213144966Svkashyap struct tw_cl_link *prev; 214144966Svkashyap}; 215144966Svkashyap 216144966Svkashyap 217144966Svkashyap/* Scatter/Gather list entry with 32 bit addresses. */ 218144966Svkashyapstruct tw_cl_sg_desc32 { 219144966Svkashyap TW_UINT32 address; 220144966Svkashyap TW_UINT32 length; 221144966Svkashyap}; 222144966Svkashyap 223144966Svkashyap 224144966Svkashyap/* Scatter/Gather list entry with 64 bit addresses. */ 225144966Svkashyapstruct tw_cl_sg_desc64 { 226144966Svkashyap TW_UINT64 address; 227144966Svkashyap TW_UINT32 length; 228144966Svkashyap}; 229144966Svkashyap 230144966Svkashyap#pragma pack() 231144966Svkashyap 232144966Svkashyap 233144966Svkashyap/* Byte swap functions. Valid only if running on big endian platforms. */ 234144966Svkashyap#ifdef TW_OSL_BIG_ENDIAN 235144966Svkashyap 236144966Svkashyap#define TW_CL_SWAP16_WITH_CAST(x) \ 237144966Svkashyap ((x << 8) | (x >> 8)) 238144966Svkashyap 239144966Svkashyap 240144966Svkashyap#define TW_CL_SWAP32_WITH_CAST(x) \ 241144966Svkashyap ((x << 24) | ((x << 8) & (0xFF0000)) | \ 242144966Svkashyap ((x >> 8) & (0xFF00)) | (x >> 24)) 243144966Svkashyap 244144966Svkashyap 245144966Svkashyap#define TW_CL_SWAP64_WITH_CAST(x) \ 246144966Svkashyap ((((TW_UINT64)(TW_CL_SWAP32(((TW_UINT32 *)(&(x)))[1]))) << 32) |\ 247144966Svkashyap ((TW_UINT32)(TW_CL_SWAP32(((TW_UINT32 *)(&(x)))[0])))) 248144966Svkashyap 249144966Svkashyap 250144966Svkashyap#else /* TW_OSL_BIG_ENDIAN */ 251144966Svkashyap 252144966Svkashyap#define TW_CL_SWAP16_WITH_CAST(x) x 253144966Svkashyap#define TW_CL_SWAP32_WITH_CAST(x) x 254144966Svkashyap#define TW_CL_SWAP64_WITH_CAST(x) x 255144966Svkashyap 256144966Svkashyap#endif /* TW_OSL_BIG_ENDIAN */ 257144966Svkashyap 258144966Svkashyap#define TW_CL_SWAP16(x) TW_CL_SWAP16_WITH_CAST((TW_UINT16)(x)) 259144966Svkashyap#define TW_CL_SWAP32(x) TW_CL_SWAP32_WITH_CAST((TW_UINT32)(x)) 260144966Svkashyap#define TW_CL_SWAP64(x) TW_CL_SWAP64_WITH_CAST((TW_UINT64)(x)) 261144966Svkashyap 262144966Svkashyap 263144966Svkashyap/* Queue manipulation functions. */ 264144966Svkashyap 265144966Svkashyap/* Initialize a queue. */ 266144966Svkashyap#define TW_CL_Q_INIT(head) do { \ 267144966Svkashyap (head)->prev = (head)->next = head; \ 268144966Svkashyap} while (0) 269144966Svkashyap 270144966Svkashyap 271144966Svkashyap/* Insert an item at the head of the queue. */ 272144966Svkashyap#define TW_CL_Q_INSERT_HEAD(head, item) do { \ 273144966Svkashyap (item)->next = (head)->next; \ 274144966Svkashyap (item)->prev = head; \ 275144966Svkashyap (head)->next->prev = item; \ 276144966Svkashyap (head)->next = item; \ 277144966Svkashyap} while (0) 278144966Svkashyap 279144966Svkashyap 280144966Svkashyap/* Insert an item at the tail of the queue. */ 281144966Svkashyap#define TW_CL_Q_INSERT_TAIL(head, item) do { \ 282144966Svkashyap (item)->next = head; \ 283144966Svkashyap (item)->prev = (head)->prev; \ 284144966Svkashyap (head)->prev->next = item; \ 285144966Svkashyap (head)->prev = item; \ 286144966Svkashyap} while (0) 287144966Svkashyap 288144966Svkashyap 289144966Svkashyap/* Remove an item from the head of the queue. */ 290144966Svkashyap#define TW_CL_Q_REMOVE_ITEM(head, item) do { \ 291144966Svkashyap (item)->prev->next = (item)->next; \ 292144966Svkashyap (item)->next->prev = (item)->prev; \ 293144966Svkashyap} while (0) 294144966Svkashyap 295144966Svkashyap 296144966Svkashyap/* Retrieve the item at the head of the queue. */ 297144966Svkashyap#define TW_CL_Q_FIRST_ITEM(head) \ 298144966Svkashyap (((head)->next != head) ? ((head)->next) : TW_CL_NULL) 299144966Svkashyap 300144966Svkashyap 301144966Svkashyap/* Retrieve the item at the tail of the queue. */ 302144966Svkashyap#define TW_CL_Q_LAST_ITEM(head) \ 303144966Svkashyap (((head)->prev != head) ? ((head)->prev) : TW_CL_NULL) 304144966Svkashyap 305144966Svkashyap 306144966Svkashyap/* Retrieve the item next to a given item in the queue. */ 307144966Svkashyap#define TW_CL_Q_NEXT_ITEM(head, item) \ 308144966Svkashyap (((item)->next != head) ? ((item)->next) : TW_CL_NULL) 309144966Svkashyap 310144966Svkashyap 311144966Svkashyap/* Retrieve the item previous to a given item in the queue. */ 312144966Svkashyap#define TW_CL_Q_PREV_ITEM(head, item) \ 313144966Svkashyap (((item)->prev != head) ? ((item)->prev) : TW_CL_NULL) 314144966Svkashyap 315144966Svkashyap 316144966Svkashyap/* Determine the offset of a field from the head of the structure it is in. */ 317144966Svkashyap#define TW_CL_STRUCT_OFFSET(struct_type, field) \ 318144966Svkashyap (TW_INT8 *)(&((struct_type *)0)->field) 319144966Svkashyap 320144966Svkashyap 321144966Svkashyap/* 322144966Svkashyap * Determine the address of the head of a structure, given the address of a 323144966Svkashyap * field within it. 324144966Svkashyap */ 325144966Svkashyap#define TW_CL_STRUCT_HEAD(addr, struct_type, field) \ 326144966Svkashyap (struct_type *)((TW_INT8 *)addr - \ 327144966Svkashyap TW_CL_STRUCT_OFFSET(struct_type, field)) 328144966Svkashyap 329144966Svkashyap 330144966Svkashyap 331152213Svkashyap#ifndef TW_BUILDING_API 332152213Svkashyap 333152213Svkashyap#include "tw_osl_inline.h" 334152213Svkashyap 335152213Svkashyap 336152213Svkashyap 337144966Svkashyap/* 338144966Svkashyap * The following are extern declarations of OS Layer defined functions called 339144966Svkashyap * by the Common Layer. If any function has been defined as a macro in 340144966Svkashyap * tw_osl_share.h, we will not make the extern declaration here. 341144966Svkashyap */ 342144966Svkashyap 343144966Svkashyap#ifndef tw_osl_breakpoint 344144966Svkashyap/* Allows setting breakpoints in the CL code for debugging purposes. */ 345144966Svkashyapextern TW_VOID tw_osl_breakpoint(TW_VOID); 346144966Svkashyap#endif 347144966Svkashyap 348144966Svkashyap 349152213Svkashyap#ifndef tw_osl_ctlr_busy 350152213Svkashyap/* Called when CL is too busy to accept new requests. */ 351152213Svkashyapextern TW_VOID tw_osl_ctlr_busy(struct tw_cl_ctlr_handle *ctlr_handle, 352152213Svkashyap struct tw_cl_req_handle *req_handle); 353152213Svkashyap#endif 354152213Svkashyap 355152213Svkashyap 356144966Svkashyap#ifndef tw_osl_ctlr_ready 357144966Svkashyap/* Called on cmd interrupt. Allows re-submission of any pending requests. */ 358144966Svkashyapextern TW_VOID tw_osl_ctlr_ready(struct tw_cl_ctlr_handle *ctlr_handle); 359144966Svkashyap#endif 360144966Svkashyap 361144966Svkashyap 362144966Svkashyap#ifndef tw_osl_cur_func 363144966Svkashyap/* Text name of current function. */ 364144966Svkashyapextern TW_INT8 *tw_osl_cur_func(TW_VOID); 365144966Svkashyap#endif 366144966Svkashyap 367144966Svkashyap 368144966Svkashyap#ifdef TW_OSL_DEBUG 369144966Svkashyap#ifndef tw_osl_dbg_printf 370144966Svkashyap/* Print to syslog/event log/debug console, as applicable. */ 371144966Svkashyapextern TW_INT32 tw_osl_dbg_printf(struct tw_cl_ctlr_handle *ctlr_handle, 372144966Svkashyap const TW_INT8 *fmt, ...); 373144966Svkashyap#endif 374144966Svkashyap#endif /* TW_OSL_DEBUG */ 375144966Svkashyap 376144966Svkashyap 377144966Svkashyap#ifndef tw_osl_delay 378144966Svkashyap/* Cause a delay of usecs micro-seconds. */ 379144966Svkashyapextern TW_VOID tw_osl_delay(TW_INT32 usecs); 380144966Svkashyap#endif 381144966Svkashyap 382144966Svkashyap 383144966Svkashyap#ifndef tw_osl_destroy_lock 384144966Svkashyap/* Create/initialize a lock for CL's use. */ 385144966Svkashyapextern TW_VOID tw_osl_destroy_lock(struct tw_cl_ctlr_handle *ctlr_handle, 386144966Svkashyap TW_LOCK_HANDLE *lock); 387144966Svkashyap#endif 388144966Svkashyap 389144966Svkashyap 390144966Svkashyap#ifndef tw_osl_free_lock 391144966Svkashyap/* Free a previously held lock. */ 392144966Svkashyapextern TW_VOID tw_osl_free_lock(struct tw_cl_ctlr_handle *ctlr_handle, 393144966Svkashyap TW_LOCK_HANDLE *lock); 394144966Svkashyap#endif 395144966Svkashyap 396144966Svkashyap 397144966Svkashyap#ifndef tw_osl_get_local_time 398144966Svkashyap/* Get local time. */ 399144966Svkashyapextern TW_TIME tw_osl_get_local_time(TW_VOID); 400144966Svkashyap#endif 401144966Svkashyap 402144966Svkashyap 403144966Svkashyap#ifndef tw_osl_get_lock 404144966Svkashyap/* Acquire a lock. */ 405144966Svkashyapextern TW_VOID tw_osl_get_lock(struct tw_cl_ctlr_handle *ctlr_handle, 406144966Svkashyap TW_LOCK_HANDLE *lock); 407144966Svkashyap#endif 408144966Svkashyap 409144966Svkashyap 410144966Svkashyap#ifndef tw_osl_init_lock 411144966Svkashyap/* Create/initialize a lock for CL's use. */ 412144966Svkashyapextern TW_VOID tw_osl_init_lock(struct tw_cl_ctlr_handle *ctlr_handle, 413144966Svkashyap TW_INT8 *lock_name, TW_LOCK_HANDLE *lock); 414144966Svkashyap#endif 415144966Svkashyap 416144966Svkashyap 417144966Svkashyap#ifndef tw_osl_memcpy 418144966Svkashyap/* Copy 'size' bytes from 'src' to 'dest'. */ 419144966Svkashyapextern TW_VOID tw_osl_memcpy(TW_VOID *src, TW_VOID *dest, TW_INT32 size); 420144966Svkashyap#endif 421144966Svkashyap 422144966Svkashyap 423144966Svkashyap#ifndef tw_osl_memzero 424144966Svkashyap/* Zero 'size' bytes starting at 'addr'. */ 425144966Svkashyapextern TW_VOID tw_osl_memzero(TW_VOID *addr, TW_INT32 size); 426144966Svkashyap#endif 427144966Svkashyap 428144966Svkashyap 429144966Svkashyap#ifndef tw_osl_notify_event 430144966Svkashyap/* Notify OSL of a controller/CL (or even OSL) event. */ 431144966Svkashyapextern TW_VOID tw_osl_notify_event(struct tw_cl_ctlr_handle *ctlr_handle, 432144966Svkashyap struct tw_cl_event_packet *event); 433144966Svkashyap#endif 434144966Svkashyap 435144966Svkashyap 436144966Svkashyap#ifdef TW_OSL_PCI_CONFIG_ACCESSIBLE 437144966Svkashyap#ifndef tw_osl_read_pci_config 438144966Svkashyap/* Read 'size' bytes from 'offset' in the PCI config space. */ 439144966Svkashyapextern TW_UINT32 tw_osl_read_pci_config( 440144966Svkashyap struct tw_cl_ctlr_handle *ctlr_handle, TW_INT32 offset, TW_INT32 size); 441144966Svkashyap#endif 442144966Svkashyap#endif /* TW_OSL_PCI_CONFIG_ACCESSIBLE */ 443144966Svkashyap 444144966Svkashyap 445144966Svkashyap#ifndef tw_osl_read_reg 446144966Svkashyap/* Read 'size' bytes at 'offset' from base address of this controller. */ 447144966Svkashyapextern TW_UINT32 tw_osl_read_reg(struct tw_cl_ctlr_handle *ctlr_handle, 448144966Svkashyap TW_INT32 offset, TW_INT32 size); 449144966Svkashyap#endif 450144966Svkashyap 451144966Svkashyap 452144966Svkashyap#ifndef tw_osl_scan_bus 453144966Svkashyap/* Request OSL for a bus scan. */ 454144966Svkashyapextern TW_VOID tw_osl_scan_bus(struct tw_cl_ctlr_handle *ctlr_handle); 455144966Svkashyap#endif 456144966Svkashyap 457144966Svkashyap 458144966Svkashyap#ifdef TW_OSL_CAN_SLEEP 459144966Svkashyap#ifndef tw_osl_sleep 460144966Svkashyap/* Sleep for 'timeout' ms or until woken up (by tw_osl_wakeup). */ 461144966Svkashyapextern TW_INT32 tw_osl_sleep(struct tw_cl_ctlr_handle *ctlr_handle, 462144966Svkashyap TW_SLEEP_HANDLE *sleep_handle, TW_INT32 timeout); 463144966Svkashyap#endif 464144966Svkashyap#endif /* TW_OSL_CAN_SLEEP */ 465144966Svkashyap 466144966Svkashyap 467144966Svkashyap#ifndef tw_osl_sprintf 468144966Svkashyap/* Standard sprintf. */ 469144966Svkashyapextern TW_INT32 tw_osl_sprintf(TW_INT8 *dest, const TW_INT8 *fmt, ...); 470144966Svkashyap#endif 471144966Svkashyap 472144966Svkashyap 473144966Svkashyap#ifndef tw_osl_strcpy 474144966Svkashyap/* Copy string 'src' to 'dest'. */ 475144966Svkashyapextern TW_INT8 *tw_osl_strcpy(TW_INT8 *dest, TW_INT8 *src); 476144966Svkashyap#endif 477144966Svkashyap 478144966Svkashyap 479144966Svkashyap#ifndef tw_osl_strlen 480144966Svkashyap/* Return length of string pointed at by 'str'. */ 481144966Svkashyapextern TW_INT32 tw_osl_strlen(TW_VOID *str); 482144966Svkashyap#endif 483144966Svkashyap 484152213Svkashyap#ifndef tw_osl_vsprintf 485152213Svkashyap/* Standard vsprintf. */ 486152213Svkashyapextern TW_INT32 tw_osl_vsprintf(TW_INT8 *dest, const TW_INT8 *fmt, va_list ap); 487152213Svkashyap#endif 488152213Svkashyap 489152213Svkashyap 490144966Svkashyap#ifdef TW_OSL_CAN_SLEEP 491144966Svkashyap#ifndef tw_osl_wakeup 492144966Svkashyap/* Wake up a thread sleeping by a call to tw_osl_sleep. */ 493144966Svkashyapextern TW_VOID tw_osl_wakeup(struct tw_cl_ctlr_handle *ctlr_handle, 494144966Svkashyap TW_SLEEP_HANDLE *sleep_handle); 495144966Svkashyap#endif 496144966Svkashyap#endif /* TW_OSL_CAN_SLEEP */ 497144966Svkashyap 498144966Svkashyap 499144966Svkashyap#ifdef TW_OSL_PCI_CONFIG_ACCESSIBLE 500144966Svkashyap#ifndef tw_osl_write_pci_config 501144966Svkashyap/* Write 'value' of 'size' bytes at 'offset' in the PCI config space. */ 502144966Svkashyapextern TW_VOID tw_osl_write_pci_config(struct tw_cl_ctlr_handle *ctlr_handle, 503144966Svkashyap TW_INT32 offset, TW_INT32 value, TW_INT32 size); 504144966Svkashyap#endif 505144966Svkashyap#endif /* TW_OSL_PCI_CONFIG_ACCESSIBLE */ 506144966Svkashyap 507144966Svkashyap 508144966Svkashyap#ifndef tw_osl_write_reg 509144966Svkashyap/* 510144966Svkashyap * Write 'value' of 'size' (max 4) bytes at 'offset' from base address of 511144966Svkashyap * this controller. 512144966Svkashyap */ 513144966Svkashyapextern TW_VOID tw_osl_write_reg(struct tw_cl_ctlr_handle *ctlr_handle, 514144966Svkashyap TW_INT32 offset, TW_INT32 value, TW_INT32 size); 515144966Svkashyap#endif 516144966Svkashyap 517144966Svkashyap 518144966Svkashyap 519144966Svkashyap/* Functions in the Common Layer */ 520144966Svkashyap 521144966Svkashyap/* Creates and queues AEN's. Also notifies OS Layer. */ 522144966Svkashyapextern TW_VOID tw_cl_create_event(struct tw_cl_ctlr_handle *ctlr_handle, 523144966Svkashyap TW_UINT8 queue_event, TW_UINT8 event_src, TW_UINT16 event_code, 524144966Svkashyap TW_UINT8 severity, TW_UINT8 *severity_str, TW_UINT8 *event_desc, 525144966Svkashyap TW_UINT8 *event_specific_desc, ...); 526144966Svkashyap 527144966Svkashyap/* Indicates whether a ctlr is supported by CL. */ 528144966Svkashyapextern TW_INT32 tw_cl_ctlr_supported(TW_INT32 vendor_id, TW_INT32 device_id); 529144966Svkashyap 530144966Svkashyap 531144966Svkashyap/* Deferred interrupt handler. */ 532144966Svkashyapextern TW_VOID tw_cl_deferred_interrupt(struct tw_cl_ctlr_handle *ctlr_handle); 533144966Svkashyap 534144966Svkashyap 535144966Svkashyap/* Submit a firmware cmd packet. */ 536144966Svkashyapextern TW_INT32 tw_cl_fw_passthru(struct tw_cl_ctlr_handle *ctlr_handle, 537144966Svkashyap struct tw_cl_req_packet *req_pkt, struct tw_cl_req_handle *req_handle); 538144966Svkashyap 539144966Svkashyap 540144966Svkashyap/* Find out how much memory CL needs. */ 541144966Svkashyapextern TW_INT32 tw_cl_get_mem_requirements( 542144966Svkashyap struct tw_cl_ctlr_handle *ctlr_handle, TW_UINT32 flags, 543152213Svkashyap TW_INT32 device_id, TW_INT32 max_simult_reqs, TW_INT32 max_aens, 544144966Svkashyap TW_UINT32 *alignment, TW_UINT32 *sg_size_factor, 545144966Svkashyap TW_UINT32 *non_dma_mem_size, TW_UINT32 *dma_mem_size 546144966Svkashyap ); 547144966Svkashyap 548144966Svkashyap 549152213Svkashyap/* Return PCI BAR info. */ 550152213Svkashyapextern TW_INT32 tw_cl_get_pci_bar_info(TW_INT32 device_id, TW_INT32 bar_type, 551152213Svkashyap TW_INT32 *bar_num, TW_INT32 *bar0_offset, TW_INT32 *bar_size); 552152213Svkashyap 553152213Svkashyap 554144966Svkashyap/* Initialize Common Layer for a given controller. */ 555144966Svkashyapextern TW_INT32 tw_cl_init_ctlr(struct tw_cl_ctlr_handle *ctlr_handle, 556152213Svkashyap TW_UINT32 flags, TW_INT32 device_id, TW_INT32 max_simult_reqs, 557152213Svkashyap TW_INT32 max_aens, TW_VOID *non_dma_mem, TW_VOID *dma_mem, 558152213Svkashyap TW_UINT64 dma_mem_phys 559144966Svkashyap ); 560144966Svkashyap 561144966Svkashyap 562144966Svkashyap/* CL's interrupt handler. */ 563144966Svkashyapextern TW_INT32 tw_cl_interrupt(struct tw_cl_ctlr_handle *ctlr_handle); 564144966Svkashyap 565144966Svkashyap 566144966Svkashyap/* CL's ioctl handler. */ 567144966Svkashyapextern TW_INT32 tw_cl_ioctl(struct tw_cl_ctlr_handle *ctlr_handle, 568197409Srdivacky u_long cmd, TW_VOID *buf); 569144966Svkashyap 570144966Svkashyap 571144966Svkashyap#ifdef TW_OSL_DEBUG 572144966Svkashyap/* Print CL's state/statistics for a controller. */ 573144966Svkashyapextern TW_VOID tw_cl_print_ctlr_stats(struct tw_cl_ctlr_handle *ctlr_handle); 574144966Svkashyap 575144966Svkashyap/* Prints CL internal details of a given request. */ 576144966Svkashyapextern TW_VOID tw_cl_print_req_info(struct tw_cl_req_handle *req_handle); 577144966Svkashyap#endif /* TW_OSL_DEBUG */ 578144966Svkashyap 579144966Svkashyap 580144966Svkashyap/* Soft reset controller. */ 581144966Svkashyapextern TW_INT32 tw_cl_reset_ctlr(struct tw_cl_ctlr_handle *ctlr_handle); 582144966Svkashyap 583144966Svkashyap 584144966Svkashyap#ifdef TW_OSL_DEBUG 585144966Svkashyap/* Reset CL's statistics for a controller. */ 586144966Svkashyapextern TW_VOID tw_cl_reset_stats(struct tw_cl_ctlr_handle *ctlr_handle); 587144966Svkashyap#endif /* TW_OSL_DEBUG */ 588144966Svkashyap 589144966Svkashyap 590144966Svkashyap/* Stop a controller. */ 591144966Svkashyapextern TW_INT32 tw_cl_shutdown_ctlr(struct tw_cl_ctlr_handle *ctlr_handle, 592144966Svkashyap TW_UINT32 flags); 593144966Svkashyap 594144966Svkashyap 595144966Svkashyap/* Submit a SCSI I/O request. */ 596144966Svkashyapextern TW_INT32 tw_cl_start_io(struct tw_cl_ctlr_handle *ctlr_handle, 597144966Svkashyap struct tw_cl_req_packet *req_pkt, struct tw_cl_req_handle *req_handle); 598144966Svkashyap 599144966Svkashyap 600152213Svkashyap#endif /* TW_BUILDING_API */ 601152213Svkashyap 602144966Svkashyap#endif /* TW_CL_SHARE_H */ 603