41 */
42
43 /*
44 *
45 * ibt_alloc_srq() - Allocate a completion queue
46 */
47 ibt_status_t
48 ibt_alloc_srq(ibt_hca_hdl_t hca_hdl, ibt_srq_flags_t flags, ibt_pd_hdl_t pd,
49 ibt_srq_sizes_t *srq_sizes, ibt_srq_hdl_t *ibt_srq_p,
50 ibt_srq_sizes_t *real_sizes_p)
51 {
52 ibt_status_t status;
53 ibt_srq_hdl_t ibt_srq;
54
55 IBTF_DPRINTF_L3(ibtf_srq, "ibt_alloc_srq(%p, %p)",
56 hca_hdl, srq_sizes);
57
58 ibt_srq = kmem_zalloc(sizeof (struct ibtl_srq_s), KM_SLEEP);
59 *ibt_srq_p = ibt_srq;
60
61 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(ibt_srq->srq_ibc_srq_hdl))
62 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(ibt_srq->srq_hca))
63 /*
64 * Set the following values before creating CI SRQ, to avoid race
65 * conditions on async callback.
66 */
67 ibt_srq->srq_hca = hca_hdl;
68
69 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_alloc_srq(
70 IBTL_HCA2CIHCA(hca_hdl), flags, ibt_srq, pd, srq_sizes,
71 &ibt_srq->srq_ibc_srq_hdl, real_sizes_p);
72
73 if (status != IBT_SUCCESS) {
74 IBTF_DPRINTF_L2(ibtf_srq, "ibt_alloc_srq: "
75 "CI SRQ handle allocation failed: status = %d", status);
76 kmem_free(ibt_srq, sizeof (struct ibtl_srq_s));
77 *ibt_srq_p = NULL;
78 return (status);
79 }
80
81 _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(ibt_srq->srq_ibc_srq_hdl))
82 _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(ibt_srq->srq_hca))
83
84 /* Update the srq resource count */
85 atomic_inc_32(&hca_hdl->ha_srq_cnt);
86
87 return (IBT_SUCCESS);
88 }
89
90
91 /*
92 * ibt_free_srq() - Free a shared receive queue
93 *
94 */
95 ibt_status_t
96 ibt_free_srq(ibt_srq_hdl_t ibt_srq)
97 {
98 ibt_status_t status;
99 ibtl_hca_t *ibt_hca = ibt_srq->srq_hca;
100
101 IBTF_DPRINTF_L3(ibtf_srq, "ibt_free_srq(%p)", ibt_srq);
102
103 status = ((IBTL_SRQ2CIHCAOPS_P(ibt_srq))->ibc_free_srq)
132 sizes_p, limit));
133 }
134
135
136 /*
137 * ibt_resize_srq() - Change the size of a srq.
138 */
139 ibt_status_t
140 ibt_modify_srq(ibt_srq_hdl_t ibt_srq, ibt_srq_modify_flags_t flags,
141 uint_t size, uint_t limit, uint_t *real_size_p)
142 {
143 IBTF_DPRINTF_L3(ibtf_srq, "ibt_modify_srq(%p, %d, %d, %d)",
144 ibt_srq, flags, size, limit);
145
146 return (IBTL_SRQ2CIHCAOPS_P(ibt_srq)->ibc_modify_srq(
147 IBTL_SRQ2CIHCA(ibt_srq), ibt_srq->srq_ibc_srq_hdl,
148 flags, size, limit, real_size_p));
149 }
150
151
152 _NOTE(SCHEME_PROTECTS_DATA("client managed", ibtl_srq_s::srq_clnt_private))
153
154 /*
155 * ibt_set_srq_private - Sets the private data on a given SRQ
156 *
157 * ibt_srq The ibt_srq_hdl_t of the allocated SRQ.
158 * clnt_private The client private data.
159 */
160 void
161 ibt_set_srq_private(ibt_srq_hdl_t ibt_srq, void *clnt_private)
162 {
163 ibt_srq->srq_clnt_private = clnt_private;
164 }
165
166
167 /*
168 * ibt_get_srq_private - Retrieves the private data for a given SRQ
169 *
170 * ibt_srq The ibt_srq_hdl_t of the allocated SRQ.
171 */
172 void *
173 ibt_get_srq_private(ibt_srq_hdl_t ibt_srq)
|
41 */
42
43 /*
44 *
45 * ibt_alloc_srq() - Allocate a completion queue
46 */
47 ibt_status_t
48 ibt_alloc_srq(ibt_hca_hdl_t hca_hdl, ibt_srq_flags_t flags, ibt_pd_hdl_t pd,
49 ibt_srq_sizes_t *srq_sizes, ibt_srq_hdl_t *ibt_srq_p,
50 ibt_srq_sizes_t *real_sizes_p)
51 {
52 ibt_status_t status;
53 ibt_srq_hdl_t ibt_srq;
54
55 IBTF_DPRINTF_L3(ibtf_srq, "ibt_alloc_srq(%p, %p)",
56 hca_hdl, srq_sizes);
57
58 ibt_srq = kmem_zalloc(sizeof (struct ibtl_srq_s), KM_SLEEP);
59 *ibt_srq_p = ibt_srq;
60
61 /*
62 * Set the following values before creating CI SRQ, to avoid race
63 * conditions on async callback.
64 */
65 ibt_srq->srq_hca = hca_hdl;
66
67 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_alloc_srq(
68 IBTL_HCA2CIHCA(hca_hdl), flags, ibt_srq, pd, srq_sizes,
69 &ibt_srq->srq_ibc_srq_hdl, real_sizes_p);
70
71 if (status != IBT_SUCCESS) {
72 IBTF_DPRINTF_L2(ibtf_srq, "ibt_alloc_srq: "
73 "CI SRQ handle allocation failed: status = %d", status);
74 kmem_free(ibt_srq, sizeof (struct ibtl_srq_s));
75 *ibt_srq_p = NULL;
76 return (status);
77 }
78
79 /* Update the srq resource count */
80 atomic_inc_32(&hca_hdl->ha_srq_cnt);
81
82 return (IBT_SUCCESS);
83 }
84
85
86 /*
87 * ibt_free_srq() - Free a shared receive queue
88 *
89 */
90 ibt_status_t
91 ibt_free_srq(ibt_srq_hdl_t ibt_srq)
92 {
93 ibt_status_t status;
94 ibtl_hca_t *ibt_hca = ibt_srq->srq_hca;
95
96 IBTF_DPRINTF_L3(ibtf_srq, "ibt_free_srq(%p)", ibt_srq);
97
98 status = ((IBTL_SRQ2CIHCAOPS_P(ibt_srq))->ibc_free_srq)
127 sizes_p, limit));
128 }
129
130
131 /*
132 * ibt_resize_srq() - Change the size of a srq.
133 */
134 ibt_status_t
135 ibt_modify_srq(ibt_srq_hdl_t ibt_srq, ibt_srq_modify_flags_t flags,
136 uint_t size, uint_t limit, uint_t *real_size_p)
137 {
138 IBTF_DPRINTF_L3(ibtf_srq, "ibt_modify_srq(%p, %d, %d, %d)",
139 ibt_srq, flags, size, limit);
140
141 return (IBTL_SRQ2CIHCAOPS_P(ibt_srq)->ibc_modify_srq(
142 IBTL_SRQ2CIHCA(ibt_srq), ibt_srq->srq_ibc_srq_hdl,
143 flags, size, limit, real_size_p));
144 }
145
146
147 /*
148 * ibt_set_srq_private - Sets the private data on a given SRQ
149 *
150 * ibt_srq The ibt_srq_hdl_t of the allocated SRQ.
151 * clnt_private The client private data.
152 */
153 void
154 ibt_set_srq_private(ibt_srq_hdl_t ibt_srq, void *clnt_private)
155 {
156 ibt_srq->srq_clnt_private = clnt_private;
157 }
158
159
160 /*
161 * ibt_get_srq_private - Retrieves the private data for a given SRQ
162 *
163 * ibt_srq The ibt_srq_hdl_t of the allocated SRQ.
164 */
165 void *
166 ibt_get_srq_private(ibt_srq_hdl_t ibt_srq)
|