From patchwork Sat May 27 08:22:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Dai X-Patchwork-Id: 24744 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 579D647CE; Sat, 27 May 2017 10:31:34 +0200 (CEST) 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) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2017 01:31:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.38,400,1491289200"; d="scan'208"; a="1135329756" Received: from dpdk6.bj.intel.com ([172.16.182.81]) by orsmga001.jf.intel.com with ESMTP; 27 May 2017 01:31:22 -0700 From: Wei Dai To: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, helin.zhang@intel.com, jingjing.wu@intel.com Cc: dev@dpdk.org, Wei Dai Date: Sat, 27 May 2017 16:22:06 +0800 Message-Id: <1495873329-43303-5-git-send-email-wei.dai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495873329-43303-1-git-send-email-wei.dai@intel.com> References: <1495873329-43303-1-git-send-email-wei.dai@intel.com> Subject: [dpdk-dev] [PATCH 4/7] ethdev: add support of MTU restoration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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 */