From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3C2D3374 for ; Thu, 29 Jun 2017 10:37:23 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2017 01:37:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,279,1496127600"; d="scan'208";a="1166044858" Received: from dw2.bj.intel.com ([172.16.117.107]) by fmsmga001.fm.intel.com with ESMTP; 29 Jun 2017 01:37:21 -0700 From: Wei Dai To: thomas@monjalon.net, wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, helin.zhang@intel.com, jingjing.wu@intel.com, yuan.peng@intel.com Cc: dev@dpdk.org, Wei Dai Date: Thu, 29 Jun 2017 16:34:01 +0800 Message-Id: <20170629083404.1271-2-wei.dai@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629083404.1271-1-wei.dai@intel.com> References: <1498572438-25125-1-git-send-email-wei.dai@intel.com> <20170629083404.1271-1-wei.dai@intel.com> Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: add support of NIC reset 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: , X-List-Received-Date: Thu, 29 Jun 2017 08:37:24 -0000 A DPDK application can reset a NIC and keep its port id afterwards. It means that all SW resources allocated in ethdev layer should be kept and SW and HW resources of the NIC in PMD need to be reset in similar way that it runs PCI dev_uninit() and then dev_init(). The sequence of dev_uninit() and dev_init() can be packed into a single interface API rte_eth_dev_reset(). Signed-off-by: Wei Dai --- lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++ lib/librte_ether/rte_ethdev.h | 12 ++++++++++++ lib/librte_ether/rte_ether_version.map | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 81a45c0..06b8839 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3349,3 +3349,19 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id, -ENOTSUP); return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en); } + +int +rte_eth_dev_reset(uint8_t port_id) +{ + struct rte_eth_dev *dev; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP); + + rte_eth_dev_stop(port_id); + ret = dev->dev_ops->dev_reset(dev); + return ret; +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index f6e6c74..4922b36 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1087,6 +1087,9 @@ typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev); typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev); /**< @internal Function used to close a configured Ethernet device. */ +typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); +/** <@internal Function used to reset a configured Ethernet device. */ + typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev); /**< @internal Function used to enable the RX promiscuous mode of an Ethernet device. */ @@ -1404,6 +1407,7 @@ struct eth_dev_ops { eth_dev_set_link_up_t dev_set_link_up; /**< Device link up. */ eth_dev_set_link_down_t dev_set_link_down; /**< Device link down. */ eth_dev_close_t dev_close; /**< Close device. */ + eth_dev_reset_t dev_reset; /**< Reset device. */ eth_link_update_t link_update; /**< Get device link state. */ eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */ @@ -2104,6 +2108,14 @@ int rte_eth_dev_set_link_down(uint8_t port_id); void rte_eth_dev_close(uint8_t port_id); /** + * Reset a Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + */ +int rte_eth_dev_reset(uint8_t port_id); + +/** * Enable receipt in promiscuous mode for an Ethernet device. * * @param port_id diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index e0881f0..d569bcb 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -153,5 +153,5 @@ DPDK_17.08 { global: rte_flow_isolate; - + rte_eth_dev_reset; } DPDK_17.05; -- 2.9.3