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