diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index b90da90ab..88a3c9db6 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -99,10 +99,10 @@ static uint16_t rss_reta_size[RTE_MAX_ETHPORTS]; static inline int send_single_packet(struct rte_mbuf *m, uint8_t port); struct ff_msg_ring { - char ring_name[2][RTE_RING_NAMESIZE]; + char ring_name[FF_MAX][RTE_RING_NAMESIZE]; /* ring[0] for lcore recv msg, other send */ /* ring[1] for lcore send msg, other read */ - struct rte_ring *ring[2]; + struct rte_ring *ring[FF_MAX]; } __rte_cache_aligned; static struct ff_msg_ring msg_ring[RTE_MAX_LCORE]; @@ -420,7 +420,7 @@ ff_msg_init(struct rte_mempool *mp, static int init_msg_ring(void) { - uint16_t i; + uint16_t i, j; uint16_t nb_procs = ff_global_cfg.dpdk.nb_procs; unsigned socketid = lcore_conf.socket_id; @@ -442,18 +442,19 @@ init_msg_ring(void) for(i = 0; i < nb_procs; ++i) { snprintf(msg_ring[i].ring_name[0], RTE_RING_NAMESIZE, "%s%u", FF_MSG_RING_IN, i); - snprintf(msg_ring[i].ring_name[1], RTE_RING_NAMESIZE, - "%s%u", FF_MSG_RING_OUT, i); - msg_ring[i].ring[0] = create_ring(msg_ring[i].ring_name[0], MSG_RING_SIZE, socketid, RING_F_SP_ENQ | RING_F_SC_DEQ); if (msg_ring[i].ring[0] == NULL) rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[0]); - msg_ring[i].ring[1] = create_ring(msg_ring[i].ring_name[1], - MSG_RING_SIZE, socketid, RING_F_SP_ENQ | RING_F_SC_DEQ); - if (msg_ring[i].ring[1] == NULL) - rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[0]); + for (j = FF_SYSCTL; j < FF_MAX; j++) { + snprintf(msg_ring[i].ring_name[j], RTE_RING_NAMESIZE, + "%s%u_%u", FF_MSG_RING_OUT, i, j); + msg_ring[i].ring[j] = create_ring(msg_ring[i].ring_name[j], + MSG_RING_SIZE, socketid, RING_F_SP_ENQ | RING_F_SC_DEQ); + if (msg_ring[i].ring[j] == NULL) + rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[j]); + } } return 0; @@ -1208,7 +1209,7 @@ handle_msg(struct ff_msg *msg, uint16_t proc_id) handle_default_msg(msg); break; } - rte_ring_enqueue(msg_ring[proc_id].ring[1], msg); + rte_ring_enqueue(msg_ring[proc_id].ring[msg->msg_type], msg); } static inline int diff --git a/lib/ff_msg.h b/lib/ff_msg.h index 715e2b585..0216d73c6 100644 --- a/lib/ff_msg.h +++ b/lib/ff_msg.h @@ -44,6 +44,11 @@ enum FF_MSG_TYPE { FF_NGCTL, FF_IPFW_CTL, FF_TRAFFIC, + + /* + * to add other msg type before FF_MAX + */ + FF_MAX, }; struct ff_sysctl_args { diff --git a/tools/compat/ff_ipc.c b/tools/compat/ff_ipc.c index 6f37f3ca6..01c4180b0 100644 --- a/tools/compat/ff_ipc.c +++ b/tools/compat/ff_ipc.c @@ -141,7 +141,7 @@ ff_ipc_send(const struct ff_msg *msg) } int -ff_ipc_recv(struct ff_msg **msg) +ff_ipc_recv(struct ff_msg **msg, enum FF_MSG_TYPE msg_type) { int ret, i; if (inited == 0) { @@ -150,8 +150,8 @@ ff_ipc_recv(struct ff_msg **msg) } char name[RTE_RING_NAMESIZE]; - snprintf(name, RTE_RING_NAMESIZE, "%s%u", - FF_MSG_RING_OUT, ff_proc_id); + snprintf(name, RTE_RING_NAMESIZE, "%s%u_%u", + FF_MSG_RING_OUT, ff_proc_id, msg_type); struct rte_ring *ring = rte_ring_lookup(name); if (ring == NULL) { printf("lookup message ring:%s failed!\n", name); diff --git a/tools/compat/ff_ipc.h b/tools/compat/ff_ipc.h index ebfda0889..8177f5921 100644 --- a/tools/compat/ff_ipc.h +++ b/tools/compat/ff_ipc.h @@ -37,6 +37,6 @@ struct ff_msg *ff_ipc_msg_alloc(void); int ff_ipc_msg_free(struct ff_msg *msg); int ff_ipc_send(const struct ff_msg *msg); -int ff_ipc_recv(struct ff_msg **msg); +int ff_ipc_recv(struct ff_msg **msg, enum FF_MSG_TYPE msg_type); #endif diff --git a/tools/compat/ioctl.c b/tools/compat/ioctl.c index 73cb81983..524a60932 100644 --- a/tools/compat/ioctl.c +++ b/tools/compat/ioctl.c @@ -139,7 +139,7 @@ ioctl_va(int fd, unsigned long com, void *data, int argc, ...) if (retmsg != NULL) { ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/compat/rtioctl.c b/tools/compat/rtioctl.c index 6579c215d..e4c627935 100644 --- a/tools/compat/rtioctl.c +++ b/tools/compat/rtioctl.c @@ -113,7 +113,7 @@ rtioctl(char *data, unsigned len, unsigned read_len) if (retmsg != NULL) { ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/compat/sysctl.c b/tools/compat/sysctl.c index f74d65fb9..7bce96cfa 100644 --- a/tools/compat/sysctl.c +++ b/tools/compat/sysctl.c @@ -117,7 +117,7 @@ sysctl(int *name, unsigned namelen, void *old, if (retmsg != NULL) { ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/ipfw/compat.c b/tools/ipfw/compat.c index d7afa1e9f..caf97b29b 100644 --- a/tools/ipfw/compat.c +++ b/tools/ipfw/compat.c @@ -84,7 +84,7 @@ ipfw_ctl(int cmd, int level, int optname, void *optval, socklen_t *optlen) if (retmsg != NULL) { ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/libnetgraph/compat.c b/tools/libnetgraph/compat.c index 6a2b58a73..55b65ba2f 100644 --- a/tools/libnetgraph/compat.c +++ b/tools/libnetgraph/compat.c @@ -118,7 +118,7 @@ ngctl(int cmd, void *data, size_t len) if (retmsg != NULL) { ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/top/top.c b/tools/top/top.c index f09992cba..22c0b8905 100644 --- a/tools/top/top.c +++ b/tools/top/top.c @@ -32,7 +32,7 @@ int cpu_status(struct ff_top_args *top) ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg); diff --git a/tools/traffic/traffic.c b/tools/traffic/traffic.c index e306f7ed0..6abe6fe5a 100644 --- a/tools/traffic/traffic.c +++ b/tools/traffic/traffic.c @@ -32,7 +32,7 @@ int traffic_status(struct ff_traffic_args *traffic) ff_ipc_msg_free(retmsg); } - ret = ff_ipc_recv(&retmsg); + ret = ff_ipc_recv(&retmsg, msg->msg_type); if (ret < 0) { errno = EPIPE; ff_ipc_msg_free(msg);