X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Flibmemif%2Fsrc%2Fmemif_private.h;h=deca80c3350af7b26d5a3fdc645367628650960b;hb=refs%2Fchanges%2F49%2F16049%2F3;hp=a512ed4eaaa8afb29ed23ad7085f018b2f631d2e;hpb=1941871e2622a17e84062c69c234414c4dc2bf4a;p=vpp.git diff --git a/extras/libmemif/src/memif_private.h b/extras/libmemif/src/memif_private.h index a512ed4eaaa..deca80c3350 100644 --- a/extras/libmemif/src/memif_private.h +++ b/extras/libmemif/src/memif_private.h @@ -28,6 +28,7 @@ #include #include +#include #include #define MEMIF_NAME_LEN 32 @@ -45,50 +46,32 @@ _Static_assert (strlen (MEMIF_DEFAULT_APP_NAME) <= MEMIF_NAME_LEN, #define MEMIF_MAX_M2S_RING 255 #define MEMIF_MAX_S2M_RING 255 #define MEMIF_MAX_REGION 255 -#define MEMIF_MAX_LOG2_RING_SIZE 15 +#define MEMIF_MAX_LOG2_RING_SIZE 14 #define MEMIF_MAX_FDS 512 #define memif_min(a,b) (((a) < (b)) ? (a) : (b)) +#define EXPECT_TRUE(x) __builtin_expect((x),1) +#define EXPECT_FALSE(x) __builtin_expect((x),0) + #ifdef MEMIF_DBG #define DBG(...) do { \ printf("MEMIF_DEBUG:%s:%s:%d: ", __FILE__, __func__, __LINE__); \ printf(__VA_ARGS__); \ printf("\n"); \ } while (0) - -#define DBG_UNIX(...) do { \ - printf("MEMIF_DEBUG_UNIX:%s:%s:%d: ", __FILE__, __func__, __LINE__); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } while (0) - -#define error_return_unix(...) do { \ - DBG_UNIX(__VA_ARGS__); \ - return -1; \ - } while (0) -#define error_return(...) do { \ - DBG(__VA_ARGS__); \ - return -1; \ - } while (0) #else #define DBG(...) -#define DBG_UNIX(...) -#define error_return_unix(...) do { \ - return -1; \ - } while (0) -#define error_return(...) do { \ - return -1; \ - } while (0) - #endif /* MEMIF_DBG */ typedef struct { - void *shm; + void *addr; uint32_t region_size; + uint32_t buffer_offset; int fd; + uint8_t is_external; } memif_region_t; typedef struct @@ -151,8 +134,11 @@ typedef struct memif_connection uint8_t remote_name[MEMIF_NAME_LEN]; uint8_t remote_disconnect_string[96]; + uint8_t regions_num; memif_region_t *regions; + uint8_t rx_queues_num; + uint8_t tx_queues_num; memif_queue_t *rx_queues; memif_queue_t *tx_queues; @@ -160,18 +146,12 @@ typedef struct memif_connection #define MEMIF_CONNECTION_FLAG_WRITE (1 << 0) } memif_connection_t; -/* - * WIP - */ typedef struct { - int key; /* fd or id */ + int key; void *data_struct; } memif_list_elt_t; -/* - * WIP - */ typedef struct { int fd; @@ -181,10 +161,6 @@ typedef struct memif_list_elt_t *interface_list; /* memif master interfaces listening on this socket */ } memif_socket_t; -/* - * WIP - */ -/* probably function like memif_cleanup () will need to be called to close timerfd */ typedef struct { memif_control_fd_update_t *control_fd_update; @@ -193,8 +169,14 @@ typedef struct uint16_t disconn_slaves; uint8_t app_name[MEMIF_NAME_LEN]; - /* master implementation... */ - memif_socket_t ms; + memif_add_external_region_t *add_external_region; + memif_get_external_region_addr_t *get_external_region_addr; + memif_del_external_region_t *del_external_region; + memif_get_external_buffer_offset_t *get_external_buffer_offset; + + memif_alloc_t *alloc; + memif_realloc_t *realloc; + memif_free_t *free; uint16_t control_list_len; uint16_t interrupt_list_len; @@ -254,7 +236,7 @@ static inline void * memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring, uint16_t index) { - return (conn->regions[ring->desc[index].region].shm + + return (conn->regions[ring->desc[index].region].addr + ring->desc[index].offset); }