[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ+HfNhsjsCoDx5NCEu=AqrT-ENRb8JnqzJfo2m8kD2xraHc+w@mail.gmail.com>
Date: Thu, 13 Jun 2019 14:48:16 +0200
From: Björn Töpel <bjorn.topel@...il.com>
To: Maxim Mikityanskiy <maximmi@...lanox.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Björn Töpel <bjorn.topel@...el.com>,
Magnus Karlsson <magnus.karlsson@...el.com>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Saeed Mahameed <saeedm@...lanox.com>,
Jonathan Lemon <bsd@...com>,
Tariq Toukan <tariqt@...lanox.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
Maciej Fijalkowski <maciejromanfijalkowski@...il.com>
Subject: Re: [PATCH bpf-next v4 06/17] xsk: Return the whole xdp_desc from xsk_umem_consume_tx
On Wed, 12 Jun 2019 at 20:05, Maxim Mikityanskiy <maximmi@...lanox.com> wrote:
>
> Some drivers want to access the data transmitted in order to implement
> acceleration features of the NICs. It is also useful in AF_XDP TX flow.
>
> Change the xsk_umem_consume_tx API to return the whole xdp_desc, that
> contains the data pointer, length and DMA address, instead of only the
> latter two. Adapt the implementation of i40e and ixgbe to this change.
>
Acked-by: Björn Töpel <bjorn.topel@...el.com>
> Signed-off-by: Maxim Mikityanskiy <maximmi@...lanox.com>
> Reviewed-by: Tariq Toukan <tariqt@...lanox.com>
> Acked-by: Saeed Mahameed <saeedm@...lanox.com>
> Cc: Björn Töpel <bjorn.topel@...el.com>
> Cc: Magnus Karlsson <magnus.karlsson@...el.com>
> ---
> drivers/net/ethernet/intel/i40e/i40e_xsk.c | 12 +++++++-----
> drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 15 +++++++++------
> include/net/xdp_sock.h | 6 +++---
> net/xdp/xsk.c | 10 +++-------
> 4 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> index 1b17486543ac..eae6fafad1b8 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
> @@ -640,8 +640,8 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)
> struct i40e_tx_desc *tx_desc = NULL;
> struct i40e_tx_buffer *tx_bi;
> bool work_done = true;
> + struct xdp_desc desc;
> dma_addr_t dma;
> - u32 len;
>
> while (budget-- > 0) {
> if (!unlikely(I40E_DESC_UNUSED(xdp_ring))) {
> @@ -650,21 +650,23 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)
> break;
> }
>
> - if (!xsk_umem_consume_tx(xdp_ring->xsk_umem, &dma, &len))
> + if (!xsk_umem_consume_tx(xdp_ring->xsk_umem, &desc))
> break;
>
> - dma_sync_single_for_device(xdp_ring->dev, dma, len,
> + dma = xdp_umem_get_dma(xdp_ring->xsk_umem, desc.addr);
> +
> + dma_sync_single_for_device(xdp_ring->dev, dma, desc.len,
> DMA_BIDIRECTIONAL);
>
> tx_bi = &xdp_ring->tx_bi[xdp_ring->next_to_use];
> - tx_bi->bytecount = len;
> + tx_bi->bytecount = desc.len;
>
> tx_desc = I40E_TX_DESC(xdp_ring, xdp_ring->next_to_use);
> tx_desc->buffer_addr = cpu_to_le64(dma);
> tx_desc->cmd_type_offset_bsz =
> build_ctob(I40E_TX_DESC_CMD_ICRC
> | I40E_TX_DESC_CMD_EOP,
> - 0, len, 0);
> + 0, desc.len, 0);
>
> xdp_ring->next_to_use++;
> if (xdp_ring->next_to_use == xdp_ring->count)
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> index bfe95ce0bd7f..0297a70a4e2d 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> @@ -621,8 +621,9 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)
> union ixgbe_adv_tx_desc *tx_desc = NULL;
> struct ixgbe_tx_buffer *tx_bi;
> bool work_done = true;
> - u32 len, cmd_type;
> + struct xdp_desc desc;
> dma_addr_t dma;
> + u32 cmd_type;
>
> while (budget-- > 0) {
> if (unlikely(!ixgbe_desc_unused(xdp_ring)) ||
> @@ -631,14 +632,16 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)
> break;
> }
>
> - if (!xsk_umem_consume_tx(xdp_ring->xsk_umem, &dma, &len))
> + if (!xsk_umem_consume_tx(xdp_ring->xsk_umem, &desc))
> break;
>
> - dma_sync_single_for_device(xdp_ring->dev, dma, len,
> + dma = xdp_umem_get_dma(xdp_ring->xsk_umem, desc.addr);
> +
> + dma_sync_single_for_device(xdp_ring->dev, dma, desc.len,
> DMA_BIDIRECTIONAL);
>
> tx_bi = &xdp_ring->tx_buffer_info[xdp_ring->next_to_use];
> - tx_bi->bytecount = len;
> + tx_bi->bytecount = desc.len;
> tx_bi->xdpf = NULL;
>
> tx_desc = IXGBE_TX_DESC(xdp_ring, xdp_ring->next_to_use);
> @@ -648,10 +651,10 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)
> cmd_type = IXGBE_ADVTXD_DTYP_DATA |
> IXGBE_ADVTXD_DCMD_DEXT |
> IXGBE_ADVTXD_DCMD_IFCS;
> - cmd_type |= len | IXGBE_TXD_CMD;
> + cmd_type |= desc.len | IXGBE_TXD_CMD;
> tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type);
> tx_desc->read.olinfo_status =
> - cpu_to_le32(len << IXGBE_ADVTXD_PAYLEN_SHIFT);
> + cpu_to_le32(desc.len << IXGBE_ADVTXD_PAYLEN_SHIFT);
>
> xdp_ring->next_to_use++;
> if (xdp_ring->next_to_use == xdp_ring->count)
> diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> index b6f5ebae43a1..057b159ff8b9 100644
> --- a/include/net/xdp_sock.h
> +++ b/include/net/xdp_sock.h
> @@ -81,7 +81,7 @@ bool xsk_umem_has_addrs(struct xdp_umem *umem, u32 cnt);
> u64 *xsk_umem_peek_addr(struct xdp_umem *umem, u64 *addr);
> void xsk_umem_discard_addr(struct xdp_umem *umem);
> void xsk_umem_complete_tx(struct xdp_umem *umem, u32 nb_entries);
> -bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma, u32 *len);
> +bool xsk_umem_consume_tx(struct xdp_umem *umem, struct xdp_desc *desc);
> void xsk_umem_consume_tx_done(struct xdp_umem *umem);
> struct xdp_umem_fq_reuse *xsk_reuseq_prepare(u32 nentries);
> struct xdp_umem_fq_reuse *xsk_reuseq_swap(struct xdp_umem *umem,
> @@ -175,8 +175,8 @@ static inline void xsk_umem_complete_tx(struct xdp_umem *umem, u32 nb_entries)
> {
> }
>
> -static inline bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma,
> - u32 *len)
> +static inline bool xsk_umem_consume_tx(struct xdp_umem *umem,
> + struct xdp_desc *desc)
> {
> return false;
> }
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 35ca531ac74e..74417a851ed5 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -172,22 +172,18 @@ void xsk_umem_consume_tx_done(struct xdp_umem *umem)
> }
> EXPORT_SYMBOL(xsk_umem_consume_tx_done);
>
> -bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma, u32 *len)
> +bool xsk_umem_consume_tx(struct xdp_umem *umem, struct xdp_desc *desc)
> {
> - struct xdp_desc desc;
> struct xdp_sock *xs;
>
> rcu_read_lock();
> list_for_each_entry_rcu(xs, &umem->xsk_list, list) {
> - if (!xskq_peek_desc(xs->tx, &desc))
> + if (!xskq_peek_desc(xs->tx, desc))
> continue;
>
> - if (xskq_produce_addr_lazy(umem->cq, desc.addr))
> + if (xskq_produce_addr_lazy(umem->cq, desc->addr))
> goto out;
>
> - *dma = xdp_umem_get_dma(umem, desc.addr);
> - *len = desc.len;
> -
> xskq_discard_desc(xs->tx);
> rcu_read_unlock();
> return true;
> --
> 2.19.1
>
Powered by blists - more mailing lists