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#ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern "C" {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * NAME: sol_uverbs_hca.h
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * DESC: Solaris OFED hca management utility.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * This file implements a very thin layer that provides the OFA user kernel
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * agents the ability to operate in the same IBT/HCA domain. That is all
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * of the OFA user space kernel agents share the same IBT client handle,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * opened by the sol_uverbs driver.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#include <sys/ib/ibtl/ibvti.h>
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Definitions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Structures
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * HCA Info.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar *
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Each IBT HCA the sol_uverbs driver knows about is maintained in a
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * a list that points to IBT handles and the client event handler
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * callbacks.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct sol_uverbs_hca {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t event_handler_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar kmutex_t event_handler_lock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t client_data_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar kmutex_t client_data_lock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_clnt_hdl_t clnt_hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ib_guid_t guid;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_hca_hdl_t hdl;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_hca_attr_t attr;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar uint32_t nports;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_hca_portinfo_t *ports;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar size_t pinfosz;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_uverbs_hca_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Client structure passed to Solaris User Verbs to provide addtion and
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * removal callbacks. The "add" function will be invoked for each
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * IBT hca in the system when it is available, the "remove" will be
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * invoked when an IBT hca is no longer available.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct sol_uverbs_ib_client {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar char *name;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void (*add)(sol_uverbs_hca_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void (*remove)(sol_uverbs_hca_t *);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_uverbs_ib_client_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Event handler structure passed to Solaris User Verbs hca management
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * to register an asynchronous event handler for an IBT hca.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikartypedef struct sol_uverbs_ib_event_handler {
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_t list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_uverbs_hca_t *hca;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar void (*handler)(struct sol_uverbs_ib_event_handler *,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_hca_hdl_t hca,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_async_code_t code,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar ibt_async_event_t *event);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar} sol_uverbs_ib_event_handler_t;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#define SOL_UVERBS_INIT_IB_EVENT_HANDLER(_struct_ptr, _hca_ptr, _func_ptr) \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar do { \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (_struct_ptr)->hca = _hca_ptr; \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar (_struct_ptr)->handler = _func_ptr; \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar llist_head_init(&(_struct_ptr)->list, 0); \
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar } while (0)
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Control structures for managmenet of common HCA list.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern kmutex_t sol_uverbs_hca_lock;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern llist_head_t sol_uverbs_hca_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarextern llist_head_t sol_uverbs_client_list;
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Functions
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * sol_uverbs HCA list management and helper sol_uverbs nternal functions.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint sol_uverbs_common_hca_init();
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_uverbs_common_hca_fini();
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_uverbs_hca_t *sol_uverbs_ibt_hdl_to_hca(ibt_hca_hdl_t hdl);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * COMMON HCA CLIENT API - See sol_uverbs_hca.c for complete
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * function description.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Register for client notifications. The "add" function pointer
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * in the client structure will be invoked for each hca in the system, the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * "remove" function pointer will be invoked as hca's are no longer
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * available.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint sol_uverbs_ib_register_client(sol_uverbs_ib_client_t *client);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Unregister for client notifications.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_uverbs_ib_unregister_client(sol_uverbs_ib_client_t *client);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Mechanism for client to associate private data with each IBT hca.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid *sol_uverbs_ib_get_client_data(sol_uverbs_hca_t *hca,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_uverbs_ib_client_t *client);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarvoid sol_uverbs_ib_set_client_data(sol_uverbs_hca_t *hca,
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar sol_uverbs_ib_client_t *client, void *data);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Mechanism for client to register/unregister for asynchronous event callbacks.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_uverbs_ib_register_event_handler(sol_uverbs_ib_event_handler_t *handler);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarsol_uverbs_ib_unregister_event_handler(sol_uverbs_ib_event_handler_t *handler);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * HELPER API provided by sol_uverbs, see sol_uverbs_qp.c for complete
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * descriptions.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Map a user QP id to an IBT QP Handle.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikaribt_qp_hdl_t sol_uverbs_uqpid_to_ibt_handle(uint32_t u_qpid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar/*
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * Inform sol_uverbs to igonore requested modify QP calls for the
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar * specific QP.
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar */
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint sol_uverbs_disable_user_qp_modify(uint32_t u_qpid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikarint sol_uverbs_enable_user_qp_modify(uint32_t u_qpid);
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#ifdef __cplusplus
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar}
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif
c39526b769298791ff5b0b6c5e761f49aabaeb4ePramod Gunjikar#endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H */