From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f174.google.com (mail-io0-f174.google.com [209.85.223.174]) by dpdk.org (Postfix) with ESMTP id F23CCFAB8 for ; Mon, 19 Dec 2016 23:00:06 +0100 (CET) Received: by mail-io0-f174.google.com with SMTP id h30so164214320iod.2 for ; Mon, 19 Dec 2016 14:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k07y65s1lQMfZUYv0JF1I0oyIEvc7uZxOdzpnl/92X8=; b=X8FCgJYOQXLDwJkVFwNNMRgjDDV22OUd7TEpc7Qe7nxHYICvVTDcrrrGJdwPE8FAur ZCCr/fuGQdpb+3LbGi3Mi4o6lDhCI+gW8OWpuOAXRN6k5so4a0RgWAQxl5KbucmzFrFi 4pxxPIBvqTW3+CrBdGbn7j+MeBktZ8HfRBaM1WCh1alDSU8BOpmNqfTUoAXQOtK4h3A6 coMURhOM/2UTtt/T8g1/cDJDVu3igu59qMQQBnRlkRAxsAS2sDvtoQU4yDwi+zbnOQYb VAKLt9iKpZ1VDF0MdVt8wLTPolSQ3hj+IztJnit7zZMw4KD47uaFD8ypZbxqrBZ6Oomg qqRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k07y65s1lQMfZUYv0JF1I0oyIEvc7uZxOdzpnl/92X8=; b=K0LRqsZU0PgVYGV/Sy5wYt7fmNX/OHCmKOITw1DX11BK1Kdee05QqLAPG/6K/9oBVG fah5g5vIwuJvBsxiX4y7ZZVg3rE081yI1rkDjBkspC8M0O2On12Dl4LFd4f1aZy8DxlU pHXGR8UdMFW8Q7bVJnvU5NQgT/EkBI0bCBLBbHNPlHNET7gQFZfLybVGRBpg6P2wLekK YgIE6H7JJA80gUyB+7guZQCsJF89nKh5TTET4glPx2mkYo8hgG5u8WJ/fAMQ2Mp6SD4u 8rPvTup3YyM0PnY67MOM0DmpvAK4eshU8BV/CZLsnxDFKLAavLuRkHWhcX1F0zoTzaD6 F+2A== X-Gm-Message-State: AIkVDXJTMJyRMMpubXp6hVsPm+5vkCozqBgGp1a4I5sewUJreE5KZVT+GqLlzUNS9gk+CA== X-Received: by 10.107.10.35 with SMTP id u35mr18396283ioi.124.1482184805345; Mon, 19 Dec 2016 14:00:05 -0800 (PST) Received: from xeon-e3.wavecable.com (204-195-18-65.wavecable.com. [204.195.18.65]) by smtp.gmail.com with ESMTPSA id p20sm8270581itc.2.2016.12.19.14.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 14:00:04 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 19 Dec 2016 13:59:43 -0800 Message-Id: <20161219215944.17226-13-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161219215944.17226-1-sthemmin@microsoft.com> References: <20161219215944.17226-1-sthemmin@microsoft.com> Subject: [dpdk-dev] [PATCH 12/13] ethdev: change pci_dev to generic 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: Mon, 19 Dec 2016 22:00:07 -0000 The rte_eth_dev structure had a long standing assumption that all devices were either virtual or associated with PCI. This is not so going forward with SOC and VMBUS. Signed-off-by: Stephen Hemminger --- app/test/virtual_pmd.c | 3 +- drivers/net/bnxt/bnxt_ethdev.c | 6 ++- drivers/net/bonding/rte_eth_bond_args.c | 12 ++--- drivers/net/cxgbe/cxgbe_ethdev.c | 2 +- drivers/net/cxgbe/cxgbe_main.c | 5 +- drivers/net/e1000/e1000_ethdev.h | 2 +- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_rxtx.c | 2 - drivers/net/fm10k/fm10k_ethdev.c | 90 ++++++++++++++++++++------------- drivers/net/i40e/i40e_ethdev.h | 2 +- drivers/net/i40e/i40e_ethdev_vf.c | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 2 +- drivers/net/qede/qede_ethdev.c | 24 +++++---- drivers/net/qede/qede_ethdev.h | 4 ++ drivers/net/virtio/virtio_ethdev.c | 9 ++-- drivers/net/virtio/virtio_user_ethdev.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 3 +- lib/librte_ether/rte_ethdev.c | 23 ++++++--- lib/librte_ether/rte_ethdev.h | 8 +-- 20 files changed, 123 insertions(+), 81 deletions(-) diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index e0447fda..16ab24e0 100644 --- a/app/test/virtual_pmd.c +++ b/app/test/virtual_pmd.c @@ -624,8 +624,7 @@ 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; + 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/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 529b6c86..fed2c205 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1012,7 +1012,8 @@ static bool bnxt_vf_pciid(uint16_t id) static int bnxt_init_board(struct rte_eth_dev *eth_dev) { struct bnxt *bp = eth_dev->data->dev_private; - struct rte_pci_device *pci_dev = eth_dev->pci_dev; + struct rte_pci_device *pci_dev = + container_of((eth_dev)->device, struct rte_pci_device, device); int rc; /* enable device (incl. PCI PM wakeup), and bus-mastering */ @@ -1046,7 +1047,8 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev) static int bnxt_dev_init(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = eth_dev->pci_dev; + struct rte_pci_device *pci_dev = + container_of((eth_dev)->device, struct rte_pci_device, device); static int version_printed; struct bnxt *bp; int rc; diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index 02ecde64..c5c7f153 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -54,20 +54,18 @@ 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_addr *eth_pci_addr; unsigned i; for (i = 0; i < rte_eth_dev_count(); i++) { + struct rte_device *dev = rte_eth_devices[i].device; + struct rte_pci_device *pdev; - if (rte_eth_devices[i].pci_dev == NULL) + if (dev == NULL || dev->driver->type != PMD_PCI) continue; - eth_pci_addr = &(rte_eth_devices[i].pci_dev->addr); + pdev = container_of(dev, struct rte_pci_device, device); - if (pci_addr->bus == eth_pci_addr->bus && - pci_addr->devid == eth_pci_addr->devid && - pci_addr->domain == eth_pci_addr->domain && - pci_addr->function == eth_pci_addr->function) + if (rte_eal_compare_pci_addr(pci_addr, &pdev->addr) == 0) return i; } return -1; diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index b7f28ebb..4fa09fa9 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -1005,7 +1005,7 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - pci_dev = eth_dev->pci_dev; + pci_dev = container_of(eth_dev->device, struct rte_pci_device, device); snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id); adapter = rte_zmalloc(name, sizeof(*adapter), 0); diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index 922155b4..237cae37 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1071,6 +1071,7 @@ void cxgbe_close(struct adapter *adapter) int cxgbe_probe(struct adapter *adapter) { + struct rte_pci_device *pci_dev = adapter->pdev; struct port_info *pi; int func, i; int err = 0; @@ -1163,14 +1164,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 = &pci_dev->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, pci_dev); TAILQ_INIT(&pi->eth_dev->link_intr_cbs); diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 134f8b91..e034ddc3 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -287,7 +287,7 @@ struct e1000_adapter { (&((struct e1000_adapter *)adapter)->filter) #define E1000_DEV_TO_PCI(eth_dev) \ - (eth_dev->pci_dev) + container_of((eth_dev)->device, struct rte_pci_device, device) /* * RX/TX IGB function prototypes */ diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index ab9a178f..46d6a5f2 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -1278,7 +1278,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - pci_dev = eth_dev->pci_dev; + pci_dev = container_of(eth_dev->device, struct rte_pci_device, device); adapter->pdev = pci_dev; PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d\n", diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 2b154ec2..9e5d21a1 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -621,7 +621,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev) eth_dev->rx_pkt_burst = &enic_recv_pkts; eth_dev->tx_pkt_burst = &enic_xmit_pkts; - pdev = eth_dev->pci_dev; + pdev = container_of(eth_dev->device, struct rte_pci_device, device); rte_eth_copy_pci_info(eth_dev, pdev); enic->pdev = pdev; addr = &pdev->addr; diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c index f762a26c..09ad6251 100644 --- a/drivers/net/enic/enic_rxtx.c +++ b/drivers/net/enic/enic_rxtx.c @@ -557,5 +557,3 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, return index; } - - diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 923690c0..63fb6e6c 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -59,7 +59,13 @@ #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1) /* default 1:1 map from queue ID to interrupt vector ID */ -#define Q2V(dev, queue_id) (dev->pci_dev->intr_handle.intr_vec[queue_id]) +static inline int Q2V(struct rte_eth_dev *dev, uint16_t queue_id) +{ + struct rte_pci_device *pci_dev + = container_of(dev->device, struct rte_pci_device, device); + + return pci_dev->intr_handle.intr_vec[queue_id]; +} /* First 64 Logical ports for PF/VMDQ, second 64 for Flow director */ #define MAX_LPORT_NUM 128 @@ -123,6 +129,10 @@ struct fm10k_xstats_name_off fm10k_hw_stats_tx_q_strings[] = { #define FM10K_NB_XSTATS (FM10K_NB_HW_XSTATS + FM10K_MAX_QUEUES_PF * \ (FM10K_NB_RX_Q_XSTATS + FM10K_NB_TX_Q_XSTATS)) + +#define FM10K_DEV_TO_PCI(dev) \ + container_of(dev->device, struct rte_pci_device, device) + static int fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev); @@ -652,6 +662,7 @@ static int fm10k_dev_tx_init(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); int i, ret; struct fm10k_tx_queue *txq; uint64_t base_addr; @@ -677,7 +688,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(pci_dev->device.devargs)) { if (hw->mac.type == fm10k_mac_pf) { FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i), FM10K_PFVTCTL_FTAG_DESC_ENABLE); @@ -710,8 +721,9 @@ static int fm10k_dev_rx_init(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); struct fm10k_macvlan_filter_info *macvlan; - struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle; + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; int i, ret; struct fm10k_rx_queue *rxq; uint64_t base_addr; @@ -1171,7 +1183,8 @@ static void fm10k_dev_stop(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle; + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; int i; PMD_INIT_FUNC_TRACE(); @@ -1387,6 +1400,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); PMD_INIT_FUNC_TRACE(); @@ -1396,7 +1410,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, dev_info->max_tx_queues = hw->mac.max_queues; dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM; dev_info->max_hash_mac_addrs = 0; - dev_info->max_vfs = dev->pci_dev->max_vfs; + dev_info->max_vfs = pci_dev->max_vfs; dev_info->vmdq_pool_base = 0; dev_info->vmdq_queue_base = 0; dev_info->max_vmdq_pools = ETH_32_POOLS; @@ -2332,6 +2346,7 @@ fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev) static int fm10k_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) { + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); /* Enable ITR */ @@ -2341,7 +2356,8 @@ fm10k_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) else FM10K_WRITE_REG(hw, FM10K_VFITR(Q2V(dev, queue_id)), FM10K_ITR_AUTOMASK | FM10K_ITR_MASK_CLEAR); - rte_intr_enable(&dev->pci_dev->intr_handle); + + rte_intr_enable(&pci_dev->intr_handle); return 0; } @@ -2364,7 +2380,8 @@ static int fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle; + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; uint32_t intr_vector, vec; uint16_t queue_id; int result = 0; @@ -2380,7 +2397,7 @@ fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) intr_vector = dev->data->nb_rx_queues; /* disable interrupt first */ - rte_intr_disable(&dev->pci_dev->intr_handle); + rte_intr_disable(intr_handle); if (hw->mac.type == fm10k_mac_pf) fm10k_dev_disable_intr_pf(dev); else @@ -2415,7 +2432,8 @@ fm10k_dev_rxq_interrupt_setup(struct rte_eth_dev *dev) fm10k_dev_enable_intr_pf(dev); else fm10k_dev_enable_intr_vf(dev); - rte_intr_enable(&dev->pci_dev->intr_handle); + + rte_intr_enable(intr_handle); hw->mac.ops.update_int_moderator(hw); return result; } @@ -2529,9 +2547,8 @@ fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr) * void */ static void -fm10k_dev_interrupt_handler_pf( - __rte_unused struct rte_intr_handle *handle, - void *param) +fm10k_dev_interrupt_handler_pf(struct rte_intr_handle *intr_handle, + void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2581,7 +2598,7 @@ fm10k_dev_interrupt_handler_pf( FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_AUTOMASK | FM10K_ITR_MASK_CLEAR); /* Re-enable interrupt from host side */ - rte_intr_enable(&(dev->pci_dev->intr_handle)); + rte_intr_enable(intr_handle); } /** @@ -2596,9 +2613,8 @@ fm10k_dev_interrupt_handler_pf( * void */ static void -fm10k_dev_interrupt_handler_vf( - __rte_unused struct rte_intr_handle *handle, - void *param) +fm10k_dev_interrupt_handler_vf(struct rte_intr_handle *intr_handle, + void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -2615,7 +2631,7 @@ fm10k_dev_interrupt_handler_vf( FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_AUTOMASK | FM10K_ITR_MASK_CLEAR); /* Re-enable interrupt from host side */ - rte_intr_enable(&(dev->pci_dev->intr_handle)); + rte_intr_enable(intr_handle); } /* Mailbox message handler in VF */ @@ -2737,7 +2753,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++) { @@ -2768,7 +2784,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 @@ -2827,6 +2843,8 @@ static int eth_fm10k_dev_init(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; int diag, i; struct fm10k_macvlan_filter_info *macvlan; @@ -2840,18 +2858,18 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - rte_eth_copy_pci_info(dev, dev->pci_dev); + rte_eth_copy_pci_info(dev, pci_dev); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); memset(macvlan, 0, sizeof(*macvlan)); /* Vendor and Device ID need to be set before init of shared code */ memset(hw, 0, sizeof(*hw)); - hw->device_id = dev->pci_dev->id.device_id; - hw->vendor_id = dev->pci_dev->id.vendor_id; - hw->subsystem_device_id = dev->pci_dev->id.subsystem_device_id; - hw->subsystem_vendor_id = dev->pci_dev->id.subsystem_vendor_id; + hw->device_id = pci_dev->id.device_id; + hw->vendor_id = pci_dev->id.vendor_id; + hw->subsystem_device_id = pci_dev->id.subsystem_device_id; + hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; hw->revision_id = 0; - hw->hw_addr = (void *)dev->pci_dev->mem_resource[0].addr; + hw->hw_addr = (void *)pci_dev->mem_resource[0].addr; if (hw->hw_addr == NULL) { PMD_INIT_LOG(ERR, "Bad mem resource." " Try to blacklist unused devices."); @@ -2921,20 +2939,20 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) /*PF/VF has different interrupt handling mechanism */ if (hw->mac.type == fm10k_mac_pf) { /* register callback func to eal lib */ - rte_intr_callback_register(&(dev->pci_dev->intr_handle), - fm10k_dev_interrupt_handler_pf, (void *)dev); + rte_intr_callback_register(intr_handle, + fm10k_dev_interrupt_handler_pf, dev); /* enable MISC interrupt */ fm10k_dev_enable_intr_pf(dev); } else { /* VF */ - rte_intr_callback_register(&(dev->pci_dev->intr_handle), - fm10k_dev_interrupt_handler_vf, (void *)dev); + rte_intr_callback_register(intr_handle, + fm10k_dev_interrupt_handler_vf, dev); fm10k_dev_enable_intr_vf(dev); } /* Enable intr after callback registered */ - rte_intr_enable(&(dev->pci_dev->intr_handle)); + rte_intr_enable(intr_handle); hw->mac.ops.update_int_moderator(hw); @@ -3004,6 +3022,8 @@ static int eth_fm10k_dev_uninit(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_pci_device *pci_dev = FM10K_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; PMD_INIT_FUNC_TRACE(); @@ -3019,7 +3039,7 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev) dev->tx_pkt_burst = NULL; /* disable uio/vfio intr */ - rte_intr_disable(&(dev->pci_dev->intr_handle)); + rte_intr_disable(intr_handle); /*PF/VF has different interrupt handling mechanism */ if (hw->mac.type == fm10k_mac_pf) { @@ -3027,14 +3047,14 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev) fm10k_dev_disable_intr_pf(dev); /* unregister callback func to eal lib */ - rte_intr_callback_unregister(&(dev->pci_dev->intr_handle), - fm10k_dev_interrupt_handler_pf, (void *)dev); + rte_intr_callback_unregister(intr_handle, + fm10k_dev_interrupt_handler_pf, dev); } else { /* disable interrupt */ fm10k_dev_disable_intr_vf(dev); - rte_intr_callback_unregister(&(dev->pci_dev->intr_handle), - fm10k_dev_interrupt_handler_vf, (void *)dev); + rte_intr_callback_unregister(intr_handle, + fm10k_dev_interrupt_handler_vf, dev); } /* free mac memory */ diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index da8dd7ef..5a6a4e05 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -618,7 +618,7 @@ void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_txq_info *qinfo); #define I40E_DEV_TO_PCI(eth_dev) \ - (eth_dev->pci_dev) + container_of((eth_dev)->device, struct rte_pci_device, device) /* I40E_DEV_PRIVATE_TO */ #define I40E_DEV_PRIVATE_TO_PF(adapter) \ diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index a4d8a66e..c177d2e8 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -64,6 +64,7 @@ #include "base/i40e_adminq_cmd.h" #include "base/i40e_type.h" + #include "i40e_rxtx.h" #include "i40e_ethdev.h" #include "i40e_pf.h" diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index a0e02aab..cbfd8b0f 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -292,7 +292,7 @@ struct ixgbe_adapter { }; #define IXGBE_DEV_TO_PCI(eth_dev) \ - (eth_dev->pci_dev) + container_of((eth_dev)->device, struct rte_pci_device, device) #define IXGBE_DEV_PRIVATE_TO_HW(adapter)\ (&((struct ixgbe_adapter *)adapter)->hw) diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index d106dd0f..b1ff6989 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -175,14 +175,14 @@ static void qede_interrupt_action(struct ecore_hwfn *p_hwfn) } static void -qede_interrupt_handler(__rte_unused struct rte_intr_handle *handle, void *param) +qede_interrupt_handler(struct rte_intr_handle *intr_handle, void *param) { struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param; struct qede_dev *qdev = eth_dev->data->dev_private; struct ecore_dev *edev = &qdev->edev; qede_interrupt_action(ECORE_LEADING_HWFN(edev)); - if (rte_intr_enable(ð_dev->pci_dev->intr_handle)) + if (rte_intr_enable(intr_handle)) DP_ERR(edev, "rte_intr_enable failed\n"); } @@ -809,6 +809,8 @@ static void qede_poll_sp_sb_cb(void *param) static void qede_dev_close(struct rte_eth_dev *eth_dev) { + struct rte_pci_device *pdev = QEDE_INIT_PDEV(eth_dev); + struct rte_intr_handle *intr_handle = &pdev->intr_handle; struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); int rc; @@ -835,10 +837,10 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev) qdev->ops->common->remove(edev); - rte_intr_disable(ð_dev->pci_dev->intr_handle); + rte_intr_disable(intr_handle); - rte_intr_callback_unregister(ð_dev->pci_dev->intr_handle, - qede_interrupt_handler, (void *)eth_dev); + rte_intr_callback_unregister(intr_handle, + qede_interrupt_handler, eth_dev); if (edev->num_hwfns > 1) rte_eal_alarm_cancel(qede_poll_sp_sb_cb, (void *)eth_dev); @@ -1383,6 +1385,7 @@ static void qede_update_pf_params(struct ecore_dev *edev) static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) { + struct rte_intr_handle *intr_handle; struct rte_pci_device *pci_dev; struct rte_pci_addr pci_addr; struct qede_dev *adapter; @@ -1401,9 +1404,11 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) int rc; /* Extract key data structures */ + pci_dev = QEDE_INIT_PDEV(eth_dev); + intr_handle = &pci_dev->intr_handle; adapter = eth_dev->data->dev_private; edev = &adapter->edev; - pci_addr = eth_dev->pci_dev->addr; + pci_addr = pci_dev->addr; PMD_INIT_FUNC_TRACE(edev); @@ -1420,7 +1425,6 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) return 0; } - pci_dev = eth_dev->pci_dev; rte_eth_copy_pci_info(eth_dev, pci_dev); @@ -1442,10 +1446,10 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) qede_update_pf_params(edev); - rte_intr_callback_register(ð_dev->pci_dev->intr_handle, - qede_interrupt_handler, (void *)eth_dev); + rte_intr_callback_register(intr_handle, + qede_interrupt_handler, eth_dev); - if (rte_intr_enable(ð_dev->pci_dev->intr_handle)) { + if (rte_intr_enable(intr_handle)) { DP_ERR(edev, "rte_intr_enable() failed\n"); return -ENODEV; } diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h index a97e3d96..454eae63 100644 --- a/drivers/net/qede/qede_ethdev.h +++ b/drivers/net/qede/qede_ethdev.h @@ -80,6 +80,10 @@ #define QEDE_SUPPORTED_AUTONEG (1 << 6) #define QEDE_SUPPORTED_PAUSE (1 << 13) + +#define QEDE_INIT_PDEV(eth_dev) \ + container_of((eth_dev)->device, struct rte_pci_device, device) + #define QEDE_INIT_QDEV(eth_dev) (eth_dev->data->dev_private) #define QEDE_INIT_EDEV(adapter) (&((struct qede_dev *)adapter)->edev) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 4db4568a..21022cf3 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -155,7 +155,9 @@ static const struct rte_virtio_xstats_name_off rte_virtio_txq_stat_strings[] = { static inline struct rte_pci_device * virtio_dev_to_pci(struct rte_eth_dev *eth_dev) { - return eth_dev->pci_dev; + struct rte_device *dev = eth_dev->device; + + return dev ? container_of(dev, struct rte_pci_device, device) : NULL; } static inline struct rte_intr_handle * @@ -501,7 +503,8 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx) * virtual address. And we need properly set _offset_, please see * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information. */ - if (dev->pci_dev) + + if (dev->device) vq->offset = offsetof(struct rte_mbuf, buf_physaddr); else { vq->vq_ring_mem = (uintptr_t)mz->addr; @@ -1662,7 +1665,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint64_t tso_mask; struct virtio_hw *hw = dev->data->dev_private; - if (!dev->pci_dev) + if (!dev->device) dev_info->driver_name = "virtio_user PMD"; dev_info->max_rx_queues = RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES); diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 406beeac..293078e3 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -310,7 +310,7 @@ 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->device = NULL; eth_dev->driver = NULL; return eth_dev; } diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 8bb13e52..ae6d081f 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -237,7 +237,8 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &vmxnet3_eth_dev_ops; eth_dev->rx_pkt_burst = &vmxnet3_recv_pkts; eth_dev->tx_pkt_burst = &vmxnet3_xmit_pkts; - pci_dev = eth_dev->pci_dev; + pci_dev = container_of(eth_dev->device, struct rte_pci_device, device); + /* * for secondary processes, we don't initialize any further as primary diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 71a8e9b9..3f7dc79e 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -257,7 +257,8 @@ 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->driver = eth_drv; eth_dev->data->rx_mbuf_alloc_failed = 0; @@ -317,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; @@ -1569,7 +1570,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info) RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); - dev_info->device = &dev->pci_dev->device; + dev_info->device = dev->device; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues; @@ -2550,6 +2551,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) { uint32_t vec; struct rte_eth_dev *dev; + struct rte_pci_device *pci_dev; struct rte_intr_handle *intr_handle; uint16_t qid; int rc; @@ -2557,7 +2559,11 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + if (dev->device->driver->type != PMD_PCI) + return -ENOTSUP; + + pci_dev = container_of(dev->device, struct rte_pci_device, device); + intr_handle = &pci_dev->intr_handle; if (!intr_handle->intr_vec) { RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n"); return -EPERM; @@ -2606,6 +2612,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, { uint32_t vec; struct rte_eth_dev *dev; + struct rte_pci_device *pci_dev; struct rte_intr_handle *intr_handle; int rc; @@ -2617,7 +2624,11 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, return -EINVAL; } - intr_handle = &dev->pci_dev->intr_handle; + if (dev->device->driver->type != PMD_PCI) + return -ENOTSUP; + + pci_dev = container_of(dev->device, struct rte_pci_device, device); + intr_handle = &pci_dev->intr_handle; if (!intr_handle->intr_vec) { RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n"); return -EPERM; @@ -3211,7 +3222,7 @@ rte_eth_dev_get_dcb_info(uint8_t port_id, } void -rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev) +rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, const struct rte_pci_device *pci_dev) { if ((eth_dev == NULL) || (pci_dev == NULL)) { RTE_PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n", diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 2b3b4014..f7e156eb 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; /**< Device info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs; /** @@ -1813,8 +1813,8 @@ struct eth_driver; * The *eth_dev* structure is supplied to the driver initialization function * with the following fields already initialized: * - * - *pci_dev*: Holds the pointers to the *rte_pci_device* structure which - * contains the generic PCI information of the matching device. + * - *device*: Holds the pointers to the *rte_device* structure which + * contains the generic device information of the matching device. * * - *driver*: Holds the pointer to the *eth_driver* structure. * @@ -4266,7 +4266,7 @@ int rte_eth_timesync_write_time(uint8_t port_id, const struct timespec *time); * - 0 on success, negative on error */ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, - struct rte_pci_device *pci_dev); + const struct rte_pci_device *pci_dev); /** * Create memzone for HW rings. -- 2.11.0