From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E09965A32 for ; Tue, 3 Nov 2015 14:02:11 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 03 Nov 2015 05:02:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,238,1444719600"; d="scan'208";a="841480971" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 03 Nov 2015 05:02:10 -0800 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 tA3D29ig011904; Tue, 3 Nov 2015 13:02:09 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id tA3D29n4019596; Tue, 3 Nov 2015 13:02:09 GMT Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id tA3D29Tf019591; Tue, 3 Nov 2015 13:02:09 GMT From: Bernard Iremonger To: dev@dpdk.org Date: Tue, 3 Nov 2015 13:01:55 +0000 Message-Id: <1446555725-19540-2-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1446555725-19540-1-git-send-email-bernard.iremonger@intel.com> References: <1446555725-19540-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH v8 01/11] librte_ether: add fields from rte_pci_driver to 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: , X-List-Received-Date: Tue, 03 Nov 2015 13:02:12 -0000 The driver fields have been added the rte_eth_dev_data so that it is no longer necessary access this data through the pci_dev pointer. The following fields have been added to rte_eth_dev_data: dev_flags, and macros for dev_flags. kdrv numa_node drv_name add function rte_eth_copy_pci_info remove branches on pci_dev librte_eal: add RTE_KDRV_NONE for vdevs Signed-off-by: Bernard Iremonger --- lib/librte_eal/common/include/rte_pci.h | 3 ++- lib/librte_ether/rte_ethdev.c | 24 ++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 27 +++++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 83e3c28..334c12e 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,6 +149,7 @@ enum rte_kernel_driver { RTE_KDRV_VFIO, RTE_KDRV_UIO_GENERIC, RTE_KDRV_NIC_UIO, + RTE_KDRV_NONE, }; /** diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 39f65bf..04eff73 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3229,3 +3229,27 @@ rte_eth_dev_get_dcb_info(uint8_t port_id, FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_dcb_info, -ENOTSUP); return (*dev->dev_ops->get_dcb_info)(dev, dcb_info); } + +void +rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev) +{ + if ((eth_dev == NULL) || (pci_dev == NULL)) { + PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n", + eth_dev, pci_dev); + } + + eth_dev->data->dev_flags = 0; + + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_NEED_MAPPING) + eth_dev->data->dev_flags |= RTE_ETH_DEV_DRV_NEED_MAPPING; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_FORCE_UNBIND) + eth_dev->data->dev_flags |= RTE_ETH_DEV_DRV_FORCE_UNBIND; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_DETACHABLE) + eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; + + eth_dev->data->kdrv = pci_dev->kdrv; + eth_dev->data->numa_node = pci_dev->numa_node; + eth_dev->data->drv_name = pci_dev->driver->name; +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index c835a2f..2e5b9b8 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1551,8 +1551,21 @@ 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) */ + uint32_t dev_flags; /**< Flags controlling handling of device. */ + enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ + int numa_node; /**< NUMA node connection */ + const char *drv_name; /**< Driver name */ }; +/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */ +#define RTE_ETH_DEV_DRV_NEED_MAPPING 0x0001 +/** Device needs to be unbound even if no module is provided */ +#define RTE_ETH_DEV_DRV_FORCE_UNBIND 0x0002 +/** Device supports link state interrupt */ +#define RTE_ETH_DEV_INTR_LSC 0x0003 +/** Device supports detaching capability */ +#define RTE_ETH_DEV_DETACHABLE 0x0004 + /** * @internal * The pool of *rte_eth_dev* structures. The size of the pool @@ -3733,6 +3746,20 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id, extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp); +/** + * Copy pci device info to the Ethernet device data. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure. + * @param pci_dev + * The *pci_dev* pointer is the address of the *rte_pci_device* structure. + * + * @return + * - 0 on success, negative on error + */ +extern void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev); + + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 7b04e95..08c97f4 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -134,5 +134,6 @@ DPDK_2.2 { rte_eth_dev_get_dcb_info; rte_eth_rx_queue_info_get; rte_eth_tx_queue_info_get; + rte_eth_copy_pci_info; } DPDK_2.1; -- 1.9.1