Commit b53ab6ba authored by Leonardo Lai's avatar Leonardo Lai

some renaming to prevent conflicts

parent c650dabb
......@@ -8,17 +8,17 @@
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
extern const void *list_t_alloc;
extern const void *list_node_t_alloc;
extern const void *udpdk_list_t_alloc;
extern const void *udpdk_list_node_t_alloc;
/*
* Allocate a new list_t. NULL on failure.
* Allocate a new udpdk_list_t. NULL on failure.
*/
list_t *
udpdk_list_t *
list_new(void) {
list_t *self;
if (!(self = udpdk_shmalloc(list_t_alloc)))
udpdk_list_t *self;
if (!(self = udpdk_shmalloc(udpdk_list_t_alloc)))
return NULL;
self->head = NULL;
self->tail = NULL;
......@@ -33,19 +33,19 @@ list_new(void) {
*/
void
list_destroy(list_t *self) {
list_destroy(udpdk_list_t *self) {
unsigned int len = self->len;
list_node_t *next;
list_node_t *curr = self->head;
udpdk_list_node_t *next;
udpdk_list_node_t *curr = self->head;
while (len--) {
next = curr->next;
if (self->free) self->free(curr->val);
udpdk_shfree(list_node_t_alloc, curr);
udpdk_shfree(udpdk_list_node_t_alloc, curr);
curr = next;
}
udpdk_shfree(list_t_alloc, self);
udpdk_shfree(udpdk_list_t_alloc, self);
}
/*
......@@ -53,8 +53,8 @@ list_destroy(list_t *self) {
* and return the node, NULL on failure.
*/
list_node_t *
list_rpush(list_t *self, list_node_t *node) {
udpdk_list_node_t *
list_rpush(udpdk_list_t *self, udpdk_list_node_t *node) {
if (!node) return NULL;
if (self->len) {
......@@ -75,11 +75,11 @@ list_rpush(list_t *self, list_node_t *node) {
* Return / detach the last node in the list, or NULL.
*/
list_node_t *
list_rpop(list_t *self) {
udpdk_list_node_t *
list_rpop(udpdk_list_t *self) {
if (!self->len) return NULL;
list_node_t *node = self->tail;
udpdk_list_node_t *node = self->tail;
if (--self->len) {
(self->tail = node->prev)->next = NULL;
......@@ -95,11 +95,11 @@ list_rpop(list_t *self) {
* Return / detach the first node in the list, or NULL.
*/
list_node_t *
list_lpop(list_t *self) {
udpdk_list_node_t *
list_lpop(udpdk_list_t *self) {
if (!self->len) return NULL;
list_node_t *node = self->head;
udpdk_list_node_t *node = self->head;
if (--self->len) {
(self->head = node->next)->prev = NULL;
......@@ -116,8 +116,8 @@ list_lpop(list_t *self) {
* and return the node, NULL on failure.
*/
list_node_t *
list_lpush(list_t *self, list_node_t *node) {
udpdk_list_node_t *
list_lpush(udpdk_list_t *self, udpdk_list_node_t *node) {
if (!node) return NULL;
if (self->len) {
......@@ -139,8 +139,8 @@ list_lpush(list_t *self, list_node_t *node) {
* (or first if the only element)
* and return the node, NULL or failure
*/
list_node_t *
list_spush(list_t *self, list_node_t *node) {
udpdk_list_node_t *
list_spush(udpdk_list_t *self, udpdk_list_node_t *node) {
if (!node) return NULL;
if (self->len) {
......@@ -161,10 +161,10 @@ list_spush(list_t *self, list_node_t *node) {
* Return the node associated to val or NULL.
*/
list_node_t *
list_find(list_t *self, void *val) {
list_iterator_t *it = list_iterator_new(self, LIST_HEAD);
list_node_t *node;
udpdk_list_node_t *
list_find(udpdk_list_t *self, void *val) {
udpdk_list_iterator_t *it = list_iterator_new(self, LIST_HEAD);
udpdk_list_node_t *node;
while ((node = list_iterator_next(it))) {
if (self->match) {
......@@ -188,9 +188,9 @@ list_find(list_t *self, void *val) {
* Return the node at the given index or NULL.
*/
list_node_t *
list_at(list_t *self, int index) {
list_direction_t direction = LIST_HEAD;
udpdk_list_node_t *
list_at(udpdk_list_t *self, int index) {
udpdk_list_direction_t direction = LIST_HEAD;
if (index < 0) {
direction = LIST_TAIL;
......@@ -198,8 +198,8 @@ list_at(list_t *self, int index) {
}
if ((unsigned)index < self->len) {
list_iterator_t *it = list_iterator_new(self, direction);
list_node_t *node = list_iterator_next(it);
udpdk_list_iterator_t *it = list_iterator_new(self, direction);
udpdk_list_node_t *node = list_iterator_next(it);
while (index--) node = list_iterator_next(it);
list_iterator_destroy(it);
return node;
......@@ -213,7 +213,7 @@ list_at(list_t *self, int index) {
*/
void
list_remove(list_t *self, list_node_t *node) {
list_remove(udpdk_list_t *self, udpdk_list_node_t *node) {
node->prev
? (node->prev->next = node->next)
: (self->head = node->next);
......@@ -224,6 +224,6 @@ list_remove(list_t *self, list_node_t *node) {
if (self->free) self->free(node->val);
udpdk_shfree(list_node_t_alloc, node);
udpdk_shfree(udpdk_list_node_t_alloc, node);
--self->len;
}
......@@ -29,92 +29,92 @@ extern "C" {
#endif
/*
* list_t iterator direction.
* udpdk_list_t iterator direction.
*/
typedef enum {
LIST_HEAD
, LIST_TAIL
} list_direction_t;
} udpdk_list_direction_t;
/*
* list_t node struct.
* udpdk_list_t node struct.
*/
typedef struct list_node {
struct list_node *prev;
struct list_node *next;
void *val;
} list_node_t;
} udpdk_list_node_t;
/*
* list_t struct.
* udpdk_list_t struct.
*/
typedef struct {
list_node_t *head;
list_node_t *tail;
udpdk_list_node_t *head;
udpdk_list_node_t *tail;
unsigned int len;
void (*free)(void *val);
int (*match)(void *a, void *b);
} list_t;
} udpdk_list_t;
/*
* list_t iterator struct.
* udpdk_list_t iterator struct.
*/
typedef struct {
list_node_t *next;
list_direction_t direction;
} list_iterator_t;
udpdk_list_node_t *next;
udpdk_list_direction_t direction;
} udpdk_list_iterator_t;
// Node prototypes.
list_node_t *
udpdk_list_node_t *
list_node_new(void *val);
// list_t prototypes.
// udpdk_list_t prototypes.
list_t *
udpdk_list_t *
list_new(void);
list_node_t *
list_rpush(list_t *self, list_node_t *node);
udpdk_list_node_t *
list_rpush(udpdk_list_t *self, udpdk_list_node_t *node);
list_node_t *
list_lpush(list_t *self, list_node_t *node);
udpdk_list_node_t *
list_lpush(udpdk_list_t *self, udpdk_list_node_t *node);
list_node_t *
list_find(list_t *self, void *val);
udpdk_list_node_t *
list_find(udpdk_list_t *self, void *val);
list_node_t *
list_at(list_t *self, int index);
udpdk_list_node_t *
list_at(udpdk_list_t *self, int index);
list_node_t *
list_rpop(list_t *self);
udpdk_list_node_t *
list_rpop(udpdk_list_t *self);
list_node_t *
list_lpop(list_t *self);
udpdk_list_node_t *
list_lpop(udpdk_list_t *self);
void
list_remove(list_t *self, list_node_t *node);
list_remove(udpdk_list_t *self, udpdk_list_node_t *node);
void
list_destroy(list_t *self);
list_destroy(udpdk_list_t *self);
// list_t iterator prototypes.
// udpdk_list_t iterator prototypes.
list_iterator_t *
list_iterator_new(list_t *list, list_direction_t direction);
udpdk_list_iterator_t *
list_iterator_new(udpdk_list_t *list, udpdk_list_direction_t direction);
list_iterator_t *
list_iterator_new_from_node(list_node_t *node, list_direction_t direction);
udpdk_list_iterator_t *
list_iterator_new_from_node(udpdk_list_node_t *node, udpdk_list_direction_t direction);
list_node_t *
list_iterator_next(list_iterator_t *self);
udpdk_list_node_t *
list_iterator_next(udpdk_list_iterator_t *self);
void
list_iterator_destroy(list_iterator_t *self);
list_iterator_destroy(udpdk_list_iterator_t *self);
#ifdef __cplusplus
}
......
#include "udpdk_list.h"
const void *list_t_alloc = NULL;
const void *list_node_t_alloc = NULL;
const void *list_iterator_t_alloc = NULL;
const void *udpdk_list_t_alloc = NULL;
const void *udpdk_list_node_t_alloc = NULL;
const void *udpdk_list_iterator_t_alloc = NULL;
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
extern const void *list_t_alloc;
extern const void *list_node_t_alloc;
extern const void *list_iterator_t_alloc;
extern const void *udpdk_list_t_alloc;
extern const void *udpdk_list_node_t_alloc;
extern const void *udpdk_list_iterator_t_alloc;
void udpdk_list_init(void)
{
list_t_alloc = udpdk_init_allocator("list_t_alloc", UDP_MAX_PORT, sizeof(list_t));
list_node_t_alloc = udpdk_init_allocator("list_node_t_alloc", NUM_SOCKETS_MAX, sizeof(list_node_t));
list_iterator_t_alloc = udpdk_init_allocator("list_iterator_t_alloc", 10, sizeof(list_iterator_t));
udpdk_list_t_alloc = udpdk_init_allocator("udpdk_list_t_alloc", UDP_MAX_PORT, sizeof(udpdk_list_t));
udpdk_list_node_t_alloc = udpdk_init_allocator("udpdk_list_node_t_alloc", NUM_SOCKETS_MAX, sizeof(udpdk_list_node_t));
udpdk_list_iterator_t_alloc = udpdk_init_allocator("udpdk_list_iterator_t_alloc", 10, sizeof(udpdk_list_iterator_t));
}
int udpdk_list_reinit(void)
{
list_t_alloc = udpdk_retrieve_allocator("list_t_alloc");
if (list_t_alloc == NULL) {
udpdk_list_t_alloc = udpdk_retrieve_allocator("udpdk_list_t_alloc");
if (udpdk_list_t_alloc == NULL) {
return -1;
}
list_node_t_alloc = udpdk_retrieve_allocator("list_node_t_alloc");
if (list_node_t_alloc == NULL) {
udpdk_list_node_t_alloc = udpdk_retrieve_allocator("udpdk_list_node_t_alloc");
if (udpdk_list_node_t_alloc == NULL) {
return -1;
}
list_iterator_t_alloc = udpdk_retrieve_allocator("list_iterator_t_alloc");
if (list_iterator_t_alloc == NULL) {
udpdk_list_iterator_t_alloc = udpdk_retrieve_allocator("udpdk_list_iterator_t_alloc");
if (udpdk_list_iterator_t_alloc == NULL) {
return -1;
}
return 0;
......@@ -31,7 +31,7 @@ int udpdk_list_reinit(void)
void udpdk_list_deinit(void)
{
udpdk_destroy_allocator(list_t_alloc);
udpdk_destroy_allocator(list_node_t_alloc);
udpdk_destroy_allocator(list_iterator_t_alloc);
udpdk_destroy_allocator(udpdk_list_t_alloc);
udpdk_destroy_allocator(udpdk_list_node_t_alloc);
udpdk_destroy_allocator(udpdk_list_iterator_t_alloc);
}
......@@ -8,30 +8,30 @@
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
extern void *list_iterator_t_alloc;
extern void *udpdk_list_iterator_t_alloc;
/*
* Allocate a new list_iterator_t. NULL on failure.
* Allocate a new udpdk_list_iterator_t. NULL on failure.
* Accepts a direction, which may be LIST_HEAD or LIST_TAIL.
*/
list_iterator_t *
list_iterator_new(list_t *list, list_direction_t direction) {
list_node_t *node = direction == LIST_HEAD
udpdk_list_iterator_t *
list_iterator_new(udpdk_list_t *list, udpdk_list_direction_t direction) {
udpdk_list_node_t *node = direction == LIST_HEAD
? list->head
: list->tail;
return list_iterator_new_from_node(node, direction);
}
/*
* Allocate a new list_iterator_t with the given start
* Allocate a new udpdk_list_iterator_t with the given start
* node. NULL on failure.
*/
list_iterator_t *
list_iterator_new_from_node(list_node_t *node, list_direction_t direction) {
list_iterator_t *self;
if (!(self = udpdk_shmalloc(list_iterator_t_alloc)))
udpdk_list_iterator_t *
list_iterator_new_from_node(udpdk_list_node_t *node, udpdk_list_direction_t direction) {
udpdk_list_iterator_t *self;
if (!(self = udpdk_shmalloc(udpdk_list_iterator_t_alloc)))
return NULL;
self->next = node;
self->direction = direction;
......@@ -39,13 +39,13 @@ list_iterator_new_from_node(list_node_t *node, list_direction_t direction) {
}
/*
* Return the next list_node_t or NULL when no more
* Return the next udpdk_list_node_t or NULL when no more
* nodes remain in the list.
*/
list_node_t *
list_iterator_next(list_iterator_t *self) {
list_node_t *curr = self->next;
udpdk_list_node_t *
list_iterator_next(udpdk_list_iterator_t *self) {
udpdk_list_node_t *curr = self->next;
if (curr) {
self->next = self->direction == LIST_HEAD
? curr->next
......@@ -59,7 +59,7 @@ list_iterator_next(list_iterator_t *self) {
*/
void
list_iterator_destroy(list_iterator_t *self) {
udpdk_shfree(list_iterator_t_alloc, self);
list_iterator_destroy(udpdk_list_iterator_t *self) {
udpdk_shfree(udpdk_list_iterator_t_alloc, self);
self = NULL;
}
......@@ -8,16 +8,16 @@
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
extern void *list_node_t_alloc;
extern void *udpdk_list_node_t_alloc;
/*
* Allocates a new list_node_t. NULL on failure.
* Allocates a new udpdk_list_node_t. NULL on failure.
*/
list_node_t *
udpdk_list_node_t *
list_node_new(void *val) {
list_node_t *self;
if (!(self = udpdk_shmalloc(list_node_t_alloc)))
udpdk_list_node_t *self;
if (!(self = udpdk_shmalloc(udpdk_list_node_t_alloc)))
return NULL;
self->prev = NULL;
self->next = NULL;
......
......@@ -15,7 +15,7 @@
#define RTE_LOGTYPE_BTABLE RTE_LOGTYPE_USER1
const void *bind_info_alloc = NULL;
list_t **sock_bind_table;
udpdk_list_t **sock_bind_table;
/* Initialize the bindings table */
void btable_init(void)
......@@ -49,8 +49,8 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
bool reuse_addr = opts & SO_REUSEADDR;
bool reuse_port = opts & SO_REUSEPORT;
bool can_bind = true;
list_iterator_t *it;
list_node_t *node;
udpdk_list_iterator_t *it;
udpdk_list_node_t *node;
unsigned long ip_oth, ip_new;
// bool oth_reuseaddr;
bool oth_reuseport;
......@@ -92,7 +92,7 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
int btable_add_binding(int s, struct in_addr ip, int port, int opts)
{
struct bind_info *b;
list_node_t *ln;
udpdk_list_node_t *ln;
// Check if binding this pair is allowed
if (!btable_can_bind(ip, port, opts)) {
......@@ -127,8 +127,8 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts)
/* Remove a binding from the port */
void btable_del_binding(int s, int port) {
list_node_t *node;
list_iterator_t *it;
udpdk_list_node_t *node;
udpdk_list_iterator_t *it;
// Remove the binding from the list
it = list_iterator_new(sock_bind_table[port], LIST_HEAD);
......@@ -149,7 +149,7 @@ void btable_del_binding(int s, int port) {
}
/* Get all the bind_info descriptors of the sockets bound to the given port */
list_t *btable_get_bindings(int port) {
udpdk_list_t *btable_get_bindings(int port) {
return sock_bind_table[port];
}
......
......@@ -18,7 +18,7 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts);
void btable_del_binding(int s, int port);
list_t *btable_get_bindings(int port);
udpdk_list_t *btable_get_bindings(int port);
void btable_destroy(void);
......
......@@ -41,7 +41,7 @@ extern struct rte_mempool *rx_pktmbuf_pool;
extern struct rte_mempool *tx_pktmbuf_pool;
extern struct rte_mempool *tx_pktmbuf_direct_pool;
extern struct rte_mempool *tx_pktmbuf_indirect_pool;
extern list_t **sock_bind_table;
extern udpdk_list_t **sock_bind_table;
extern int primary_argc;
extern int secondary_argc;
extern char *primary_argv[MAX_ARGC];
......@@ -207,7 +207,7 @@ static int init_udp_bind_table(void)
{
const struct rte_memzone *mz;
mz = rte_memzone_reserve(UDP_BIND_TABLE_NAME, UDP_MAX_PORT * sizeof(struct list_t *), rte_socket_id(), 0);
mz = rte_memzone_reserve(UDP_BIND_TABLE_NAME, UDP_MAX_PORT * sizeof(struct udpdk_list_t *), rte_socket_id(), 0);
if (mz == NULL) {
RTE_LOG(ERR, INIT, "Cannot allocate shared memory for L4 switching table\n");
return -1;
......
......@@ -37,7 +37,7 @@ static volatile int poller_alive = 1;
extern struct exch_zone_info *exch_zone_desc;
extern struct exch_slot *exch_slots;
extern list_t **sock_bind_table;
extern udpdk_list_t **sock_bind_table;
extern const void *bind_info_alloc;
/* Descriptor of a RX queue */
......@@ -350,13 +350,13 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
ip_dst_addr = get_ipv4_dst_addr(ip_hdr);
// Find the sock_ids corresponding to the UDP dst port (L4 switching) and enqueue the packet to its queue
list_t *binds = btable_get_bindings(udp_dst_port);
udpdk_list_t *binds = btable_get_bindings(udp_dst_port);
if (binds == NULL) {
RTE_LOG(WARNING, POLLBODY, "Dropping packet for port %d: no socket bound\n", ntohs(udp_dst_port));
return;
}
list_iterator_t *it = list_iterator_new(binds, LIST_HEAD);
list_node_t *node;
udpdk_list_iterator_t *it = list_iterator_new(binds, LIST_HEAD);
udpdk_list_node_t *node;
while ((node = list_iterator_next(it))) {
unsigned long ip_oth = ((struct bind_info *)(node->val))->ip_addr.s_addr;
bool oth_reuseaddr = ((struct bind_info *)(node->val))->reuse_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment