From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 6/6] fm10k: use rte_eth_dma_zone_reserve
Date: Thu, 22 Oct 2015 23:34:50 -0700 [thread overview]
Message-ID: <1445582090-5927-7-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1445582090-5927-1-git-send-email-stephen@networkplumber.org>
Adapt to Xen at runtime.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - fix typo where virt to phys is done
drivers/net/fm10k/fm10k_ethdev.c | 47 +++++-----------------------------------
1 file changed, 6 insertions(+), 41 deletions(-)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a69c990..571f5f0 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1144,34 +1144,6 @@ check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
return 0;
}
-/*
- * Create a memzone for hardware descriptor rings. Malloc cannot be used since
- * the physical address is required. If the memzone is already created, then
- * this function returns a pointer to the existing memzone.
- */
-static inline const struct rte_memzone *
-allocate_hw_ring(const char *driver_name, const char *ring_name,
- uint8_t port_id, uint16_t queue_id, int socket_id,
- uint32_t size, uint32_t align)
-{
- char name[RTE_MEMZONE_NAMESIZE];
- const struct rte_memzone *mz;
-
- snprintf(name, sizeof(name), "%s_%s_%d_%d_%d",
- driver_name, ring_name, port_id, queue_id, socket_id);
-
- /* return the memzone if it already exists */
- mz = rte_memzone_lookup(name);
- if (mz)
- return mz;
-
-#ifdef RTE_LIBRTE_XEN_DOM0
- return rte_memzone_reserve_bounded(name, size, socket_id, 0, align,
- RTE_PGSIZE_2M);
-#else
- return rte_memzone_reserve_aligned(name, size, socket_id, 0, align);
-#endif
-}
static inline int
check_thresh(uint16_t min, uint16_t max, uint16_t div, uint16_t request)
@@ -1317,9 +1289,9 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
* enough to hold the maximum ring size is requested to allow for
* resizing in later calls to the queue setup function.
*/
- mz = allocate_hw_ring(dev->driver->pci_drv.name, "rx_ring",
- dev->data->port_id, queue_id, socket_id,
- FM10K_MAX_RX_RING_SZ, FM10K_ALIGN_RX_DESC);
+ mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_id,
+ FM10K_MAX_RX_RING_SZ, FM10K_ALIGN_RX_DESC,
+ socket_id);
if (mz == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate hardware ring");
rte_free(q->sw_ring);
@@ -1327,11 +1299,8 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
return (-ENOMEM);
}
q->hw_ring = mz->addr;
-#ifdef RTE_LIBRTE_XEN_DOM0
q->hw_ring_phys_addr = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
-#else
- q->hw_ring_phys_addr = mz->phys_addr;
-#endif
dev->data->rx_queues[queue_id] = q;
return 0;
@@ -1467,9 +1436,9 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
* enough to hold the maximum ring size is requested to allow for
* resizing in later calls to the queue setup function.
*/
- mz = allocate_hw_ring(dev->driver->pci_drv.name, "tx_ring",
- dev->data->port_id, queue_id, socket_id,
- FM10K_MAX_TX_RING_SZ, FM10K_ALIGN_TX_DESC);
+ mz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_id,
+ FM10K_MAX_TX_RING_SZ, FM10K_ALIGN_TX_DESC,
+ socket_id);
if (mz == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate hardware ring");
rte_free(q->sw_ring);
@@ -1477,11 +1446,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id,
return (-ENOMEM);
}
q->hw_ring = mz->addr;
-#ifdef RTE_LIBRTE_XEN_DOM0
q->hw_ring_phys_addr = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
-#else
- q->hw_ring_phys_addr = mz->phys_addr;
-#endif
/*
* allocate memory for the RS bit tracker. Enough slots to hold the
--
2.1.4
next prev parent reply other threads:[~2015-10-23 6:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 6:34 [dpdk-dev] [PATCH v2 0/6] Xen DOM0 runtime support Stephen Hemminger
2015-10-23 6:34 ` [dpdk-dev] [PATCH 1/6] xen: allow determining DOM0 at runtime Stephen Hemminger
2015-10-23 6:34 ` [dpdk-dev] [PATCH 2/6] ethdev: add common function for reserving DMA regions Stephen Hemminger
2015-10-23 6:34 ` [dpdk-dev] [PATCH 3/6] e1000: use rte_eth_dma_zone_reserve Stephen Hemminger
2015-10-23 6:34 ` [dpdk-dev] [PATCH 4/6] ixgbe: " Stephen Hemminger
2015-10-23 6:34 ` [dpdk-dev] [PATCH 5/6] i40e: " Stephen Hemminger
2015-10-23 6:34 ` Stephen Hemminger [this message]
2015-10-26 7:24 ` [dpdk-dev] [PATCH v2 0/6] Xen DOM0 runtime support Liu, Jijiang
2015-11-03 0:40 ` Thomas Monjalon
-- strict thread matches above, loose matches on Subject: below --
2015-09-29 0:44 [dpdk-dev] [PATCH " Stephen Hemminger
2015-09-29 0:44 ` [dpdk-dev] [PATCH 6/6] fm10k: use rte_eth_dma_zone_reserve Stephen Hemminger
2015-10-04 18:44 ` David Marchand
2015-10-21 14:37 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445582090-5927-7-git-send-email-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).