xref: /onnv-gate/usr/src/uts/common/sys/ib/ibtl/impl/ibtl_cm.h (revision 12064:e9b12471d136)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54703Shiremath  * Common Development and Distribution License (the "License").
64703Shiremath  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12064SShantkumar.Hiremath@Sun.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef _SYS_IB_IBTL_IMPL_IBTL_CM_H
260Sstevel@tonic-gate #define	_SYS_IB_IBTL_IMPL_IBTL_CM_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * ibtl_cm.h
300Sstevel@tonic-gate  *
310Sstevel@tonic-gate  * All data structures and function prototypes that are specific to the
320Sstevel@tonic-gate  * IBTL <-> IBCM private interface.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * ibt_ud_dest_t is defined in ibtl_ci_types.h, it holds all the
410Sstevel@tonic-gate  * information needed to reach a UD destination.
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  *	typedef struct ibt_ud_dest_s {
440Sstevel@tonic-gate  *		ibc_ah_hdl_t		ud_ah;		* Address handle *
450Sstevel@tonic-gate  *		ib_qpn_t		ud_dst_qpn;	* Destination QPN *
460Sstevel@tonic-gate  *		ib_qkey_t		ud_qkey;	* Q_Key *
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  *		* The following fields are CM-only, i.e., opaque to the CI *
490Sstevel@tonic-gate  *		struct ibtl_hca_s	*ud_hca;	* IBTL HCA handle *
500Sstevel@tonic-gate  *	} ibt_ud_dest_t;
510Sstevel@tonic-gate  */
520Sstevel@tonic-gate #define	ud_dest_hca	ud_dest_opaque1
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /* CM private data */
550Sstevel@tonic-gate void ibtl_cm_set_chan_private(ibt_channel_hdl_t chan, void *cm_private);
560Sstevel@tonic-gate void *ibtl_cm_get_chan_private(ibt_channel_hdl_t chan);
570Sstevel@tonic-gate void ibtl_cm_release_chan_private(ibt_channel_hdl_t chan);
580Sstevel@tonic-gate void ibtl_cm_wait_chan_private(ibt_channel_hdl_t chan);
590Sstevel@tonic-gate 
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate  * ibtl_cm_get_hca_port() helper function will retrieve these for the
620Sstevel@tonic-gate  * specified SGID value.
630Sstevel@tonic-gate  */
640Sstevel@tonic-gate typedef struct ibtl_cm_hca_port_s {
650Sstevel@tonic-gate 	ib_guid_t	hp_hca_guid;	/* HCA GUID. */
660Sstevel@tonic-gate 	ib_guid_t	hp_port_guid;   /* Port GUID. */
670Sstevel@tonic-gate 	ib_lid_t	hp_base_lid;	/* Base LID of Port. */
680Sstevel@tonic-gate 	uint8_t		hp_port;	/* HCA Port Number. */
690Sstevel@tonic-gate 	uint8_t		hp_sgid_ix;	/* SGID Index in SGID Table. */
700Sstevel@tonic-gate 	uint8_t		hp_lmc:3;	/* Local mask control */
710Sstevel@tonic-gate 	ib_mtu_t	hp_mtu;		/* Max transfer unit - pkt */
720Sstevel@tonic-gate } ibtl_cm_hca_port_t;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * ibtl_cm_get_hca_port()
760Sstevel@tonic-gate  *
770Sstevel@tonic-gate  * 	A helper function to get HCA node GUID, Base LID, SGID Index,
780Sstevel@tonic-gate  *	port number, LMC and MTU for the specified SGID.
790Sstevel@tonic-gate  *
800Sstevel@tonic-gate  *	sgid		Input Source GID.
810Sstevel@tonic-gate  *
820Sstevel@tonic-gate  *	hca_guid	Optional HCA Guid.
830Sstevel@tonic-gate  *
840Sstevel@tonic-gate  *	hca_port	Pointer to ibtl_cm_hca_port_t structure,
850Sstevel@tonic-gate  */
860Sstevel@tonic-gate ibt_status_t ibtl_cm_get_hca_port(ib_gid_t sgid, ib_guid_t hca_guid,
870Sstevel@tonic-gate     ibtl_cm_hca_port_t *hca_port);
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 
900Sstevel@tonic-gate ibt_status_t ibtl_cm_get_local_comp_gids(ib_guid_t hca_guid, ib_gid_t sgid,
910Sstevel@tonic-gate     ib_gid_t **gids_p, uint_t *num_gids_p);
920Sstevel@tonic-gate 
930Sstevel@tonic-gate int ibtl_cm_is_multi_sm(ib_guid_t hca_guid);
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /*
960Sstevel@tonic-gate  * ibtl_cm_get_1st_full_pkey_ix()
970Sstevel@tonic-gate  *
980Sstevel@tonic-gate  *	A helper function to get P_Key Index of the first full member P_Key
990Sstevel@tonic-gate  *	available on the specified HCA and Port combination.
1000Sstevel@tonic-gate  *
1010Sstevel@tonic-gate  *	hca_guid	HCA GUID.
1020Sstevel@tonic-gate  *
1030Sstevel@tonic-gate  *	port		HCA port number.
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate uint16_t ibtl_cm_get_1st_full_pkey_ix(ib_guid_t hca_guid, uint8_t port);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * Functions to support CM and clients to reliably free RC QPs.
1100Sstevel@tonic-gate  *
1110Sstevel@tonic-gate  * ibtl_cm_chan_is_open()
1120Sstevel@tonic-gate  *
1130Sstevel@tonic-gate  *	Inform IBTL that the connection has been established on this
1140Sstevel@tonic-gate  *	channel so that a later call to ibtl_cm_chan_is_closed()
1150Sstevel@tonic-gate  *	will be required to free the QPN used by this channel.
1160Sstevel@tonic-gate  *
11711369SPramod.Gunjikar@Sun.COM  * ibtl_cm_chan_is_opening()
11811369SPramod.Gunjikar@Sun.COM  *
11911369SPramod.Gunjikar@Sun.COM  *	Inform IBTL that the connection established on this channel is
12011369SPramod.Gunjikar@Sun.COM  *	in progress.
12111369SPramod.Gunjikar@Sun.COM  *
122*12064SShantkumar.Hiremath@Sun.COM  * ibtl_cm_chan_open_is_aborted()
123*12064SShantkumar.Hiremath@Sun.COM  *
124*12064SShantkumar.Hiremath@Sun.COM  *	Inform IBTL that the connection established on this channel has
125*12064SShantkumar.Hiremath@Sun.COM  *	aborted. So undo what was done in ibtl_cm_chan_is_opening().
126*12064SShantkumar.Hiremath@Sun.COM  *
1270Sstevel@tonic-gate  * ibtl_cm_chan_is_closing()
1280Sstevel@tonic-gate  *
1290Sstevel@tonic-gate  *	Inform IBTL that the TIMEWAIT delay for the connection has been
1300Sstevel@tonic-gate  *	started for this channel so that the QP can be freed.
1310Sstevel@tonic-gate  *
1320Sstevel@tonic-gate  * ibtl_cm_is_chan_closing()
1330Sstevel@tonic-gate  *
1340Sstevel@tonic-gate  *	Returns 1 if the connection on this channel has been moved to TIME WAIT
1350Sstevel@tonic-gate  *
1360Sstevel@tonic-gate  * ibtl_cm_is_chan_closed()
1370Sstevel@tonic-gate  *
1380Sstevel@tonic-gate  *	Returns 1 if the connection on this channel has completed TIME WAIT
1390Sstevel@tonic-gate  *
1400Sstevel@tonic-gate  * ibtl_cm_chan_is_closed()
1410Sstevel@tonic-gate  *
1420Sstevel@tonic-gate  *	Inform IBTL that the TIMEWAIT delay for the connection has been
1430Sstevel@tonic-gate  *	reached for this channel so that the QPN can be reused.
1440Sstevel@tonic-gate  *
1450Sstevel@tonic-gate  *	rc_chan		Channel Handle
1460Sstevel@tonic-gate  *
1470Sstevel@tonic-gate  * ibtl_cm_chan_is_reused()
1480Sstevel@tonic-gate  *
1490Sstevel@tonic-gate  *	Inform IBTL that the channel is going to be re-used for another
1500Sstevel@tonic-gate  *	connection.
1510Sstevel@tonic-gate  *
1520Sstevel@tonic-gate  *	rc_chan		Channel Handle
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate void ibtl_cm_chan_is_open(ibt_channel_hdl_t rc_chan);
15511369SPramod.Gunjikar@Sun.COM void ibtl_cm_chan_is_opening(ibt_channel_hdl_t rc_chan);
156*12064SShantkumar.Hiremath@Sun.COM void ibtl_cm_chan_open_is_aborted(ibt_channel_hdl_t rc_chan);
1570Sstevel@tonic-gate void ibtl_cm_chan_is_closing(ibt_channel_hdl_t rc_chan);
1580Sstevel@tonic-gate void ibtl_cm_chan_is_closed(ibt_channel_hdl_t rc_chan);
1590Sstevel@tonic-gate void ibtl_cm_chan_is_reused(ibt_channel_hdl_t rc_chan);
1600Sstevel@tonic-gate int  ibtl_cm_is_chan_closing(ibt_channel_hdl_t rc_chan);
1610Sstevel@tonic-gate int  ibtl_cm_is_chan_closed(ibt_channel_hdl_t rc_chan);
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
1640Sstevel@tonic-gate  * ibtl_cm_get_chan_type()
1650Sstevel@tonic-gate  *
1660Sstevel@tonic-gate  *	A helper function to get channel transport type.
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate ibt_tran_srv_t ibtl_cm_get_chan_type(ibt_channel_hdl_t chan);
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate /*
1710Sstevel@tonic-gate  * ibtl_cm_change_service_cnt()
1720Sstevel@tonic-gate  *
1730Sstevel@tonic-gate  *	Inform IBTL that service registration count has changed
1740Sstevel@tonic-gate  *	so that it can correctly manage whether or not it should
1750Sstevel@tonic-gate  *	allow ibt_detach() to succeed.
1760Sstevel@tonic-gate  */
1770Sstevel@tonic-gate void ibtl_cm_change_service_cnt(ibt_clnt_hdl_t ibt_hdl, int delta_num_sids);
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate /*
1800Sstevel@tonic-gate  * ibtl_cm_query_hca_ports_byguid()
1810Sstevel@tonic-gate  *
1820Sstevel@tonic-gate  *	Use the cached copy of the portinfo.
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate ibt_status_t ibtl_cm_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port,
1850Sstevel@tonic-gate     ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p);
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate /*
1890Sstevel@tonic-gate  * ibtl_cm_get_active_plist
1900Sstevel@tonic-gate  *
1910Sstevel@tonic-gate  *	Returns a list of active source points which satisfy the desired
1920Sstevel@tonic-gate  *	attribute. The memory allocated for the array "port_list_p" should
1930Sstevel@tonic-gate  *	be freed by the caller using ibtl_cm_free_active_plist().
1940Sstevel@tonic-gate  *
1950Sstevel@tonic-gate  * ibtl_cm_free_active_plist
1960Sstevel@tonic-gate  *
1970Sstevel@tonic-gate  *	Frees the memory allocated in ibtl_cm_get_active_plist().
1980Sstevel@tonic-gate  */
1990Sstevel@tonic-gate 
200401Shiremath #define	IBTL_CM_SIMPLE_SETUP	0
201401Shiremath #define	IBTL_CM_MULTI_SM	(1 << 0)
202401Shiremath #define	IBTL_CM_MULTI_HCA	(1 << 1)
203401Shiremath 
2040Sstevel@tonic-gate typedef struct ibtl_cm_port_list_s {
2050Sstevel@tonic-gate 	ib_guid_t	p_hca_guid;
2060Sstevel@tonic-gate 	ib_gid_t	p_sgid;
2070Sstevel@tonic-gate 	ib_lid_t	p_base_lid;
2080Sstevel@tonic-gate 	ib_mtu_t	p_mtu;
2090Sstevel@tonic-gate 	uint8_t		p_sgid_ix;
2100Sstevel@tonic-gate 	uint8_t		p_port_num;
211401Shiremath 	uint8_t		p_count;
212401Shiremath 	uint8_t		p_multi;
2130Sstevel@tonic-gate 	void		*p_saa_hdl;
2144703Shiremath 	ibt_ip_addr_t	p_src_ip;
2150Sstevel@tonic-gate } ibtl_cm_port_list_t;
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate ibt_status_t ibtl_cm_get_active_plist(ibt_path_attr_t *attr,
2180Sstevel@tonic-gate     ibt_path_flags_t flags, ibtl_cm_port_list_t **port_list_p);
2190Sstevel@tonic-gate void ibtl_cm_free_active_plist(ibtl_cm_port_list_t *port_list);
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate  * Functions to support ibt_register_subnet_notices and the
2230Sstevel@tonic-gate  * related callbacks.
2240Sstevel@tonic-gate  *
2250Sstevel@tonic-gate  * ibtl_cm_set_sm_notice_handler
2260Sstevel@tonic-gate  *	Pass the handler into IBTL where it will actually be used.
2270Sstevel@tonic-gate  *
2280Sstevel@tonic-gate  * ibtl_cm_sm_notice_handler
2290Sstevel@tonic-gate  *	Post an event to interested IBT clients.
2300Sstevel@tonic-gate  *
2310Sstevel@tonic-gate  * ibtl_cm_sm_notice_init_failure
2320Sstevel@tonic-gate  *	Inform the client that callbacks are not working.
2330Sstevel@tonic-gate  */
2340Sstevel@tonic-gate void ibtl_cm_sm_notice_handler(ib_gid_t sgid, ibt_subnet_event_code_t code,
2350Sstevel@tonic-gate     ibt_subnet_event_t *event);
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate void ibtl_cm_set_sm_notice_handler(ibt_clnt_hdl_t ibt_hdl,
2380Sstevel@tonic-gate     ibt_sm_notice_handler_t sm_notice_handler, void *private);
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate /* pass all failing sgids at once */
2410Sstevel@tonic-gate typedef struct ibtl_cm_sm_init_fail_s {
2420Sstevel@tonic-gate 	int		smf_num_sgids;
2430Sstevel@tonic-gate 	ibt_clnt_hdl_t	smf_ibt_hdl;
2440Sstevel@tonic-gate 	ib_gid_t	smf_sgid[1];
2450Sstevel@tonic-gate } ibtl_cm_sm_init_fail_t;
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate void ibtl_cm_sm_notice_init_failure(ibtl_cm_sm_init_fail_t *ifail);
2480Sstevel@tonic-gate 
2499349SShantkumar.Hiremath@Sun.COM char *ibtl_cm_get_clnt_name(ibt_clnt_hdl_t ibt_hdl);
2509349SShantkumar.Hiremath@Sun.COM 
2519891SRajkumar.Sivaprakasam@Sun.COM /*
2529891SRajkumar.Sivaprakasam@Sun.COM  * ibtl_cm_set_node_info_cb: This is a private interface between IBTL and IBCM
2539891SRajkumar.Sivaprakasam@Sun.COM  * to let IBTL get the Node Record of a remote port. This interface is used by
2549891SRajkumar.Sivaprakasam@Sun.COM  * IBCM to register a callback which can be used by IBTL to get the Node record.
2559891SRajkumar.Sivaprakasam@Sun.COM  */
2569891SRajkumar.Sivaprakasam@Sun.COM void ibtl_cm_set_node_info_cb(ibt_status_t (*)(ib_guid_t, uint8_t, ib_lid_t,
2579891SRajkumar.Sivaprakasam@Sun.COM     ibt_node_info_t *));
2589891SRajkumar.Sivaprakasam@Sun.COM 
2590Sstevel@tonic-gate #ifdef __cplusplus
2600Sstevel@tonic-gate }
2610Sstevel@tonic-gate #endif
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate #endif /* _SYS_IB_IBTL_IMPL_IBTL_CM_H */
264