git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/ice/base: fix flow director rule completion report
[dpdk.git]
/
lib
/
librte_eal
/
common
/
hotplug_mp.c
diff --git
a/lib/librte_eal/common/hotplug_mp.c
b/lib/librte_eal/common/hotplug_mp.c
index
d9e6790
..
ee79190
100644
(file)
--- a/
lib/librte_eal/common/hotplug_mp.c
+++ b/
lib/librte_eal/common/hotplug_mp.c
@@
-4,6
+4,7
@@
#include <string.h>
#include <rte_eal.h>
#include <string.h>
#include <rte_eal.h>
+#include <rte_errno.h>
#include <rte_alarm.h>
#include <rte_string_fns.h>
#include <rte_devargs.h>
#include <rte_alarm.h>
#include <rte_string_fns.h>
#include <rte_devargs.h>
@@
-87,7
+88,7
@@
__handle_secondary_request(void *param)
const struct eal_dev_mp_req *req =
(const struct eal_dev_mp_req *)msg->param;
struct eal_dev_mp_req tmp_req;
const struct eal_dev_mp_req *req =
(const struct eal_dev_mp_req *)msg->param;
struct eal_dev_mp_req tmp_req;
- struct rte_devargs
*
da;
+ struct rte_devargs da;
struct rte_device *dev;
struct rte_bus *bus;
int ret = 0;
struct rte_device *dev;
struct rte_bus *bus;
int ret = 0;
@@
-114,15
+115,11
@@
__handle_secondary_request(void *param)
goto rollback;
}
} else if (req->t == EAL_DEV_REQ_TYPE_DETACH) {
goto rollback;
}
} else if (req->t == EAL_DEV_REQ_TYPE_DETACH) {
- da = calloc(1, sizeof(*da));
- if (da == NULL) {
- ret = -ENOMEM;
- goto finish;
- }
-
- ret = rte_devargs_parse(da, req->devargs);
+ ret = rte_devargs_parse(&da, req->devargs);
if (ret != 0)
goto finish;
if (ret != 0)
goto finish;
+ free(da.args); /* we don't need those */
+ da.args = NULL;
ret = eal_dev_hotplug_request_to_secondary(&tmp_req);
if (ret != 0) {
ret = eal_dev_hotplug_request_to_secondary(&tmp_req);
if (ret != 0) {
@@
-131,16
+128,16
@@
__handle_secondary_request(void *param)
goto rollback;
}
goto rollback;
}
- bus = rte_bus_find_by_name(da
->
bus->name);
+ bus = rte_bus_find_by_name(da
.
bus->name);
if (bus == NULL) {
if (bus == NULL) {
- RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da
->
bus->name);
+ RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da
.
bus->name);
ret = -ENOENT;
goto finish;
}
ret = -ENOENT;
goto finish;
}
- dev = bus->find_device(NULL, cmp_dev_name, da
->
name);
+ dev = bus->find_device(NULL, cmp_dev_name, da
.
name);
if (dev == NULL) {
if (dev == NULL) {
- RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da
->
name);
+ RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da
.
name);
ret = -ENOENT;
goto finish;
}
ret = -ENOENT;
goto finish;
}
@@
-204,6
+201,11
@@
handle_secondary_request(const struct rte_mp_msg *msg, const void *peer)
* when it is ready.
*/
bundle->peer = strdup(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
/**
* We are at IPC callback thread, sync IPC is not allowed due to
@@
-212,6
+214,8
@@
handle_secondary_request(const struct rte_mp_msg *msg, const void *peer)
ret = rte_eal_alarm_set(1, __handle_secondary_request, bundle);
if (ret != 0) {
RTE_LOG(ERR, EAL, "failed to add mp task\n");
ret = rte_eal_alarm_set(1, __handle_secondary_request, bundle);
if (ret != 0) {
RTE_LOG(ERR, EAL, "failed to add mp task\n");
+ free(bundle->peer);
+ free(bundle);
return send_response_to_secondary(req, ret, peer);
}
return 0;
return send_response_to_secondary(req, ret, peer);
}
return 0;
@@
-315,6
+319,7
@@
handle_primary_request(const struct rte_mp_msg *msg, const void *peer)
bundle = calloc(1, sizeof(*bundle));
if (bundle == NULL) {
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)
resp->result = -ENOMEM;
ret = rte_mp_reply(&mp_resp, peer);
if (ret)
@@
-329,6
+334,15
@@
handle_primary_request(const struct rte_mp_msg *msg, const void *peer)
* when it is ready.
*/
bundle->peer = (void *)strdup(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
/**
* We are at IPC callback thread, sync IPC is not allowed due to
@@
-336,6
+350,8
@@
handle_primary_request(const struct rte_mp_msg *msg, const void *peer)
*/
ret = rte_eal_alarm_set(1, __handle_primary_request, bundle);
if (ret != 0) {
*/
ret = rte_eal_alarm_set(1, __handle_primary_request, bundle);
if (ret != 0) {
+ free(bundle->peer);
+ free(bundle);
resp->result = ret;
ret = rte_mp_reply(&mp_resp, peer);
if (ret != 0) {
resp->result = ret;
ret = rte_mp_reply(&mp_resp, peer);
if (ret != 0) {
@@
-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) {
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;
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) {
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;
}
return ret;
}
@@
-404,13
+424,13
@@
int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
struct eal_dev_mp_req *resp =
(struct eal_dev_mp_req *)mp_reply.msgs[i].param;
if (resp->result != 0) {
struct eal_dev_mp_req *resp =
(struct eal_dev_mp_req *)mp_reply.msgs[i].param;
if (resp->result != 0) {
- req->result = resp->result;
if (req->t == EAL_DEV_REQ_TYPE_ATTACH &&
if (req->t == EAL_DEV_REQ_TYPE_ATTACH &&
- re
q->result !
= -EEXIST)
-
break
;
+ re
sp->result =
= -EEXIST)
+
continue
;
if (req->t == EAL_DEV_REQ_TYPE_DETACH &&
if (req->t == EAL_DEV_REQ_TYPE_DETACH &&
- req->result != -ENOENT)
- break;
+ resp->result == -ENOENT)
+ continue;
+ req->result = resp->result;
}
}
}
}
@@
-418,14
+438,15
@@
int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
return 0;
}
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);
{
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;
RTE_LOG(ERR, EAL, "Couldn't register '%s' action\n",
EAL_DEV_MP_ACTION_REQUEST);
return ret;