From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Dai Subject: [PATCH 4/7] ethdev: add support of MTU restoration Date: Sat, 27 May 2017 16:22:06 +0800 Message-ID: <1495873329-43303-5-git-send-email-wei.dai@intel.com> References: <1495873329-43303-1-git-send-email-wei.dai@intel.com> Cc: dev@dpdk.org, Wei Dai To: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, helin.zhang@intel.com, jingjing.wu@intel.com Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id EE0302BA7 for ; Sat, 27 May 2017 10:31:23 +0200 (CEST) In-Reply-To: <1495873329-43303-1-git-send-email-wei.dai@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Wei Dai --- 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