1*c39526b7SPramod Gunjikar /* 2*c39526b7SPramod Gunjikar * CDDL HEADER START 3*c39526b7SPramod Gunjikar * 4*c39526b7SPramod Gunjikar * The contents of this file are subject to the terms of the 5*c39526b7SPramod Gunjikar * Common Development and Distribution License (the "License"). 6*c39526b7SPramod Gunjikar * You may not use this file except in compliance with the License. 7*c39526b7SPramod Gunjikar * 8*c39526b7SPramod Gunjikar * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*c39526b7SPramod Gunjikar * or http://www.opensolaris.org/os/licensing. 10*c39526b7SPramod Gunjikar * See the License for the specific language governing permissions 11*c39526b7SPramod Gunjikar * and limitations under the License. 12*c39526b7SPramod Gunjikar * 13*c39526b7SPramod Gunjikar * When distributing Covered Code, include this CDDL HEADER in each 14*c39526b7SPramod Gunjikar * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*c39526b7SPramod Gunjikar * If applicable, add the following below this CDDL HEADER, with the 16*c39526b7SPramod Gunjikar * fields enclosed by brackets "[]" replaced with your own identifying 17*c39526b7SPramod Gunjikar * information: Portions Copyright [yyyy] [name of copyright owner] 18*c39526b7SPramod Gunjikar * 19*c39526b7SPramod Gunjikar * CDDL HEADER END 20*c39526b7SPramod Gunjikar */ 21*c39526b7SPramod Gunjikar 22*c39526b7SPramod Gunjikar /* 23*c39526b7SPramod Gunjikar * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*c39526b7SPramod Gunjikar */ 25*c39526b7SPramod Gunjikar 26*c39526b7SPramod Gunjikar #ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H 27*c39526b7SPramod Gunjikar #define _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H 28*c39526b7SPramod Gunjikar 29*c39526b7SPramod Gunjikar #ifdef __cplusplus 30*c39526b7SPramod Gunjikar extern "C" { 31*c39526b7SPramod Gunjikar #endif 32*c39526b7SPramod Gunjikar 33*c39526b7SPramod Gunjikar /* 34*c39526b7SPramod Gunjikar * 35*c39526b7SPramod Gunjikar * NAME: sol_uverbs_hca.h 36*c39526b7SPramod Gunjikar * 37*c39526b7SPramod Gunjikar * DESC: Solaris OFED hca management utility. 38*c39526b7SPramod Gunjikar * 39*c39526b7SPramod Gunjikar * This file implements a very thin layer that provides the OFA user kernel 40*c39526b7SPramod Gunjikar * agents the ability to operate in the same IBT/HCA domain. That is all 41*c39526b7SPramod Gunjikar * of the OFA user space kernel agents share the same IBT client handle, 42*c39526b7SPramod Gunjikar * opened by the sol_uverbs driver. 43*c39526b7SPramod Gunjikar * 44*c39526b7SPramod Gunjikar */ 45*c39526b7SPramod Gunjikar 46*c39526b7SPramod Gunjikar #include <sys/ib/ibtl/ibvti.h> 47*c39526b7SPramod Gunjikar 48*c39526b7SPramod Gunjikar /* 49*c39526b7SPramod Gunjikar * Definitions 50*c39526b7SPramod Gunjikar */ 51*c39526b7SPramod Gunjikar 52*c39526b7SPramod Gunjikar /* 53*c39526b7SPramod Gunjikar * Structures 54*c39526b7SPramod Gunjikar */ 55*c39526b7SPramod Gunjikar 56*c39526b7SPramod Gunjikar /* 57*c39526b7SPramod Gunjikar * HCA Info. 58*c39526b7SPramod Gunjikar * 59*c39526b7SPramod Gunjikar * Each IBT HCA the sol_uverbs driver knows about is maintained in a 60*c39526b7SPramod Gunjikar * a list that points to IBT handles and the client event handler 61*c39526b7SPramod Gunjikar * callbacks. 62*c39526b7SPramod Gunjikar */ 63*c39526b7SPramod Gunjikar typedef struct sol_uverbs_hca { 64*c39526b7SPramod Gunjikar llist_head_t list; 65*c39526b7SPramod Gunjikar llist_head_t event_handler_list; 66*c39526b7SPramod Gunjikar kmutex_t event_handler_lock; 67*c39526b7SPramod Gunjikar llist_head_t client_data_list; 68*c39526b7SPramod Gunjikar kmutex_t client_data_lock; 69*c39526b7SPramod Gunjikar ibt_clnt_hdl_t clnt_hdl; 70*c39526b7SPramod Gunjikar ib_guid_t guid; 71*c39526b7SPramod Gunjikar ibt_hca_hdl_t hdl; 72*c39526b7SPramod Gunjikar ibt_hca_attr_t attr; 73*c39526b7SPramod Gunjikar uint32_t nports; 74*c39526b7SPramod Gunjikar ibt_hca_portinfo_t *ports; 75*c39526b7SPramod Gunjikar size_t pinfosz; 76*c39526b7SPramod Gunjikar } sol_uverbs_hca_t; 77*c39526b7SPramod Gunjikar 78*c39526b7SPramod Gunjikar /* 79*c39526b7SPramod Gunjikar * Client structure passed to Solaris User Verbs to provide addtion and 80*c39526b7SPramod Gunjikar * removal callbacks. The "add" function will be invoked for each 81*c39526b7SPramod Gunjikar * IBT hca in the system when it is available, the "remove" will be 82*c39526b7SPramod Gunjikar * invoked when an IBT hca is no longer available. 83*c39526b7SPramod Gunjikar */ 84*c39526b7SPramod Gunjikar typedef struct sol_uverbs_ib_client { 85*c39526b7SPramod Gunjikar llist_head_t list; 86*c39526b7SPramod Gunjikar char *name; 87*c39526b7SPramod Gunjikar void (*add)(sol_uverbs_hca_t *); 88*c39526b7SPramod Gunjikar void (*remove)(sol_uverbs_hca_t *); 89*c39526b7SPramod Gunjikar } sol_uverbs_ib_client_t; 90*c39526b7SPramod Gunjikar 91*c39526b7SPramod Gunjikar /* 92*c39526b7SPramod Gunjikar * Event handler structure passed to Solaris User Verbs hca management 93*c39526b7SPramod Gunjikar * to register an asynchronous event handler for an IBT hca. 94*c39526b7SPramod Gunjikar */ 95*c39526b7SPramod Gunjikar typedef struct sol_uverbs_ib_event_handler { 96*c39526b7SPramod Gunjikar llist_head_t list; 97*c39526b7SPramod Gunjikar sol_uverbs_hca_t *hca; 98*c39526b7SPramod Gunjikar void (*handler)(struct sol_uverbs_ib_event_handler *, 99*c39526b7SPramod Gunjikar ibt_hca_hdl_t hca, 100*c39526b7SPramod Gunjikar ibt_async_code_t code, 101*c39526b7SPramod Gunjikar ibt_async_event_t *event); 102*c39526b7SPramod Gunjikar } sol_uverbs_ib_event_handler_t; 103*c39526b7SPramod Gunjikar 104*c39526b7SPramod Gunjikar #define SOL_UVERBS_INIT_IB_EVENT_HANDLER(_struct_ptr, _hca_ptr, _func_ptr) \ 105*c39526b7SPramod Gunjikar do { \ 106*c39526b7SPramod Gunjikar (_struct_ptr)->hca = _hca_ptr; \ 107*c39526b7SPramod Gunjikar (_struct_ptr)->handler = _func_ptr; \ 108*c39526b7SPramod Gunjikar llist_head_init(&(_struct_ptr)->list, 0); \ 109*c39526b7SPramod Gunjikar } while (0) 110*c39526b7SPramod Gunjikar 111*c39526b7SPramod Gunjikar /* 112*c39526b7SPramod Gunjikar * Control structures for managmenet of common HCA list. 113*c39526b7SPramod Gunjikar */ 114*c39526b7SPramod Gunjikar extern kmutex_t sol_uverbs_hca_lock; 115*c39526b7SPramod Gunjikar extern llist_head_t sol_uverbs_hca_list; 116*c39526b7SPramod Gunjikar extern llist_head_t sol_uverbs_client_list; 117*c39526b7SPramod Gunjikar 118*c39526b7SPramod Gunjikar /* 119*c39526b7SPramod Gunjikar * Functions 120*c39526b7SPramod Gunjikar */ 121*c39526b7SPramod Gunjikar /* 122*c39526b7SPramod Gunjikar * sol_uverbs HCA list management and helper sol_uverbs nternal functions. 123*c39526b7SPramod Gunjikar */ 124*c39526b7SPramod Gunjikar int sol_uverbs_common_hca_init(); 125*c39526b7SPramod Gunjikar void sol_uverbs_common_hca_fini(); 126*c39526b7SPramod Gunjikar sol_uverbs_hca_t *sol_uverbs_ibt_hdl_to_hca(ibt_hca_hdl_t hdl); 127*c39526b7SPramod Gunjikar 128*c39526b7SPramod Gunjikar /* 129*c39526b7SPramod Gunjikar * COMMON HCA CLIENT API - See sol_uverbs_hca.c for complete 130*c39526b7SPramod Gunjikar * function description. 131*c39526b7SPramod Gunjikar */ 132*c39526b7SPramod Gunjikar 133*c39526b7SPramod Gunjikar /* 134*c39526b7SPramod Gunjikar * Register for client notifications. The "add" function pointer 135*c39526b7SPramod Gunjikar * in the client structure will be invoked for each hca in the system, the 136*c39526b7SPramod Gunjikar * "remove" function pointer will be invoked as hca's are no longer 137*c39526b7SPramod Gunjikar * available. 138*c39526b7SPramod Gunjikar */ 139*c39526b7SPramod Gunjikar int sol_uverbs_ib_register_client(sol_uverbs_ib_client_t *client); 140*c39526b7SPramod Gunjikar 141*c39526b7SPramod Gunjikar /* 142*c39526b7SPramod Gunjikar * Unregister for client notifications. 143*c39526b7SPramod Gunjikar */ 144*c39526b7SPramod Gunjikar void sol_uverbs_ib_unregister_client(sol_uverbs_ib_client_t *client); 145*c39526b7SPramod Gunjikar 146*c39526b7SPramod Gunjikar /* 147*c39526b7SPramod Gunjikar * Mechanism for client to associate private data with each IBT hca. 148*c39526b7SPramod Gunjikar */ 149*c39526b7SPramod Gunjikar void *sol_uverbs_ib_get_client_data(sol_uverbs_hca_t *hca, 150*c39526b7SPramod Gunjikar sol_uverbs_ib_client_t *client); 151*c39526b7SPramod Gunjikar 152*c39526b7SPramod Gunjikar void sol_uverbs_ib_set_client_data(sol_uverbs_hca_t *hca, 153*c39526b7SPramod Gunjikar sol_uverbs_ib_client_t *client, void *data); 154*c39526b7SPramod Gunjikar 155*c39526b7SPramod Gunjikar /* 156*c39526b7SPramod Gunjikar * Mechanism for client to register/unregister for asynchronous event callbacks. 157*c39526b7SPramod Gunjikar */ 158*c39526b7SPramod Gunjikar int 159*c39526b7SPramod Gunjikar sol_uverbs_ib_register_event_handler(sol_uverbs_ib_event_handler_t *handler); 160*c39526b7SPramod Gunjikar 161*c39526b7SPramod Gunjikar int 162*c39526b7SPramod Gunjikar sol_uverbs_ib_unregister_event_handler(sol_uverbs_ib_event_handler_t *handler); 163*c39526b7SPramod Gunjikar 164*c39526b7SPramod Gunjikar /* 165*c39526b7SPramod Gunjikar * HELPER API provided by sol_uverbs, see sol_uverbs_qp.c for complete 166*c39526b7SPramod Gunjikar * descriptions. 167*c39526b7SPramod Gunjikar */ 168*c39526b7SPramod Gunjikar 169*c39526b7SPramod Gunjikar /* 170*c39526b7SPramod Gunjikar * Map a user QP id to an IBT QP Handle. 171*c39526b7SPramod Gunjikar */ 172*c39526b7SPramod Gunjikar ibt_qp_hdl_t sol_uverbs_uqpid_to_ibt_handle(uint32_t u_qpid); 173*c39526b7SPramod Gunjikar 174*c39526b7SPramod Gunjikar /* 175*c39526b7SPramod Gunjikar * Inform sol_uverbs to igonore requested modify QP calls for the 176*c39526b7SPramod Gunjikar * specific QP. 177*c39526b7SPramod Gunjikar */ 178*c39526b7SPramod Gunjikar int sol_uverbs_disable_user_qp_modify(uint32_t u_qpid); 179*c39526b7SPramod Gunjikar int sol_uverbs_enable_user_qp_modify(uint32_t u_qpid); 180*c39526b7SPramod Gunjikar 181*c39526b7SPramod Gunjikar #ifdef __cplusplus 182*c39526b7SPramod Gunjikar } 183*c39526b7SPramod Gunjikar #endif 184*c39526b7SPramod Gunjikar #endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_HCA_H */ 185