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.
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.
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]
23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
33 * MODULE: dapl_provider.c
35 * PURPOSE: Provider function table
36 * Description: DAT Interfaces to this provider
38 * $Id: dapl_provider.c,v 1.7 2003/08/08 19:42:54 sjs2 Exp $
41 #include "dapl_provider.h"
50 DAPL_PROVIDER_LIST g_dapl_provider_list
;
54 * the function table for this provider
57 DAT_PROVIDER g_dapl_provider_template
=
65 &dapl_set_consumer_context
,
66 &dapl_get_consumer_context
,
67 &dapl_get_handle_type
,
70 &dapl_cno_modify_agent
,
99 &dapl_ep_post_rdma_read
,
100 &dapl_ep_post_rdma_write
,
125 &dapl_psp_create_any
,
127 &dapl_evd_set_unwaitable
,
128 &dapl_evd_clear_unwaitable
,
130 &dapl_lmr_sync_rdma_read
,
131 &dapl_lmr_sync_rdma_write
,
133 &dapl_ep_create_with_srq
,
135 &dapl_ep_set_watermark
,
149 * Function Prototypes
154 dapl_provider_list_key_cmp(
161 * Function Definitions
166 dapl_provider_list_create(void)
170 status
= DAT_SUCCESS
;
172 /* create the head node */
173 g_dapl_provider_list
.head
= dapl_os_alloc(
174 sizeof (DAPL_PROVIDER_LIST_NODE
));
175 if (NULL
== g_dapl_provider_list
.head
) {
176 status
= DAT_ERROR(DAT_INSUFFICIENT_RESOURCES
,
177 DAT_RESOURCE_MEMORY
);
181 (void) dapl_os_memzero(g_dapl_provider_list
.head
,
182 sizeof (DAPL_PROVIDER_LIST_NODE
));
184 /* create the tail node */
185 g_dapl_provider_list
.tail
= dapl_os_alloc(
186 sizeof (DAPL_PROVIDER_LIST_NODE
));
187 if (NULL
== g_dapl_provider_list
.tail
) {
188 status
= DAT_ERROR(DAT_INSUFFICIENT_RESOURCES
,
189 DAT_RESOURCE_MEMORY
);
193 (void) dapl_os_memzero(g_dapl_provider_list
.tail
,
194 sizeof (DAPL_PROVIDER_LIST_NODE
));
196 g_dapl_provider_list
.head
->next
= g_dapl_provider_list
.tail
;
197 g_dapl_provider_list
.tail
->prev
= g_dapl_provider_list
.head
;
198 g_dapl_provider_list
.size
= 0;
201 if (DAT_SUCCESS
!= status
) {
202 if (NULL
!= g_dapl_provider_list
.head
) {
203 dapl_os_free(g_dapl_provider_list
.head
,
204 sizeof (DAPL_PROVIDER_LIST_NODE
));
207 if (NULL
!= g_dapl_provider_list
.tail
) {
208 dapl_os_free(g_dapl_provider_list
.tail
,
209 sizeof (DAPL_PROVIDER_LIST_NODE
));
218 dapl_provider_list_destroy(void)
220 DAPL_PROVIDER_LIST_NODE
*cur_node
;
222 while (NULL
!= g_dapl_provider_list
.head
) {
223 cur_node
= g_dapl_provider_list
.head
;
224 g_dapl_provider_list
.head
= cur_node
->next
;
226 dapl_os_free(cur_node
, sizeof (DAPL_PROVIDER_LIST_NODE
));
229 return (DAT_SUCCESS
);
234 dapl_provider_list_size(void)
236 return (g_dapl_provider_list
.size
);
241 dapl_provider_list_insert(
243 IN DAT_PROVIDER
**p_data
)
245 DAPL_PROVIDER_LIST_NODE
*cur_node
, *prev_node
, *next_node
;
249 status
= DAT_SUCCESS
;
252 cur_node
= dapl_os_alloc(sizeof (DAPL_PROVIDER_LIST_NODE
));
254 if (NULL
== cur_node
) {
255 status
= DAT_ERROR(DAT_INSUFFICIENT_RESOURCES
,
256 DAT_RESOURCE_MEMORY
);
260 len
= dapl_os_strlen(name
);
262 if (DAT_NAME_MAX_LENGTH
<= len
) {
263 status
= DAT_ERROR(DAT_INSUFFICIENT_RESOURCES
,
264 DAT_RESOURCE_MEMORY
);
268 /* insert node at end of list to preserve registration order */
269 prev_node
= g_dapl_provider_list
.tail
->prev
;
270 next_node
= g_dapl_provider_list
.tail
;
272 (void) dapl_os_memcpy(cur_node
->name
, name
, len
);
273 cur_node
->name
[len
] = '\0';
274 cur_node
->data
= g_dapl_provider_template
;
275 cur_node
->data
.device_name
= cur_node
->name
;
276 cur_node
->next
= next_node
;
277 cur_node
->prev
= prev_node
;
279 prev_node
->next
= cur_node
;
280 next_node
->prev
= cur_node
;
282 g_dapl_provider_list
.size
++;
284 if (NULL
!= p_data
) {
285 *p_data
= &cur_node
->data
;
289 if (DAT_SUCCESS
!= status
) {
290 if (NULL
!= cur_node
) {
291 dapl_os_free(cur_node
,
292 sizeof (DAPL_PROVIDER_LIST_NODE
));
301 dapl_provider_list_search(
303 OUT DAT_PROVIDER
**p_data
)
305 DAPL_PROVIDER_LIST_NODE
*cur_node
;
308 status
= DAT_ERROR(DAT_NAME_NOT_FOUND
, 0);
310 for (cur_node
= g_dapl_provider_list
.head
->next
;
311 g_dapl_provider_list
.tail
!= cur_node
;
312 cur_node
= cur_node
->next
) {
313 if (dapl_provider_list_key_cmp(cur_node
->name
, name
)) {
314 if (NULL
!= p_data
) {
315 *p_data
= &cur_node
->data
;
318 status
= DAT_SUCCESS
;
329 dapl_provider_list_remove(
332 DAPL_PROVIDER_LIST_NODE
*cur_node
, *prev_node
, *next_node
;
335 status
= DAT_ERROR(DAT_NAME_NOT_FOUND
, 0);
337 for (cur_node
= g_dapl_provider_list
.head
->next
;
338 g_dapl_provider_list
.tail
!= cur_node
;
339 cur_node
= cur_node
->next
) {
340 if (dapl_provider_list_key_cmp(cur_node
->name
, name
)) {
341 prev_node
= cur_node
->prev
;
342 next_node
= cur_node
->next
;
344 prev_node
->next
= next_node
;
345 next_node
->prev
= prev_node
;
347 dapl_os_free(cur_node
,
348 sizeof (DAPL_PROVIDER_LIST_NODE
));
350 g_dapl_provider_list
.size
--;
352 status
= DAT_SUCCESS
;
363 dapl_provider_list_key_cmp(
369 len
= dapl_os_strlen(name_a
);
371 if (dapl_os_strlen(name_b
) != len
) {
373 } else if (dapl_os_memcmp(name_a
, name_b
, len
)) {