Skip to content

Commit

Permalink
Tools: All tools can work in parallel now.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfb8856606 committed Jul 25, 2019
1 parent 10b909a commit 6194fcd
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 22 deletions.
23 changes: 12 additions & 11 deletions lib/ff_dpdk_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/ff_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tools/compat/ff_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/compat/ff_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tools/compat/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/compat/rtioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/compat/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/ipfw/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/libnetgraph/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/top/top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/traffic/traffic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6194fcd

Please sign in to comment.