dapl_evd_create.c revision 9517:b4839b0aa7a4
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved. 24 */ 25 26/* 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31/* 32 * 33 * MODULE: dapl_evd_create.c 34 * 35 * PURPOSE: EVENT management 36 * 37 * Description: Interfaces in this file are completely defined in 38 * the uDAPL 1.1 API, Chapter 6, section 3 39 * 40 * $Id: dapl_evd_create.c,v 1.12 2003/08/06 14:04:27 sjs2 Exp $ 41 */ 42 43#include "dapl.h" 44#include "dapl_evd_util.h" 45 46/* 47 * dapl_evd_create 48 * 49 * DAPL Requirements Version xxx, 6.3.2.1 50 * 51 * Create and instance of Event Dispatcher. 52 * 53 * Input: 54 * ia_handle 55 * cno_handle 56 * evd_min_qlen 57 * evd_flags 58 * 59 * Output: 60 * evd_handle 61 * 62 * Returns: 63 * DAT_SUCCESS 64 * DAT_INSUFFICIENT_RESOURCES 65 * DAT_INVALID_PARAMETER 66 */ 67 68/* 69 * ** REVISIT ** 70 * 71 * Selecting the cqe handing domain must still be done. 72 * We *probably* want one per hca, but we could have one 73 * per provider or one per consumer. 74 */ 75/* 76 * Note that if there already is a cq, it is not deleted 77 * even if it is not required. However, it will not be armed. 78 */ 79 80DAT_RETURN dapl_evd_create( 81 IN DAT_IA_HANDLE ia_handle, 82 IN DAT_COUNT evd_min_qlen, 83 IN DAT_CNO_HANDLE cno_handle, 84 IN DAT_EVD_FLAGS evd_flags, 85 OUT DAT_EVD_HANDLE *evd_handle) 86{ 87 DAPL_IA *ia_ptr; 88 DAPL_EVD *evd_ptr; 89 DAPL_CNO *cno_ptr; 90 DAT_RETURN dat_status; 91 DAT_PROVIDER_ATTR provider_attr = {0}; 92 int i; 93 int j; 94 DAT_EVD_FLAGS mask[6] = {DAT_EVD_SOFTWARE_FLAG, 95 DAT_EVD_CR_FLAG, DAT_EVD_DTO_FLAG, DAT_EVD_CONNECTION_FLAG, 96 DAT_EVD_RMR_BIND_FLAG, DAT_EVD_ASYNC_FLAG}; 97 98 dapl_dbg_log(DAPL_DBG_TYPE_API, 99 "dapl_evd_create (%p, %d, %p, 0x%x, %p)\n", 100 ia_handle, 101 evd_min_qlen, 102 cno_handle, 103 evd_flags, 104 evd_handle); 105 106 ia_ptr = (DAPL_IA *)ia_handle; 107 cno_ptr = (DAPL_CNO *)cno_handle; 108 evd_ptr = NULL; 109 *evd_handle = NULL; 110 dat_status = DAT_SUCCESS; 111 112 if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) { 113 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 114 DAT_INVALID_HANDLE_IA); 115 goto bail; 116 } 117 118 if (evd_min_qlen <= 0) { 119 dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2); 120 goto bail; 121 } 122 if (evd_min_qlen > ia_ptr->hca_ptr->ia_attr.max_evd_qlen) { 123 dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 124 DAT_RESOURCE_TEVD); 125 goto bail; 126 } 127 128 if ((cno_handle != DAT_HANDLE_NULL) && 129 DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) { 130 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 131 DAT_INVALID_HANDLE_CNO); 132 goto bail; 133 } 134 135 /* 136 * Check the merging attributes to ensure the combination of 137 * flags requested is supported. 138 */ 139 (void) dapl_ia_query(ia_handle, NULL, 140 0, NULL, 141 DAT_PROVIDER_FIELD_ALL, &provider_attr); 142 143 144 for (i = 0; i < 6; i++) { 145 if (mask[i] & evd_flags) { 146 for (j = i; j < 6; j++) { 147 if (mask[j] & evd_flags) { 148 if (provider_attr. 149 evd_stream_merging_supported[i][j] 150 == DAT_FALSE) { 151 dat_status = DAT_ERROR( 152 DAT_INVALID_PARAMETER, 153 DAT_INVALID_ARG4); 154 goto bail; 155 } 156 } 157 } /* end for j */ 158 } 159 } /* end for i */ 160 161 dat_status = dapls_evd_internal_create(ia_ptr, 162 cno_ptr, 163 evd_min_qlen, 164 evd_flags, 165 &evd_ptr); 166 if (dat_status != DAT_SUCCESS) { 167 goto bail; 168 } 169 170 evd_ptr->evd_state = DAPL_EVD_STATE_OPEN; 171 172 *evd_handle = (DAT_EVD_HANDLE) evd_ptr; 173 174bail: 175 if (dat_status != DAT_SUCCESS) { 176 if (evd_ptr) { 177 (void) dapl_evd_free(evd_ptr); 178 } 179 } 180 181 dapl_dbg_log(DAPL_DBG_TYPE_RTN, 182 "dapl_evd_create () returns 0x%x\n", 183 dat_status); 184 185 return (dat_status); 186} 187