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 "user_log.h"
13 : #include "hccp_ctx.h"
14 : #include "ra_hdc_ctx.h"
15 : #include "ra_hdc_async_ctx.h"
16 : #include "ra_rs_ctx.h"
17 : #include "ra_rs_comm.h"
18 : #include "rs_ctx.h"
19 : #include "ra_adp.h"
20 : #include "ra_adp_ctx.h"
21 :
22 : struct RsCtxOps gRaRsCtxOps = {
23 : .getDevEidInfoNum = RsGetDevEidInfoNum,
24 : .getDevEidInfoList = RsGetDevEidInfoList,
25 : .ctxInit = RsCtxInit,
26 : .ctxGetAsyncEvents = RsCtxGetAsyncEvents,
27 : .ctxDeinit = RsCtxDeinit,
28 : .getEidByIp = RsGetEidByIp,
29 : .getIpByEid = RsGetIpByEid,
30 : .getTpInfoList = RsGetTpInfoList,
31 : .getTpAttr = RsGetTpAttr,
32 : .setTpAttr = RsSetTpAttr,
33 : .ctxTokenIdAlloc = RsCtxTokenIdAlloc,
34 : .ctxTokenIdFree = RsCtxTokenIdFree,
35 : .ctxLmemReg = RsCtxLmemReg,
36 : .ctxLmemUnreg = RsCtxLmemUnreg,
37 : .ctxRmemImport = RsCtxRmemImport,
38 : .ctxRmemUnimport = RsCtxRmemUnimport,
39 : .ctxChanCreate = RsCtxChanCreate,
40 : .ctxChanDestroy = RsCtxChanDestroy,
41 : .ctxCqCreate = RsCtxCqCreate,
42 : .ctxCqDestroy = RsCtxCqDestroy,
43 : .ctxQpCreate = RsCtxQpCreate,
44 : .ctxQpQueryBatch = RsCtxQpQueryBatch,
45 : .ctxQpDestroy = RsCtxQpDestroy,
46 : .ctxQpDestroyBatch = RsCtxQpDestroyBatch,
47 : .ctxQpImport = RsCtxQpImport,
48 : .ctxQpUnimport = RsCtxQpUnimport,
49 : .ctxQpBind = RsCtxQpBind,
50 : .ctxQpUnbind = RsCtxQpUnbind,
51 : .ctxBatchSendWr = RsCtxBatchSendWr,
52 : .ctxUpdateCi = RsCtxUpdateCi,
53 : .ctxGetAuxInfo = RsCtxGetAuxInfo,
54 : .ctxGetCrErrInfoList = RsCtxGetCrErrInfoList,
55 : .ctxGetUbContext = RsCtxGetUbContext,
56 : };
57 :
58 1 : int RaRsGetDevEidInfoNum(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
59 : {
60 1 : union OpGetDevEidInfoNumData *opData = (union OpGetDevEidInfoNumData *)(inBuf +
61 : sizeof(struct MsgHead));
62 1 : unsigned int num = 0;
63 :
64 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetDevEidInfoNumData), sizeof(struct MsgHead), rcvBufLen,
65 : opResult);
66 :
67 1 : *opResult = gRaRsCtxOps.getDevEidInfoNum(opData->txData.phyId, &num);
68 1 : CHK_PRT_RETURN(*opResult != 0, hccp_err("[get][eid]get_dev_eid_info_num failed, ret[%d].", *opResult), 0);
69 :
70 1 : opData = (union OpGetDevEidInfoNumData *)(outBuf + sizeof(struct MsgHead));
71 1 : opData->rxData.num = num;
72 1 : return 0;
73 : }
74 :
75 1 : int RaRsGetDevEidInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
76 : {
77 1 : union OpGetDevEidInfoListData *opData = (union OpGetDevEidInfoListData *)(inBuf +
78 : sizeof(struct MsgHead));
79 1 : struct HccpDevEidInfo infoList[MAX_DEV_INFO_TRANS_NUM] = {0};
80 :
81 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetDevEidInfoListData), sizeof(struct MsgHead), rcvBufLen,
82 : opResult);
83 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.count, 0, MAX_DEV_INFO_TRANS_NUM, opResult);
84 :
85 1 : *opResult = gRaRsCtxOps.getDevEidInfoList(opData->txData.phyId, infoList,
86 : opData->txData.startIndex, opData->txData.count);
87 1 : CHK_PRT_RETURN(*opResult != 0, hccp_err("[get][eid]get_dev_eid_info_list failed, ret[%d].", *opResult), 0);
88 :
89 1 : opData = (union OpGetDevEidInfoListData *)(outBuf + sizeof(struct MsgHead));
90 1 : (void)memcpy_s(opData->rxData.infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM,
91 : infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM);
92 1 : return 0;
93 : }
94 :
95 1 : int RaRsCtxInit(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
96 : {
97 1 : union OpCtxInitData *opDataOut = (union OpCtxInitData *)(outBuf + sizeof(struct MsgHead));
98 1 : union OpCtxInitData *opData = (union OpCtxInitData *)(inBuf + sizeof(struct MsgHead));
99 :
100 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxInitData), sizeof(struct MsgHead), rcvBufLen, opResult);
101 :
102 1 : *opResult = gRaRsCtxOps.ctxInit(&opData->txData.attr, &opDataOut->rxData.devIndex,
103 : &opDataOut->rxData.devAttr);
104 1 : if (*opResult != 0) {
105 0 : hccp_err("[init][ra_rs_ctx]init failed, ret[%d]", *opResult);
106 : }
107 :
108 1 : return 0;
109 : }
110 :
111 0 : int RaRsCtxGetAsyncEvents(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
112 : {
113 0 : union OpCtxGetAsyncEventsData *opDataOut =
114 : (union OpCtxGetAsyncEventsData *)(outBuf + sizeof(struct MsgHead));
115 0 : union OpCtxGetAsyncEventsData *opData =
116 : (union OpCtxGetAsyncEventsData *)(inBuf + sizeof(struct MsgHead));
117 0 : struct RaRsDevInfo devInfo = {0};
118 :
119 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetAsyncEventsData), sizeof(struct MsgHead), rcvBufLen,
120 : opResult);
121 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, ASYNC_EVENT_MAX_NUM, opResult);
122 :
123 0 : opDataOut->rxData.num = opData->txData.num;
124 0 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
125 0 : *opResult = gRaRsCtxOps.ctxGetAsyncEvents(&devInfo, opDataOut->rxData.events,
126 : &opDataOut->rxData.num);
127 0 : if (*opResult != 0) {
128 0 : hccp_err("[get][async_events]ctx_get_async_events failed, ret[%d] phyId[%u] devIndex[0x%x]",
129 : *opResult, devInfo.phyId, devInfo.devIndex);
130 : }
131 :
132 0 : return 0;
133 : }
134 :
135 1 : int RaRsCtxDeinit(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
136 : {
137 1 : union OpCtxDeinitData *opData = (union OpCtxDeinitData *)(inBuf + sizeof(struct MsgHead));
138 1 : struct RaRsDevInfo devInfo = {0};
139 :
140 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxDeinitData), sizeof(struct MsgHead), rcvBufLen, opResult);
141 :
142 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
143 1 : *opResult = gRaRsCtxOps.ctxDeinit(&devInfo);
144 1 : if (*opResult != 0) {
145 0 : hccp_err("[deinit][ra_rs_ctx]deinit failed, ret[%d] phyId[%u] devIndex[0x%x]",
146 : *opResult, devInfo.phyId, devInfo.devIndex);
147 : }
148 :
149 1 : return 0;
150 : }
151 :
152 3 : int RaRsGetEidByIp(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
153 : {
154 3 : union OpGetEidByIpData *opDataOut = (union OpGetEidByIpData *)(outBuf + sizeof(struct MsgHead));
155 3 : union OpGetEidByIpData *opData = (union OpGetEidByIpData *)(inBuf + sizeof(struct MsgHead));
156 3 : struct RaRsDevInfo devInfo = {0};
157 :
158 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetEidByIpData), sizeof(struct MsgHead), rcvBufLen, opResult);
159 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_EID_IP_QUERY_MAX_NUM, opResult);
160 :
161 3 : opDataOut->rxData.num = opData->txData.num;
162 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
163 3 : *opResult = gRaRsCtxOps.getEidByIp(&devInfo, opData->txData.ip, opDataOut->rxData.eid,
164 : &opDataOut->rxData.num);
165 3 : if (*opResult != 0) {
166 1 : hccp_err("[get][eid_by_ip]get_eid_by_ip failed, ret[%d], phyId[%u]", *opResult,
167 : opData->txData.phyId);
168 : }
169 :
170 3 : return 0;
171 : }
172 :
173 3 : int RaRsGetIpByEid(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
174 : {
175 3 : union OpGetIpByEidData *opDataOut = (union OpGetIpByEidData *)(outBuf + sizeof(struct MsgHead));
176 3 : union OpGetIpByEidData *opData = (union OpGetIpByEidData *)(inBuf + sizeof(struct MsgHead));
177 3 : struct RaRsDevInfo devInfo = {0};
178 :
179 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetIpByEidData), sizeof(struct MsgHead), rcvBufLen, opResult);
180 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_EID_IP_QUERY_MAX_NUM, opResult);
181 :
182 3 : opDataOut->rxData.num = opData->txData.num;
183 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
184 3 : *opResult = gRaRsCtxOps.getIpByEid(&devInfo, opData->txData.eid, opDataOut->rxData.ip,
185 : &opDataOut->rxData.num);
186 3 : if (*opResult != 0) {
187 1 : hccp_err("[get][IpByEid]getIpByEid failed, ret[%d], phyId[%u]", *opResult,
188 : opData->txData.phyId);
189 : }
190 :
191 3 : return 0;
192 : }
193 :
194 3 : int RaRsGetTpInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
195 : {
196 3 : union OpGetTpInfoListData *opDataOut = (union OpGetTpInfoListData *)(outBuf + sizeof(struct MsgHead));
197 3 : union OpGetTpInfoListData *opData = (union OpGetTpInfoListData *)(inBuf + sizeof(struct MsgHead));
198 3 : struct RaRsDevInfo devInfo = {0};
199 :
200 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetTpInfoListData), sizeof(struct MsgHead), rcvBufLen,
201 : opResult);
202 :
203 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_TPID_INFO_NUM, opResult);
204 3 : opDataOut->rxData.num = opData->txData.num;
205 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
206 3 : *opResult = gRaRsCtxOps.getTpInfoList(&devInfo, &opData->txData.cfg, opDataOut->rxData.infoList,
207 : &opDataOut->rxData.num);
208 3 : if (*opResult != 0) {
209 1 : hccp_err("[get][ra_rs_ctx]get_tp_info_list failed, ret[%d] phyId[%u] devIndex[0x%x]",
210 : *opResult, devInfo.phyId, devInfo.devIndex);
211 : }
212 :
213 3 : return 0;
214 : }
215 :
216 1 : int RaRsGetTpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
217 : {
218 1 : union OpGetTpAttrData *opDataOut = (union OpGetTpAttrData *)(outBuf + sizeof(struct MsgHead));
219 1 : union OpGetTpAttrData *opData = (union OpGetTpAttrData *)(inBuf + sizeof(struct MsgHead));
220 1 : struct RaRsDevInfo devInfo = {0};
221 :
222 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetTpAttrData), sizeof(struct MsgHead), rcvBufLen,
223 : opResult);
224 :
225 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
226 1 : opDataOut->rxData.attrBitmap = opData->txData.attrBitmap;
227 1 : *opResult = gRaRsCtxOps.getTpAttr(&devInfo, &opDataOut->rxData.attrBitmap,
228 : opData->txData.tpHandle, &opDataOut->rxData.attr);
229 1 : if (*opResult != 0) {
230 0 : hccp_err("[get_tp_attr][ra_rs_ctx]get attr failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
231 : }
232 :
233 1 : return 0;
234 : }
235 :
236 1 : int RaRsSetTpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
237 : {
238 1 : union OpSetTpAttrData *opData = (union OpSetTpAttrData *)(inBuf + sizeof(struct MsgHead));
239 1 : struct RaRsDevInfo devInfo = {0};
240 :
241 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpSetTpAttrData), sizeof(struct MsgHead), rcvBufLen,
242 : opResult);
243 :
244 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
245 1 : *opResult = gRaRsCtxOps.setTpAttr(&devInfo, opData->txData.attrBitmap,
246 : opData->txData.tpHandle, &opData->txData.attr);
247 1 : if (*opResult != 0) {
248 0 : hccp_err("[set_tp_attr][ra_rs_ctx]set attr failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
249 : }
250 :
251 1 : return 0;
252 : }
253 :
254 1 : int RaRsCtxTokenIdAlloc(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
255 : {
256 1 : union OpTokenIdAllocData *opDataOut = (union OpTokenIdAllocData *)(outBuf + sizeof(struct MsgHead));
257 1 : union OpTokenIdAllocData *opData = (union OpTokenIdAllocData *)(inBuf + sizeof(struct MsgHead));
258 1 : struct RaRsDevInfo devInfo = {0};
259 :
260 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTokenIdAllocData), sizeof(struct MsgHead), rcvBufLen,
261 : opResult);
262 :
263 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
264 1 : *opResult = gRaRsCtxOps.ctxTokenIdAlloc(&devInfo, &opDataOut->rxData.addr,
265 : &opDataOut->rxData.tokenId);
266 1 : if (*opResult != 0) {
267 0 : hccp_err("[init][ra_rs_token_id]alloc failed, ret[%d] phyId[%u] devIndex[0x%x]",
268 : *opResult, devInfo.phyId, devInfo.devIndex);
269 : }
270 1 : return 0;
271 : }
272 :
273 1 : int RaRsCtxTokenIdFree(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
274 : {
275 1 : union OpTokenIdFreeData *opData = (union OpTokenIdFreeData *)(inBuf + sizeof(struct MsgHead));
276 1 : struct RaRsDevInfo devInfo = {0};
277 :
278 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTokenIdFreeData), sizeof(struct MsgHead), rcvBufLen,
279 : opResult);
280 :
281 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
282 1 : *opResult = gRaRsCtxOps.ctxTokenIdFree(&devInfo, opData->txData.addr);
283 1 : if (*opResult != 0) {
284 0 : hccp_err("[deinit][ra_rs_token_id]free failed, ret[%d] phyId[%u] devIndex[0x%x]",
285 : *opResult, devInfo.phyId, devInfo.devIndex);
286 : }
287 1 : return 0;
288 : }
289 :
290 1 : int RaRsLmemReg(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
291 : {
292 1 : union OpLmemRegInfoData *opDataOut = (union OpLmemRegInfoData *)(outBuf + sizeof(struct MsgHead));
293 1 : union OpLmemRegInfoData *opData = (union OpLmemRegInfoData *)(inBuf + sizeof(struct MsgHead));
294 1 : struct RaRsDevInfo devInfo = {0};
295 :
296 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpLmemRegInfoData), sizeof(struct MsgHead), rcvBufLen, opResult);
297 :
298 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
299 1 : *opResult = gRaRsCtxOps.ctxLmemReg(&devInfo, &opData->txData.memAttr, &opDataOut->rxData.memInfo);
300 1 : if (*opResult != 0) {
301 0 : hccp_err("[init][ra_rs_lmem]reg failed, ret[%d] phyId[%u] devIndex[0x%x]",
302 : *opResult, devInfo.phyId, devInfo.devIndex);
303 : }
304 :
305 1 : return 0;
306 : }
307 :
308 1 : int RaRsLmemUnreg(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
309 : {
310 1 : union OpLmemUnregInfoData *opData = (union OpLmemUnregInfoData *)(inBuf + sizeof(struct MsgHead));
311 1 : struct RaRsDevInfo devInfo = {0};
312 :
313 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpLmemUnregInfoData), sizeof(struct MsgHead), rcvBufLen,
314 : opResult);
315 :
316 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
317 1 : *opResult = gRaRsCtxOps.ctxLmemUnreg(&devInfo, opData->txData.addr);
318 1 : if (*opResult != 0) {
319 0 : hccp_err("[deinit][ra_rs_lmem]unreg failed, ret[%d] phyId[%u] devIndex[0x%x]",
320 : *opResult, devInfo.phyId, devInfo.devIndex);
321 : }
322 :
323 1 : return 0;
324 : }
325 :
326 1 : int RaRsRmemImport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
327 : {
328 1 : union OpRmemImportInfoData *opDataOut = (union OpRmemImportInfoData *)(outBuf + sizeof(struct MsgHead));
329 1 : union OpRmemImportInfoData *opData = (union OpRmemImportInfoData *)(inBuf + sizeof(struct MsgHead));
330 1 : struct RaRsDevInfo devInfo = {0};
331 :
332 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpRmemImportInfoData), sizeof(struct MsgHead), rcvBufLen,
333 : opResult);
334 :
335 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
336 1 : *opResult = gRaRsCtxOps.ctxRmemImport(&devInfo, &opData->txData.memAttr, &opDataOut->rxData.memInfo);
337 1 : if (*opResult != 0) {
338 0 : hccp_err("[init][ra_rs_rmem]import failed, ret[%d] phyId[%u] devIndex[0x%x]",
339 : *opResult, devInfo.phyId, devInfo.devIndex);
340 : }
341 :
342 1 : return 0;
343 : }
344 :
345 1 : int RaRsRmemUnimport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
346 : {
347 1 : union OpRmemUnimportInfoData *opData = (union OpRmemUnimportInfoData *)(inBuf + sizeof(struct MsgHead));
348 1 : struct RaRsDevInfo devInfo = {0};
349 :
350 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpRmemUnimportInfoData), sizeof(struct MsgHead), rcvBufLen,
351 : opResult);
352 :
353 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
354 1 : *opResult = gRaRsCtxOps.ctxRmemUnimport(&devInfo, opData->txData.addr);
355 1 : if (*opResult != 0) {
356 0 : hccp_err("[deinit][ra_rs_rmem]unimport failed, ret[%d] phyId[%u] devIndex[0x%x]",
357 : *opResult, devInfo.phyId, devInfo.devIndex);
358 : }
359 :
360 1 : return 0;
361 : }
362 :
363 1 : int RaRsCtxChanCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
364 : {
365 1 : union OpCtxChanCreateData *opDataOut = (union OpCtxChanCreateData *)(outBuf + sizeof(struct MsgHead));
366 1 : union OpCtxChanCreateData *opData = (union OpCtxChanCreateData *)(inBuf + sizeof(struct MsgHead));
367 1 : struct RaRsDevInfo devInfo = {0};
368 :
369 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxChanCreateData), sizeof(struct MsgHead), rcvBufLen,
370 : opResult);
371 :
372 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
373 1 : *opResult = gRaRsCtxOps.ctxChanCreate(&devInfo, opData->txData.dataPlaneFlag,
374 : &opDataOut->rxData.addr, &opDataOut->rxData.fd);
375 1 : if (*opResult != 0) {
376 0 : hccp_err("[init][ra_rs_chan]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
377 : *opResult, devInfo.phyId, devInfo.devIndex);
378 : }
379 :
380 1 : return 0;
381 : }
382 :
383 1 : int RaRsCtxChanDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
384 : {
385 1 : union OpCtxChanDestroyData *opData = (union OpCtxChanDestroyData *)(inBuf + sizeof(struct MsgHead));
386 1 : struct RaRsDevInfo devInfo = {0};
387 :
388 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxChanDestroyData), sizeof(struct MsgHead), rcvBufLen, opResult);
389 :
390 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
391 1 : *opResult = gRaRsCtxOps.ctxChanDestroy(&devInfo, opData->txData.addr);
392 1 : if (*opResult != 0) {
393 0 : hccp_err("[deinit][ra_rs_chan]destroy failed, ret[%d] phyId[%u] devIndex[0x%x]",
394 : *opResult, devInfo.phyId, devInfo.devIndex);
395 : }
396 :
397 1 : return 0;
398 : }
399 :
400 1 : int RaRsCtxCqCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
401 : {
402 1 : union OpCtxCqCreateData *opDataOut = (union OpCtxCqCreateData *)(outBuf + sizeof(struct MsgHead));
403 1 : union OpCtxCqCreateData *opData = (union OpCtxCqCreateData *)(inBuf + sizeof(struct MsgHead));
404 1 : struct RaRsDevInfo devInfo = {0};
405 :
406 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxCqCreateData), sizeof(struct MsgHead), rcvBufLen, opResult);
407 :
408 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
409 1 : *opResult = gRaRsCtxOps.ctxCqCreate(&devInfo, &opData->txData.attr, &opDataOut->rxData.info);
410 1 : if (*opResult != 0) {
411 0 : hccp_err("[init][ra_rs_cq]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
412 : *opResult, devInfo.phyId, devInfo.devIndex);
413 : }
414 :
415 1 : return 0;
416 : }
417 :
418 1 : int RaRsCtxCqDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
419 : {
420 1 : union OpCtxCqDestroyData *opData = (union OpCtxCqDestroyData *)(inBuf + sizeof(struct MsgHead));
421 1 : struct RaRsDevInfo devInfo = {0};
422 :
423 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxCqDestroyData), sizeof(struct MsgHead), rcvBufLen,
424 : opResult);
425 :
426 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
427 1 : *opResult = gRaRsCtxOps.ctxCqDestroy(&devInfo, opData->txData.addr);
428 1 : if (*opResult != 0) {
429 0 : hccp_err("[deinit][ra_rs_cq]destroy failed, ret[%d] phyId[%u] devIndex[0x%x]",
430 : *opResult, devInfo.phyId, devInfo.devIndex);
431 : }
432 :
433 1 : return 0;
434 : }
435 :
436 1 : int RaRsCtxQpCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
437 : {
438 1 : union OpCtxQpCreateData *opDataOut = (union OpCtxQpCreateData *)(outBuf + sizeof(struct MsgHead));
439 1 : union OpCtxQpCreateData *opData = (union OpCtxQpCreateData *)(inBuf + sizeof(struct MsgHead));
440 1 : struct RaRsDevInfo devInfo = {0};
441 :
442 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpCreateData), sizeof(struct MsgHead), rcvBufLen, opResult);
443 :
444 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
445 1 : *opResult = gRaRsCtxOps.ctxQpCreate(&devInfo, &opData->txData.qpAttr, &opDataOut->rxData.qpInfo);
446 1 : if (*opResult != 0) {
447 0 : hccp_err("[init][ra_rs_qp]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
448 : *opResult, devInfo.phyId, devInfo.devIndex);
449 : }
450 :
451 1 : return 0;
452 : }
453 :
454 3 : int RaRsCtxQpQueryBatch(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
455 : {
456 3 : union OpCtxQpQueryBatchData *opData = (union OpCtxQpQueryBatchData *)(inBuf + sizeof(struct MsgHead));
457 3 : union OpCtxQpQueryBatchData *opDataOut = (union OpCtxQpQueryBatchData *)(outBuf +
458 : sizeof(struct MsgHead));
459 3 : struct RaRsDevInfo devInfo = {0};
460 :
461 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpQueryBatchData), sizeof(struct MsgHead), rcvBufLen,
462 : opResult);
463 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_QP_QUERY_NUM, opResult);
464 :
465 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
466 3 : opDataOut->rxData.num = opData->txData.num;
467 3 : *opResult = gRaRsCtxOps.ctxQpQueryBatch(&devInfo, opData->txData.ids, opDataOut->rxData.attr,
468 : &opDataOut->rxData.num);
469 3 : if (*opResult != 0) {
470 1 : hccp_err("[qp_batch][ra_rs_ctx]query failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
471 : }
472 :
473 3 : return 0;
474 : }
475 :
476 1 : int RaRsCtxQpDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
477 : {
478 1 : union OpCtxQpDestroyData *opData = (union OpCtxQpDestroyData *)(inBuf + sizeof(struct MsgHead));
479 1 : struct RaRsDevInfo devInfo = {0};
480 :
481 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpDestroyData), sizeof(struct MsgHead), rcvBufLen,
482 : opResult);
483 :
484 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
485 :
486 1 : *opResult = gRaRsCtxOps.ctxQpDestroy(&devInfo, opData->txData.id);
487 1 : CHK_PRT_RETURN(*opResult == -ENODEV, hccp_warn("[deinit][ra_rs_qp]jetty not found, ret[%d] phyId[%u] "
488 : "devIndex[0x%x] qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
489 1 : CHK_PRT_RETURN(*opResult != 0, hccp_err("[deinit][ra_rs_qp]destroy failed, ret[%d] phyId[%u] devIndex[0x%x] "
490 : "qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
491 1 : return 0;
492 : }
493 :
494 3 : int RaRsCtxQpDestroyBatch(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
495 : {
496 3 : union OpCtxQpDestroyBatchData *opDataOut = (union OpCtxQpDestroyBatchData *)(outBuf +
497 : sizeof(struct MsgHead));
498 3 : union OpCtxQpDestroyBatchData *opData = (union OpCtxQpDestroyBatchData *)(inBuf +
499 : sizeof(struct MsgHead));
500 3 : struct RaRsDevInfo devInfo = {0};
501 :
502 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpDestroyBatchData), sizeof(struct MsgHead), rcvBufLen,
503 : opResult);
504 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_QP_DESTROY_BATCH_NUM, opResult);
505 :
506 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
507 3 : opDataOut->rxData.num = opData->txData.num;
508 3 : *opResult = gRaRsCtxOps.ctxQpDestroyBatch(&devInfo, opData->txData.ids, &opDataOut->rxData.num);
509 3 : if (*opResult != 0) {
510 1 : hccp_err("[qp_batch][ra_rs_ctx]destroy failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
511 : }
512 :
513 3 : return 0;
514 : }
515 :
516 1 : int RaRsCtxQpImport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
517 : {
518 1 : union OpCtxQpImportData *opDataOut = (union OpCtxQpImportData *)(outBuf + sizeof(struct MsgHead));
519 1 : union OpCtxQpImportData *opData = (union OpCtxQpImportData *)(inBuf + sizeof(struct MsgHead));
520 1 : struct RsJettyImportAttr importAttr = {0};
521 1 : struct RsJettyImportInfo importInfo = {0};
522 1 : struct RaRsDevInfo devInfo = {0};
523 :
524 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpImportData), sizeof(struct MsgHead), rcvBufLen, opResult);
525 :
526 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
527 1 : importAttr.key = opData->txData.key;
528 1 : importAttr.attr = opData->txData.attr;
529 1 : *opResult = gRaRsCtxOps.ctxQpImport(&devInfo, &importAttr, &importInfo);
530 1 : if (*opResult != 0) {
531 0 : hccp_err("[init][ra_rs_qp]import failed, ret[%d] phyId[%u] devIndex[0x%x]",
532 : *opResult, devInfo.phyId, devInfo.devIndex);
533 : }
534 :
535 1 : opDataOut->rxData.remJettyId = importInfo.remJettyId;
536 1 : opDataOut->rxData.info = importInfo.info;
537 :
538 1 : return 0;
539 : }
540 :
541 1 : int RaRsCtxQpUnimport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
542 : {
543 1 : union OpCtxQpUnimportData *opData = (union OpCtxQpUnimportData *)(inBuf + sizeof(struct MsgHead));
544 1 : struct RaRsDevInfo devInfo = {0};
545 :
546 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpUnimportData), sizeof(struct MsgHead), rcvBufLen, opResult);
547 :
548 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
549 1 : *opResult = gRaRsCtxOps.ctxQpUnimport(&devInfo, opData->txData.rawRemJettyId, REM_JETTY_ID_SIZE);
550 1 : if (*opResult != 0) {
551 0 : hccp_err("unimport failed, ret[%d] phyId[%u] devIndex[0x%x]", *opResult, devInfo.phyId, devInfo.devIndex);
552 : }
553 :
554 1 : return 0;
555 : }
556 :
557 1 : int RaRsCtxQpUnimportDeprecated(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
558 : {
559 1 : union OpCtxQpUnimportData *opData = (union OpCtxQpUnimportData *)(inBuf + sizeof(struct MsgHead));
560 1 : struct RaRsDevInfo devInfo = {0};
561 :
562 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpUnimportData), sizeof(struct MsgHead), rcvBufLen, opResult);
563 :
564 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
565 1 : *opResult = gRaRsCtxOps.ctxQpUnimport(&devInfo, opData->txData.rawRemJettyId, REM_JETTY_ID_DEPRECATED_SIZE);
566 1 : if (*opResult != 0) {
567 0 : hccp_err("unimport failed, ret[%d] phyId[%u] devIndex[0x%x]", *opResult, devInfo.phyId, devInfo.devIndex);
568 : }
569 :
570 1 : return 0;
571 : }
572 :
573 1 : int RaRsCtxQpBind(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
574 : {
575 1 : union OpCtxQpBindData *opData = (union OpCtxQpBindData *)(inBuf + sizeof(struct MsgHead));
576 1 : struct RsCtxQpInfo remoteQpInfo = {0};
577 1 : struct RsCtxQpInfo localQpInfo = {0};
578 1 : struct RaRsDevInfo devInfo = {0};
579 :
580 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpBindData), sizeof(struct MsgHead), rcvBufLen, opResult);
581 :
582 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
583 1 : localQpInfo.id = opData->txData.id;
584 1 : localQpInfo.key = opData->txData.localQpKey;
585 1 : remoteQpInfo.id = opData->txData.remId;
586 1 : remoteQpInfo.key = opData->txData.remoteQpKey;
587 1 : *opResult = gRaRsCtxOps.ctxQpBind(&devInfo, &localQpInfo, &remoteQpInfo);
588 1 : if (*opResult != 0) {
589 0 : hccp_err("[init][ra_rs_qp]bind failed, ret[%d] phyId[%u] devIndex[0x%x] qpId[%u] rem_qp_id[%u]",
590 : *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id, opData->txData.remId);
591 : }
592 :
593 1 : return 0;
594 : }
595 :
596 1 : int RaRsCtxQpUnbind(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
597 : {
598 1 : union OpCtxQpUnbindData *opData = (union OpCtxQpUnbindData *)(inBuf + sizeof(struct MsgHead));
599 1 : struct RaRsDevInfo devInfo = {0};
600 :
601 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpUnbindData), sizeof(struct MsgHead), rcvBufLen, opResult);
602 :
603 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
604 :
605 1 : *opResult = gRaRsCtxOps.ctxQpUnbind(&devInfo, opData->txData.id);
606 1 : CHK_PRT_RETURN(*opResult == -ENODEV, hccp_warn("[deinit][ra_rs_qp]jetty not found, ret[%d] phyId[%u] "
607 : "devIndex[0x%x] qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
608 1 : CHK_PRT_RETURN(*opResult != 0, hccp_err("[deinit][ra_rs_qp]unbind failed, ret[%d] phyId[%u] devIndex[0x%x] "
609 : "qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
610 1 : return 0;
611 : }
612 :
613 1 : int RaRsCtxBatchSendWr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
614 : {
615 1 : union OpCtxBatchSendWrData *opData = (union OpCtxBatchSendWrData *)(inBuf + sizeof(struct MsgHead));
616 1 : union OpCtxBatchSendWrData *opDataOut = (union OpCtxBatchSendWrData *)(outBuf +
617 : sizeof(struct MsgHead));
618 1 : struct WrlistSendCompleteNum wrlistNum = {0};
619 :
620 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxBatchSendWrData), sizeof(struct MsgHead), rcvBufLen,
621 : opResult);
622 :
623 1 : wrlistNum.sendNum = opData->txData.sendNum;
624 1 : wrlistNum.completeNum = &opDataOut->rxData.completeNum;
625 2 : *opResult = gRaRsCtxOps.ctxBatchSendWr(&opData->txData.baseInfo, opData->txData.wrData,
626 1 : opDataOut->rxData.wrResp, &wrlistNum);
627 1 : if (*opResult != 0) {
628 0 : hccp_err("[send][ra_rs_ctx]batch send wr failed, ret[%d] qpId[%u] sendNum[%d] completeNum[%d]",
629 : *opResult, opData->txData.baseInfo.qpn, wrlistNum.sendNum, *wrlistNum.completeNum);
630 : }
631 :
632 1 : return 0;
633 : }
634 :
635 1 : int RaRsCtxUpdateCi(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
636 : {
637 1 : union OpCtxUpdateCiData *opData = (union OpCtxUpdateCiData *)(inBuf + sizeof(struct MsgHead));
638 1 : struct RaRsDevInfo devInfo = {0};
639 :
640 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxUpdateCiData), sizeof(struct MsgHead), rcvBufLen, opResult);
641 :
642 1 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
643 1 : *opResult = gRaRsCtxOps.ctxUpdateCi(&devInfo, opData->txData.jettyId, opData->txData.ci);
644 1 : if (*opResult != 0) {
645 0 : hccp_err("[update_ci][ra_rs_ctx]update ci failed, ret[%d] phyId[%u] devIndex[0x%x] qpId[%u]",
646 : *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.jettyId);
647 : }
648 :
649 1 : return 0;
650 : }
651 :
652 3 : int RaRsCtxGetAuxInfo(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
653 : {
654 3 : union OpCtxGetAuxInfoData *opDataOut = (union OpCtxGetAuxInfoData *)(outBuf + sizeof(struct MsgHead));
655 3 : union OpCtxGetAuxInfoData *opData = (union OpCtxGetAuxInfoData *)(inBuf + sizeof(struct MsgHead));
656 3 : struct RaRsDevInfo devInfo = {0};
657 :
658 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetAuxInfoData), sizeof(struct MsgHead), rcvBufLen,
659 : opResult);
660 :
661 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
662 3 : *opResult = gRaRsCtxOps.ctxGetAuxInfo(&devInfo, &opData->txData.info, &opDataOut->rxData.info);
663 3 : if (*opResult != 0) {
664 1 : hccp_err("[get_aux_info][ra_rs_ctx]get aux info failed, ret[%d] phyId[%u] devIndex[0x%x]", *opResult,
665 : devInfo.phyId, devInfo.devIndex);
666 : }
667 :
668 3 : return 0;
669 : }
670 :
671 3 : int RaRsCtxGetCrErrInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
672 : {
673 3 : union OpCtxGetCrErrInfoListData *opDataOut =
674 : (union OpCtxGetCrErrInfoListData *)(outBuf + sizeof(struct MsgHead));
675 3 : union OpCtxGetCrErrInfoListData *opData =
676 : (union OpCtxGetCrErrInfoListData *)(inBuf + sizeof(struct MsgHead));
677 3 : struct RaRsDevInfo devInfo = {0};
678 :
679 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetCrErrInfoListData), sizeof(struct MsgHead), rcvBufLen,
680 : opResult);
681 : HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, CR_ERR_INFO_MAX_NUM, opResult);
682 :
683 3 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
684 3 : opDataOut->rxData.num = opData->txData.num;
685 3 : *opResult = gRaRsCtxOps.ctxGetCrErrInfoList(&devInfo, opDataOut->rxData.infoList,
686 : &opDataOut->rxData.num);
687 3 : if (*opResult != 0) {
688 1 : hccp_err("[get][cr_err]ctx_get_cr_err_info_list failed, ret[%d], phyId[%u]", *opResult,
689 : opData->txData.phyId);
690 : }
691 :
692 3 : return 0;
693 : }
694 :
695 0 : int RaRsCtxGetUbContext(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
696 : {
697 0 : union OpCtxGetContextData *opDataOut =
698 : (union OpCtxGetContextData *)(outBuf + sizeof(struct MsgHead));
699 0 : union OpCtxGetContextData *opData =
700 : (union OpCtxGetContextData *)(inBuf + sizeof(struct MsgHead));
701 0 : struct RaRsDevInfo devInfo = {0};
702 :
703 : HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetContextData), sizeof(struct MsgHead), rcvBufLen,
704 : opResult);
705 :
706 0 : RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
707 0 : opDataOut->rxData.len = opData->txData.len;
708 0 : *opResult = gRaRsCtxOps.ctxGetUbContext(&devInfo, opData->txData.id, opData->txData.contextType, opDataOut->rxData.context,
709 : &opDataOut->rxData.len);
710 0 : if (*opResult != 0) {
711 0 : hccp_err("[get][jettyContext]ctxGetJettyContext failed, ret:%d, phyId:%u devIndex:0x%x", *opResult,
712 : devInfo.phyId, devInfo.devIndex);
713 : }
714 :
715 0 : return 0;
716 : }
|