From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 7E77E10CFA for ; Wed, 21 Dec 2016 16:10:33 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id l2so5473193wml.2 for ; Wed, 21 Dec 2016 07:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hoe7G3rNDoiKxANEjaioQBl1SRrh85bZxgb/LIo4ryo=; b=mQAhOZhUEnD1hZ79HOFSyylzsVPyN9FrnFqDAaf4h3xxowbXxA50mBD1rMwbvRvJ+k fMI+W2RTukH3I/i3C37hDwbP4D3nM3gPqIItOyYvJxY20EyCEu5tTIqNEiyslHlEABcn zCADeCA0OU/m/fqWFMSOEdatDEwhHIL0HJ5vtGiRFaAVU4OpyCA7LupeBLwvON4l/8pP j/dXkrR/9vymXHBaxQ0it32To4NNXEWfM44sALFaGomf7ifF0LjFRroJ2dMh4GvPoqQn E+hCCUpZz3J+7ucVzZXAvV5NoMalg8tEgCdhLvn/Mtgflmq5aHruOhLc/ySmuzxKVO38 84qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Hoe7G3rNDoiKxANEjaioQBl1SRrh85bZxgb/LIo4ryo=; b=XrnRckUhqoNgFfXkPZaNxG1sIu64RiKlw7ZFySk53xYLXDltD2KgfIGI+wT6rRYbJW fi4VX2x9R0jDBJDapUytlqHQ0su/zTeoFXs3ECfPh90n3U1pNacQE6nyIClE6VbOQeTT y5itHvTbeBeRcxhIBlk+xAP3DcblKBJtX2vmxz6hv6wdLH3OfgqlVxhP/RRrrc/+Iu5N 2d7phq7Y1dLA63BBeqUx8MiduqP1ZR+uGzBSqFlxNSiLvm7Xh4WIu0XDzQY+SlBIjQF3 hA7LRp/ycRtZYgmMFWqwqqAZSoB8Wi9Ian4dMP05gtLapY0jDh45N9JlXEELZEd/pTEO BSxQ== X-Gm-Message-State: AIkVDXJ4AyGwG1CXzoqBiKhARo4W5TeoH1+1Wx9udB6SAL/x5QiisuAWrn45x6JXhAaVJA== X-Received: by 10.28.109.156 with SMTP id b28mr5335258wmi.116.1482333033186; Wed, 21 Dec 2016 07:10:33 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id 135sm27627375wmh.14.2016.12.21.07.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Dec 2016 07:10:32 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: shreyansh.jain@nxp.com, david.marchand@6wind.com, stephen@networkplumber.org Date: Wed, 21 Dec 2016 16:09:46 +0100 Message-Id: <1482332986-7599-24-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482332986-7599-1-git-send-email-jblunck@infradead.org> References: <1482332986-7599-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v4 23/23] ethdev: Decouple struct rte_eth_dev from struct rte_pci_device 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: Wed, 21 Dec 2016 15:10:33 -0000 Signed-off-by: Jan Blunck Acked-by: Shreyansh Jain --- app/test/virtual_pmd.c | 4 ++-- drivers/net/bonding/rte_eth_bond_args.c | 12 ++++++++++-- drivers/net/cxgbe/cxgbe_main.c | 4 ++-- drivers/net/fm10k/fm10k_ethdev.c | 6 +++--- drivers/net/mlx4/mlx4.c | 2 +- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/virtio/virtio_user_ethdev.c | 1 - lib/librte_eal/common/include/rte_pci.h | 6 ++++++ lib/librte_ether/rte_ethdev.c | 6 +++--- lib/librte_ether/rte_ethdev.h | 4 ++-- 10 files changed, 30 insertions(+), 17 deletions(-) diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index e0447fd..f4c7f3c 100644 --- a/app/test/virtual_pmd.c +++ b/app/test/virtual_pmd.c @@ -624,8 +624,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, dev_private->dev_ops = virtual_ethdev_default_dev_ops; eth_dev->dev_ops = &dev_private->dev_ops; - eth_dev->pci_dev = pci_dev; - eth_dev->pci_dev->device.driver = ð_drv->pci_drv.driver; + pci_dev->device.driver = ð_drv->pci_drv.driver; + eth_dev->device = &pci_dev->device; eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success; eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success; diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index 02ecde6..ae27a5f 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -54,15 +54,23 @@ const char *pmd_bond_init_valid_arguments[] = { static inline int find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr) { + struct rte_pci_device *pci_dev; struct rte_pci_addr *eth_pci_addr; unsigned i; for (i = 0; i < rte_eth_dev_count(); i++) { - if (rte_eth_devices[i].pci_dev == NULL) + /* Currently populated by rte_eth_copy_pci_info(). + * + * TODO: Once the PCI bus has arrived we should have a better + * way to test for being a PCI device or not. + */ + if (rte_eth_devices[i].data->kdrv == RTE_KDRV_UNKNOWN || + rte_eth_devices[i].data->kdrv == RTE_KDRV_NONE) continue; - eth_pci_addr = &(rte_eth_devices[i].pci_dev->addr); + pci_dev = rte_eth_dev_to_pci(&rte_eth_devices[i]); + eth_pci_addr = &pci_dev->addr; if (pci_addr->bus == eth_pci_addr->bus && pci_addr->devid == eth_pci_addr->devid && diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index 922155b..ea13c7e 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1163,14 +1163,14 @@ int cxgbe_probe(struct adapter *adapter) pi->eth_dev->data = data; allocate_mac: - pi->eth_dev->pci_dev = adapter->pdev; + pi->eth_dev->device = &adapter->pdev->device; pi->eth_dev->data->dev_private = pi; pi->eth_dev->driver = adapter->eth_dev->driver; pi->eth_dev->dev_ops = adapter->eth_dev->dev_ops; pi->eth_dev->tx_pkt_burst = adapter->eth_dev->tx_pkt_burst; pi->eth_dev->rx_pkt_burst = adapter->eth_dev->rx_pkt_burst; - rte_eth_copy_pci_info(pi->eth_dev, pi->eth_dev->pci_dev); + rte_eth_copy_pci_info(pi->eth_dev, adapter->pdev); TAILQ_INIT(&pi->eth_dev->link_intr_cbs); diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 43a88f8..8f9ee55 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -677,7 +677,7 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev) /* Enable use of FTAG bit in TX descriptor, PFVTCTL * register is read-only for VF. */ - if (fm10k_check_ftag(dev->pci_dev->device.devargs)) { + if (fm10k_check_ftag(dev->device->devargs)) { if (hw->mac.type == fm10k_mac_pf) { FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i), FM10K_PFVTCTL_FTAG_DESC_ENABLE); @@ -2744,7 +2744,7 @@ fm10k_set_tx_function(struct rte_eth_dev *dev) int use_sse = 1; uint16_t tx_ftag_en = 0; - if (fm10k_check_ftag(dev->pci_dev->device.devargs)) + if (fm10k_check_ftag(dev->device->devargs)) tx_ftag_en = 1; for (i = 0; i < dev->data->nb_tx_queues; i++) { @@ -2775,7 +2775,7 @@ fm10k_set_rx_function(struct rte_eth_dev *dev) uint16_t i, rx_using_sse; uint16_t rx_ftag_en = 0; - if (fm10k_check_ftag(dev->pci_dev->device.devargs)) + if (fm10k_check_ftag(dev->device->devargs)) rx_ftag_en = 1; /* In order to allow Vector Rx there are a few configuration diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 1df8faa..3ac3947 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -5840,7 +5840,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mtu = ETHER_MTU; eth_dev->data->mac_addrs = priv->mac; } - eth_dev->pci_dev = pci_dev; + eth_dev->device = &pci_dev->device; rte_eth_copy_pci_info(eth_dev, pci_dev); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 90cc35e..8ed4cef 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -657,7 +657,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; } - eth_dev->pci_dev = pci_dev; + eth_dev->device = &pci_dev->device; rte_eth_copy_pci_info(eth_dev, pci_dev); eth_dev->driver = &mlx5_driver; priv->dev = eth_dev; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 406beea..8cb983c 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -310,7 +310,6 @@ virtio_user_eth_dev_alloc(const char *name) data->numa_node = SOCKET_ID_ANY; data->kdrv = RTE_KDRV_NONE; data->dev_flags = RTE_ETH_DEV_DETACHABLE; - eth_dev->pci_dev = NULL; eth_dev->driver = NULL; return eth_dev; } diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 9ce8847..19deaf6 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -160,6 +160,12 @@ struct rte_pci_device { enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ }; +/** + * @internal + * Helper macro for drivers that need to convert to struct rte_pci_device. + */ +#define DEV_PCI_DEV(ptr) container_of(ptr, struct rte_pci_device, device) + /** Any PCI device identifier (vendor, device, ...) */ #define PCI_ANY_ID (0xffff) #define RTE_CLASS_ANY_ID (0xffffff) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 764b6cd..29c5ea2 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -257,7 +257,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, if (eth_dev->data->dev_private == NULL) rte_panic("Cannot allocate memzone for private port data\n"); } - eth_dev->pci_dev = pci_dev; + eth_dev->device = &pci_dev->device; eth_dev->intr_handle = &pci_dev->intr_handle; eth_dev->driver = eth_drv; eth_dev->data->rx_mbuf_alloc_failed = 0; @@ -318,7 +318,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(eth_dev->data->dev_private); - eth_dev->pci_dev = NULL; + eth_dev->device = NULL; eth_dev->driver = NULL; eth_dev->data = NULL; @@ -2590,7 +2590,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, const struct rte_memzone *mz; snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - dev->driver->pci_drv.driver.name, ring_name, + dev->data->drv_name, ring_name, dev->data->port_id, queue_id); mz = rte_memzone_lookup(z_name); diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index cc93ca9..2431c29 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1628,7 +1628,7 @@ struct rte_eth_dev { struct rte_eth_dev_data *data; /**< Pointer to device data */ const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ - struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */ + struct rte_device *device; /**< Backing device for this device */ struct rte_intr_handle *intr_handle; /**< Device interrupt handle */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs; @@ -1652,7 +1652,7 @@ struct rte_eth_dev { static inline struct rte_pci_device *__attribute__((always_inline)) rte_eth_dev_to_pci(struct rte_eth_dev *eth_dev) { - return eth_dev->pci_dev; + return DEV_PCI_DEV(eth_dev->device); } struct rte_eth_dev_sriov { -- 2.7.4