Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 : #ifndef RS_NDA_H
12 : #define RS_NDA_H
13 :
14 : #include "ibv_extend.h"
15 : #include "hccp_nda.h"
16 : #include "rs_rdma_inner.h"
17 : #include "rs_list.h"
18 : #include "rs.h"
19 :
20 : struct RsNdaPcieCb {
21 : struct ibv_extend_ops ibvExOps;
22 : struct RsListHead ndaDbList;
23 : };
24 :
25 : struct RsNdaUbCb {
26 : struct ibv_extend_ops ibvExOps;
27 : struct RsListHead ndaDbList;
28 : uint16_t ndaDbGuidCnt;
29 : };
30 :
31 : struct RsNdaCb {
32 : struct NdaOps ndaOps;
33 : struct RsNdaPcieCb ndaPcieCb;
34 : struct RsNdaUbCb ndaUbCb;
35 : };
36 :
37 : struct NdaPcieDbCb {
38 : uint64_t hva;
39 : uint64_t dva;
40 : uint32_t refCnt;
41 : uint32_t resv;
42 :
43 : struct RsListHead list;
44 : };
45 :
46 : struct NdaUbDbCb {
47 : uint64_t guidL;
48 : uint64_t guidH;
49 : uint16_t guidIdx;
50 : uint16_t resv;
51 : uint32_t refCnt;
52 :
53 : struct RsListHead list;
54 : };
55 :
56 : union DbUbResInfo {
57 : struct {
58 : uint32_t dbIdx : 12;
59 : uint32_t guidIdx : 16;
60 : uint32_t resv : 4;
61 : };
62 : uint32_t resId;
63 : };
64 :
65 : struct NdaUbResMapPrivInfo {
66 : unsigned long long guid_l;
67 : unsigned long long guid_h;
68 : unsigned int db_idx;
69 : unsigned int db_num;
70 : unsigned int resv[8];
71 : };
72 :
73 7 : static inline unsigned int RsNdaGenerateResId(uint32_t dbIdx, uint16_t guidIdx)
74 : {
75 7 : union DbUbResInfo resInfo = {0};
76 :
77 7 : resInfo.dbIdx = dbIdx;
78 7 : resInfo.guidIdx = guidIdx;
79 7 : return resInfo.resId;
80 : }
81 :
82 8 : static inline uint64_t AlignDown(uint64_t val, uint64_t align)
83 : {
84 8 : return (val) & ~(align - 1);
85 : }
86 :
87 4 : static inline uint64_t AlignUp(uint64_t val, uint64_t align)
88 : {
89 4 : return (val + align - 1) & ~(align - 1);
90 : }
91 :
92 : int RsInitNdaCb(struct RsRdevCb *rdevCb);
93 : void RsDeinitNdaCb(struct RsRdevCb *rdevCb);
94 : RS_ATTRI_VISI_DEF int RsNdaGetDirectFlag(unsigned int phyId, unsigned int rdevIndex, int *directFlag);
95 : RS_ATTRI_VISI_DEF int RsNdaCqCreate(unsigned int phyId, unsigned int rdevIndex, struct NdaCqInitAttr *attr,
96 : struct NdaCqInfo *info, void **ibvCqExt);
97 : RS_ATTRI_VISI_DEF int RsNdaCqDestroy(unsigned int phyId, unsigned int rdevIndex, void *ibvCqExt);
98 : RS_ATTRI_VISI_DEF int RsNdaQpCreate(unsigned int phyId, unsigned int rdevIndex, struct NdaQpInitAttr *attr,
99 : struct NdaQpInfo *info, struct RsQpResp *qpResp);
100 : RS_ATTRI_VISI_DEF int RsNdaQpDestroy(unsigned int phyId, unsigned int rdevIndex, unsigned int qpn);
101 : RS_ATTRI_VISI_DEF int RsGetQpHyperFeature(unsigned int phyId, unsigned int rdevIndex, unsigned int qpn,
102 : struct HyperFeature *hyperFeature);
103 : #endif // RS_NDA_H
|