From: Gaetan Rivet Date: Tue, 18 Jul 2017 12:48:22 +0000 (+0200) Subject: net/failsafe: support flow API isolation mode X-Git-Tag: spdx-start~2425 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2cc52cd76dff6387cb9bf0dcc0449a500d02fe8b;p=dpdk.git net/failsafe: support flow API isolation mode Signed-off-by: Gaetan Rivet --- diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index d205f61b8e..a3a8cce953 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -73,6 +73,28 @@ fs_flow_complain(struct rte_flow_error *error) return -err; } +static int +eth_dev_flow_isolate_set(struct rte_eth_dev *dev, + struct sub_device *sdev) +{ + struct rte_flow_error ferror; + int ret; + + if (!PRIV(dev)->flow_isolated) { + DEBUG("Flow isolation already disabled"); + } else { + DEBUG("Enabling flow isolation"); + ret = rte_flow_isolate(PORT_ID(sdev), + PRIV(dev)->flow_isolated, + &ferror); + if (ret) { + fs_flow_complain(&ferror); + return ret; + } + } + return 0; +} + static int fs_eth_dev_conf_apply(struct rte_eth_dev *dev, struct sub_device *sdev) @@ -334,9 +356,17 @@ failsafe_eth_dev_state_sync(struct rte_eth_dev *dev) if (PRIV(dev)->state < DEV_ACTIVE) return 0; inactive = 0; - FOREACH_SUBDEV(sdev, i, dev) - if (sdev->state == DEV_PROBED) + FOREACH_SUBDEV(sdev, i, dev) { + if (sdev->state == DEV_PROBED) { inactive |= UINT32_C(1) << i; + ret = eth_dev_flow_isolate_set(dev, sdev); + if (ret) { + ERROR("Could not apply configuration to sub_device %d", + i); + goto err_remove; + } + } + } ret = dev->dev_ops->dev_configure(dev); if (ret) goto err_remove; diff --git a/drivers/net/failsafe/failsafe_flow.c b/drivers/net/failsafe/failsafe_flow.c index 0098672bda..153ceeed48 100644 --- a/drivers/net/failsafe/failsafe_flow.c +++ b/drivers/net/failsafe/failsafe_flow.c @@ -206,10 +206,39 @@ fs_flow_query(struct rte_eth_dev *dev, return -1; } +static int +fs_flow_isolate(struct rte_eth_dev *dev, + int set, + struct rte_flow_error *error) +{ + struct sub_device *sdev; + uint8_t i; + int ret; + + FOREACH_SUBDEV(sdev, i, dev) { + if (sdev->state < DEV_PROBED) + continue; + DEBUG("Calling rte_flow_isolate on sub_device %d", i); + if (PRIV(dev)->flow_isolated != sdev->flow_isolated) + WARN("flow isolation mode of sub_device %d in incoherent state.", + i); + ret = rte_flow_isolate(PORT_ID(sdev), set, error); + if (ret) { + ERROR("Operation rte_flow_isolate failed for sub_device %d" + " with error %d", i, ret); + return ret; + } + sdev->flow_isolated = set; + } + PRIV(dev)->flow_isolated = set; + return 0; +} + const struct rte_flow_ops fs_flow_ops = { .validate = fs_flow_validate, .create = fs_flow_create, .destroy = fs_flow_destroy, .flush = fs_flow_flush, .query = fs_flow_query, + .isolate = fs_flow_isolate, }; diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 2c52d2ba4b..0361cf4346 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -108,6 +108,8 @@ struct sub_device { struct rte_eth_dev *fs_dev; /* flag calling for recollection */ volatile unsigned int remove:1; + /* flow isolation state */ + int flow_isolated:1; }; struct fs_priv { @@ -139,6 +141,8 @@ struct fs_priv { */ enum dev_state state; unsigned int pending_alarm:1; /* An alarm is pending */ + /* flow isolation state */ + int flow_isolated:1; }; /* MISC */