From: Matan Azrad Date: Sat, 20 Jan 2018 21:12:23 +0000 (+0000) Subject: ethdev: adjust removal error report in flow API X-Git-Tag: spdx-start~25 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2407c4e6e73b28f159fc42cf30dc4fd6a3e50d8b;p=dpdk.git ethdev: adjust removal error report in flow API rte_eth_dev_is_removed API was added to detect a device removal synchronously. When a device removal occurs during flow command execution, many different errors can be reported to the user. Adjust all flow APIs error reports to return -EIO in case of device removal using rte_eth_dev_is_removed API. Signed-off-by: Matan Azrad Acked-by: Thomas Monjalon --- diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 913d1a55a2..a86bfbd1a4 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -107,6 +107,18 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), }; +static int +flow_err(uint16_t port_id, int ret, struct rte_flow_error *error) +{ + if (ret == 0) + return 0; + if (rte_eth_dev_is_removed(port_id)) + return rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(EIO)); + return ret; +} + /* Get generic flow operations structure from a port. */ const struct rte_flow_ops * rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error) @@ -145,7 +157,8 @@ rte_flow_validate(uint16_t port_id, if (unlikely(!ops)) return -rte_errno; if (likely(!!ops->validate)) - return ops->validate(dev, attr, pattern, actions, error); + return flow_err(port_id, ops->validate(dev, attr, pattern, + actions, error), error); return rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); @@ -160,12 +173,17 @@ rte_flow_create(uint16_t port_id, struct rte_flow_error *error) { struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct rte_flow *flow; const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); if (unlikely(!ops)) return NULL; - if (likely(!!ops->create)) - return ops->create(dev, attr, pattern, actions, error); + if (likely(!!ops->create)) { + flow = ops->create(dev, attr, pattern, actions, error); + if (flow == NULL) + flow_err(port_id, -rte_errno, error); + return flow; + } rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); return NULL; @@ -183,7 +201,8 @@ rte_flow_destroy(uint16_t port_id, if (unlikely(!ops)) return -rte_errno; if (likely(!!ops->destroy)) - return ops->destroy(dev, flow, error); + return flow_err(port_id, ops->destroy(dev, flow, error), + error); return rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); @@ -200,7 +219,7 @@ rte_flow_flush(uint16_t port_id, if (unlikely(!ops)) return -rte_errno; if (likely(!!ops->flush)) - return ops->flush(dev, error); + return flow_err(port_id, ops->flush(dev, error), error); return rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); @@ -220,7 +239,8 @@ rte_flow_query(uint16_t port_id, if (!ops) return -rte_errno; if (likely(!!ops->query)) - return ops->query(dev, flow, action, data, error); + return flow_err(port_id, ops->query(dev, flow, action, data, + error), error); return rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); @@ -238,7 +258,7 @@ rte_flow_isolate(uint16_t port_id, if (!ops) return -rte_errno; if (likely(!!ops->isolate)) - return ops->isolate(dev, set, error); + return flow_err(port_id, ops->isolate(dev, set, error), error); return rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOSYS)); diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index e0402cf92a..07ec217ca6 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1267,6 +1267,8 @@ struct rte_flow_error { * * -ENOSYS: underlying device does not support this functionality. * + * -EIO: underlying device is removed. + * * -EINVAL: unknown or invalid rule specification. * * -ENOTSUP: valid but unsupported rule specification (e.g. partial