c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER START
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The contents of this file are subject to the terms of the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Common Development and Distribution License (the "License").
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You may not use this file except in compliance with the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * or http://www.opensolaris.org/os/licensing.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * See the License for the specific language governing permissions
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * and limitations under the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * When distributing Covered Code, include this CDDL HEADER in each
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * If applicable, add the following below this CDDL HEADER, with the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * fields enclosed by brackets "[]" replaced with your own identifying
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * information: Portions Copyright [yyyy] [name of copyright owner]
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER END
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifdef __cplusplus
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern "C" {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/ib/ibtl/ibvti.h>
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * If there is yet an active async event, hdl is not freed. However,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * if the device state is IB_DEV_CLOSE, the device is about to be closed
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * so that the event should be discarded.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define FIRE_QP_EVENT(clnt, hdl, ib_event, qpp, type) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rw_enter(&clnt->lock, RW_READER); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (qpp && qpp->event_handler && \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota qpp->device->reg_state == IB_DEV_OPEN) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.device = qpp->device; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.event = type; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.element.qp = qpp; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota qpp->event_handler(&ib_event, qpp->qp_context); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota } \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rw_exit(&clnt->lock)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define FIRE_CQ_EVENT(clnt, hdl, ib_event, cqp, type) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rw_enter(&clnt->lock, RW_READER); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (cqp && cqp->event_handler && \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota cqp->device->reg_state == IB_DEV_OPEN) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.device = cqp->device; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.event = type; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_event.element.cq = cqp; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota cqp->event_handler(&ib_event, cqp->cq_context); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota } \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rw_exit(&clnt->lock)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define IBTF2OF_PGSZ(hca_page_sz) ((hca_page_sz) << 10)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define OF2IBTF_STATE(s) ((enum ibt_cep_state_e)(s))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define OF2IBTF_SRATE(r) ((enum ibt_srate_e)(r))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define OF2IBTF_PATH_MIG_STATE(s) ((ibt_cep_cmstate_t)((s)+1))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define OF2IBTF_PATH_MTU(m) ((ib_mtu_t)(m))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otatypedef unsigned int gfp_t;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otatypedef struct sol_ofs_client_s {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ib_client_t *ib_client;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ibt_clnt_modinfo_t ibt_client;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ibt_clnt_hdl_t ibt_hdl;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint_t hca_num;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint_t hca_open_num;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota llist_head_t device_list;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota llist_head_t client_list;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota krwlock_t lock;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota enum {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota IB_OFS_CLNT_UNINITIALIZED,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota IB_OFS_CLNT_INITIALIZED
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota } state;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} ofs_client_t;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifdef __cplusplus
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota}
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_KVERB_IMPL_H */