1 /* 2 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved. 3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file 9 * COPYING in the main directory of this source tree, or the 10 * OpenIB.org BSD license below: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 20 * - Redistributions in binary form must reproduce the above 21 * copyright notice, this list of conditions and the following 22 * disclaimer in the documentation and/or other materials 23 * provided with the distribution. 24 * 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * SOFTWARE. 33 * 34 */ 35 36 #ifndef _OSMV_RMPP_CTX_H 37 #define _OSMV_RMPP_CTX_H 38 39 #include <complib/cl_event.h> 40 #include <opensm/osm_log.h> 41 #include <opensm/osm_madw.h> 42 #include <vendor/osm_vendor_mlx_sar.h> 43 44 #ifdef __cplusplus 45 # define BEGIN_C_DECLS extern "C" { 46 # define END_C_DECLS } 47 #else /* !__cplusplus */ 48 # define BEGIN_C_DECLS 49 # define END_C_DECLS 50 #endif /* __cplusplus */ 51 52 BEGIN_C_DECLS 53 54 typedef struct _osmv_rmpp_send_ctx { 55 56 uint8_t status; 57 58 uint32_t window_first; 59 uint32_t window_last; 60 61 uint32_t mad_sz; 62 boolean_t is_sa_mad; 63 64 cl_event_t event; 65 66 /* Segmentation engine */ 67 osmv_rmpp_sar_t sar; 68 osm_log_t *p_log; 69 70 } osmv_rmpp_send_ctx_t; 71 72 typedef struct _osmv_rmpp_recv_ctx { 73 74 boolean_t is_sa_mad; 75 76 uint32_t expected_seg; 77 78 /* Reassembly buffer */ 79 cl_qlist_t *p_rbuf; 80 81 /* Reassembly engine */ 82 osmv_rmpp_sar_t sar; 83 osm_log_t *p_log; 84 85 } osmv_rmpp_recv_ctx_t; 86 87 /* 88 * NAME 89 * osmv_rmpp_send_ctx_init 90 * 91 * DESCRIPTION 92 * c'tor for rmpp_send_ctx obj 93 * 94 * SEE ALSO 95 * 96 */ 97 ib_api_status_t 98 osmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t * p_ctx, void *arbt_mad, 99 uint32_t mad_sz, osm_log_t * p_log); 100 101 /* 102 * NAME 103 * osmv_rmpp_send_ctx_done 104 * 105 * DESCRIPTION 106 * d'tor for rmpp_send_ctx obj 107 * 108 * SEE ALSO 109 * 110 */ 111 void osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t * ctx); 112 113 /* 114 * NAME 115 * osmv_rmpp_send_ctx_get_wf 116 * 117 * DESCRIPTION 118 * returns number of first segment in current window 119 * SEE ALSO 120 * 121 */ 122 static inline uint32_t 123 osmv_rmpp_send_ctx_get_wf(IN const osmv_rmpp_send_ctx_t * p_ctx) 124 { 125 CL_ASSERT(p_ctx); 126 return p_ctx->window_first; 127 } 128 129 /* 130 * NAME 131 * osmv_rmpp_send_ctx_set_wf 132 * 133 * DESCRIPTION 134 * sets number of first segment in current window 135 * SEE ALSO 136 * 137 */ 138 static inline void 139 osmv_rmpp_send_ctx_set_wf(IN osmv_rmpp_send_ctx_t * p_ctx, IN uint32_t val) 140 { 141 CL_ASSERT(p_ctx); 142 p_ctx->window_first = val; 143 } 144 145 /* 146 * NAME 147 * osmv_rmpp_send_ctx_get_wl 148 * 149 * DESCRIPTION 150 * returns number of last segment in current window 151 * SEE ALSO 152 * 153 */ 154 static inline uint32_t 155 osmv_rmpp_send_ctx_get_wl(IN const osmv_rmpp_send_ctx_t * p_send_ctx) 156 { 157 CL_ASSERT(p_send_ctx); 158 return p_send_ctx->window_last; 159 } 160 161 /* 162 * NAME 163 * osmv_rmpp_send_ctx_set_wl 164 * 165 * DESCRIPTION 166 * sets number of last segment in current window 167 * SEE ALSO 168 * 169 */ 170 static inline void 171 osmv_rmpp_send_ctx_set_wl(IN osmv_rmpp_send_ctx_t * p_ctx, IN uint32_t val) 172 { 173 CL_ASSERT(p_ctx); 174 p_ctx->window_last = val; 175 } 176 177 /* 178 * NAME 179 * osmv_rmpp_send_ctx_get_num_segs 180 * 181 * DESCRIPTION 182 * returns the total number of mad segments to send 183 * SEE ALSO 184 * 185 */ 186 uint32_t osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t * p_send_ctx); 187 188 /* 189 * NAME 190 * osmv_rmpp_send_ctx_get_seg 191 * 192 * DESCRIPTION 193 * Retrieves the mad segment by seg number (including setting the mad relevant bits & hdrs) 194 * SEE ALSO 195 * 196 */ 197 ib_api_status_t 198 osmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t * p_send_ctx, 199 IN uint32_t seg_idx, IN uint32_t resp_timeout, 200 OUT void *p_mad); 201 202 /* 203 * NAME 204 * osmv_rmpp_recv_ctx_init 205 * 206 * DESCRIPTION 207 * c'tor for rmpp_recv_ctx obj 208 * SEE ALSO 209 * 210 */ 211 ib_api_status_t 212 osmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t * p_ctx, osm_log_t * p_log); 213 214 /* 215 * NAME 216 * osmv_rmpp_recv_ctx_done 217 * 218 * DESCRIPTION 219 * d'tor for rmpp_recv_ctx obj 220 * SEE ALSO 221 * 222 */ 223 void osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t * p_ctx); 224 225 /* 226 * NAME 227 * osmv_rmpp_recv_ctx_get_es 228 * 229 * DESCRIPTION 230 * retrunes index of expected segement in the curr window 231 * 232 */ 233 static inline uint32_t 234 osmv_rmpp_recv_ctx_get_es(IN const osmv_rmpp_recv_ctx_t * p_recv_ctx) 235 { 236 CL_ASSERT(p_recv_ctx); 237 return p_recv_ctx->expected_seg; 238 } 239 240 /* 241 * NAME 242 * osmv_rmpp_recv_ctx_set_es 243 * 244 * DESCRIPTION 245 * sets index of expected segement in the curr window 246 * 247 */ 248 static inline void 249 osmv_rmpp_recv_ctx_set_es(IN osmv_rmpp_recv_ctx_t * p_recv_ctx, IN uint32_t val) 250 { 251 CL_ASSERT(p_recv_ctx); 252 p_recv_ctx->expected_seg = val; 253 } 254 255 /* 256 * NAME 257 * osmv_rmpp_recv_ctx_store_madw_seg 258 * 259 * DESCRIPTION 260 * stores rmpp mad in the list 261 * 262 */ 263 ib_api_status_t 264 osmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t * p_recv_ctx, 265 IN void *p_mad); 266 267 uint32_t 268 osmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t * p_recv_ctx); 269 270 uint32_t 271 osmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t * 272 p_recv_ctx); 273 274 uint32_t 275 osmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t * p_recv_ctx); 276 277 /* 278 * NAME 279 * osmv_rmpp_recv_ctx_reassemble_arbt_mad 280 * 281 * DESCRIPTION 282 * reassembles all rmpp buffs to one big arbitrary mad 283 */ 284 ib_api_status_t 285 osmv_rmpp_recv_ctx_reassemble_arbt_mad(IN osmv_rmpp_recv_ctx_t * p_recv_ctx, 286 IN uint32_t size, IN void *p_arbt_mad); 287 288 END_C_DECLS 289 #endif 290