xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_af_thr_impl.h (revision 5d5562f583b2b6affe19bdce0b3c8b1840d667a4)
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _RDSV3_AF_THR_IMPL_H
26 #define	_RDSV3_AF_THR_IMPL_H
27 
28 /*
29  * This file is only present in Solaris
30  */
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	ddi_intr_set_affinity set_intr_affinity
37 #include <sys/ib/clients/rdsv3/rdsv3_af_thr.h>
38 #define	SCQ_BIND_CPU (SCQ_HCA_BIND_CPU | SCQ_WRK_BIND_CPU)
39 
40 #define	RDSV3_AFT_MAX_CONN 4
41 #define	RDSV3_AFT_PER_CONN_CPU 1
42 #define	RDSV3_AFT_CONN_CPU_POOL (RDSV3_AFT_MAX_CONN * RDSV3_AFT_PER_CONN_CPU)
43 
44 #define	RDSV3_CPUID_POOL_MAX 128
45 static uint32_t rdsv3_cpuid_pool[RDSV3_CPUID_POOL_MAX];
46 static int rdsv3_cpuid_pool_cnt;
47 #define	RDSV3_MSIX_POOL_MAX 128
48 static uint32_t rdsv3_msix_pool[RDSV3_MSIX_POOL_MAX];
49 static int rdsv3_msix_pool_cnt;
50 
51 #define	RDSV3_CPUFLAGS_ON 		0x0001
52 #define	RDSV3_CPUFLAGS_OFF 		0x0002
53 #define	RDSV3_CPUFLAGS_ASSIGNED		0x0004
54 #define	RDSV3_CPUFLAGS_INTR		0x0008
55 #define	RDSV3_CPUFLAGS_HCA		0x0010
56 
57 #define	RDSV3_CPUFLAGS_UNAVAIL (RDSV3_CPUFLAGS_OFF | RDSV3_CPUFLAGS_INTR)
58 
59 struct rdsv3_af_grp_s {
60 	ibt_hca_hdl_t		g_hca_hdl;
61 	ibt_sched_hdl_t		g_sched_hdl;
62 	processorid_t		g_hca_cpuid;
63 	processorid_t		g_conn_cpuid_pool[RDSV3_AFT_CONN_CPU_POOL];
64 	int			g_conn_cpuid_idx;
65 };
66 
67 struct rdsv3_af_thr_s {
68 	/* Keep the most used members 64bytes cache aligned */
69 	kmutex_t	aft_lock;	/* lock before using any member */
70 	kcondvar_t	aft_async;	/* async thread blocks on */
71 	kthread_t	*aft_worker;	/* kernel thread id */
72 	void		*aft_data;	/* argument of cq_drain_func */
73 	processorid_t	aft_cpuid;	/* processor to bind to */
74 	uint16_t	aft_state;	/* state flags */
75 	uint16_t	aft_cflag;	/* creation flags */
76 	rdsv3_af_thr_drain_func_t aft_drain_func;
77 	rdsv3_af_grp_t	*aft_grp;
78 	ddi_intr_handle_t aft_intr;	/* intr cookie */
79 };
80 
81 /*
82  * State flags.
83  */
84 #define	AFT_PROC		0x0001	/* being processed */
85 #define	AFT_BOUND		0x0002	/* Worker thread is bound to a cpu */
86 #define	AFT_ARMED		0x0004	/* armed worker thread */
87 #define	AFT_CONDEMNED		0x0100	/* Being torn down */
88 
89 static void rdsv3_af_thr_worker(rdsv3_af_thr_t *ringp);
90 static cpu_t *rdsv3_af_thr_bind(rdsv3_af_thr_t *ringp, processorid_t cpuid);
91 static void rdsv3_af_thr_unbind(rdsv3_af_thr_t *ringp);
92 
93 #ifdef	__cplusplus
94 }
95 #endif
96 
97 #endif /* _RDSV3_AF_THR_IMPL_H */
98