From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 10/10] igc: Enable TX via AF_XDP zero-copy
Date: Tue, 22 Dec 2020 15:16:44 +0100 [thread overview]
Message-ID: <20201222141644.GH2943@ranger.igk.intel.com> (raw)
In-Reply-To: <20201217202415.77891-11-andre.guedes@intel.com>
On Thu, Dec 17, 2020 at 12:24:15PM -0800, Andre Guedes wrote:
> This patch adds support for transmitting packets via AF_XDP zero-copy
> mechanism.
>
> The packet transmission itself is implemented by igc_xdp_xmit_zc() which
> is called from igc_clean_tx_irq() when the ring has AF_XDP zero-copy
> enabled. Likewise i40e and ice drivers, the transmission budget used is
> the number of descriptors available on the ring.
>
> A new tx buffer type is introduced to 'enum igc_tx_buffer_type' to
> indicate the tx buffer uses memory from xsk pool so it can be properly
> cleaned after transmission or when the ring is cleaned.
>
> The I225 controller has only 4 Tx hardware queues so the main difference
> between igc and other Intel drivers that support AF_XDP zero-copy is
> that there is no tx ring dedicated exclusively to XDP. Instead, tx
> rings are shared between the network stack and XDP, and netdev queue
> lock is used to ensure mutual exclusion. This is the same approach
> implemented to support XDP_TX and XDP_REDIRECT actions.
>
> Signed-off-by: Andre Guedes <andre.guedes@intel.com>
> ---
> drivers/net/ethernet/intel/igc/igc.h | 3 +
> drivers/net/ethernet/intel/igc/igc_base.h | 1 +
> drivers/net/ethernet/intel/igc/igc_main.c | 115 +++++++++++++++++++++-
> drivers/net/ethernet/intel/igc/igc_xdp.c | 20 +++-
> 4 files changed, 131 insertions(+), 8 deletions(-)
>
[...]
>
> +static void igc_xdp_xmit_zc(struct igc_ring *ring)
> +{
> + struct xsk_buff_pool *pool = ring->xsk_pool;
> + struct netdev_queue *nq = txring_txq(ring);
> + int cpu = smp_processor_id();
> + struct xdp_desc xdp_desc;
> + bool work_done;
> + u16 budget;
> +
> + if (!netif_carrier_ok(ring->netdev))
> + return;
> +
> + __netif_tx_lock(nq, cpu);
> +
> + budget = igc_desc_unused(ring);
> + work_done = false;
> +
> + while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
> + u32 cmd_type, olinfo_status;
> + union igc_adv_tx_desc *desc;
> + struct igc_tx_buffer *bi;
> + dma_addr_t dma;
> +
> + cmd_type = IGC_ADVTXD_DTYP_DATA | IGC_ADVTXD_DCMD_DEXT |
> + IGC_ADVTXD_DCMD_IFCS | IGC_TXD_DCMD |
> + xdp_desc.len;
> + olinfo_status = xdp_desc.len << IGC_ADVTXD_PAYLEN_SHIFT;
> +
> + dma = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
> + xsk_buff_raw_dma_sync_for_device(pool, dma, xdp_desc.len);
> +
> + desc = IGC_TX_DESC(ring, ring->next_to_use);
> + desc->read.cmd_type_len = cpu_to_le32(cmd_type);
> + desc->read.olinfo_status = cpu_to_le32(olinfo_status);
> + desc->read.buffer_addr = cpu_to_le64(dma);
> +
> + bi = &ring->tx_buffer_info[ring->next_to_use];
> + bi->type = IGC_TX_BUFFER_TYPE_XSK;
> + bi->protocol = 0;
> + bi->bytecount = xdp_desc.len;
> + bi->gso_segs = 1;
> + bi->time_stamp = jiffies;
> + bi->next_to_watch = desc;
> +
> + netdev_tx_sent_queue(txring_txq(ring), xdp_desc.len);
> +
> + ring->next_to_use++;
> + if (ring->next_to_use == ring->count)
> + ring->next_to_use = 0;
> +
> + work_done = true;
nit: setting it on each iteration feels semi-optimal.
> + }
> +
> + if (work_done) {
> + igc_flush_tx_descriptors(ring);
> + xsk_tx_release(pool);
> + }
> +
> + __netif_tx_unlock(nq);
> +}
next prev parent reply other threads:[~2020-12-22 14:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 20:24 [Intel-wired-lan] [PATCH 00/10] igc: Add support for AF_XDP zero-copy Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 01/10] igc: Move igc_xdp_is_enabled() Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 02/10] igc: Refactor igc_xdp_run_prog() Andre Guedes
2020-12-21 22:45 ` Maciej Fijalkowski
2020-12-22 1:12 ` Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 03/10] igc: Refactor igc_clean_rx_ring() Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 04/10] igc: Refactor XDP rxq info registration Andre Guedes
2020-12-21 22:53 ` Maciej Fijalkowski
2020-12-22 1:13 ` Andre Guedes
2020-12-22 12:32 ` Maciej Fijalkowski
2020-12-22 17:43 ` Andre Guedes
2020-12-22 20:59 ` Maciej Fijalkowski
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 05/10] igc: Introduce igc_update_rx_stats() Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 06/10] igc: Introduce igc_update_tx_stats() Andre Guedes
2020-12-21 22:58 ` Maciej Fijalkowski
2020-12-22 1:13 ` Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 07/10] igc: Introduce igc_unmap_tx_buffer() helper Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 08/10] igc: Replace IGC_TX_FLAGS_XDP flag by an enum Andre Guedes
2020-12-21 23:09 ` Maciej Fijalkowski
2020-12-22 1:13 ` Andre Guedes
2020-12-22 12:33 ` Maciej Fijalkowski
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 09/10] igc: Enable RX via AF_XDP zero-copy Andre Guedes
2020-12-22 13:14 ` Maciej Fijalkowski
2020-12-22 17:43 ` Andre Guedes
2020-12-22 20:59 ` Maciej Fijalkowski
2020-12-23 19:27 ` Andre Guedes
2020-12-17 20:24 ` [Intel-wired-lan] [PATCH 10/10] igc: Enable TX " Andre Guedes
2020-12-22 14:16 ` Maciej Fijalkowski [this message]
2020-12-22 14:20 ` [Intel-wired-lan] [PATCH 00/10] igc: Add support for " Maciej Fijalkowski
2020-12-22 17:43 ` Andre Guedes
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=20201222141644.GH2943@ranger.igk.intel.com \
--to=maciej.fijalkowski@intel.com \
--cc=intel-wired-lan@osuosl.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