From patchwork Thu Aug 27 15:40:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iremonger, Bernard" X-Patchwork-Id: 6801 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 D5BD28D8B; Thu, 27 Aug 2015 17:40:51 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A877A5927 for ; Thu, 27 Aug 2015 17:40:48 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 27 Aug 2015 08:40:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,422,1437462000"; d="scan'208";a="549646577" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 27 Aug 2015 08:40:46 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t7RFej8A004300; Thu, 27 Aug 2015 16:40:45 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t7RFej6S032439; Thu, 27 Aug 2015 16:40:45 +0100 Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id t7RFejBu032435; Thu, 27 Aug 2015 16:40:45 +0100 From: Bernard Iremonger To: dev@dpdk.org Date: Thu, 27 Aug 2015 16:40:36 +0100 Message-Id: <1440690041-32391-2-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1440690041-32391-1-git-send-email-bernard.iremonger@intel.com> References: <1440690041-32391-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [RFC PATCH 1/6] librte_ether: add fields from rte_pci_driver to rte_eth_dev and rte_eth_dev_data. 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" add dev_flags to rte_eth_dev, add macros for dev_flags. add numa_node to rte_eth_dev_data. use dev_type to distinguish between vdev's and pdev's. remove unused RTE_ETH_DEV_MAX. Signed-off-by: Bernard Iremonger --- lib/librte_ether/rte_ethdev.c | 19 +++++++++++++++---- lib/librte_ether/rte_ethdev.h | 8 +++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 6b2400c..64e5a20 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -260,6 +260,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type) eth_dev->data->port_id = port_id; eth_dev->attached = DEV_ATTACHED; eth_dev->dev_type = type; + eth_dev->dev_flags = 0; nb_ports++; return eth_dev; } @@ -424,7 +425,10 @@ rte_eth_dev_socket_id(uint8_t port_id) { if (!rte_eth_dev_is_valid_port(port_id)) return -1; - return rte_eth_devices[port_id].pci_dev->numa_node; + if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) + return rte_eth_devices[port_id].pci_dev->numa_node; + else + return rte_eth_devices[port_id].data->numa_node; } uint8_t @@ -504,6 +508,7 @@ static int rte_eth_dev_is_detachable(uint8_t port_id) { uint32_t drv_flags; + uint32_t dev_flags; if (!rte_eth_dev_is_valid_port(port_id)) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); @@ -520,10 +525,14 @@ rte_eth_dev_is_detachable(uint8_t port_id) default: return -ENOTSUP; } + drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags; + return !(drv_flags & RTE_PCI_DRV_DETACHABLE); + } else if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_VIRTUAL) { + dev_flags = rte_eth_devices[port_id].dev_flags; + return !(dev_flags & RTE_ETH_DEV_DETACHABLE); } - drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags; - return !(drv_flags & RTE_PCI_DRV_DETACHABLE); + return -ENOTSUP; } /* attach the new physical device, then store port_id of the device */ @@ -1795,8 +1804,10 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info) FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; - if (dev->driver) + if (dev->dev_type == RTE_ETH_DEV_PCI) dev_info->driver_name = dev->driver->pci_drv.name; + else + dev_info->driver_name = dev->data->name; } void diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 544afe0..a0a648f 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1553,7 +1553,6 @@ enum rte_eth_dev_type { RTE_ETH_DEV_PCI, /**< Physical function and Virtual function of PCI devices */ RTE_ETH_DEV_VIRTUAL, /**< non hardware device */ - RTE_ETH_DEV_MAX /**< max value of this enum */ }; /** @@ -1587,8 +1586,14 @@ struct rte_eth_dev { struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; uint8_t attached; /**< Flag indicating the port is attached */ enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */ + uint32_t dev_flags; /**< Flags controlling handling of device. */ }; +/** Device supports link state interrupt */ +#define RTE_ETH_DEV_INTR_LSC 0x0008 +/** Device supports detaching capability */ +#define RTE_ETH_DEV_DETACHABLE 0x0010 + struct rte_eth_dev_sriov { uint8_t active; /**< SRIOV is active with 16, 32 or 64 pools */ uint8_t nb_q_per_pool; /**< rx queue number per pool */ @@ -1639,6 +1644,7 @@ struct rte_eth_dev_data { all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */ dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */ lro : 1; /**< RX LRO is ON(1) / OFF(0) */ + int numa_node; }; /**