c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * CDDL HEADER START
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 * 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 * 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 * CDDL HEADER END
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
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 * The APIs defined are :
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 1. User Objects
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 2. Linked Lists
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * 3. Debug Routines
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 * User Objects functions and structures.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef enum {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* User objects for sol_uverbs driver */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar /* User Objects for sol_ucma driver */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
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 Gunjikartypedef struct {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_ofs_uobj_t *ofs_uoblk_blks[SOL_OFS_UO_BLKSZ];
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct {
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 Gunjikarvoid sol_ofs_uobj_init(sol_ofs_uobj_t *, uint64_t, sol_ofs_uobj_type_t);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_ofs_uobj_free(sol_ofs_uobj_t *uobj);
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 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 * Generic linked list management functions
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#define LLIST_HEAD_INIT(x) { &(x), &(x), NULL }
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_head_init(llist_head_t *list, void *ptr)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void __llist_add(llist_head_t *new, llist_head_t *prv,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_add(llist_head_t *new, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_add_tail(llist_head_t *new, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void llist_del(llist_head_t *entry)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int llist_is_last(llist_head_t *list, llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline int llist_empty(llist_head_t *head)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->nxt; _pos != (_head); _pos = _pos->nxt)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->nxt, n = _pos->nxt; _pos != (_head); \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Doubly linked per user context IB resource list definitions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Protection must occur * outside of the list.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikargenlist_entry_t *add_genlist(genlist_t *list, uintptr_t data,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar for (_pos = (_head)->head; _pos; _pos = _pos->next)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid delete_genlist(genlist_t *list, genlist_entry_t *entry);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikargenlist_entry_t *remove_genlist_head(genlist_t *list);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid insert_genlist_tail(genlist_t *list, genlist_entry_t *entry);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarstatic inline void init_genlist(genlist_t *list)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Debug printfs defines
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#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#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_OFS_COMMON_H */