1a23fd118Syl /* 2a23fd118Syl * CDDL HEADER START 3a23fd118Syl * 4a23fd118Syl * The contents of this file are subject to the terms of the 5a23fd118Syl * Common Development and Distribution License (the "License"). 6a23fd118Syl * You may not use this file except in compliance with the License. 7a23fd118Syl * 8a23fd118Syl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9a23fd118Syl * or http://www.opensolaris.org/os/licensing. 10a23fd118Syl * See the License for the specific language governing permissions 11a23fd118Syl * and limitations under the License. 12a23fd118Syl * 13a23fd118Syl * When distributing Covered Code, include this CDDL HEADER in each 14a23fd118Syl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15a23fd118Syl * If applicable, add the following below this CDDL HEADER, with the 16a23fd118Syl * fields enclosed by brackets "[]" replaced with your own identifying 17a23fd118Syl * information: Portions Copyright [yyyy] [name of copyright owner] 18a23fd118Syl * 19a23fd118Syl * CDDL HEADER END 20a23fd118Syl * 218347601bSyl * Copyright (c) 2002-2006 Neterion, Inc. 22a23fd118Syl */ 23a23fd118Syl 24*da14cebeSEric Cheng /* 25*da14cebeSEric Cheng * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 26*da14cebeSEric Cheng * Use is subject to license terms. 27*da14cebeSEric Cheng */ 28*da14cebeSEric Cheng 29a23fd118Syl #ifndef XGE_HAL_CHANNEL_H 30a23fd118Syl #define XGE_HAL_CHANNEL_H 31a23fd118Syl 32a23fd118Syl #include "xge-os-pal.h" 33a23fd118Syl #include "xge-list.h" 34a23fd118Syl #include "xgehal-types.h" 35a23fd118Syl #include "xgehal-stats.h" 36a23fd118Syl 378347601bSyl __EXTERN_BEGIN_DECLS 388347601bSyl 39a23fd118Syl /** 40a23fd118Syl * enum xge_hal_channel_type_e - Enumerated channel types. 41a23fd118Syl * @XGE_HAL_CHANNEL_TYPE_FIFO: fifo. 42a23fd118Syl * @XGE_HAL_CHANNEL_TYPE_RING: ring. 437eced415Sxw * @XGE_HAL_CHANNEL_TYPE_SEND_QUEUE: Send Queue 447eced415Sxw * @XGE_HAL_CHANNEL_TYPE_RECEIVE_QUEUE: Receive Queue 457eced415Sxw * @XGE_HAL_CHANNEL_TYPE_COMPLETION_QUEUE: Receive queue completion queue 467eced415Sxw * @XGE_HAL_CHANNEL_TYPE_UP_MESSAGE_QUEUE: Up message queue 477eced415Sxw * @XGE_HAL_CHANNEL_TYPE_DOWN_MESSAGE_QUEUE: Down message queue 48a23fd118Syl * @XGE_HAL_CHANNEL_TYPE_MAX: Maximum number of HAL-supported 49a23fd118Syl * (and recognized) channel types. Currently: two. 50a23fd118Syl * 51a23fd118Syl * Enumerated channel types. Currently there are only two link-layer 52a23fd118Syl * channels - Xframe fifo and Xframe ring. In the future the list will grow. 53a23fd118Syl */ 54a23fd118Syl typedef enum xge_hal_channel_type_e { 55a23fd118Syl XGE_HAL_CHANNEL_TYPE_FIFO, 56a23fd118Syl XGE_HAL_CHANNEL_TYPE_RING, 578347601bSyl XGE_HAL_CHANNEL_TYPE_SEND_QUEUE, 587eced415Sxw XGE_HAL_CHANNEL_TYPE_RECEIVE_QUEUE, 597eced415Sxw XGE_HAL_CHANNEL_TYPE_COMPLETION_QUEUE, 608347601bSyl XGE_HAL_CHANNEL_TYPE_UP_MESSAGE_QUEUE, 618347601bSyl XGE_HAL_CHANNEL_TYPE_DOWN_MESSAGE_QUEUE, 62a23fd118Syl XGE_HAL_CHANNEL_TYPE_MAX 63a23fd118Syl } xge_hal_channel_type_e; 64a23fd118Syl 65a23fd118Syl /** 66a23fd118Syl * enum xge_hal_channel_flag_e - Channel flags. 67a23fd118Syl * @XGE_HAL_CHANNEL_FLAG_NONE: zero (nil) flag. 68a23fd118Syl * @XGE_HAL_CHANNEL_FLAG_USE_TX_LOCK: use lock when posting transmit 69a23fd118Syl * descriptor. 70a23fd118Syl * @XGE_HAL_CHANNEL_FLAG_FREE_RXD: to-be-defined. 71a23fd118Syl * 72a23fd118Syl * Channel opening flags. Reserved for future usage. 73a23fd118Syl */ 74a23fd118Syl typedef enum xge_hal_channel_flag_e { 75a23fd118Syl XGE_HAL_CHANNEL_FLAG_NONE = 0x0, 76a23fd118Syl XGE_HAL_CHANNEL_FLAG_USE_TX_LOCK = 0x1, 77*da14cebeSEric Cheng XGE_HAL_CHANNEL_FLAG_FREE_RXD = 0x2, 78*da14cebeSEric Cheng XGE_HAL_CHANNEL_FLAG_USE_RX_POLLING = 0x4 79a23fd118Syl } xge_hal_channel_flag_e; 80a23fd118Syl 81a23fd118Syl /** 82a23fd118Syl * enum xge_hal_dtr_state_e - Descriptor (DTR) state. 83a23fd118Syl * @XGE_HAL_DTR_STATE_NONE: Invalid state. 84a23fd118Syl * @XGE_HAL_DTR_STATE_AVAIL: Descriptor is available for reservation 85a23fd118Syl * (via xge_hal_fifo_dtr_reserve(), xge_hal_ring_dtr_reserve(), etc.). 86a23fd118Syl * @XGE_HAL_DTR_STATE_POSTED: Descriptor is posted for processing by the 87a23fd118Syl * device. 88a23fd118Syl * @XGE_HAL_DTR_STATE_FREED: Descriptor is free and can be reused for 89a23fd118Syl * filling-in and posting later. 90a23fd118Syl * 91a23fd118Syl * Xframe/HAL descriptor states. For more on descriptor states and transitions 92a23fd118Syl * please refer to ch_intern{}. 93a23fd118Syl * 94a23fd118Syl * See also: xge_hal_channel_dtr_term_f{}. 95a23fd118Syl */ 96a23fd118Syl typedef enum xge_hal_dtr_state_e { 97a23fd118Syl XGE_HAL_DTR_STATE_NONE = 0, 98a23fd118Syl XGE_HAL_DTR_STATE_AVAIL = 1, 99a23fd118Syl XGE_HAL_DTR_STATE_POSTED = 2, 100a23fd118Syl XGE_HAL_DTR_STATE_FREED = 3 101a23fd118Syl } xge_hal_dtr_state_e; 102a23fd118Syl 103a23fd118Syl /** 104a23fd118Syl * enum xge_hal_channel_reopen_e - Channel open, close, or reopen option. 105a23fd118Syl * @XGE_HAL_CHANNEL_RESET_ONLY: Do not (de)allocate channel; used with 106a23fd118Syl * xge_hal_channel_open(), xge_hal_channel_close(). 107a23fd118Syl * @XGE_HAL_CHANNEL_OC_NORMAL: Do (de)allocate channel; used with 108a23fd118Syl * xge_hal_channel_open(), xge_hal_channel_close(). 109a23fd118Syl * 110a23fd118Syl * Enumerates options used with channel open and close operations. 111a23fd118Syl * The @XGE_HAL_CHANNEL_RESET_ONLY can be used when resetting the device; 112a23fd118Syl * in this case there is actually no need to free and then again malloc 113a23fd118Syl * the memory (including DMA-able memory) used for channel operation. 114a23fd118Syl */ 115a23fd118Syl typedef enum xge_hal_channel_reopen_e { 116a23fd118Syl XGE_HAL_CHANNEL_RESET_ONLY = 1, 117a23fd118Syl XGE_HAL_CHANNEL_OC_NORMAL = 2 118a23fd118Syl } xge_hal_channel_reopen_e; 119a23fd118Syl 120a23fd118Syl /** 121a23fd118Syl * function xge_hal_channel_callback_f - Channel callback. 122a23fd118Syl * @channelh: Channel "containing" 1 or more completed descriptors. 123a23fd118Syl * @dtrh: First completed descriptor. 124a23fd118Syl * @t_code: Transfer code, as per Xframe User Guide. 125a23fd118Syl * Returned by HAL. 126a23fd118Syl * @host_control: Opaque 64bit data stored by ULD inside the Xframe 127a23fd118Syl * descriptor prior to posting the latter on the channel 128a23fd118Syl * via xge_hal_fifo_dtr_post() or xge_hal_ring_dtr_post(). 129a23fd118Syl * The @host_control is returned as is to the ULD with each 130a23fd118Syl * completed descriptor. 131a23fd118Syl * @userdata: Opaque per-channel data specified at channel open 132a23fd118Syl * time, via xge_hal_channel_open(). 133a23fd118Syl * 134a23fd118Syl * Channel completion callback (type declaration). A single per-channel 135a23fd118Syl * callback is specified at channel open time, via 136a23fd118Syl * xge_hal_channel_open(). 137a23fd118Syl * Typically gets called as part of the processing of the Interrupt 138a23fd118Syl * Service Routine. 139a23fd118Syl * 140a23fd118Syl * Channel callback gets called by HAL if, and only if, there is at least 141a23fd118Syl * one new completion on a given ring or fifo channel. Upon processing the 142a23fd118Syl * first @dtrh ULD is _supposed_ to continue consuming completions 1438347601bSyl * using�one of the following HAL APIs: 144a23fd118Syl * - xge_hal_fifo_dtr_next_completed() 145a23fd118Syl * or 146a23fd118Syl * - xge_hal_ring_dtr_next_completed(). 147a23fd118Syl * 148a23fd118Syl * Note that failure to process new completions in a timely fashion 149a23fd118Syl * leads to XGE_HAL_INF_OUT_OF_DESCRIPTORS condition. 150a23fd118Syl * 151a23fd118Syl * Non-zero @t_code means failure to process (transmit or receive, depending 152a23fd118Syl * on the channel type) the descriptor. 153a23fd118Syl * 154a23fd118Syl * In the "transmit" case the failure could happen, for instance, when the 155a23fd118Syl * link is down, in which case Xframe completes the descriptor because it 156a23fd118Syl * is not able to send the data out. 157a23fd118Syl * 158a23fd118Syl * For details please refer to Xframe User Guide. 159a23fd118Syl * 160a23fd118Syl * See also: xge_hal_fifo_dtr_next_completed(), 161a23fd118Syl * xge_hal_ring_dtr_next_completed(), xge_hal_channel_dtr_term_f{}. 162a23fd118Syl */ 163a23fd118Syl typedef xge_hal_status_e (*xge_hal_channel_callback_f) 164a23fd118Syl (xge_hal_channel_h channelh, xge_hal_dtr_h dtrh, 165a23fd118Syl u8 t_code, void *userdata); 166a23fd118Syl 167a23fd118Syl /** 168a23fd118Syl * function xge_hal_channel_dtr_init_f - Initialize descriptor callback. 169a23fd118Syl * @channelh: Channel "containing" the @dtrh descriptor. 170a23fd118Syl * @dtrh: Descriptor. 171a23fd118Syl * @index: Index of the descriptor in the channel's set of descriptors. 172a23fd118Syl * @userdata: Per-channel user data (a.k.a. context) specified at 173a23fd118Syl * channel open time, via xge_hal_channel_open(). 174a23fd118Syl * @reopen: See xge_hal_channel_reopen_e{}. 175a23fd118Syl * 176a23fd118Syl * Initialize descriptor callback. Unless NULL is specified in the 177a23fd118Syl * xge_hal_channel_attr_t{} structure passed to xge_hal_channel_open()), 178a23fd118Syl * HAL invokes the callback as part of the xge_hal_channel_open() 179a23fd118Syl * implementation. 180a23fd118Syl * For the ring type of channel the ULD is expected to fill in this descriptor 181a23fd118Syl * with buffer(s) and control information. 182a23fd118Syl * For the fifo type of channel the ULD could use the callback to 183a23fd118Syl * pre-set DMA mappings and/or alignment buffers. 184a23fd118Syl * 185a23fd118Syl * See also: xge_hal_channel_attr_t{}, xge_hal_channel_dtr_term_f{}. 186a23fd118Syl */ 187a23fd118Syl typedef xge_hal_status_e (*xge_hal_channel_dtr_init_f) 188a23fd118Syl (xge_hal_channel_h channelh, 189a23fd118Syl xge_hal_dtr_h dtrh, 190a23fd118Syl int index, 191a23fd118Syl void *userdata, 192a23fd118Syl xge_hal_channel_reopen_e reopen); 193a23fd118Syl 194a23fd118Syl /** 195a23fd118Syl * function xge_hal_channel_dtr_term_f - Terminate descriptor callback. 196a23fd118Syl * @channelh: Channel "containing" the @dtrh descriptor. 197a23fd118Syl * @dtrh: First completed descriptor. 198a23fd118Syl * @state: One of the xge_hal_dtr_state_e{} enumerated states. 199a23fd118Syl * @userdata: Per-channel user data (a.k.a. context) specified at 200a23fd118Syl * channel open time, via xge_hal_channel_open(). 201a23fd118Syl * @reopen: See xge_hal_channel_reopen_e{}. 202a23fd118Syl * 203a23fd118Syl * Terminate descriptor callback. Unless NULL is specified in the 204a23fd118Syl * xge_hal_channel_attr_t{} structure passed to xge_hal_channel_open()), 205a23fd118Syl * HAL invokes the callback as part of closing the corresponding 206a23fd118Syl * channel, prior to de-allocating the channel and associated data 207a23fd118Syl * structures (including descriptors). 208a23fd118Syl * ULD should utilize the callback to (for instance) unmap 209a23fd118Syl * and free DMA data buffers associated with the posted (state = 210a23fd118Syl * XGE_HAL_DTR_STATE_POSTED) descriptors, 211a23fd118Syl * as well as other relevant cleanup functions. 212a23fd118Syl * 213a23fd118Syl * See also: xge_hal_channel_attr_t{}, xge_hal_channel_dtr_init_f{}. 214a23fd118Syl */ 215a23fd118Syl typedef void (*xge_hal_channel_dtr_term_f) (xge_hal_channel_h channelh, 216a23fd118Syl xge_hal_dtr_h dtrh, 217a23fd118Syl xge_hal_dtr_state_e state, 218a23fd118Syl void *userdata, 219a23fd118Syl xge_hal_channel_reopen_e reopen); 220a23fd118Syl 221a23fd118Syl 222a23fd118Syl /** 223a23fd118Syl * struct xge_hal_channel_attr_t - Channel open "template". 224a23fd118Syl * @type: xge_hal_channel_type_e channel type. 2257eced415Sxw * @vp_id: Virtual path id 226a23fd118Syl * @post_qid: Queue ID to post descriptors. For the link layer this 227a23fd118Syl * number should be in the 0..7 range. 228a23fd118Syl * @compl_qid: Completion queue ID. Must be set to zero for the link layer. 229a23fd118Syl * @callback: Channel completion callback. HAL invokes the callback when there 230a23fd118Syl * are new completions on that channel. In many implementations 231a23fd118Syl * the @callback executes in the hw interrupt context. 232a23fd118Syl * @dtr_init: Channel's descriptor-initialize callback. 233a23fd118Syl * See xge_hal_channel_dtr_init_f{}. 234a23fd118Syl * If not NULL, HAL invokes the callback when opening 235a23fd118Syl * the channel via xge_hal_channel_open(). 236a23fd118Syl * @dtr_term: Channel's descriptor-terminate callback. If not NULL, 237a23fd118Syl * HAL invokes the callback when closing the corresponding channel. 238a23fd118Syl * See also xge_hal_channel_dtr_term_f{}. 239a23fd118Syl * @userdata: User-defined "context" of _that_ channel. Passed back to the 240a23fd118Syl * user as one of the @callback, @dtr_init, and @dtr_term arguments. 241a23fd118Syl * @per_dtr_space: If specified (i.e., greater than zero): extra space 242a23fd118Syl * reserved by HAL per each transmit or receive (depending on the 243a23fd118Syl * channel type) descriptor. Can be used to store, 244a23fd118Syl * and retrieve on completion, information specific 245a23fd118Syl * to the upper-layer. 246a23fd118Syl * @flags: xge_hal_channel_flag_e enumerated flags. 247a23fd118Syl * 248a23fd118Syl * Channel open "template". User fills the structure with channel 249a23fd118Syl * attributes and passes it to xge_hal_channel_open(). 250a23fd118Syl * Usage: See ex_open{}. 251a23fd118Syl */ 252a23fd118Syl typedef struct xge_hal_channel_attr_t { 253a23fd118Syl xge_hal_channel_type_e type; 254a23fd118Syl int post_qid; 255a23fd118Syl int compl_qid; 256a23fd118Syl xge_hal_channel_callback_f callback; 257a23fd118Syl xge_hal_channel_dtr_init_f dtr_init; 258a23fd118Syl xge_hal_channel_dtr_term_f dtr_term; 259a23fd118Syl void *userdata; 260a23fd118Syl int per_dtr_space; 261a23fd118Syl xge_hal_channel_flag_e flags; 262a23fd118Syl } xge_hal_channel_attr_t; 263a23fd118Syl 264a23fd118Syl /* 265a23fd118Syl * xge_hal_channel_t 266a23fd118Syl * ---------- complete/free section --------------- 267a23fd118Syl * @item: List item; used to maintain a list of open channels. 268a23fd118Syl * @callback: Channel completion callback. See 269a23fd118Syl * xge_hal_channel_callback_f. 270a23fd118Syl * @compl_index: Completion index. At any point in time points on the 271a23fd118Syl * position in the channel, which will contain next 272a23fd118Syl * to-be-completed descriptor. 273a23fd118Syl * @length: Channel length. Currently allocated number of descriptors. 274a23fd118Syl * The channel length "grows" when more descriptors get allocated. 275a23fd118Syl * See _hal_mempool_grow. 276a23fd118Syl * @free_arr: Free array. Contains completed descriptors that were freed 277a23fd118Syl * (i.e., handed over back to HAL) by ULD. 278a23fd118Syl * See xge_hal_fifo_dtr_free(), xge_hal_ring_dtr_free(). 279a23fd118Syl * @free_lock: Lock to protect @free_arr. 280a23fd118Syl * ----------- reserve/post section --------------- 281a23fd118Syl * @post_index: Post index. At any point in time points on the 282a23fd118Syl * position in the channel, which'll contain next to-be-posted 283a23fd118Syl * descriptor. 284a23fd118Syl * @post_lock: Lock to serialize multiple concurrent "posters" of descriptors 285a23fd118Syl * on the given channel. 286a23fd118Syl * @reserve_arr: Reserve array. Contains descriptors that can be reserved 287a23fd118Syl * by ULD for the subsequent send or receive operation. 288a23fd118Syl * See xge_hal_fifo_dtr_reserve(), 289a23fd118Syl * xge_hal_ring_dtr_reserve(). 290a23fd118Syl * @reserve_length: Length of the @reserve_arr. The length dynamically 291a23fd118Syl * changes: it decrements each time descriptor is reserved. 292a23fd118Syl * @reserve_lock: Lock to serialize multiple concurrent threads accessing 293a23fd118Syl * @reserve_arr. 294a23fd118Syl * @reserve_threshold: Reserve threshold. Minimal number of free descriptors 295a23fd118Syl * that ought to be preserved in the channel at all times. 296a23fd118Syl * Note that @reserve_threshold >= 0 && 297a23fd118Syl * @reserve_threshold < @reserve_max. 298a23fd118Syl * ------------ common section -------------------- 299a23fd118Syl * @devh: Device handle. HAL device object that contains _this_ channel. 300a23fd118Syl * @dmah: Channel's DMA address. Used to synchronize (to/from device) 301a23fd118Syl * descriptors. 302a23fd118Syl * @regh0: Base address of the device memory space handle. Copied from HAL device 303a23fd118Syl * at channel open time. 304a23fd118Syl * @regh1: Base address of the device memory space handle. Copied from HAL device 305a23fd118Syl * at channel open time. 306a23fd118Syl * @userdata: Per-channel opaque (void*) user-defined context, which may be 307a23fd118Syl * upper-layer driver object, ULP connection, etc. 308a23fd118Syl * Once channel is open, @userdata is passed back to user via 309a23fd118Syl * xge_hal_channel_callback_f. 310a23fd118Syl * @work_arr: Work array. Contains descriptors posted to the channel. 311a23fd118Syl * Note that at any point in time @work_arr contains 3 types of 312a23fd118Syl * descriptors: 313a23fd118Syl * 1) posted but not yet consumed by Xframe device; 314a23fd118Syl * 2) consumed but not yet completed; 315a23fd118Syl * 3) completed but not yet freed 316a23fd118Syl * (via xge_hal_fifo_dtr_free() or xge_hal_ring_dtr_free()) 317a23fd118Syl * @saved_arr: Array used internally to optimize channel full-duplex 318a23fd118Syl * operation. 319a23fd118Syl * @stats: Channel statistcis. Includes HAL internal counters, including 320a23fd118Syl * for instance, number of times out-of-descriptors 321a23fd118Syl * (see XGE_HAL_INF_OUT_OF_DESCRIPTORS) condition happened. 322a23fd118Syl * ------------- "slow" section ------------------ 323a23fd118Syl * @type: Channel type. See xge_hal_channel_type_e{}. 3247eced415Sxw * @vp_id: Virtual path id 325a23fd118Syl * @post_qid: Identifies Xframe queue used for posting descriptors. 326a23fd118Syl * @compl_qid: Identifies Xframe completion queue. 327a23fd118Syl * @flags: Channel flags. See xge_hal_channel_flag_e{}. 328a23fd118Syl * @reserve_initial: Initial number of descriptors allocated at channel open 329a23fd118Syl * time (see xge_hal_channel_open()). The number of 330a23fd118Syl * channel descriptors can grow at runtime 331a23fd118Syl * up to @reserve_max value. 332a23fd118Syl * @reserve_max: Maximum number of channel descriptors. See @reserve_initial. 333a23fd118Syl * @is_open: True, if channel is open; false - otherwise. 334a23fd118Syl * @per_dtr_space: Per-descriptor space (in bytes) that channel user can utilize 335a23fd118Syl * to store per-operation control information. 336a23fd118Syl * HAL channel object. HAL devices (see xge_hal_device_t{}) contains 337a23fd118Syl * zero or more channels. HAL channel contains zero or more descriptors. The 338a23fd118Syl * latter are used by ULD(s) to manage the device and/or send and receive data 339a23fd118Syl * to remote peer(s) via the channel. 340a23fd118Syl * 341a23fd118Syl * See also: xge_hal_channel_type_e{}, xge_hal_channel_flag_e, 342a23fd118Syl * xge_hal_channel_callback_f{} 343a23fd118Syl */ 344a23fd118Syl typedef struct { 345a23fd118Syl /* complete/free section */ 346a23fd118Syl xge_list_t item; 347a23fd118Syl xge_hal_channel_callback_f callback; 348a23fd118Syl void **free_arr; 349a23fd118Syl int length; 350a23fd118Syl int free_length; 3518347601bSyl #if defined(XGE_HAL_RX_MULTI_FREE_IRQ) || defined(XGE_HAL_TX_MULTI_FREE_IRQ) || \ 3528347601bSyl defined(XGE_HAL_RX_MULTI_FREE) || defined(XGE_HAL_TX_MULTI_FREE) 353a23fd118Syl spinlock_t free_lock; 3548347601bSyl #endif 355a23fd118Syl int compl_index; 3568347601bSyl unsigned int usage_cnt; 3578347601bSyl unsigned int poll_bytes; 358a23fd118Syl 359a23fd118Syl /* reserve/post data path section */ 3607eced415Sxw int terminating; 361a23fd118Syl #ifdef __XGE_WIN__ 362a23fd118Syl int __xge_os_attr_cacheline_aligned 363a23fd118Syl post_index; 364a23fd118Syl #else 365a23fd118Syl int post_index 366a23fd118Syl __xge_os_attr_cacheline_aligned; 367a23fd118Syl #endif 368a23fd118Syl spinlock_t reserve_lock; 369a23fd118Syl spinlock_t post_lock; 370a23fd118Syl 371a23fd118Syl void **reserve_arr; 372a23fd118Syl int reserve_length; 373a23fd118Syl int reserve_threshold; 374a23fd118Syl int reserve_top; 375a23fd118Syl int unused1; 376a23fd118Syl 377a23fd118Syl /* common section */ 378a23fd118Syl xge_hal_device_h devh; 379a23fd118Syl pci_dev_h pdev; 380a23fd118Syl pci_reg_h regh0; 381a23fd118Syl pci_reg_h regh1; 382a23fd118Syl void *userdata; 383a23fd118Syl void **work_arr; 384a23fd118Syl void **saved_arr; 385a23fd118Syl void **orig_arr; 386a23fd118Syl xge_hal_stats_channel_info_t stats; 387a23fd118Syl 388a23fd118Syl /* slow section */ 389a23fd118Syl xge_hal_channel_type_e type; 390a23fd118Syl int post_qid; 391a23fd118Syl int compl_qid; 392a23fd118Syl xge_hal_channel_flag_e flags; 393a23fd118Syl int reserve_initial; 394a23fd118Syl int reserve_max; 395a23fd118Syl int is_open; 396a23fd118Syl int per_dtr_space; 397a23fd118Syl xge_hal_channel_dtr_term_f dtr_term; 398a23fd118Syl xge_hal_channel_dtr_init_f dtr_init; 3997eced415Sxw /* MSI stuff */ 400a23fd118Syl u32 msi_msg; 401a23fd118Syl u8 rti; 402a23fd118Syl u8 tti; 403a23fd118Syl u16 unused2; 4047eced415Sxw /* MSI-X stuff */ 405a23fd118Syl u64 msix_address; 406a23fd118Syl u32 msix_data; 407a23fd118Syl int msix_idx; 4087eced415Sxw volatile int in_interrupt; 4098347601bSyl unsigned int magic; 410a23fd118Syl #ifdef __XGE_WIN__ 411a23fd118Syl } __xge_os_attr_cacheline_aligned xge_hal_channel_t ; 412a23fd118Syl #else 413a23fd118Syl } xge_hal_channel_t __xge_os_attr_cacheline_aligned; 414a23fd118Syl #endif 415a23fd118Syl 416a23fd118Syl /* ========================== CHANNEL PRIVATE API ========================= */ 417a23fd118Syl 418a23fd118Syl xge_hal_status_e 419a23fd118Syl __hal_channel_initialize(xge_hal_channel_h channelh, 420a23fd118Syl xge_hal_channel_attr_t *attr, void **reserve_arr, 421a23fd118Syl int reserve_initial, int reserve_max, int reserve_threshold); 422a23fd118Syl 423a23fd118Syl void __hal_channel_terminate(xge_hal_channel_h channelh); 424a23fd118Syl 425a23fd118Syl xge_hal_channel_t* 426a23fd118Syl __hal_channel_allocate(xge_hal_device_h devh, int post_qid, 427a23fd118Syl xge_hal_channel_type_e type); 428a23fd118Syl 429a23fd118Syl void __hal_channel_free(xge_hal_channel_t *channel); 430a23fd118Syl 431a23fd118Syl #if defined(XGE_DEBUG_FP) && (XGE_DEBUG_FP & XGE_DEBUG_FP_CHANNEL) 432a23fd118Syl #define __HAL_STATIC_CHANNEL 433a23fd118Syl #define __HAL_INLINE_CHANNEL 434a23fd118Syl 435a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e 436a23fd118Syl __hal_channel_dtr_alloc(xge_hal_channel_h channelh, xge_hal_dtr_h *dtrh); 437a23fd118Syl 438a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 439a23fd118Syl __hal_channel_dtr_post(xge_hal_channel_h channelh, xge_hal_dtr_h dtrh); 440a23fd118Syl 441a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 442a23fd118Syl __hal_channel_dtr_try_complete(xge_hal_channel_h channelh, xge_hal_dtr_h *dtrh); 443a23fd118Syl 444a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 445a23fd118Syl __hal_channel_dtr_complete(xge_hal_channel_h channelh); 446a23fd118Syl 447a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 448a23fd118Syl __hal_channel_dtr_free(xge_hal_channel_h channelh, xge_hal_dtr_h dtrh); 449a23fd118Syl 450a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 451a23fd118Syl __hal_channel_dtr_dealloc(xge_hal_channel_h channelh, xge_hal_dtr_h dtrh); 452a23fd118Syl 453a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void 454a23fd118Syl __hal_channel_dtr_restore(xge_hal_channel_h channelh, xge_hal_dtr_h dtrh, 455a23fd118Syl int offset); 456a23fd118Syl 457a23fd118Syl /* ========================== CHANNEL PUBLIC API ========================= */ 458a23fd118Syl 4598347601bSyl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL int 4608347601bSyl xge_hal_channel_dtr_count(xge_hal_channel_h channelh); 4618347601bSyl 462a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void* 463a23fd118Syl xge_hal_channel_userdata(xge_hal_channel_h channelh); 464a23fd118Syl 465a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL int 466a23fd118Syl xge_hal_channel_id(xge_hal_channel_h channelh); 467a23fd118Syl 468a23fd118Syl __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL int 469a23fd118Syl xge_hal_check_alignment(dma_addr_t dma_pointer, int size, int alignment, 470a23fd118Syl int copy_size); 471a23fd118Syl 472a23fd118Syl #else /* XGE_FASTPATH_EXTERN */ 473a23fd118Syl #define __HAL_STATIC_CHANNEL static 474a23fd118Syl #define __HAL_INLINE_CHANNEL inline 475a23fd118Syl #include "xgehal-channel-fp.c" 476a23fd118Syl #endif /* XGE_FASTPATH_INLINE */ 477a23fd118Syl 478a23fd118Syl xge_hal_status_e 479a23fd118Syl xge_hal_channel_open(xge_hal_device_h hldev, xge_hal_channel_attr_t *attr, 480a23fd118Syl xge_hal_channel_h *channel, 481a23fd118Syl xge_hal_channel_reopen_e reopen); 482a23fd118Syl 483a23fd118Syl void xge_hal_channel_close(xge_hal_channel_h channelh, 484a23fd118Syl xge_hal_channel_reopen_e reopen); 485a23fd118Syl 486a23fd118Syl void xge_hal_channel_abort(xge_hal_channel_h channelh, 487a23fd118Syl xge_hal_channel_reopen_e reopen); 488a23fd118Syl 4898347601bSyl __EXTERN_END_DECLS 4908347601bSyl 491a23fd118Syl #endif /* XGE_HAL_CHANNEL_H */ 492