[dpdk-dev] [PATCH 4/7] ethdev: add support of MTU restoration
Wei Dai
wei.dai at intel.com
Sat May 27 10:22:06 CEST 2017
Signed-off-by: Wei Dai <wei.dai at intel.com>
---
lib/librte_ether/rte_ethdev.c | 23 +++++++++++++++++++++--
lib/librte_ether/rte_ethdev.h | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index af8ccf6..0d9544c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -945,6 +945,22 @@ rte_eth_dev_link_status_restore(uint8_t port_id)
}
static void
+rte_eth_dev_mtu_restore(uint8_t port_id)
+{
+ struct rte_eth_dev *dev;
+
+ dev = &rte_eth_devices[port_id];
+
+ if (dev->data->in_restoration == 0) {
+ dev->data->restore_mtu = dev->data->mtu;
+ return;
+ }
+
+ if (dev->data->restore_mtu != dev->data->mtu)
+ rte_eth_dev_set_mtu(port_id, dev->data->restore_mtu);
+}
+
+static void
rte_eth_dev_config_restore(uint8_t port_id)
{
struct rte_eth_dev *dev;
@@ -1005,6 +1021,8 @@ rte_eth_dev_config_restore(uint8_t port_id)
rte_eth_dev_tx_queue_restore(port_id, q);
rte_eth_dev_link_status_restore(port_id);
+
+ rte_eth_dev_mtu_restore(port_id);
}
int
@@ -2106,9 +2124,10 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
ret = (*dev->dev_ops->mtu_set)(dev, mtu);
- if (!ret)
+ if (!ret) {
dev->data->mtu = mtu;
-
+ dev->data->restore_mtu = mtu;
+ }
return ret;
}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9428f57..aca8510 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1739,6 +1739,7 @@ struct rte_eth_dev_data {
struct rte_eth_conf dev_conf; /**< Configuration applied to device. */
uint16_t mtu; /**< Maximum Transmission Unit. */
+ uint16_t restore_mtu;
uint32_t min_rx_buf_size;
/**< Common rx buffer size handled by all queues */
--
2.7.4
More information about the dev
mailing list