rdma: api: prepare support for direct verb
[vpp.git] / src / plugins / rdma / rdma.h
index c7df6f7..470309a 100644 (file)
@@ -20,6 +20,9 @@
 
 #include <infiniband/verbs.h>
 #include <vlib/log.h>
+#include <vlib/pci/pci.h>
+#include <vnet/interface.h>
+#include <vnet/ethernet/mac_address.h>
 
 #define foreach_rdma_device_flags \
   _(0, ERROR, "error") \
@@ -37,40 +40,47 @@ enum
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-  u32 size;
-  u32 n_enq;
   struct ibv_cq *cq;
   struct ibv_wq *wq;
+  u32 *bufs;
+  u32 size;
+  u32 head;
+  u32 tail;
 } rdma_rxq_t;
 
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
-  u32 size;
-  u32 n_enq;
+  clib_spinlock_t lock;
   struct ibv_cq *cq;
   struct ibv_qp *qp;
-  clib_spinlock_t lock;
+  u32 *bufs;
+  u32 size;
+  u32 head;
+  u32 tail;
 } rdma_txq_t;
 
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
+  /* following fields are accessed in datapath */
+  rdma_rxq_t *rxqs;
+  rdma_txq_t *txqs;
   u32 flags;
   u32 per_interface_next_index;
-
-  u32 dev_instance;
   u32 sw_if_index;
   u32 hw_if_index;
+  u32 lkey;                    /* cache of mr->lkey */
+  u8 pool;                     /* buffer pool index */
 
-  u32 async_event_clib_file_index;
-
-  rdma_rxq_t *rxqs;
-  rdma_txq_t *txqs;
-
+  /* fields below are not accessed in datapath */
+  vlib_pci_device_info_t *pci;
   u8 *name;
+  u8 *linux_ifname;
   mac_address_t hwaddr;
-  vlib_pci_addr_t pci_addr;
+  u32 async_event_clib_file_index;
+  u32 dev_instance;
 
   struct ibv_context *ctx;
   struct ibv_pd *pd;
@@ -80,7 +90,6 @@ typedef struct
   struct ibv_flow *flow_ucast;
   struct ibv_flow *flow_mcast;
 
-  /* error */
   clib_error_t *error;
 } rdma_device_t;
 
@@ -88,10 +97,18 @@ typedef struct
 {
   rdma_device_t *devices;
   vlib_log_class_t log_class;
+  u16 msg_id_base;
 } rdma_main_t;
 
 extern rdma_main_t rdma_main;
 
+typedef enum
+{
+  RDMA_MODE_AUTO = 0,
+  RDMA_MODE_IBV,
+  RDMA_MODE_DV,
+} rdma_mode_t;
+
 typedef struct
 {
   u8 *ifname;
@@ -99,6 +116,7 @@ typedef struct
   u32 rxq_size;
   u32 txq_size;
   u32 rxq_num;
+  rdma_mode_t mode;
 
   /* return */
   int rv;
@@ -112,10 +130,10 @@ void rdma_delete_if (vlib_main_t * vm, rdma_device_t * rd);
 extern vlib_node_registration_t rdma_input_node;
 extern vnet_device_class_t rdma_device_class;
 
-/* format.c */
 format_function_t format_rdma_device;
 format_function_t format_rdma_device_name;
 format_function_t format_rdma_input_trace;
+unformat_function_t unformat_rdma_create_if_args;
 
 typedef struct
 {