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