FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
rdma_mlx5dv.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2020 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #ifndef _RDMA_MLX5DV_H_
19 #define _RDMA_MLX5DV_H_
20 
21 #undef always_inline
22 #include <infiniband/mlx5dv.h>
23 #define always_inline static_always_inline
24 #include <vppinfra/types.h>
25 #include <vppinfra/error.h>
26 /* CQE flags - bits 16-31 of qword at offset 0x1c */
27 #define CQE_FLAG_L4_OK 10
28 #define CQE_FLAG_L3_OK 9
29 #define CQE_FLAG_L2_OK 8
30 #define CQE_FLAG_IP_FRAG 7
31 #define CQE_FLAG_L4_HDR_TYPE(f) (((f) >> 4) & 7)
32 #define CQE_FLAG_L3_HDR_TYPE_SHIFT (2)
33 #define CQE_FLAG_L3_HDR_TYPE_MASK (3 << CQE_FLAG_L3_HDR_TYPE_SHIFT)
34 #define CQE_FLAG_L3_HDR_TYPE(f) (((f) & CQE_FLAG_L3_HDR_TYPE_MASK) >> CQE_FLAG_L3_HDR_TYPE_SHIFT)
35 #define CQE_FLAG_L3_HDR_TYPE_IP4 1
36 #define CQE_FLAG_L3_HDR_TYPE_IP6 2
37 #define CQE_FLAG_IP_EXT_OPTS 1
38 
39 /* CQE byte count (Striding RQ) */
40 #define CQE_BC_FILLER_MASK (1 << 31)
41 #define CQE_BC_CONSUMED_STRIDES_SHIFT (16)
42 #define CQE_BC_CONSUMED_STRIDES_MASK (0x3fff << CQE_BC_CONSUMED_STRIDES_SHIFT)
43 #define CQE_BC_BYTE_COUNT_MASK (0xffff)
44 typedef struct
45 {
46  struct
47  {
48  u8 pad1[28];
50  u8 pad2[14];
51  union
52  {
55  };
56  u8 pad3[12];
60  };
61 } mlx5dv_cqe_t;
62 
64 
65 typedef struct
66 {
67  union
68  {
71  };
74 
75 typedef struct
76 {
79 } mlx5dv_wqe_ds_t; /* a WQE data segment */
80 
81 typedef struct
82 {
83  u8 rsvd0[2];
86  u8 rsvd1[11];
88 
89 #define foreach_cqe_rx_field \
90  _(0x1c, 26, 26, l4_ok) \
91  _(0x1c, 25, 25, l3_ok) \
92  _(0x1c, 24, 24, l2_ok) \
93  _(0x1c, 23, 23, ip_frag) \
94  _(0x1c, 22, 20, l4_hdr_type) \
95  _(0x1c, 19, 18, l3_hdr_type) \
96  _(0x1c, 17, 17, ip_ext_opts) \
97  _(0x1c, 16, 16, cv) \
98  _(0x2c, 31, 0, byte_cnt) \
99  _(0x30, 63, 0, timestamp) \
100  _(0x38, 31, 24, rx_drop_counter) \
101  _(0x38, 23, 0, flow_tag) \
102  _(0x3c, 31, 16, wqe_counter) \
103  _(0x3c, 15, 8, signature) \
104  _(0x3c, 7, 4, opcode) \
105  _(0x3c, 3, 2, cqe_format) \
106  _(0x3c, 1, 1, sc) \
107  _(0x3c, 0, 0, owner)
108 
109 
110 /* inline functions */
111 
112 static inline u32
113 mlx5_get_u32 (void *start, int offset)
114 {
115  return clib_net_to_host_u32 (*(u32 *) (((u8 *) start) + offset));
116 }
117 
118 static inline u64
119 mlx5_get_u64 (void *start, int offset)
120 {
121  return clib_net_to_host_u64 (*(u64 *) (((u8 *) start) + offset));
122 }
123 
124 static inline void
125 mlx5_set_u32 (void *start, int offset, u32 value)
126 {
127  (*(u32 *) (((u8 *) start) + offset)) = clib_host_to_net_u32 (value);
128 }
129 
130 static inline void
131 mlx5_set_u64 (void *start, int offset, u64 value)
132 {
133  (*(u64 *) (((u8 *) start) + offset)) = clib_host_to_net_u64 (value);
134 }
135 
136 static inline void
137 mlx5_set_bits (void *start, int offset, int first, int last, u32 value)
138 {
139  u32 mask = (1 << (first - last + 1)) - 1;
140  u32 old = mlx5_get_u32 (start, offset);
141  if ((last == 0) && (first == 31))
142  {
143  mlx5_set_u32 (start, offset, value);
144  return;
145  }
146  ASSERT (value == (value & mask));
147  value &= mask;
148  old &= ~(mask << last);
149  mlx5_set_u32 (start, offset, old | value << last);
150 }
151 
152 static inline u32
153 mlx5_get_bits (void *start, int offset, int first, int last)
154 {
155  u32 value = mlx5_get_u32 (start, offset);
156  if ((last == 0) && (first == 31))
157  return value;
158  value >>= last;
159  value &= (1 << (first - last + 1)) - 1;
160  return value;
161 }
162 
163 
164 #endif /* RDMA_MLX5DV_H */
165 
166 /*
167  * fd.io coding-style-patch-verification: ON
168  *
169  * Local Variables:
170  * eval: (c-set-style "gnu")
171  * End:
172  */
mlx5dv_wqe_srq_next_t::signature
u8 signature
Definition: rdma_mlx5dv.h:85
mlx5dv_cqe_t::byte_cnt
u32 byte_cnt
Definition: rdma_mlx5dv.h:53
mlx5dv_mini_cqe_t::rx_hash_result
u32 rx_hash_result
Definition: rdma_mlx5dv.h:70
mlx5_get_u64
static u64 mlx5_get_u64(void *start, int offset)
Definition: rdma_mlx5dv.h:119
types.h
mlx5dv_cqe_t::signature
u8 signature
Definition: rdma_mlx5dv.h:58
mlx5dv_wqe_ds_t::dsz_and_lkey
u64 dsz_and_lkey
Definition: rdma_mlx5dv.h:77
mlx5_set_u64
static void mlx5_set_u64(void *start, int offset, u64 value)
Definition: rdma_mlx5dv.h:131
u16
unsigned short u16
Definition: types.h:57
first
static heap_elt_t * first(heap_header_t *h)
Definition: heap.c:59
mlx5dv_mini_cqe_t
Definition: rdma_mlx5dv.h:65
mlx5dv_mini_cqe_t::byte_count
u32 byte_count
Definition: rdma_mlx5dv.h:72
error.h
mlx5dv_wqe_ds_t
Definition: rdma_mlx5dv.h:75
mlx5dv_cqe_t
Definition: rdma_mlx5dv.h:44
offset
struct clib_bihash_value offset
template key/value backing page structure
mlx5dv_cqe_t::opcode_cqefmt_se_owner
u8 opcode_cqefmt_se_owner
Definition: rdma_mlx5dv.h:59
mlx5dv_cqe_t::wqe_counter
u16 wqe_counter
Definition: rdma_mlx5dv.h:57
last
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
mlx5dv_wqe_ds_t::addr
u64 addr
Definition: rdma_mlx5dv.h:78
STATIC_ASSERT_SIZEOF
STATIC_ASSERT_SIZEOF(mlx5dv_cqe_t, 64)
mlx5_get_u32
static u32 mlx5_get_u32(void *start, int offset)
Definition: rdma_mlx5dv.h:113
mlx5dv_mini_cqe_t::checksum
u32 checksum
Definition: rdma_mlx5dv.h:69
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
mlx5dv_cqe_t::flags
u16 flags
Definition: rdma_mlx5dv.h:49
u64
unsigned long u64
Definition: types.h:89
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
u32
unsigned int u32
Definition: types.h:88
mlx5_set_bits
static void mlx5_set_bits(void *start, int offset, int first, int last, u32 value)
Definition: rdma_mlx5dv.h:137
mlx5dv_cqe_t::mini_cqe_num
u32 mini_cqe_num
Definition: rdma_mlx5dv.h:54
value
u8 value
Definition: qos.api:54
mlx5_get_bits
static u32 mlx5_get_bits(void *start, int offset, int first, int last)
Definition: rdma_mlx5dv.h:153
mlx5dv_wqe_srq_next_t
Definition: rdma_mlx5dv.h:81
u8
unsigned char u8
Definition: types.h:56
mlx5_set_u32
static void mlx5_set_u32(void *start, int offset, u32 value)
Definition: rdma_mlx5dv.h:125
mlx5dv_wqe_srq_next_t::next_wqe_index
u16 next_wqe_index
Definition: rdma_mlx5dv.h:84