From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 743CB7EB0 for ; Tue, 7 Jun 2016 08:13:03 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 06 Jun 2016 23:13:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,432,1459839600"; d="scan'208";a="117318740" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga004.fm.intel.com with ESMTP; 06 Jun 2016 23:13:00 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u576Cslx028950; Tue, 7 Jun 2016 14:12:54 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u576CphQ005558; Tue, 7 Jun 2016 14:12:53 +0800 Received: (from zhetao@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u576CpX1005554; Tue, 7 Jun 2016 14:12:51 +0800 From: Zhe Tao To: dev@dpdk.org Cc: wenzhuo.lu@intel.com, zhe.tao@intel.com, konstantin.ananyev@intel.com, bruce.richardson@intel.com, jing.d.chen@intel.com, cunming.liang@intel.com, jingjing.wu@intel.com, helin.zhang@intel.com Date: Tue, 7 Jun 2016 14:12:41 +0800 Message-Id: <1465279968-5515-2-git-send-email-zhe.tao@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1465279968-5515-1-git-send-email-zhe.tao@intel.com> References: <1465279968-5515-1-git-send-email-zhe.tao@intel.com> Subject: [dpdk-dev] [PATCH v3 1/8] lib/librte_ether: support device reset X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2016 06:13:03 -0000 Add an API to reset 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 reset VF port. Most likely, APP should call it in its management thread and guarantee the thread safe. Signed-off-by: Wenzhuo Lu --- lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++ lib/librte_ether/rte_ether_version.map | 7 +++++++ 3 files changed, 38 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index e148028..e43dca9 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3346,3 +3346,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, -EINVAL); + + 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 2757510..74e895f 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1318,6 +1318,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,8 @@ struct eth_dev_ops { eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf; /** Enable/disable l2 tunnel offload functions */ eth_l2_tunnel_offload_set_t l2_tunnel_offload_set; + /** Reset device. */ + eth_dev_reset_t dev_reset; }; /** @@ -4253,6 +4258,15 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id, uint32_t mask, uint8_t en); +/** + * Reset an Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + */ +int +rte_eth_dev_reset(uint8_t port_id); + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 214ecc7..c34207e 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -132,3 +132,10 @@ DPDK_16.04 { rte_eth_tx_buffer_set_err_callback; } DPDK_2.2; + +DPDK_16.07 { + global: + + rte_eth_dev_reset; + +} DPDK_16.04; -- 2.1.4