c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER START
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * The contents of this file are subject to the terms of the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Common Development and Distribution License (the "License").
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * You may not use this file except in compliance with the License.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * or http://www.opensolaris.org/os/licensing.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * See the License for the specific language governing permissions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * and limitations under the License.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * When distributing Covered Code, include this CDDL HEADER in each
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * If applicable, add the following below this CDDL HEADER, with the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * fields enclosed by brackets "[]" replaced with your own identifying
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * information: Portions Copyright [yyyy] [name of copyright owner]
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER END
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * This header file contains definations for utility routines
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * which can be used by all Solaris OFUV related kernel drivers
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * and misc modules. The kernel modules using these APIs, should
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * load sol_ofs using :
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * ld -r -N misc/sol_ofs
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * The APIs defined are :
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 1. User Objects
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 2. Linked Lists
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 3. Debug Routines
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern "C" {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/types.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ksynch.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * User Objects functions and structures.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* User objects for sol_uverbs driver */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UCTXT_UOBJ_TYPE = 0,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UPD_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UAH_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UMR_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UCQ_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_USRQ_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UQP_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UVERBS_UFILE_UOBJ_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* User Objects for sol_ucma driver */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UCMA_EVT_FILE_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UCMA_CM_ID_TYPE,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar SOL_UCMA_MCAST_TYPE
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_ofs_uobj_type_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint64_t uo_user_handle;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_ofs_uobj_type_t uo_type;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar krwlock_t uo_lock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t uo_id;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar kmutex_t uo_reflock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t uo_refcnt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t uo_live;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar size_t uo_uobj_sz;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_ofs_uobj_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Objects are maintained in tables that allow an easy table ID to User Object
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * mapping and can grow as resources are created.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_UO_BLKSZ 16
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar int ofs_uo_blk_avail;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_ofs_uobj_t *ofs_uoblk_blks[SOL_OFS_UO_BLKSZ];
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_ofs_uobj_blk_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar krwlock_t uobj_tbl_lock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar int uobj_tbl_used_blks;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint_t uobj_tbl_num_blks;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar size_t uobj_tbl_uo_sz;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar int uobj_tbl_uo_cnt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_ofs_uobj_blk_t **uobj_tbl_uo_root;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_ofs_uobj_table_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/* User object table management routines */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_tbl_init(sol_ofs_uobj_table_t *, size_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_tbl_fini(sol_ofs_uobj_table_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_init(sol_ofs_uobj_t *, uint64_t, sol_ofs_uobj_type_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_ref(sol_ofs_uobj_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_deref(sol_ofs_uobj_t *,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid (*free_func)(sol_ofs_uobj_t *));
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_put(sol_ofs_uobj_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_free(sol_ofs_uobj_t *uobj);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint sol_ofs_uobj_add(sol_ofs_uobj_table_t *, sol_ofs_uobj_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_ofs_uobj_t *sol_ofs_uobj_remove(sol_ofs_uobj_table_t *,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_ofs_uobj_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_ofs_uobj_t *sol_ofs_uobj_get_read(sol_ofs_uobj_table_t *, uint32_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_ofs_uobj_t *sol_ofs_uobj_get_write(sol_ofs_uobj_table_t *, uint32_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Generic linked list management functions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef uchar_t bool;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define FALSE 0
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define TRUE 1
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define INVALID_HANDLE 0xFFFFFFFF
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define MAX_HASH_SIZE 1024
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Simple doubly linked list for opaque addresses. Protection must occur
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * outside of the list. These behavior very much like the linux kernel
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * lists, hence the familiar look of the API; but note there are
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * some signficant differences, mainly the list header is not embedded
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * in the element, so the container (typeof) constructs are not required.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct llist_head {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct llist_head *prv;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct llist_head *nxt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *ptr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} llist_head_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define LLIST_HEAD_INIT(x) { &(x), &(x), NULL }
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_head_init(llist_head_t *list, void *ptr)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar list->prv = list->nxt = list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar list->ptr = ptr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void __llist_add(llist_head_t *new, llist_head_t *prv,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t *nxt)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar nxt->prv = new;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new->nxt = nxt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar new->prv = prv;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar prv->nxt = new;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_add(llist_head_t *new, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar __llist_add(new, head, head->nxt);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_add_tail(llist_head_t *new, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar __llist_add(new, head->prv, head);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_del(llist_head_t *entry)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar entry->nxt->prv = entry->prv;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar entry->prv->nxt = entry->nxt;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int llist_is_last(llist_head_t *list, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (list->nxt == head);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int llist_empty(llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar return (head->nxt == head);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define list_for_each(_pos, _head) \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->nxt; _pos != (_head); _pos = _pos->nxt)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define list_for_each_safe(_pos, n, _head) \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->nxt, n = _pos->nxt; _pos != (_head); \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar _pos = n, n = _pos->nxt)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Doubly linked per user context IB resource list definitions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Protection must occur * outside of the list.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct genlist_entry_s {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uintptr_t data;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *data_context;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct genlist_entry_s *next;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar struct genlist_entry_s *prev;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} genlist_entry_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct genlist_s {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t count;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_entry_t *head;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar genlist_entry_t *tail;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} genlist_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikargenlist_entry_t *add_genlist(genlist_t *list, uintptr_t data,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void *data_context);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define genlist_for_each(_pos, _head) \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->head; _pos; _pos = _pos->next)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid delete_genlist(genlist_t *list, genlist_entry_t *entry);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikargenlist_entry_t *remove_genlist_head(genlist_t *list);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid insert_genlist_tail(genlist_t *list, genlist_entry_t *entry);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid flush_genlist(genlist_t *list);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarbool genlist_empty(genlist_t *list);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void init_genlist(genlist_t *list)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar{
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar list->head = list->tail = NULL;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar list->count = 0;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Debug printfs defines
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l5(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l4(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l3(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l2(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l1(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_dprintf_l0(char *name, char *fmt, ...);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L5 sol_ofs_dprintf_l5
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L4 sol_ofs_dprintf_l4
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L3 sol_ofs_dprintf_l3
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L2 sol_ofs_dprintf_l2
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L1 sol_ofs_dprintf_l1
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DPRINTF_L0 sol_ofs_dprintf_l0
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/* Misc */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_OFS_DRV_NAME_LEN 64
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H */