1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff#ifndef _OSMV_RMPP_CTX_H
37219820Sjeff#define _OSMV_RMPP_CTX_H
38219820Sjeff
39219820Sjeff#include <complib/cl_event.h>
40219820Sjeff#include <opensm/osm_log.h>
41219820Sjeff#include <opensm/osm_madw.h>
42219820Sjeff#include <vendor/osm_vendor_mlx_sar.h>
43219820Sjeff
44219820Sjeff#ifdef __cplusplus
45219820Sjeff#  define BEGIN_C_DECLS extern "C" {
46219820Sjeff#  define END_C_DECLS   }
47219820Sjeff#else				/* !__cplusplus */
48219820Sjeff#  define BEGIN_C_DECLS
49219820Sjeff#  define END_C_DECLS
50219820Sjeff#endif				/* __cplusplus */
51219820Sjeff
52219820SjeffBEGIN_C_DECLS
53219820Sjeff
54219820Sjefftypedef struct _osmv_rmpp_send_ctx {
55219820Sjeff
56219820Sjeff	uint8_t status;
57219820Sjeff
58219820Sjeff	uint32_t window_first;
59219820Sjeff	uint32_t window_last;
60219820Sjeff
61219820Sjeff	uint32_t mad_sz;
62219820Sjeff	boolean_t is_sa_mad;
63219820Sjeff
64219820Sjeff	cl_event_t event;
65219820Sjeff
66219820Sjeff	/* Segmentation engine */
67219820Sjeff	osmv_rmpp_sar_t sar;
68219820Sjeff	osm_log_t *p_log;
69219820Sjeff
70219820Sjeff} osmv_rmpp_send_ctx_t;
71219820Sjeff
72219820Sjefftypedef struct _osmv_rmpp_recv_ctx {
73219820Sjeff
74219820Sjeff	boolean_t is_sa_mad;
75219820Sjeff
76219820Sjeff	uint32_t expected_seg;
77219820Sjeff
78219820Sjeff	/* Reassembly buffer */
79219820Sjeff	cl_qlist_t *p_rbuf;
80219820Sjeff
81219820Sjeff	/* Reassembly engine */
82219820Sjeff	osmv_rmpp_sar_t sar;
83219820Sjeff	osm_log_t *p_log;
84219820Sjeff
85219820Sjeff} osmv_rmpp_recv_ctx_t;
86219820Sjeff
87219820Sjeff/*
88219820Sjeff * NAME
89219820Sjeff *   osmv_rmpp_send_ctx_init
90219820Sjeff *
91219820Sjeff * DESCRIPTION
92219820Sjeff *  c'tor for rmpp_send_ctx obj
93219820Sjeff *
94219820Sjeff * SEE ALSO
95219820Sjeff *
96219820Sjeff */
97219820Sjeffib_api_status_t
98219820Sjeffosmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t * p_ctx, void *arbt_mad,
99219820Sjeff			uint32_t mad_sz, osm_log_t * p_log);
100219820Sjeff
101219820Sjeff/*
102219820Sjeff * NAME
103219820Sjeff *   osmv_rmpp_send_ctx_done
104219820Sjeff *
105219820Sjeff * DESCRIPTION
106219820Sjeff *  d'tor for rmpp_send_ctx obj
107219820Sjeff *
108219820Sjeff * SEE ALSO
109219820Sjeff *
110219820Sjeff */
111219820Sjeffvoid osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t * ctx);
112219820Sjeff
113219820Sjeff/*
114219820Sjeff * NAME
115219820Sjeff *   osmv_rmpp_send_ctx_get_wf
116219820Sjeff *
117219820Sjeff * DESCRIPTION
118219820Sjeff *  returns number of first segment in current window
119219820Sjeff * SEE ALSO
120219820Sjeff *
121219820Sjeff */
122219820Sjeffstatic inline uint32_t
123219820Sjeffosmv_rmpp_send_ctx_get_wf(IN const osmv_rmpp_send_ctx_t * p_ctx)
124219820Sjeff{
125219820Sjeff	CL_ASSERT(p_ctx);
126219820Sjeff	return p_ctx->window_first;
127219820Sjeff}
128219820Sjeff
129219820Sjeff/*
130219820Sjeff * NAME
131219820Sjeff *   osmv_rmpp_send_ctx_set_wf
132219820Sjeff *
133219820Sjeff * DESCRIPTION
134219820Sjeff *  sets number of first segment in current window
135219820Sjeff * SEE ALSO
136219820Sjeff *
137219820Sjeff */
138219820Sjeffstatic inline void
139219820Sjeffosmv_rmpp_send_ctx_set_wf(IN osmv_rmpp_send_ctx_t * p_ctx, IN uint32_t val)
140219820Sjeff{
141219820Sjeff	CL_ASSERT(p_ctx);
142219820Sjeff	p_ctx->window_first = val;
143219820Sjeff}
144219820Sjeff
145219820Sjeff/*
146219820Sjeff * NAME
147219820Sjeff *   osmv_rmpp_send_ctx_get_wl
148219820Sjeff *
149219820Sjeff * DESCRIPTION
150219820Sjeff *  returns number of last segment in current window
151219820Sjeff * SEE ALSO
152219820Sjeff *
153219820Sjeff */
154219820Sjeffstatic inline uint32_t
155219820Sjeffosmv_rmpp_send_ctx_get_wl(IN const osmv_rmpp_send_ctx_t * p_send_ctx)
156219820Sjeff{
157219820Sjeff	CL_ASSERT(p_send_ctx);
158219820Sjeff	return p_send_ctx->window_last;
159219820Sjeff}
160219820Sjeff
161219820Sjeff/*
162219820Sjeff * NAME
163219820Sjeff *   osmv_rmpp_send_ctx_set_wl
164219820Sjeff *
165219820Sjeff * DESCRIPTION
166219820Sjeff *  sets number of last segment in current window
167219820Sjeff * SEE ALSO
168219820Sjeff *
169219820Sjeff */
170219820Sjeffstatic inline void
171219820Sjeffosmv_rmpp_send_ctx_set_wl(IN osmv_rmpp_send_ctx_t * p_ctx, IN uint32_t val)
172219820Sjeff{
173219820Sjeff	CL_ASSERT(p_ctx);
174219820Sjeff	p_ctx->window_last = val;
175219820Sjeff}
176219820Sjeff
177219820Sjeff/*
178219820Sjeff * NAME
179219820Sjeff *   osmv_rmpp_send_ctx_get_num_segs
180219820Sjeff *
181219820Sjeff * DESCRIPTION
182219820Sjeff *   returns the total number of mad segments to send
183219820Sjeff * SEE ALSO
184219820Sjeff *
185219820Sjeff */
186219820Sjeffuint32_t osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t * p_send_ctx);
187219820Sjeff
188219820Sjeff/*
189219820Sjeff * NAME
190219820Sjeff *   osmv_rmpp_send_ctx_get_seg
191219820Sjeff *
192219820Sjeff * DESCRIPTION
193219820Sjeff *   Retrieves the mad segment by seg number (including setting the mad relevant bits & hdrs)
194219820Sjeff * SEE ALSO
195219820Sjeff *
196219820Sjeff */
197219820Sjeffib_api_status_t
198219820Sjeffosmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t * p_send_ctx,
199219820Sjeff			   IN uint32_t seg_idx, IN uint32_t resp_timeout,
200219820Sjeff			   OUT void *p_mad);
201219820Sjeff
202219820Sjeff/*
203219820Sjeff * NAME
204219820Sjeff *   osmv_rmpp_recv_ctx_init
205219820Sjeff *
206219820Sjeff * DESCRIPTION
207219820Sjeff *   c'tor for rmpp_recv_ctx obj
208219820Sjeff * SEE ALSO
209219820Sjeff *
210219820Sjeff */
211219820Sjeffib_api_status_t
212219820Sjeffosmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t * p_ctx, osm_log_t * p_log);
213219820Sjeff
214219820Sjeff/*
215219820Sjeff * NAME
216219820Sjeff *   osmv_rmpp_recv_ctx_done
217219820Sjeff *
218219820Sjeff * DESCRIPTION
219219820Sjeff *   d'tor for rmpp_recv_ctx obj
220219820Sjeff * SEE ALSO
221219820Sjeff *
222219820Sjeff */
223219820Sjeffvoid osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t * p_ctx);
224219820Sjeff
225219820Sjeff/*
226219820Sjeff * NAME
227219820Sjeff *   osmv_rmpp_recv_ctx_get_es
228219820Sjeff *
229219820Sjeff * DESCRIPTION
230219820Sjeff *   retrunes index of expected segement in the curr window
231219820Sjeff *
232219820Sjeff */
233219820Sjeffstatic inline uint32_t
234219820Sjeffosmv_rmpp_recv_ctx_get_es(IN const osmv_rmpp_recv_ctx_t * p_recv_ctx)
235219820Sjeff{
236219820Sjeff	CL_ASSERT(p_recv_ctx);
237219820Sjeff	return p_recv_ctx->expected_seg;
238219820Sjeff}
239219820Sjeff
240219820Sjeff/*
241219820Sjeff * NAME
242219820Sjeff *   osmv_rmpp_recv_ctx_set_es
243219820Sjeff *
244219820Sjeff * DESCRIPTION
245219820Sjeff *   sets index of expected segement in the curr window
246219820Sjeff *
247219820Sjeff */
248219820Sjeffstatic inline void
249219820Sjeffosmv_rmpp_recv_ctx_set_es(IN osmv_rmpp_recv_ctx_t * p_recv_ctx, IN uint32_t val)
250219820Sjeff{
251219820Sjeff	CL_ASSERT(p_recv_ctx);
252219820Sjeff	p_recv_ctx->expected_seg = val;
253219820Sjeff}
254219820Sjeff
255219820Sjeff/*
256219820Sjeff * NAME
257219820Sjeff *   osmv_rmpp_recv_ctx_store_madw_seg
258219820Sjeff *
259219820Sjeff * DESCRIPTION
260219820Sjeff *  stores rmpp mad in the list
261219820Sjeff *
262219820Sjeff */
263219820Sjeffib_api_status_t
264219820Sjeffosmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
265219820Sjeff				 IN void *p_mad);
266219820Sjeff
267219820Sjeffuint32_t
268219820Sjeffosmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t * p_recv_ctx);
269219820Sjeff
270219820Sjeffuint32_t
271219820Sjeffosmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t *
272219820Sjeff					   p_recv_ctx);
273219820Sjeff
274219820Sjeffuint32_t
275219820Sjeffosmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t * p_recv_ctx);
276219820Sjeff
277219820Sjeff/*
278219820Sjeff * NAME
279219820Sjeff *   osmv_rmpp_recv_ctx_reassemble_arbt_mad
280219820Sjeff *
281219820Sjeff * DESCRIPTION
282219820Sjeff *  reassembles all rmpp buffs to one big arbitrary mad
283219820Sjeff */
284219820Sjeffib_api_status_t
285219820Sjeffosmv_rmpp_recv_ctx_reassemble_arbt_mad(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
286219820Sjeff				       IN uint32_t size, IN void *p_arbt_mad);
287219820Sjeff
288219820SjeffEND_C_DECLS
289219820Sjeff#endif
290