Harmonize vec/pool_get_aligned object sizes and alignment requests
[vpp.git] / src / plugins / memif / private.h
index b7c18c9..5c8a919 100644 (file)
@@ -80,9 +80,12 @@ typedef struct
 
 typedef struct
 {
+  /* Required for vec_validate_aligned */
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   void *shm;
   memif_region_size_t region_size;
   int fd;
+  u8 is_external;
 } memif_region_t;
 
 typedef struct
@@ -101,6 +104,7 @@ typedef struct
 
   u16 last_head;
   u16 last_tail;
+  u32 *buffers;
 
   /* interrupts */
   int int_fd;
@@ -116,7 +120,9 @@ typedef struct
   _(1, IS_SLAVE, "slave")              \
   _(2, CONNECTING, "connecting")       \
   _(3, CONNECTED, "connected")         \
-  _(4, DELETING, "deleting")
+  _(4, DELETING, "deleting")           \
+  _(5, ZERO_COPY, "zero-copy")         \
+  _(6, ERROR, "error")
 
 typedef enum
 {
@@ -174,6 +180,36 @@ typedef struct
   u8 *remote_disc_string;
 } memif_if_t;
 
+typedef struct
+{
+  u32 packet_len;
+  u16 first_buffer_vec_index;
+} memif_packet_op_t;
+
+typedef struct
+{
+  void *data;
+  u32 data_len;
+  i16 buffer_offset;
+  u16 buffer_vec_index;
+} memif_copy_op_t;
+
+#define MEMIF_RX_VECTOR_SZ VLIB_FRAME_SIZE
+
+typedef struct
+{
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
+  /* copy vector */
+  memif_packet_op_t packet_ops[MEMIF_RX_VECTOR_SZ];
+  memif_copy_op_t *copy_ops;
+  u32 *buffers;
+
+  /* buffer template */
+  vlib_buffer_t buffer_template;
+  memif_desc_t desc_template;
+} memif_per_thread_data_t;
+
 typedef struct
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
@@ -188,8 +224,8 @@ typedef struct
   memif_socket_file_t *socket_files;
   uword *socket_file_index_by_sock_id; /* map user socket id to pool idx */
 
-  /* rx buffer cache */
-  u32 **rx_buffers;
+  /* per thread data */
+  memif_per_thread_data_t *per_thread_data;
 
 } memif_main_t;
 
@@ -209,6 +245,7 @@ typedef struct
   u32 socket_id;
   u8 *secret;
   u8 is_master;
+  u8 is_zero_copy;
   memif_interface_mode_t mode:8;
   memif_log2_ring_size_t log2_ring_size;
   u16 buffer_size;