flow: Add 'drop' and 'redirect-to-queue' actions support
[vpp.git] / src / plugins / rdma / rdma.h
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
24 #define foreach_rdma_device_flags \
25   _(0, ERROR, "error") \
26   _(1, ADMIN_UP, "admin-up") \
27   _(2, LINK_UP, "link-up") \
28   _(3, PROMISC, "promiscuous")
29
30 enum
31 {
32 #define _(a, b, c) RDMA_DEVICE_F_##b = (1 << a),
33   foreach_rdma_device_flags
34 #undef _
35 };
36
37 typedef struct
38 {
39   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
40   struct ibv_cq *cq;
41   struct ibv_wq *wq;
42   u32 *bufs;
43   u32 size;
44   u32 head;
45   u32 tail;
46 } rdma_rxq_t;
47
48 typedef struct
49 {
50   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
51   clib_spinlock_t lock;
52   struct ibv_cq *cq;
53   struct ibv_qp *qp;
54   u32 *bufs;
55   u32 size;
56   u32 head;
57   u32 tail;
58 } rdma_txq_t;
59
60 typedef struct
61 {
62   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
63
64   /* following fields are accessed in datapath */
65   rdma_rxq_t *rxqs;
66   rdma_txq_t *txqs;
67   u32 flags;
68   u32 per_interface_next_index;
69   u32 sw_if_index;
70   u32 hw_if_index;
71   u32 lkey;                     /* cache of mr->lkey */
72   u8 pool;                      /* buffer pool index */
73
74   /* fields below are not accessed in datapath */
75   vlib_pci_device_info_t *pci;
76   u8 *name;
77   u8 *linux_ifname;
78   mac_address_t hwaddr;
79   u32 async_event_clib_file_index;
80   u32 dev_instance;
81
82   struct ibv_context *ctx;
83   struct ibv_pd *pd;
84   struct ibv_mr *mr;
85   struct ibv_qp *rx_qp;
86   struct ibv_rwq_ind_table *rx_rwq_ind_tbl;
87   struct ibv_flow *flow_ucast;
88   struct ibv_flow *flow_mcast;
89
90   clib_error_t *error;
91 } rdma_device_t;
92
93 typedef struct
94 {
95   rdma_device_t *devices;
96   vlib_log_class_t log_class;
97 } rdma_main_t;
98
99 extern rdma_main_t rdma_main;
100
101 typedef struct
102 {
103   u8 *ifname;
104   u8 *name;
105   u32 rxq_size;
106   u32 txq_size;
107   u32 rxq_num;
108
109   /* return */
110   int rv;
111   u32 sw_if_index;
112   clib_error_t *error;
113 } rdma_create_if_args_t;
114
115 void rdma_create_if (vlib_main_t * vm, rdma_create_if_args_t * args);
116 void rdma_delete_if (vlib_main_t * vm, rdma_device_t * rd);
117
118 extern vlib_node_registration_t rdma_input_node;
119 extern vnet_device_class_t rdma_device_class;
120
121 /* format.c */
122 format_function_t format_rdma_device;
123 format_function_t format_rdma_device_name;
124 format_function_t format_rdma_input_trace;
125
126 typedef struct
127 {
128   u32 next_index;
129   u32 hw_if_index;
130 } rdma_input_trace_t;
131
132 #define foreach_rdma_tx_func_error             \
133 _(NO_FREE_SLOTS, "no free tx slots")
134
135 typedef enum
136 {
137 #define _(f,s) RDMA_TX_ERROR_##f,
138   foreach_rdma_tx_func_error
139 #undef _
140     RDMA_TX_N_ERROR,
141 } rdma_tx_func_error_t;
142
143 #endif /* AVF_H */
144
145 /*
146  * fd.io coding-style-patch-verification: ON
147  *
148  * Local Variables:
149  * eval: (c-set-style "gnu")
150  * End:
151  */