From patchwork Fri Mar 3 04:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao1, Wei" X-Patchwork-Id: 21176 X-Patchwork-Delegate: thomas@monjalon.net 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 84F86C304; Fri, 3 Mar 2017 06:03:52 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AEEEB2B9D for ; Fri, 3 Mar 2017 06:03:14 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2017 21:03:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,235,1484035200"; d="scan'208";a="830405473" Received: from dpdk1.bj.intel.com ([172.16.182.84]) by FMSMGA003.fm.intel.com with ESMTP; 02 Mar 2017 21:03:12 -0800 From: Wei Zhao To: dev@dpdk.org Cc: Wei Zhao , Wenzhuo Lu Date: Fri, 3 Mar 2017 12:56:23 +0800 Message-Id: <1488516984-34702-3-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1488516984-34702-1-git-send-email-wei.zhao1@intel.com> References: <1488516984-34702-1-git-send-email-wei.zhao1@intel.com> Subject: [dpdk-dev] [PATCH 2/3] lib/librte_ether: add support for port 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for vf port reset in rte layer. Add an API to restart the device. It's for VF device in this scenario, kernel PF + DPDK VF. When the PF port down->up, APP should call this API to restart VF port. Most likely, APP should call it in its management thread and guarantee the thread safe. It means APP should stop the rx/tx and the device, then restart the device, then recover the device and rx/tx. Also, it's APP's responsibilty to release the occupied memory. Signed-off-by: Wei Zhao Signed-off-by: Wenzhuo Lu --- app/test-pmd/testpmd.c | 1 + lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 25 +++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 6 ++++++ 4 files changed, 49 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 12b7aaa..44fcc51 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1615,6 +1615,7 @@ reset_port(portid_t pid) continue; } + rte_eth_dev_reset(pi); reset_ports[pi] = 0; if (rte_atomic16_cmpset(&(port->port_status), diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index eb0a94a..2e06dca 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3273,3 +3273,20 @@ 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 diag; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP); + + diag = (*dev->dev_ops->dev_reset)(dev); + + return diag; +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 97f3e2d..77a5b79 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1367,6 +1367,9 @@ typedef int (*eth_l2_tunnel_offload_set_t) uint8_t en); /**< @internal enable/disable the l2 tunnel offload functions */ +typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); +/**< @internal Function used to reset a configured Ethernet device. */ + #ifdef RTE_NIC_BYPASS enum { @@ -1508,6 +1511,9 @@ struct eth_dev_ops { eth_l2_tunnel_offload_set_t l2_tunnel_offload_set; /** Enable/disable l2 tunnel offload functions. */ + /** Reset device. */ + eth_dev_reset_t dev_reset; + eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */ rss_hash_update_t rss_hash_update; /** Configure RSS hash protocols. */ @@ -4407,6 +4413,25 @@ int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name); /** + * Reset an ethernet device when it's not working. One scenario is, after PF + * port is down and up, the related VF port should be reset. + * The API will stop the port, clear the rx/tx queues, re-setup the rx/tx + * queues, restart the port. + * Before calling this API, APP should stop the rx/tx. When tx is being stopped, + * APP can drop the packets and release the buffer instead of sending them. + * + * @param port_id + * The port identifier of the Ethernet device. + * + * @return + * - (0) if successful. + * - (-ENODEV) if port identifier is invalid. + * - (-ENOTSUP) if hardware doesn't support this function. + */ +int +rte_eth_dev_reset(uint8_t port_id); + +/** * @internal * Wrapper for use by pci drivers as a .probe function to attach to a ethdev * interface. diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index c6c9d0d..529b27f 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -154,3 +154,9 @@ DPDK_17.02 { rte_flow_validate; } DPDK_16.11; + +DPDK_17.05 { + global: + + rte_eth_dev_reset; +} DPDK_17.02; \ No newline at end of file