FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
rdma.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 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_H_
19 #define _RDMA_H_
20 
21 #include <infiniband/verbs.h>
22 #include <vlib/log.h>
23 #include <vlib/pci/pci.h>
24 #include <vnet/interface.h>
26 
27 #define foreach_rdma_device_flags \
28  _(0, ERROR, "error") \
29  _(1, ADMIN_UP, "admin-up") \
30  _(2, LINK_UP, "link-up") \
31  _(3, PROMISC, "promiscuous")
32 
33 enum
34 {
35 #define _(a, b, c) RDMA_DEVICE_F_##b = (1 << a),
37 #undef _
38 };
39 
40 typedef struct
41 {
42  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
43  struct ibv_cq *cq;
44  struct ibv_wq *wq;
49 } rdma_rxq_t;
50 
51 typedef struct
52 {
53  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
55  struct ibv_cq *cq;
56  struct ibv_qp *qp;
61 } rdma_txq_t;
62 
63 typedef struct
64 {
65  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
66 
67  /* following fields are accessed in datapath */
74  u32 lkey; /* cache of mr->lkey */
75  u8 pool; /* buffer pool index */
76 
77  /* fields below are not accessed in datapath */
79  u8 *name;
84 
85  struct ibv_context *ctx;
86  struct ibv_pd *pd;
87  struct ibv_mr *mr;
88  struct ibv_qp *rx_qp;
89  struct ibv_rwq_ind_table *rx_rwq_ind_tbl;
90  struct ibv_flow *flow_ucast;
91  struct ibv_flow *flow_mcast;
92 
95 
96 typedef struct
97 {
101 } rdma_main_t;
102 
103 extern rdma_main_t rdma_main;
104 
105 typedef enum
106 {
110 } rdma_mode_t;
111 
112 typedef struct
113 {
120 
121  /* return */
122  int rv;
126 
129 
132 
137 
138 typedef struct
139 {
143 
144 #define foreach_rdma_tx_func_error \
145 _(NO_FREE_SLOTS, "no free tx slots")
146 
147 typedef enum
148 {
149 #define _(f,s) RDMA_TX_ERROR_##f,
151 #undef _
154 
155 #endif /* AVF_H */
156 
157 /*
158  * fd.io coding-style-patch-verification: ON
159  *
160  * Local Variables:
161  * eval: (c-set-style "gnu")
162  * End:
163  */
struct ibv_mr * mr
Definition: rdma.h:87
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
void rdma_delete_if(vlib_main_t *vm, rdma_device_t *rd)
Definition: device.c:730
u8 * linux_ifname
Definition: rdma.h:80
format_function_t format_rdma_device
Definition: rdma.h:133
void rdma_create_if(vlib_main_t *vm, rdma_create_if_args_t *args)
Definition: device.c:580
u32 size
Definition: rdma.h:46
rdma_mode_t
Definition: rdma.h:105
vlib_pci_device_info_t * pci
Definition: rdma.h:78
u32 dev_instance
Definition: rdma.h:83
struct ibv_wq * wq
Definition: rdma.h:44
u32 size
Definition: rdma.h:58
u32 per_interface_next_index
Definition: rdma.h:71
format_function_t format_rdma_input_trace
Definition: rdma.h:135
rdma_main_t rdma_main
Definition: device.c:46
struct _vnet_device_class vnet_device_class_t
u32 tail
Definition: rdma.h:48
mac_address_t hwaddr
Definition: rdma.h:81
unsigned char u8
Definition: types.h:56
clib_spinlock_t lock
Definition: rdma.h:54
vlib_log_class_t log_class
Definition: rdma.h:99
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
u32 vlib_log_class_t
Definition: vlib.h:51
struct ibv_pd * pd
Definition: rdma.h:86
rdma_device_t * devices
Definition: rdma.h:98
struct ibv_cq * cq
Definition: rdma.h:55
u32 tail
Definition: rdma.h:60
unsigned int u32
Definition: types.h:88
unformat_function_t unformat_rdma_create_if_args
Definition: rdma.h:136
u32 flags
Definition: rdma.h:70
u32 * bufs
Definition: rdma.h:45
u32 head
Definition: rdma.h:59
unsigned short u16
Definition: types.h:57
u8 pool
Definition: rdma.h:75
struct ibv_cq * cq
Definition: rdma.h:43
struct ibv_qp * qp
Definition: rdma.h:56
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:233
vlib_main_t * vm
Definition: in2out_ed.c:1810
u32 hw_if_index
Definition: rdma.h:73
struct ibv_rwq_ind_table * rx_rwq_ind_tbl
Definition: rdma.h:89
clib_error_t * error
Definition: rdma.h:93
clib_error_t * error
Definition: rdma.h:124
rdma_mode_t mode
Definition: rdma.h:119
u32 lkey
Definition: rdma.h:74
vlib_node_registration_t rdma_input_node
(constructor) VLIB_REGISTER_NODE (rdma_input_node)
Definition: input.c:361
u32 sw_if_index
Definition: rdma.h:72
u32 head
Definition: rdma.h:47
format_function_t format_rdma_device_name
Definition: rdma.h:134
u16 msg_id_base
Definition: rdma.h:100
u8 * name
Definition: rdma.h:79
rdma_txq_t * txqs
Definition: rdma.h:69
rdma_rxq_t * rxqs
Definition: rdma.h:68
vnet_device_class_t rdma_device_class
rdma_tx_func_error_t
Definition: rdma.h:147
struct _vlib_node_registration vlib_node_registration_t
u32 async_event_clib_file_index
Definition: rdma.h:82
u32 * bufs
Definition: rdma.h:57
#define foreach_rdma_tx_func_error
Definition: rdma.h:144
#define foreach_rdma_device_flags
Definition: rdma.h:27
struct ibv_flow * flow_ucast
Definition: rdma.h:90
struct ibv_flow * flow_mcast
Definition: rdma.h:91
struct ibv_context * ctx
Definition: rdma.h:85
struct ibv_qp * rx_qp
Definition: rdma.h:88