X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Fhotplug_mp.c;h=ee791903b3b74fe73240cbdcf2305128cda36b49;hb=f002ee9c8e26d2d7f0cda418d2565adc696584cf;hp=9d610a8a201487e5fad07b2af95724f4b910474e;hpb=e14bc93e8f231455ac7ffb45189f8dedcc45276d;p=dpdk.git diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 9d610a8a20..ee791903b3 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -200,6 +201,11 @@ handle_secondary_request(const struct rte_mp_msg *msg, const void *peer) * when it is ready. */ bundle->peer = strdup(peer); + if (bundle->peer == NULL) { + free(bundle); + RTE_LOG(ERR, EAL, "not enough memory\n"); + return send_response_to_secondary(req, -ENOMEM, peer); + } /** * We are at IPC callback thread, sync IPC is not allowed due to @@ -313,6 +319,7 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer) bundle = calloc(1, sizeof(*bundle)); if (bundle == NULL) { + RTE_LOG(ERR, EAL, "not enough memory\n"); resp->result = -ENOMEM; ret = rte_mp_reply(&mp_resp, peer); if (ret) @@ -327,6 +334,15 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer) * when it is ready. */ bundle->peer = (void *)strdup(peer); + if (bundle->peer == NULL) { + RTE_LOG(ERR, EAL, "not enough memory\n"); + free(bundle); + resp->result = -ENOMEM; + ret = rte_mp_reply(&mp_resp, peer); + if (ret) + RTE_LOG(ERR, EAL, "failed to send reply to primary request\n"); + return ret; + } /** * We are at IPC callback thread, sync IPC is not allowed due to @@ -361,7 +377,7 @@ int eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req) ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts); if (ret || mp_reply.nb_received != 1) { - RTE_LOG(ERR, EAL, "cannot send request to primary"); + RTE_LOG(ERR, EAL, "Cannot send request to primary\n"); if (!ret) return -1; return ret; @@ -389,7 +405,11 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_mp_request_sync failed\n"); + /* if IPC is not supported, behave as if the call succeeded */ + if (rte_errno != ENOTSUP) + RTE_LOG(ERR, EAL, "rte_mp_request_sync failed\n"); + else + ret = 0; return ret; } @@ -418,14 +438,15 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) return 0; } -int rte_mp_dev_hotplug_init(void) +int eal_mp_dev_hotplug_init(void) { int ret; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { ret = rte_mp_action_register(EAL_DEV_MP_ACTION_REQUEST, handle_secondary_request); - if (ret != 0) { + /* primary is allowed to not support IPC */ + if (ret != 0 && rte_errno != ENOTSUP) { RTE_LOG(ERR, EAL, "Couldn't register '%s' action\n", EAL_DEV_MP_ACTION_REQUEST); return ret;