xref: /illumos-gate/usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h (revision 7b4c5c8b4fd48b69fab033a244cf1eaf942ee6bd)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_IB_IBNEX_IBNEX_DEVCTL_H
27 #define	_SYS_IB_IBNEX_IBNEX_DEVCTL_H
28 
29 #include <sys/ib/ib_types.h>
30 #include <sys/ib/ibtl/ibtl_types.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This file contains info for devctls issued by IB cfgadm plugin.
38  * The only devctl of interest is DEVCTL_AP_CONTROL which uses
39  * these defines and data structures.
40  */
41 
42 #define	IBNEX_HCAGUID_STRSZ	17
43 
44 /*
45  * types of attachment point Identifiers (APID)s supported
46  */
47 #define	IBNEX_BASE_APID		0x01	/* Base static attachment point */
48 #define	IBNEX_HCA_APID		0x02	/* HCA static attachment point */
49 #define	IBNEX_DYN_APID		0x04	/* Dynamic IOC/DLPI attachment point */
50 #define	IBNEX_UNKNOWN_APID	0x08	/* Unknown attachment point */
51 
52 
53 /* defines for dynamic APID handling */
54 #define	DYN_SEP		"::"
55 #define	GET_DYN(a)	(((a) != NULL) ? strstr((a), DYN_SEP) : (void *)0)
56 
57 #define	IBNEX_FABRIC		"fabric"
58 #define	IBNEX_VPPA_STR		"vppa"
59 #define	IBNEX_PORT_STR		"port"
60 #define	IBNEX_HCASVC_STR	"hca-svc"
61 
62 /* Enums while reading ib.conf file */
63 typedef enum ib_service_type_e {
64 	IB_NAME,		/* name = */
65 	IB_CLASS,		/* class = */
66 	IB_PORT_SERVICE,	/* port-svc-list = */
67 	IB_VPPA_SERVICE,	/* vppa-svc-list = */
68 	IB_HCASVC_SERVICE,	/* hca-svc-list = */
69 	IB_NONE
70 } ib_service_type_t;
71 
72 /*
73  * defines for nvlist types: (for PORT devices and IOCs)
74  * The first 6 are common to both IOC and PORT devices.
75  * The last 9 are used only for IOC devices.
76  */
77 #define	IBNEX_NODE_INFO_NVL		"node_info"
78 #define	IBNEX_NODE_APID_NVL		"node_apid"
79 #define	IBNEX_NODE_TYPE_NVL		"node_type"
80 #define	IBNEX_NODE_RSTATE_NVL		"node_rstate"
81 #define	IBNEX_NODE_OSTATE_NVL		"node_ostate"
82 #define	IBNEX_NODE_COND_NVL		"node_condition"
83 
84 /*
85  * This flag is passed from cfgadm to ib(7d) to convey that it
86  * need not attempt to probe the fabric.
87  *
88  * The value of these flags should be same as flags in enum
89  * ibdm_ibnex_get_ioclist_mtd_t.
90  */
91 #define	IBNEX_DONOT_PROBE_FLAG	1
92 #define	IBNEX_NORMAL_PROBE	0	/* flag used by ib(7d) only */
93 
94 /*
95  * The following are sub-commands to DEVCTL_AP_CONTROL.
96  * NOTE: IBNEX_NUM_DEVICE_NODES and IBNEX_NUM_HCA_NODES need to be
97  * separate. The former is used to figure out the dynamic ap_ids for
98  * the IB fabric. The latter is used for a HCA count on a given host only.
99  */
100 #define	IBNEX_NUM_DEVICE_NODES	0x00010	/* how many device nodes exist? */
101 #define	IBNEX_NUM_HCA_NODES	0x00020	/* how many HCAs exist in the host? */
102 #define	IBNEX_SNAPSHOT_SIZE	0x00040	/* What is the "snapshot" size? */
103 #define	IBNEX_GET_SNAPSHOT	0x00080	/* Get the actual dynamic "snapshot" */
104 #define	IBNEX_DEVICE_PATH_SZ	0x00100	/* Given APID's device path size */
105 #define	IBNEX_GET_DEVICE_PATH	0x00200	/* Get device path for a Dynamic APID */
106 #define	IBNEX_HCA_LIST_SZ	0x00400	/* -x list_clients size for HCA APID */
107 #define	IBNEX_HCA_LIST_INFO	0x00800	/* -x list_clients info for HCA APID */
108 #define	IBNEX_UNCFG_CLNTS_SZ	0x01000	/* -x unconfig_clients option size */
109 #define	IBNEX_UNCFG_CLNTS_INFO	0x02000	/* -x unconfig_clients option data */
110 #define	IBNEX_UPDATE_PKEY_TBLS	0x04000	/* -x update_pkey_tbls */
111 #define	IBNEX_CONF_ENTRY_ADD	0x08000	/* -x conf_file add_service */
112 #define	IBNEX_CONF_ENTRY_DEL	0x10000	/* -x conf_file delete_service */
113 #define	IBNEX_HCA_VERBOSE_SZ	0x20000	/* -alv hca_apid devctl size */
114 #define	IBNEX_HCA_VERBOSE_INFO	0x40000	/* -alv hca_apid devctl data */
115 #define	IBNEX_UPDATE_IOC_CONF	0x80000	/* -x update_ioc_conf */
116 
117 /*
118  * Data structure passed back and forth user/kernel w/ DEVCTL_AP_CONTROL
119  * devctl. Note that these are separate structures as some fields are pointers.
120  */
121 typedef struct ibnex_ioctl_data {
122 	uint_t		cmd;		/* one of the above commands */
123 	caddr_t		buf;		/* data buffer */
124 	uint_t		bufsiz;		/* data buffer size */
125 	caddr_t		ap_id;		/* Search based on this AP_ID name */
126 	uint_t		ap_id_len;	/* AP_ID name len */
127 	uint_t		misc_arg;	/* reserved */
128 } ibnex_ioctl_data_t;
129 
130 
131 /* For 32-bit app/64-bit kernel */
132 typedef struct ibnex_ioctl_data_32 {
133 	uint32_t	cmd;		/* one of the above commands */
134 	caddr32_t	buf;		/* data buffer */
135 	uint32_t	bufsiz;		/* data buffer size */
136 	caddr32_t	ap_id;		/* Search based on this AP_ID name */
137 	uint32_t	ap_id_len;	/* AP_ID name len */
138 	uint32_t	misc_arg;	/* reserved */
139 } ibnex_ioctl_data_32_t;
140 
141 /*
142  * General ibnex IOCTLs
143  *
144  * IBNEX_CTL_GET_API_VER
145  * ======================
146  *
147  * Gets the version number of the API that IB nexus currently supports.
148  *
149  * arg - pointer to a structure of type ibnex_ctl_api_ver_t
150  *
151  * Caller does not set any field of this structure. When this IOCTL is issued,
152  * ib nexus will set api_ver_num field to the currently supported API
153  * version number.
154  *
155  * The caller could issue this IOCTL prior to issuing any other general
156  * ibnex IOCTLs to detect incompatible changes to the API. The caller may
157  * call other IOCTLs only if the api_ver_num matches the API version number
158  * used by the caller.
159  *
160  *
161  * IBNEX_CTL_GET_HCA_LIST
162  * ======================
163  *
164  * Gets GUIDs for all HCAs in the system
165  *
166  * arg - pointer to a structure of type ibnex_ctl_get_hca_list_t
167  *
168  * Caller allocates memory for HCA GUIDs. Sets hca_guids field to point to the
169  * allocated memory. Sets hca_guids_alloc_sz to the number of GUIDs for which
170  * memory has been allocated.
171  *
172  * Upon successful return from the IOCTL, nhcas will contain the number of
173  * HCAs in the system. HCA GUIDs will be copied into hca_guids array.
174  * The number of GUIDs copied are nhcas or hca_guids_alloc_sz which ever is
175  * smaller.
176  *
177  *
178  * IBNEX_CTL_QUERY_HCA
179  * ===================
180  *
181  * Query HCA attributes
182  *
183  * arg - pointer to a structure of type ibnex_ctl_query_hca_t
184  *
185  * Caller sets hca_guid field of this structure.
186  *
187  * Upon successful return from the IOCTL, hca_info will contain HCA attributes
188  * for the specified GUID.
189  *
190  *
191  * IBNEX_CTL_QUERY_HCA_PORT
192  * ========================
193  *
194  * Query HCA port attributes
195  *
196  * arg - pointer to a structure of type ibnex_ctl_query_hca_port_t
197  *
198  * Caller sets hca_guid and port_num fields.
199  *
200  * Caller allocates memory for sgid entries. Sets sgid_tbl to point to
201  * the allocated memory and sgid_tbl_alloc_sz to the number of sgid entries
202  * for which memory has been allocated.
203  *
204  * Caller allocates memory for pkey entries. Sets pkey_tbl to point to
205  * the allocated memory and pkey_tbl_alloc_sz to the number of pkey entries
206  * for which memory has been allocated.
207  *
208  * Upon successful return from the IOCTL, port_info will contain HCA port
209  * attributes for the specified HCA port. port_info.p_sgid_tbl_sz will contain
210  * the actual number of sgids associated with this port. port_info.p_pkey_tbl_sz
211  * will contain the actual number of pkeys associated with this port.
212  *
213  * port_info.p_sgid_tbl will point to an array containing sgids. The number of
214  * sgids in the array is sgid_tbl_alloc_sz or port_info.p_sgid_tbl_sz
215  * whichever is smaller.
216  *
217  * port_info.p_pkey_tbl will point to an array containing pkeys. The number of
218  * pkeys in the array is pkey_tbl_alloc_sz or port_info.p_pkey_tbl_sz
219  * whichever is smaller.
220  */
221 
222 
223 /*
224  * ibnex specific ioctls
225  *
226  * NOTE: The ioctl codes should not collide with generic devctl ioctls
227  * such as DEVCTL_AP_CONFIGURE.
228  */
229 #define	IBNEX_IOC		(1 << 16)
230 #define	IBNEX_CTL_GET_API_VER	(IBNEX_IOC + 1)	/* Get API version # */
231 #define	IBNEX_CTL_GET_HCA_LIST	(IBNEX_IOC + 2)	/* Get HCA GUID list */
232 #define	IBNEX_CTL_QUERY_HCA	(IBNEX_IOC + 3)	/* Query HCA attributes */
233 #define	IBNEX_CTL_QUERY_HCA_PORT (IBNEX_IOC + 4) /* Query HCA port attributes */
234 
235 /*
236  * The device to open for issuing ibnex IOCTLs
237  */
238 #define	IBNEX_DEVCTL_DEV		"/devices/ib:devctl"
239 
240 /*
241  * ibnex IOCTL API version number - to be incremented when making an
242  * incompatible change to the API.
243  */
244 #define	IBNEX_CTL_API_VERSION		1
245 
246 #define	MAX_HCA_DRVNAME_LEN		16
247 
248 /*
249  * Data structure for IBNEX_CTL_GET_API_VER
250  */
251 typedef struct ibnex_ctl_api_ver_s {
252 	uint_t		api_ver_num;		/* out: supported API version */
253 } ibnex_ctl_api_ver_t;
254 
255 /*
256  * Data structure for IBNEX_CTL_GET_HCA_LIST
257  */
258 typedef struct ibnex_ctl_get_hca_list_s {
259 	ib_guid_t	*hca_guids;		/* in/out: HCA GUID array */
260 	uint_t		hca_guids_alloc_sz;	/* in: # of HCA GUIDs for */
261 						/* which storage is allocated */
262 	uint_t		nhcas;			/* out: actual number of HCAs */
263 } ibnex_ctl_get_hca_list_t;
264 
265 typedef struct ibnex_ctl_get_hca_list_32_s {
266 	caddr32_t	hca_guids;		/* in/out: HCA GUID array */
267 	uint_t		hca_guids_alloc_sz;	/* in: # of HCA GUIDs for */
268 						/* which storage is allocated */
269 	uint_t		nhcas;			/* out: actual number of HCAs */
270 } ibnex_ctl_get_hca_list_32_t;
271 
272 /*
273  * HCA information structure
274  */
275 typedef struct ibnex_ctl_hca_info_s {
276 	ib_guid_t	hca_node_guid;		/* Node GUID */
277 	ib_guid_t	hca_si_guid;		/* Optional System Image GUID */
278 	uint_t		hca_nports;		/* Number of physical ports */
279 
280 	/* HCA driver name and instance number */
281 	char		hca_driver_name[MAX_HCA_DRVNAME_LEN];
282 	int		hca_driver_instance;
283 
284 	ibt_hca_flags_t		hca_flags;	/* HCA capabilities etc */
285 	ibt_hca_flags2_t	hca_flags2;	/* HCA capabilities etc */
286 
287 	uint32_t	hca_vendor_id;		/* Vendor ID */
288 	uint16_t	hca_device_id;		/* Device ID */
289 	uint32_t	hca_version_id;		/* Version ID */
290 
291 	uint_t		hca_max_chans;		/* Max channels supported */
292 	uint_t		hca_max_chan_sz;	/* Max outstanding WRs on any */
293 						/* channel */
294 
295 	uint_t		hca_max_sgl;		/* Max SGL entries per WR */
296 
297 	uint_t		hca_max_cq;		/* Max num of CQs supported  */
298 	uint_t		hca_max_cq_sz;		/* Max capacity of each CQ */
299 
300 	ibt_page_sizes_t	hca_page_sz;	/* Bit mask of page sizes */
301 
302 	uint_t		hca_max_memr;		/* Max num of HCA mem regions */
303 	ib_memlen_t	hca_max_memr_len;	/* Largest block, in bytes of */
304 						/* mem that can be registered */
305 	uint_t		hca_max_mem_win;	/* Max Memory windows in HCA */
306 
307 	uint_t		hca_max_rsc; 		/* Max Responder Resources of */
308 						/* this HCA for RDMAR/Atomics */
309 						/* with this HCA as target. */
310 	uint8_t		hca_max_rdma_in_chan;	/* Max RDMAR/Atomics in per */
311 						/* chan this HCA as target. */
312 	uint8_t		hca_max_rdma_out_chan;	/* Max RDMA Reads/Atomics out */
313 						/* per channel by this HCA */
314 	uint_t		hca_max_ipv6_chan;	/* Max IPV6 channels in HCA */
315 	uint_t		hca_max_ether_chan;	/* Max Ether channels in HCA */
316 
317 	uint_t		hca_max_mcg_chans;	/* Max number of channels */
318 						/* that can join multicast */
319 						/* groups */
320 	uint_t		hca_max_mcg;		/* Max multicast groups */
321 	uint_t		hca_max_chan_per_mcg;	/* Max number of channels per */
322 						/* Multicast group in HCA */
323 	uint16_t	hca_max_partitions;	/* Max partitions in HCA */
324 
325 	ib_time_t	hca_local_ack_delay;
326 
327 	uint_t		hca_max_port_sgid_tbl_sz;
328 	uint16_t	hca_max_port_pkey_tbl_sz;
329 	uint_t		hca_max_pd;		/* Max# of Protection Domains */
330 
331 	uint_t		hca_max_ud_dest;
332 	uint_t		hca_max_srqs;		/* Max SRQs supported */
333 	uint_t		hca_max_srqs_sz;	/* Max outstanding WRs on any */
334 						/* SRQ */
335 	uint_t		hca_max_srq_sgl;	/* Max SGL entries per SRQ WR */
336 	uint_t		hca_max_cq_handlers;
337 	ibt_lkey_t	hca_reserved_lkey;	/* Reserved L_Key value */
338 	uint_t		hca_max_fmrs;		/* Max FMR Supported */
339 
340 	uint_t		hca_max_lso_size;
341 	uint_t		hca_max_lso_hdr_size;
342 	uint_t		hca_max_inline_size;
343 
344 	uint_t		hca_max_cq_mod_count;	/* CQ notify moderation */
345 	uint_t		hca_max_cq_mod_usec;
346 
347 	uint32_t	hca_fw_major_version;	/* firmware version */
348 	uint16_t	hca_fw_minor_version;
349 	uint16_t	hca_fw_micro_version;
350 
351 	/* detailed WQE size info */
352 	uint_t		hca_ud_send_inline_sz;	/* inline size in bytes */
353 	uint_t		hca_conn_send_inline_sz;
354 	uint_t		hca_conn_rdmaw_inline_overhead;
355 	uint_t		hca_recv_sgl_sz;	/* detailed SGL sizes */
356 	uint_t		hca_ud_send_sgl_sz;
357 	uint_t		hca_conn_send_sgl_sz;
358 	uint_t		hca_conn_rdma_sgl_overhead;
359 	int32_t		hca_pad;
360 } ibnex_ctl_hca_info_t;
361 
362 /*
363  * Data structure for IBNEX_CTL_QUERY_HCA
364  */
365 typedef struct ibnex_ctl_query_hca_s {
366 	ib_guid_t		hca_guid;	/* in: HCA GUID */
367 	ibnex_ctl_hca_info_t	hca_info;	/* out: HCA information */
368 } ibnex_ctl_query_hca_t;
369 
370 /*
371  * HCA port information structure
372  */
373 typedef struct ibnex_ctl_hca_port_info_s {
374 	ib_lid_t		p_lid;		/* Base LID of port */
375 	ib_qkey_cntr_t		p_qkey_violations; /* Bad Q_Key cnt */
376 	ib_pkey_cntr_t		p_pkey_violations; /* Optional bad P_Key cnt */
377 	uint8_t			p_sm_sl;	/* SM Service level */
378 	ib_port_phys_state_t	p_phys_state;
379 	ib_lid_t		p_sm_lid;	/* SM LID */
380 	ibt_port_state_t	p_linkstate;	/* Port state */
381 	uint8_t			p_port_num;	/* Port number */
382 
383 	ib_link_width_t		p_width_supported;
384 	ib_link_width_t		p_width_enabled;
385 	ib_link_width_t		p_width_active;
386 
387 	ib_mtu_t		p_mtu;		/* Max transfer unit - pkt */
388 	uint8_t			p_lmc;		/* LID mask control */
389 
390 	ib_link_speed_t		p_speed_supported;
391 	ib_link_speed_t		p_speed_enabled;
392 	ib_link_speed_t		p_speed_active;
393 
394 	ib_gid_t		*p_sgid_tbl;	/* SGID Table */
395 	uint_t			p_sgid_tbl_sz;	/* # of entries in SGID table */
396 
397 	ib_pkey_t		*p_pkey_tbl;	/* P_Key table */
398 	uint16_t		p_pkey_tbl_sz;	/* # of entries in P_Key tbl */
399 	uint16_t		p_def_pkey_ix;	/* default pkey index for TI */
400 
401 	uint8_t			p_max_vl;	/* Max num of virtual lanes */
402 	uint8_t			p_init_type_reply; /* Optional InitTypeReply */
403 	ib_time_t		p_subnet_timeout; /* Max Subnet Timeout */
404 	ibt_port_caps_t		p_capabilities;	/* Port Capabilities */
405 	uint32_t		p_msg_sz;	/* Max message size */
406 } ibnex_ctl_hca_port_info_t;
407 
408 typedef struct ibnex_ctl_hca_port_info_32_s {
409 	ib_lid_t		p_lid;		/* Base LID of port */
410 	ib_qkey_cntr_t		p_qkey_violations; /* Bad Q_Key cnt */
411 	ib_pkey_cntr_t		p_pkey_violations; /* Optional bad P_Key cnt */
412 	uint8_t			p_sm_sl;	/* SM Service level */
413 	ib_port_phys_state_t	p_phys_state;
414 	ib_lid_t		p_sm_lid;	/* SM LID */
415 	ibt_port_state_t	p_linkstate;	/* Port state */
416 	uint8_t			p_port_num;	/* Port number */
417 
418 	ib_link_width_t		p_width_supported;
419 	ib_link_width_t		p_width_enabled;
420 	ib_link_width_t		p_width_active;
421 
422 	ib_mtu_t		p_mtu;		/* Max transfer unit - pkt */
423 	uint8_t			p_lmc;		/* LID mask control */
424 
425 	ib_link_speed_t		p_speed_supported;
426 	ib_link_speed_t		p_speed_enabled;
427 	ib_link_speed_t		p_speed_active;
428 
429 	caddr32_t		p_sgid_tbl;	/* SGID Table */
430 	uint_t			p_sgid_tbl_sz;	/* # of entries in SGID table */
431 
432 	caddr32_t		p_pkey_tbl;	/* P_Key table */
433 	uint16_t		p_pkey_tbl_sz;	/* # of entries in P_Key tbl */
434 	uint16_t		p_def_pkey_ix;	/* default pkey index for TI */
435 
436 	uint8_t			p_max_vl;	/* Max num of virtual lanes */
437 	uint8_t			p_init_type_reply; /* Optional InitTypeReply */
438 	ib_time_t		p_subnet_timeout; /* Max Subnet Timeout */
439 	ibt_port_caps_t		p_capabilities;	/* Port Capabilities */
440 	uint32_t		p_msg_sz;	/* Max message size */
441 } ibnex_ctl_hca_port_info_32_t;
442 
443 /*
444  * Data structure for IBNEX_CTL_QUERY_HCA_PORT
445  */
446 typedef struct ibnex_ctl_query_hca_port_s {
447 	ib_guid_t	hca_guid;		/* in: HCA GUID */
448 	uint_t		port_num;		/* in: port number */
449 
450 	ib_gid_t	*sgid_tbl;		/* in: SGID Table */
451 	uint_t		sgid_tbl_alloc_sz; /* in: # of entries in SGID table */
452 
453 	ib_pkey_t	*pkey_tbl;		/* in: P_Key table */
454 	uint_t		pkey_tbl_alloc_sz; /* in: # of entries in P_Key table */
455 
456 	uint32_t	pad;
457 	ibnex_ctl_hca_port_info_t port_info;	/* out: port information */
458 } ibnex_ctl_query_hca_port_t;
459 
460 typedef struct ibnex_ctl_query_hca_port_32_s {
461 	ib_guid_t	hca_guid;		/* in: HCA GUID */
462 	uint_t		port_num;		/* in: port number */
463 
464 	caddr32_t	sgid_tbl;		/* in: SGID Table */
465 	uint_t		sgid_tbl_alloc_sz; /* in: # of entries in SGID table */
466 
467 	caddr32_t	pkey_tbl;		/* in: P_Key table */
468 	uint_t		pkey_tbl_alloc_sz; /* in: # of entries in P_Key table */
469 
470 	uint32_t	pad;
471 	ibnex_ctl_hca_port_info_32_t port_info;	/* out: port information */
472 } ibnex_ctl_query_hca_port_32_t;
473 
474 #ifdef _KERNEL
475 _NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_info_s))
476 _NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_port_info_s))
477 _NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_hca_port_info_32_s))
478 _NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_query_hca_port_s))
479 _NOTE(SCHEME_PROTECTS_DATA("", ibnex_ctl_query_hca_port_32_s))
480 #endif
481 
482 
483 #ifdef __cplusplus
484 }
485 #endif
486 
487 #endif	/* _SYS_IB_IBNEX_IBNEX_DEVCTL_H */
488