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]
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 #include <sys/types.h>
27 #include <sys/ksynch.h>
28 #include <sys/ib/ibtl/ibti_common.h>
30 kmutex_t ibtl_part_attr_mutex
;
31 ibt_status_t (*ibtl_get_part_attr_cb
)(datalink_id_t
, ibt_part_attr_t
*);
32 ibt_status_t (*ibtl_get_all_part_attr_cb
)(ibt_part_attr_t
**, int *);
35 ibt_register_part_attr_cb(
36 ibt_status_t (*get_part_attr
)(datalink_id_t
, ibt_part_attr_t
*),
37 ibt_status_t (*get_all_part_attr
)(ibt_part_attr_t
**, int *))
39 mutex_enter(&ibtl_part_attr_mutex
);
40 ibtl_get_part_attr_cb
= get_part_attr
;
41 ibtl_get_all_part_attr_cb
= get_all_part_attr
;
42 mutex_exit(&ibtl_part_attr_mutex
);
46 ibt_unregister_part_attr_cb(void)
48 mutex_enter(&ibtl_part_attr_mutex
);
49 ibtl_get_part_attr_cb
= NULL
;
50 ibtl_get_all_part_attr_cb
= NULL
;
51 mutex_exit(&ibtl_part_attr_mutex
);
55 ibt_get_part_attr(datalink_id_t linkid
, ibt_part_attr_t
*attr
)
59 mutex_enter(&ibtl_part_attr_mutex
);
60 if (ibtl_get_part_attr_cb
!= NULL
)
61 status
= (*ibtl_get_part_attr_cb
) (linkid
, attr
);
63 status
= IBT_NO_SUCH_OBJECT
;
64 mutex_exit(&ibtl_part_attr_mutex
);
70 ibt_get_all_part_attr(ibt_part_attr_t
**attr
, int *nparts
)
74 mutex_enter(&ibtl_part_attr_mutex
);
75 if (ibtl_get_all_part_attr_cb
!= NULL
)
76 status
= (*ibtl_get_all_part_attr_cb
) (attr
, nparts
);
82 mutex_exit(&ibtl_part_attr_mutex
);
88 ibt_free_part_attr(ibt_part_attr_t
*attr
, int nparts
)
91 kmem_free(attr
, sizeof (ibt_part_attr_t
) * nparts
);