From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next v2 08/12] bnxt_en: Add tx ring mapping logic.
Date: Thu, 2 Feb 2017 11:55:36 -0500 [thread overview]
Message-ID: <1486054540-366-9-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1486054540-366-1-git-send-email-michael.chan@broadcom.com>
To support XDP_TX, we need to add a set of dedicated TX rings, each
associated with the NAPI of an RX ring. To assign XDP rings and regular
rings in a flexible way, we add a bp->tx_ring_map[] array to do the
remapping. The netdev txq index is stored in the new field txq_index
so that we can retrieve the netdev txq when handling TX completions.
In this patch, before we introduce XDP_TX, the mapping is 1:1.
v2: Fixed a bug in bnxt_tx_int().
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++++++++++---
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 91fc72d..5d402e957 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -262,8 +262,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
- txr = &bp->tx_ring[i];
txq = netdev_get_tx_queue(dev, i);
+ txr = &bp->tx_ring[bp->tx_ring_map[i]];
prod = txr->tx_prod;
free_size = bnxt_tx_avail(bp, txr);
@@ -509,8 +509,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts)
{
struct bnxt_tx_ring_info *txr = bnapi->tx_ring;
- int index = txr - &bp->tx_ring[0];
- struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, index);
+ struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
u16 cons = txr->tx_cons;
struct pci_dev *pdev = bp->pdev;
int i;
@@ -2972,6 +2971,8 @@ static void bnxt_free_mem(struct bnxt *bp, bool irq_re_init)
bnxt_free_stats(bp);
bnxt_free_ring_grps(bp);
bnxt_free_vnics(bp);
+ kfree(bp->tx_ring_map);
+ bp->tx_ring_map = NULL;
kfree(bp->tx_ring);
bp->tx_ring = NULL;
kfree(bp->rx_ring);
@@ -3024,6 +3025,12 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
if (!bp->tx_ring)
return -ENOMEM;
+ bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16),
+ GFP_KERNEL);
+
+ if (!bp->tx_ring_map)
+ return -ENOMEM;
+
if (bp->flags & BNXT_FLAG_SHARED_RINGS)
j = 0;
else
@@ -3032,6 +3039,8 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
for (i = 0; i < bp->tx_nr_rings; i++, j++) {
bp->tx_ring[i].bnapi = bp->bnapi[j];
bp->bnapi[j]->tx_ring = &bp->tx_ring[i];
+ bp->tx_ring_map[i] = i;
+ bp->tx_ring[i].txq_index = i;
}
rc = bnxt_alloc_stats(bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index e1d9056..0a7f045 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -566,6 +566,7 @@ struct bnxt_tx_ring_info {
struct bnxt_napi *bnapi;
u16 tx_prod;
u16 tx_cons;
+ u16 txq_index;
void __iomem *tx_doorbell;
struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
@@ -995,6 +996,7 @@ struct bnxt {
struct bnxt_rx_ring_info *rx_ring;
struct bnxt_tx_ring_info *tx_ring;
+ u16 *tx_ring_map;
struct sk_buff * (*gro_func)(struct bnxt_tpa_info *, int, int,
struct sk_buff *);
--
1.8.3.1
next prev parent reply other threads:[~2017-02-02 16:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 16:55 [PATCH net-next v2 00/12] bnxt_en: Add XDP support Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 01/12] bnxt_en: Refactor rx SKB function Michael Chan
2017-02-02 22:56 ` Jakub Kicinski
2017-02-02 23:40 ` Michael Chan
2017-02-03 0:22 ` Jakub Kicinski
2017-02-03 0:34 ` Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 02/12] bnxt_en: Don't use DEFINE_DMA_UNMAP_ADDR to store DMA address in RX path Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 03/12] bnxt_en: Add bp->rx_dir field for rx buffer DMA direction Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 04/12] bnxt_en: Parameterize RX buffer offsets Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 05/12] bnxt_en: Add RX page mode support Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 06/12] bnxt_en: Use event bit map in RX path Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 07/12] bnxt_en: Centralize logic to reserve rings Michael Chan
2017-02-02 16:55 ` Michael Chan [this message]
2017-02-02 16:55 ` [PATCH net-next v2 09/12] bnxt_en: Add a set of TX rings to support XDP Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 10/12] bnxt_en: Refactor tx completion path Michael Chan
2017-02-02 16:55 ` [PATCH net-next v2 11/12] bnxt_en: Add basic XDP support Michael Chan
2017-02-02 17:18 ` Mintz, Yuval
2017-02-02 21:30 ` Michael Chan
2017-02-02 23:08 ` Jakub Kicinski
2017-02-02 23:57 ` Alexei Starovoitov
2017-02-02 16:55 ` [PATCH net-next v2 12/12] bnxt_en: Add support for XDP_TX action Michael Chan
2017-02-03 20:49 ` [PATCH net-next v2 00/12] bnxt_en: Add XDP support David Miller
2017-02-03 21:13 ` Michael Chan
2017-02-03 21:50 ` David Miller
2017-02-03 21:58 ` Tom Herbert
2017-02-03 22:02 ` David Miller
2017-02-03 22:25 ` Tom Herbert
2017-02-03 22:29 ` David Miller
2017-02-04 0:33 ` Jakub Kicinski
2017-02-04 1:32 ` Michael Chan
2017-02-04 1:41 ` Jakub Kicinski
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=1486054540-366-9-git-send-email-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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).