X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_proc.c;h=6d1af3c0e756a2975bb1390a5770b916daaf75ca;hb=e863fe3a13da89787fdf3b5c590101a3c0f10af6;hp=c649789a52756e26555c125cc10745b701167540;hpb=57a2efb304775135e320acde1e0622b1190bffa9;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index c649789a52..6d1af3c0e7 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -29,6 +29,7 @@ #include #include +#include "eal_memcfg.h" #include "eal_private.h" #include "eal_filesystem.h" #include "eal_internal_cfg.h" @@ -422,7 +423,7 @@ process_async_request(struct pending_request *sr, const struct timespec *now) /* did we timeout? */ timeout = timespec_cmp(¶m->end, now) <= 0; - /* if we received a response, adjust relevant data and copy mesasge. */ + /* if we received a response, adjust relevant data and copy message. */ if (sr->reply_received == 1 && sr->reply) { struct rte_mp_msg *msg, *user_msgs, *tmp; @@ -629,7 +630,7 @@ rte_mp_channel_init(void) if (rte_ctrl_thread_create(&mp_handle_tid, "rte_mp_handle", NULL, mp_handle, NULL) < 0) { - RTE_LOG(ERR, EAL, "failed to create mp thead: %s\n", + RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n", strerror(errno)); close(mp_fd); close(dir_fd); @@ -1232,3 +1233,43 @@ rte_mp_reply(struct rte_mp_msg *msg, const char *peer) return mp_send(msg, peer, MP_REP); } + +/* Internally, the status of the mp feature is represented as a three-state: + * - "unknown" as long as no secondary process attached to a primary process + * and there was no call to rte_mp_disable yet, + * - "enabled" as soon as a secondary process attaches to a primary process, + * - "disabled" when a primary process successfully called rte_mp_disable, + */ +enum mp_status { + MP_STATUS_UNKNOWN, + MP_STATUS_DISABLED, + MP_STATUS_ENABLED, +}; + +static bool +set_mp_status(enum mp_status status) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + uint8_t expected; + uint8_t desired; + + expected = MP_STATUS_UNKNOWN; + desired = status; + if (__atomic_compare_exchange_n(&mcfg->mp_status, &expected, desired, + false, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + return true; + + return __atomic_load_n(&mcfg->mp_status, __ATOMIC_RELAXED) == desired; +} + +bool +rte_mp_disable(void) +{ + return set_mp_status(MP_STATUS_DISABLED); +} + +bool +__rte_mp_enable(void) +{ + return set_mp_status(MP_STATUS_ENABLED); +}