From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <viktorin@rehivetech.com>
Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16])
 by dpdk.org (Postfix) with ESMTP id CDF7B5A0A
 for <dev@dpdk.org>; Fri,  6 May 2016 15:50:11 +0200 (CEST)
Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz
 [147.229.13.147])
 by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3r1Y7R4fxzz7Jd;
 Fri,  6 May 2016 15:50:11 +0200 (CEST)
From: Jan Viktorin <viktorin@rehivetech.com>
To: dev@dpdk.org
Cc: Jan Viktorin <viktorin@rehivetech.com>,
 David Marchand <david.marchand@6wind.com>,
 Thomas Monjalon <thomas.monjalon@6wind.com>,
 Bruce Richardson <bruce.richardson@intel.com>,
 Declan Doherty <declan.doherty@intel.com>, jianbo.liu@linaro.org,
 jerin.jacob@caviumnetworks.com, Keith Wiles <keith.wiles@intel.com>,
 Stephen Hemminger <stephen@networkplumber.org>
Date: Fri,  6 May 2016 15:48:08 +0200
Message-Id: <1462542490-15556-27-git-send-email-viktorin@rehivetech.com>
X-Mailer: git-send-email 2.8.0
In-Reply-To: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com>
References: <1462542490-15556-1-git-send-email-viktorin@rehivetech.com>
In-Reply-To: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com>
References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com>
Subject: [dpdk-dev] [PATCH v1 26/28] ether: extract function
	eth_dev_get_intr_handle
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 06 May 2016 13:50:12 -0000

We abstract access to the intr_handle here as we want to get
it either from the pci_dev or soc_dev.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0b0dcbc..9378a4a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2404,6 +2404,17 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 }
 
+static inline
+struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
+{
+	if (dev->pci_dev) {
+		return &dev->pci_dev->intr_handle;
+	}
+
+	RTE_VERIFY(0);
+	return NULL;
+}
+
 int
 rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 {
@@ -2419,7 +2430,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 	}
 
 	dev = &rte_eth_devices[port_id];
-	intr_handle = &dev->pci_dev->intr_handle;
+	intr_handle = eth_dev_get_intr_handle(dev);
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
@@ -2482,7 +2493,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
-	intr_handle = &dev->pci_dev->intr_handle;
+	intr_handle = eth_dev_get_intr_handle(dev);
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
-- 
2.8.0