Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "securec.h"
12 : #include "dl_hal_function.h"
13 : #include "dl_ibverbs_function.h"
14 : #include "dl_urma_function.h"
15 : #include "dl_ccu_function.h"
16 : #include "dl_net_function.h"
17 : #include "hccp_ctx.h"
18 : #include "ra_rs_ctx.h"
19 : #include "ra_rs_err.h"
20 : #include "rs_inner.h"
21 : #include "rs_ctx_inner.h"
22 : #include "rs_ub.h"
23 : #include "rs_ub_tp.h"
24 : #include "rs_ub_dfx.h"
25 : #include "rs_ctx.h"
26 :
27 0 : int RsGetChipProtocol(unsigned int chipId, enum NetworkMode hccpMode, enum ProtocolTypeT *protocol,
28 : unsigned int logicId)
29 : {
30 : #define CHIP_NAME_950 "950"
31 : #define CHIP_NAME_910_96 "910_96"
32 0 : halChipInfo chipInfo = {0};
33 : int ret;
34 :
35 : // set default protocol to RDMA for compatibility issue
36 0 : *protocol = PROTOCOL_RDMA;
37 : // other modes skip to get protocol
38 0 : if (hccpMode != NETWORK_OFFLINE) {
39 0 : return 0;
40 : }
41 :
42 0 : ret = DlHalGetChipInfo(logicId, &chipInfo);
43 0 : CHK_PRT_RETURN(ret != 0,
44 : hccp_warn("hal get chip info unsuccessful, chipId[%u], logicId[%u], ret[%d]", chipId, logicId, ret), 0);
45 :
46 0 : if ((strncmp((char *)chipInfo.name, CHIP_NAME_950, sizeof(CHIP_NAME_950) - 1) == 0) ||
47 0 : (strncmp((char *)chipInfo.name, CHIP_NAME_910_96, sizeof(CHIP_NAME_910_96) - 1) == 0)) {
48 0 : *protocol = PROTOCOL_UDMA;
49 : }
50 0 : return 0;
51 : }
52 :
53 0 : int RsCtxApiInit(enum NetworkMode hccpMode, enum ProtocolTypeT protocol)
54 : {
55 0 : int ret = 0;
56 :
57 : // other modes skip to init api
58 0 : if (hccpMode != NETWORK_OFFLINE) {
59 0 : return ret;
60 : }
61 :
62 0 : switch (protocol) {
63 0 : case PROTOCOL_RDMA:
64 0 : ret = RsApiInit();
65 0 : CHK_PRT_RETURN(ret != 0, hccp_err("RsApiInit failed, protocol[%u], ret[%d]", protocol, ret), ret);
66 0 : break;
67 0 : case PROTOCOL_UDMA:
68 0 : ret = RsUbApiInit();
69 0 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_api_init failed, protocol[%u], ret[%d]", protocol, ret), ret);
70 0 : ret = RsCcuApiInit();
71 0 : if (ret != 0) {
72 0 : hccp_err("rs_ccu_api_init failed, protocol[%u], ret[%d]", protocol, ret);
73 0 : RsUbApiDeinit();
74 0 : return ret;
75 : }
76 0 : ret = RsNetApiInit();
77 0 : if (ret != 0) {
78 0 : hccp_err("rs_net_api_init failed, protocol[%u], ret[%d]", protocol, ret);
79 0 : RsCcuApiDeinit();
80 0 : RsUbApiDeinit();
81 0 : return ret;
82 : }
83 0 : break;
84 0 : default:
85 0 : hccp_err("unsupported protocol[%u]", protocol);
86 0 : return -EINVAL;
87 : }
88 :
89 0 : return ret;
90 : }
91 :
92 0 : int RsCtxApiDeinit(enum NetworkMode hccpMode, enum ProtocolTypeT protocol)
93 : {
94 : // other modes skip to deinit api
95 0 : if (hccpMode != NETWORK_OFFLINE) {
96 0 : return 0;
97 : }
98 :
99 0 : switch (protocol) {
100 0 : case PROTOCOL_RDMA:
101 0 : RsApiDeinit();
102 0 : break;
103 0 : case PROTOCOL_UDMA:
104 0 : RsUbApiDeinit();
105 0 : RsCcuApiDeinit();
106 0 : RsNetApiDeinit();
107 0 : break;
108 0 : default:
109 0 : hccp_err("unsupported protocol[%u]", protocol);
110 0 : return -EINVAL;
111 : }
112 0 : return 0;
113 : }
114 :
115 1 : RS_ATTRI_VISI_DEF int RsGetDevEidInfoNum(unsigned int phyId, unsigned int *num)
116 : {
117 1 : int ret = 0;
118 :
119 1 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
120 :
121 1 : ret = RsUbGetDevEidInfoNum(phyId, num);
122 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_get_dev_eid_info_num failed, phyId:%u, ret:%d", phyId, ret), ret);
123 :
124 1 : return ret;
125 : }
126 :
127 1 : RS_ATTRI_VISI_DEF int RsGetDevEidInfoList(unsigned int phyId, struct HccpDevEidInfo infoList[], unsigned int startIndex,
128 : unsigned int count)
129 : {
130 1 : int ret = 0;
131 :
132 1 : RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
133 :
134 1 : ret = RsUbGetDevEidInfoList(phyId, infoList, startIndex, count);
135 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_get_dev_eid_info_list failed, phyId:%u, ret:%d", phyId, ret), ret);
136 :
137 1 : return ret;
138 : }
139 :
140 1 : RS_ATTRI_VISI_DEF int RsCtxInit(struct CtxInitAttr *attr, unsigned int *devIndex, struct DevBaseAttr *devAttr)
141 : {
142 1 : struct rs_cb *rscb = NULL;
143 : unsigned int phyId;
144 1 : int ret = 0;
145 :
146 1 : RS_CHECK_POINTER_NULL_RETURN_INT(attr);
147 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devIndex);
148 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devAttr);
149 1 : phyId = attr->phyId;
150 1 : ret = RsGetRsCb(phyId, &rscb);
151 1 : CHK_PRT_RETURN(ret != 0, hccp_err("RsGetRsCb failed, ret:%d", ret), ret);
152 :
153 : #ifdef CUSTOM_INTERFACE
154 : // setup sharemem for pingmesh
155 1 : ret = RsSetupSharemem(rscb, false, phyId);
156 1 : CHK_PRT_RETURN(ret != 0, hccp_err("RsSetupSharemem failed, phyId:%u, ret:%d", phyId, ret), ret);
157 : #endif
158 :
159 1 : ret = RsUbCtxInit(rscb, attr, devIndex, devAttr);
160 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_init failed, devIndex:0x%x, ret:%d", *devIndex, ret), ret);
161 :
162 1 : return ret;
163 : }
164 :
165 0 : RS_ATTRI_VISI_DEF int RsCtxGetAsyncEvents(struct RaRsDevInfo *devInfo, struct AsyncEvent asyncEvents[],
166 : unsigned int *num)
167 : {
168 0 : struct RsUbDevCb *devCb = NULL;
169 0 : struct rs_cb *rscb = NULL;
170 0 : int ret = 0;
171 :
172 0 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
173 0 : RS_CHECK_POINTER_NULL_RETURN_INT(asyncEvents);
174 0 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
175 :
176 0 : CHK_PRT_RETURN(*num == 0, hccp_err("num can not be 0"), -EINVAL);
177 :
178 0 : ret = RsGetRsCb(devInfo->phyId, &rscb);
179 0 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
180 :
181 0 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
182 0 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
183 :
184 0 : RsUbCtxGetAsyncEvents(devCb, asyncEvents, num);
185 :
186 0 : return ret;
187 : }
188 :
189 1 : RS_ATTRI_VISI_DEF int RsCtxDeinit(struct RaRsDevInfo *devInfo)
190 : {
191 1 : struct RsUbDevCb *devCb = NULL;
192 1 : struct rs_cb *rscb = NULL;
193 1 : int ret = 0;
194 :
195 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
196 :
197 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
198 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
199 :
200 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
201 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb fail, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
202 :
203 1 : ret = RsUbCtxDeinit(devCb);
204 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs ub ctx deinit failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
205 :
206 1 : return ret;
207 : }
208 :
209 4 : RS_ATTRI_VISI_DEF int RsGetEidByIp(struct RaRsDevInfo *devInfo, struct IpInfo ip[], union HccpEid eid[],
210 : unsigned int *num)
211 : {
212 4 : struct RsUbDevCb *devCb = NULL;
213 4 : struct rs_cb *rscb = NULL;
214 4 : int ret = 0;
215 :
216 4 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
217 4 : RS_CHECK_POINTER_NULL_RETURN_INT(ip);
218 4 : RS_CHECK_POINTER_NULL_RETURN_INT(eid);
219 4 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
220 :
221 4 : ret = RsGetRsCb(devInfo->phyId, &rscb);
222 4 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
223 :
224 3 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
225 3 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
226 :
227 2 : ret = RsUbGetEidByIp(devCb, ip, eid, num);
228 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get_eid_by_ip failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
229 :
230 1 : return ret;
231 : }
232 :
233 4 : RS_ATTRI_VISI_DEF int RsGetIpByEid(struct RaRsDevInfo *devInfo, union HccpEid eid[], struct IpInfo ip[],
234 : unsigned int *num)
235 : {
236 4 : struct RsUbDevCb *devCb = NULL;
237 4 : struct rs_cb *rscb = NULL;
238 4 : int ret = 0;
239 :
240 4 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
241 4 : RS_CHECK_POINTER_NULL_RETURN_INT(eid);
242 4 : RS_CHECK_POINTER_NULL_RETURN_INT(ip);
243 4 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
244 :
245 4 : ret = RsGetRsCb(devInfo->phyId, &rscb);
246 4 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
247 :
248 3 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
249 3 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
250 :
251 2 : ret = RsUbGetIpByEid(devCb, eid, ip, num);
252 2 : CHK_PRT_RETURN(ret != 0, hccp_err("RsUbGetIpByEid failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
253 :
254 1 : return ret;
255 : }
256 :
257 2 : RS_ATTRI_VISI_DEF int RsGetTpInfoList(struct RaRsDevInfo *devInfo, struct GetTpCfg *cfg, struct HccpTpInfo infoList[],
258 : unsigned int *num)
259 : {
260 2 : struct RsUbDevCb *devCb = NULL;
261 2 : struct rs_cb *rscb = NULL;
262 2 : int ret = 0;
263 :
264 2 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
265 2 : RS_CHECK_POINTER_NULL_RETURN_INT(cfg);
266 2 : RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
267 2 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
268 :
269 2 : ret = RsGetRsCb(devInfo->phyId, &rscb);
270 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
271 :
272 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
273 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
274 1 : ret = RsUbGetTpInfoList(devCb, cfg, infoList, num);
275 :
276 1 : return ret;
277 : }
278 :
279 5 : RS_ATTRI_VISI_DEF int RsGetTpAttr(struct RaRsDevInfo *devInfo, unsigned int *attrBitmap, const uint64_t tpHandle,
280 : struct TpAttr *attr)
281 : {
282 5 : struct RsUbDevCb *devCb = NULL;
283 5 : struct rs_cb *rscb = NULL;
284 5 : int ret = 0;
285 :
286 5 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
287 4 : RS_CHECK_POINTER_NULL_RETURN_INT(attrBitmap);
288 3 : RS_CHECK_POINTER_NULL_RETURN_INT(attr);
289 :
290 2 : ret = RsGetRsCb(devInfo->phyId, &rscb);
291 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
292 :
293 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
294 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
295 1 : ret = RsUbGetTpAttr(devCb, attrBitmap, tpHandle, attr);
296 :
297 1 : return ret;
298 : }
299 :
300 4 : RS_ATTRI_VISI_DEF int RsSetTpAttr(struct RaRsDevInfo *devInfo, const unsigned int attrBitmap, const uint64_t tpHandle,
301 : struct TpAttr *attr)
302 : {
303 4 : struct RsUbDevCb *devCb = NULL;
304 4 : struct rs_cb *rscb = NULL;
305 4 : int ret = 0;
306 :
307 4 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
308 3 : RS_CHECK_POINTER_NULL_RETURN_INT(attr);
309 :
310 2 : ret = RsGetRsCb(devInfo->phyId, &rscb);
311 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
312 :
313 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
314 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
315 1 : ret = RsUbSetTpAttr(devCb, attrBitmap, tpHandle, attr);
316 :
317 1 : return ret;
318 : }
319 :
320 1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdAlloc(struct RaRsDevInfo *devInfo, unsigned long long *addr, unsigned int *tokenId)
321 : {
322 1 : struct RsUbDevCb *devCb = NULL;
323 1 : struct rs_cb *rscb = NULL;
324 : int ret;
325 :
326 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
327 1 : RS_CHECK_POINTER_NULL_RETURN_INT(addr);
328 1 : RS_CHECK_POINTER_NULL_RETURN_INT(tokenId);
329 :
330 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
331 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
332 :
333 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
334 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
335 :
336 1 : ret = RsUbCtxTokenIdAlloc(devCb, addr, tokenId);
337 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_alloc failed, ret:%d, devIndex:0x%x", ret, devInfo->devIndex),
338 : ret);
339 :
340 1 : return ret;
341 : }
342 :
343 1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdFree(struct RaRsDevInfo *devInfo, unsigned long long addr)
344 : {
345 1 : struct RsUbDevCb *devCb = NULL;
346 1 : struct rs_cb *rscb = NULL;
347 : int ret;
348 :
349 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
350 :
351 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
352 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
353 :
354 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
355 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
356 :
357 1 : ret = RsUbCtxTokenIdFree(devCb, addr);
358 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_free failed, ret:%d, devIndex:0x%x", ret, devInfo->devIndex),
359 : ret);
360 :
361 1 : return ret;
362 : }
363 :
364 1 : RS_ATTRI_VISI_DEF int RsCtxLmemReg(struct RaRsDevInfo *devInfo, struct MemRegAttrT *memAttr,
365 : struct MemRegInfoT *memInfo)
366 : {
367 1 : struct RsUbDevCb *devCb = NULL;
368 1 : struct rs_cb *rscb = NULL;
369 : int ret;
370 :
371 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
372 1 : RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
373 1 : RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
374 :
375 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
376 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
377 :
378 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
379 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
380 :
381 1 : ret = RsUbCtxLmemReg(devCb, memAttr, memInfo);
382 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_reg failed, ret:%d, devIndex:0x%x", ret, devInfo->devIndex), ret);
383 :
384 1 : return ret;
385 : }
386 :
387 1 : RS_ATTRI_VISI_DEF int RsCtxLmemUnreg(struct RaRsDevInfo *devInfo, unsigned long long addr)
388 : {
389 1 : struct RsUbDevCb *devCb = NULL;
390 1 : struct rs_cb *rscb = NULL;
391 : int ret;
392 :
393 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
394 :
395 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
396 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
397 :
398 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
399 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
400 :
401 1 : ret = RsUbCtxLmemUnreg(devCb, addr);
402 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_unreg failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
403 : ret);
404 :
405 1 : return ret;
406 : }
407 :
408 1 : RS_ATTRI_VISI_DEF int RsCtxRmemImport(struct RaRsDevInfo *devInfo, struct MemImportAttrT *memAttr,
409 : struct MemImportInfoT *memInfo)
410 : {
411 1 : struct RsUbDevCb *devCb = NULL;
412 1 : struct rs_cb *rscb = NULL;
413 : int ret;
414 :
415 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
416 1 : RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
417 1 : RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
418 :
419 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
420 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
421 :
422 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
423 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
424 :
425 1 : ret = RsUbCtxRmemImport(devCb, memAttr, memInfo);
426 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_import failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
427 : ret);
428 :
429 1 : return ret;
430 : }
431 :
432 1 : RS_ATTRI_VISI_DEF int RsCtxRmemUnimport(struct RaRsDevInfo *devInfo, unsigned long long addr)
433 : {
434 1 : struct RsUbDevCb *devCb = NULL;
435 1 : struct rs_cb *rscb = NULL;
436 : int ret;
437 :
438 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
439 :
440 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
441 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
442 :
443 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
444 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
445 :
446 1 : ret = RsUbCtxRmemUnimport(devCb, addr);
447 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_unimport failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
448 : ret);
449 :
450 1 : return ret;
451 : }
452 :
453 1 : RS_ATTRI_VISI_DEF int RsCtxChanCreate(struct RaRsDevInfo *devInfo, union DataPlaneCstmFlag dataPlaneFlag,
454 : unsigned long long *addr, int *fd)
455 : {
456 1 : struct RsUbDevCb *devCb = NULL;
457 1 : struct rs_cb *rscb = NULL;
458 : int ret;
459 :
460 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
461 1 : RS_CHECK_POINTER_NULL_RETURN_INT(addr);
462 :
463 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
464 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
465 :
466 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
467 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
468 :
469 1 : ret = RsUbCtxChanCreate(devCb, dataPlaneFlag, addr, fd);
470 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_create failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
471 : ret);
472 :
473 1 : return ret;
474 : }
475 :
476 1 : RS_ATTRI_VISI_DEF int RsCtxChanDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
477 : {
478 1 : struct RsUbDevCb *devCb = NULL;
479 1 : struct rs_cb *rscb = NULL;
480 : int ret;
481 :
482 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
483 :
484 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
485 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
486 :
487 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
488 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
489 :
490 1 : ret = RsUbCtxChanDestroy(devCb, addr);
491 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_destroy failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
492 : ret);
493 :
494 1 : return ret;
495 : }
496 :
497 1 : RS_ATTRI_VISI_DEF int RsCtxCqCreate(struct RaRsDevInfo *devInfo, struct CtxCqAttr *attr, struct CtxCqInfo *info)
498 : {
499 1 : struct RsUbDevCb *devCb = NULL;
500 1 : struct rs_cb *rscb = NULL;
501 : int ret;
502 :
503 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
504 1 : RS_CHECK_POINTER_NULL_RETURN_INT(attr);
505 1 : RS_CHECK_POINTER_NULL_RETURN_INT(info);
506 :
507 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
508 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
509 :
510 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
511 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
512 :
513 1 : ret = RsUbCtxJfcCreate(devCb, attr, info);
514 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_create failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
515 : ret);
516 :
517 1 : return ret;
518 : }
519 :
520 1 : RS_ATTRI_VISI_DEF int RsCtxCqDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
521 : {
522 1 : struct RsUbDevCb *devCb = NULL;
523 1 : struct rs_cb *rscb = NULL;
524 : int ret;
525 :
526 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
527 :
528 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
529 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
530 :
531 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
532 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
533 :
534 1 : ret = RsUbCtxJfcDestroy(devCb, addr);
535 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_destroy failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
536 : ret);
537 :
538 1 : return ret;
539 : }
540 :
541 1 : RS_ATTRI_VISI_DEF int RsCtxQpCreate(struct RaRsDevInfo *devInfo, struct CtxQpAttr *qpAttr, struct QpCreateInfo *qpInfo)
542 : {
543 1 : struct RsUbDevCb *devCb = NULL;
544 1 : struct rs_cb *rscb = NULL;
545 : int ret;
546 :
547 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
548 1 : RS_CHECK_POINTER_NULL_RETURN_INT(qpAttr);
549 1 : RS_CHECK_POINTER_NULL_RETURN_INT(qpInfo);
550 :
551 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
552 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
553 :
554 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
555 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
556 :
557 1 : ret = RsUbCtxJettyCreate(devCb, qpAttr, qpInfo);
558 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_create failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
559 : ret);
560 :
561 1 : return ret;
562 : }
563 :
564 1 : RS_ATTRI_VISI_DEF int RsCtxQpDestroy(struct RaRsDevInfo *devInfo, unsigned int id)
565 : {
566 1 : struct RsUbDevCb *devCb = NULL;
567 1 : struct rs_cb *rscb = NULL;
568 : int ret;
569 :
570 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
571 :
572 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
573 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
574 :
575 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
576 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
577 :
578 1 : ret = RsUbCtxJettyDestroy(devCb, id);
579 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_destroy failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
580 : ret);
581 :
582 1 : return ret;
583 : }
584 :
585 1 : RS_ATTRI_VISI_DEF int RsCtxQpImport(struct RaRsDevInfo *devInfo, struct RsJettyImportAttr *importAttr,
586 : struct RsJettyImportInfo *importInfo)
587 : {
588 1 : struct RsUbDevCb *devCb = NULL;
589 1 : struct rs_cb *rscb = NULL;
590 : int ret;
591 :
592 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
593 1 : RS_CHECK_POINTER_NULL_RETURN_INT(importAttr);
594 1 : RS_CHECK_POINTER_NULL_RETURN_INT(importInfo);
595 :
596 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
597 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
598 :
599 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
600 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
601 :
602 1 : ret = RsUbCtxJettyImport(devCb, importAttr, importInfo);
603 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_import failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
604 : ret);
605 :
606 1 : return ret;
607 : }
608 :
609 1 : RS_ATTRI_VISI_DEF int RsCtxQpUnimport(struct RaRsDevInfo *devInfo, unsigned char rawRemJettyId[], unsigned int size)
610 : {
611 1 : struct RsUbDevCb *devCb = NULL;
612 1 : struct rs_cb *rscb = NULL;
613 : int ret;
614 :
615 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
616 :
617 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
618 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
619 :
620 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
621 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
622 :
623 1 : ret = RsUbCtxJettyUnimport(devCb, rawRemJettyId, size);
624 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unimport failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
625 : ret);
626 :
627 1 : return ret;
628 : }
629 :
630 1 : RS_ATTRI_VISI_DEF int RsCtxQpBind(struct RaRsDevInfo *devInfo, struct RsCtxQpInfo *localQpInfo,
631 : struct RsCtxQpInfo *remoteQpInfo)
632 : {
633 1 : struct RsUbDevCb *devCb = NULL;
634 1 : struct rs_cb *rscb = NULL;
635 : int ret;
636 :
637 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
638 1 : RS_CHECK_POINTER_NULL_RETURN_INT(localQpInfo);
639 1 : RS_CHECK_POINTER_NULL_RETURN_INT(remoteQpInfo);
640 :
641 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
642 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
643 :
644 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
645 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
646 :
647 1 : ret = RsUbCtxJettyBind(devCb, localQpInfo, remoteQpInfo);
648 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_bind failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
649 : ret);
650 :
651 1 : return ret;
652 : }
653 :
654 1 : RS_ATTRI_VISI_DEF int RsCtxQpUnbind(struct RaRsDevInfo *devInfo, unsigned int qpId)
655 : {
656 1 : struct RsUbDevCb *devCb = NULL;
657 1 : struct rs_cb *rscb = NULL;
658 : int ret;
659 :
660 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
661 :
662 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
663 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
664 :
665 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
666 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
667 :
668 1 : ret = RsUbCtxJettyUnbind(devCb, qpId);
669 1 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unbind failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
670 : ret);
671 :
672 1 : return ret;
673 : }
674 :
675 1 : RS_ATTRI_VISI_DEF int RsCtxBatchSendWr(struct WrlistBaseInfo *baseInfo, struct BatchSendWrData *wrData,
676 : struct SendWrResp *wrResp, struct WrlistSendCompleteNum *wrlistNum)
677 : {
678 1 : struct rs_cb *rscb = NULL;
679 : int ret;
680 :
681 1 : RS_CHECK_POINTER_NULL_RETURN_INT(baseInfo);
682 1 : RS_CHECK_POINTER_NULL_RETURN_INT(wrData);
683 1 : RS_CHECK_POINTER_NULL_RETURN_INT(wrResp);
684 1 : RS_CHECK_POINTER_NULL_RETURN_INT(wrlistNum);
685 :
686 1 : ret = RsGetRsCb(baseInfo->phyId, &rscb);
687 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
688 :
689 1 : switch (rscb->protocol) {
690 1 : case PROTOCOL_UDMA:
691 1 : ret = RsUbCtxBatchSendWr(rscb, baseInfo, wrData, wrResp, wrlistNum);
692 1 : break;
693 0 : default:
694 0 : hccp_err("protocol[%d] not support", rscb->protocol);
695 0 : return -EINVAL;
696 : }
697 1 : return ret;
698 : }
699 :
700 1 : RS_ATTRI_VISI_DEF int RsCtxUpdateCi(struct RaRsDevInfo *devInfo, unsigned int qpId, uint16_t ci)
701 : {
702 1 : struct RsUbDevCb *devCb = NULL;
703 1 : struct rs_cb *rscb = NULL;
704 : int ret;
705 :
706 1 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
707 :
708 1 : ret = RsGetRsCb(devInfo->phyId, &rscb);
709 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
710 :
711 1 : switch (rscb->protocol) {
712 1 : case PROTOCOL_UDMA:
713 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
714 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
715 1 : ret = RsUbCtxJettyUpdateCi(devCb, qpId, ci);
716 1 : break;
717 0 : default:
718 0 : hccp_err("protocol[%d] not support", rscb->protocol);
719 0 : return -EINVAL;
720 : }
721 1 : return ret;
722 : }
723 :
724 5 : RS_ATTRI_VISI_DEF int RsCtxQpDestroyBatch(struct RaRsDevInfo *devInfo, unsigned int ids[], unsigned int *num)
725 : {
726 5 : struct RsUbDevCb *devCb = NULL;
727 5 : struct rs_cb *rscb = NULL;
728 : int ret;
729 :
730 5 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
731 4 : RS_CHECK_POINTER_NULL_RETURN_INT(ids);
732 3 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
733 :
734 2 : ret = RsGetRsCb(devInfo->phyId, &rscb);
735 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
736 :
737 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
738 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
739 1 : ret = RsUbCtxJettyDestroyBatch(devCb, ids, num);
740 :
741 1 : return ret;
742 : }
743 :
744 6 : RS_ATTRI_VISI_DEF int RsCtxQpQueryBatch(struct RaRsDevInfo *devInfo, unsigned int ids[], struct JettyAttr attr[],
745 : unsigned int *num)
746 : {
747 6 : struct RsUbDevCb *devCb = NULL;
748 6 : struct rs_cb *rscb = NULL;
749 : int ret;
750 :
751 6 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
752 5 : RS_CHECK_POINTER_NULL_RETURN_INT(ids);
753 4 : RS_CHECK_POINTER_NULL_RETURN_INT(attr);
754 3 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
755 :
756 2 : ret = RsGetRsCb(devInfo->phyId, &rscb);
757 2 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
758 :
759 1 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
760 1 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
761 1 : ret = RsUbCtxQueryJettyBatch(devCb, ids, attr, num);
762 :
763 1 : return ret;
764 : }
765 :
766 7 : RS_ATTRI_VISI_DEF int RsCtxGetAuxInfo(struct RaRsDevInfo *devInfo, struct HccpAuxInfoIn *infoIn,
767 : struct HccpAuxInfoOut *infoOut)
768 : {
769 7 : struct RsUbDevCb *devCb = NULL;
770 7 : struct rs_cb *rscb = NULL;
771 : int ret;
772 :
773 7 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
774 6 : RS_CHECK_POINTER_NULL_RETURN_INT(infoIn);
775 5 : RS_CHECK_POINTER_NULL_RETURN_INT(infoOut);
776 :
777 4 : ret = RsGetRsCb(devInfo->phyId, &rscb);
778 4 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
779 :
780 3 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
781 3 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
782 :
783 2 : ret = RsUbCtxGetAuxInfo(devCb, infoIn, infoOut);
784 2 : CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_get_aux_info failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
785 : ret);
786 :
787 1 : return ret;
788 : }
789 :
790 7 : RS_ATTRI_VISI_DEF int RsCtxGetCrErrInfoList(struct RaRsDevInfo *devInfo, struct CrErrInfo infoList[], unsigned int *num)
791 : {
792 7 : struct RsCtxJettyCb *jettyCbCurr = NULL;
793 7 : struct RsCtxJettyCb *jettyCbNext = NULL;
794 7 : struct RsUbDevCb *devCb = NULL;
795 7 : unsigned int crErrIdx = 0;
796 7 : struct rs_cb *rscb = NULL;
797 7 : unsigned int numTmp = 0;
798 7 : int ret = 0;
799 :
800 7 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
801 6 : RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
802 5 : RS_CHECK_POINTER_NULL_RETURN_INT(num);
803 :
804 4 : ret = RsGetRsCb(devInfo->phyId, &rscb);
805 4 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
806 :
807 3 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
808 3 : CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
809 :
810 2 : if (RsListEmpty(&devCb->jettyList)) {
811 1 : *num = 0;
812 1 : return ret;
813 : }
814 :
815 1 : numTmp = *num;
816 1 : RS_LIST_GET_HEAD_ENTRY(jettyCbCurr, jettyCbNext, &devCb->jettyList, list, struct RsCtxJettyCb);
817 2 : for (; (&jettyCbCurr->list) != &devCb->jettyList;
818 1 : jettyCbCurr = jettyCbNext, jettyCbNext = list_entry(jettyCbNext->list.next, struct RsCtxJettyCb, list)) {
819 1 : if (jettyCbCurr->crErrInfo.info.status != 0) {
820 1 : RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->crErrInfo.mutex);
821 1 : infoList[crErrIdx].status = jettyCbCurr->crErrInfo.info.status;
822 1 : infoList[crErrIdx].jettyId = jettyCbCurr->crErrInfo.info.jettyId;
823 1 : infoList[crErrIdx].time = jettyCbCurr->crErrInfo.info.time;
824 1 : jettyCbCurr->crErrInfo.info.status = 0;
825 1 : RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->crErrInfo.mutex);
826 1 : RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
827 1 : jettyCbCurr->devCb->cqeErrCnt--;
828 1 : RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
829 1 : crErrIdx++;
830 1 : if (crErrIdx == numTmp) {
831 0 : break;
832 : }
833 : }
834 : }
835 :
836 1 : *num = crErrIdx;
837 1 : return ret;
838 : }
839 :
840 0 : RS_ATTRI_VISI_DEF int RsCtxGetUbContext(struct RaRsDevInfo *devInfo, unsigned int id, unsigned int contextType,
841 : uint8_t context[], unsigned int *len)
842 : {
843 0 : struct RsUbDevCb *devCb = NULL;
844 0 : struct rs_cb *rscb = NULL;
845 0 : int ret = 0;
846 :
847 0 : RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
848 0 : RS_CHECK_POINTER_NULL_RETURN_INT(context);
849 0 : RS_CHECK_POINTER_NULL_RETURN_INT(len);
850 0 : CHK_PRT_RETURN(*len < CONTEXT_MAX_LEN, hccp_err("len:%u less than %u", *len, CONTEXT_MAX_LEN), -EINVAL);
851 :
852 0 : ret = RsGetRsCb(devInfo->phyId, &rscb);
853 0 : CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
854 :
855 0 : ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
856 0 : CHK_PRT_RETURN(ret != 0, hccp_err("get devCb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
857 :
858 0 : if (contextType == CONTEXT_TYPE_JETTY) {
859 0 : ret = RsUbGetJettyContext(devCb, id, context, len);
860 : } else {
861 0 : hccp_err("invalid contextType:%u, devIndex:0x%x", contextType, devInfo->devIndex);
862 0 : ret = -EINVAL;
863 : }
864 :
865 0 : return ret;
866 : }
|