lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ+HfNiQgU7quKO_AO=Gayb9i82B4XTAcfnLy46R_Y_A-yeKsA@mail.gmail.com>
Date:   Tue, 18 Dec 2018 15:34:47 +0100
From:   Björn Töpel <bjorn.topel@...il.com>
To:     William Tu <u9012063@...il.com>
Cc:     Magnus Karlsson <magnus.karlsson@...il.com>, ast@...nel.org,
        Daniel Borkmann <daniel@...earbox.net>,
        Netdev <netdev@...r.kernel.org>, makita.toshiaki@....ntt.co.jp,
        "Karlsson, Magnus" <magnus.karlsson@...el.com>
Subject: Re: [bpf-next RFC 1/3] xsk: add xsk_umem_consume_tx_virtual.

Den mån 17 dec. 2018 kl 20:40 skrev William Tu <u9012063@...il.com>:
>
> Currently the xsk_umem_consume_tx expects only the physical NICs so
> the api returns a dma address.  This patch introduce the new function
> to return the virtual address, when XSK is used by a virtual device.
>
> Signed-off-by: William Tu <u9012063@...il.com>
> ---
>  include/net/xdp_sock.h |  7 +++++++
>  net/xdp/xsk.c          | 24 ++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> index 13acb9803a6d..8de6b8456945 100644
> --- a/include/net/xdp_sock.h
> +++ b/include/net/xdp_sock.h
> @@ -81,6 +81,7 @@ 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_virtual(struct xdp_umem *umem, char **addr, u32 *len);
>  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,
> @@ -165,6 +166,12 @@ static inline bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma,
>         return false;
>  }
>
> +static inline bool xsk_umem_consume_tx_virtual(struct xdp_umem *umem,
> +                                              char **dma, u32 *len)

Nit: dma->addr

> +{
> +       return false;
> +}
> +
>  static inline void xsk_umem_consume_tx_done(struct xdp_umem *umem)
>  {
>  }
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 07156f43d295..379f5e9d0c81 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -197,6 +197,30 @@ bool xsk_umem_consume_tx(struct xdp_umem *umem, dma_addr_t *dma, u32 *len)
>  }
>  EXPORT_SYMBOL(xsk_umem_consume_tx);
>
> +bool xsk_umem_consume_tx_virtual(struct xdp_umem *umem, char **addr, u32 *len)

Prefer void ** in favor of char**?

> +{
> +       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))
> +                        continue;
> +               if (xskq_produce_addr_lazy(umem->cq, desc.addr))
> +                       goto out;
> +
> +               *addr = xdp_umem_get_data(umem, desc.addr);
> +               *len = desc.len;
> +               xskq_discard_desc(xs->tx);
> +               rcu_read_unlock();
> +               return true;
> +       }
> +out:
> +       rcu_read_unlock();
> +       return false;
> +}
> +EXPORT_SYMBOL(xsk_umem_consume_tx_virtual);

Is possible to make xsk_umem_consume_tx_virtual and
xsk_umem_consume_tx share a common implementation. They are very
similar.

> +
>  static int xsk_zc_xmit(struct sock *sk)
>  {
>         struct xdp_sock *xs = xdp_sk(sk);
> --
> 2.7.4
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ