netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	edumazet@google.com, pabeni@redhat.com
Subject: Re: [PATCH net-next v4 09/10] tsnep: Add XDP RX support
Date: Tue, 10 Jan 2023 14:30:10 -0800	[thread overview]
Message-ID: <CAKgT0UcEMDZXUeEVJdVTDOFRvG9uhkVZe252psyASiNN8XqqvQ@mail.gmail.com> (raw)
In-Reply-To: <a78d3011-738c-2289-7a70-cd046cde12d5@engleder-embedded.com>

On Tue, Jan 10, 2023 at 1:28 PM Gerhard Engleder
<gerhard@engleder-embedded.com> wrote:
>
> On 10.01.23 18:40, Alexander H Duyck wrote:
> > On Mon, 2023-01-09 at 20:15 +0100, Gerhard Engleder wrote:
> >> If BPF program is set up, then run BPF program for every received frame
> >> and execute the selected action.
> >>
> >> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> >> ---
> >>   drivers/net/ethernet/engleder/tsnep_main.c | 122 ++++++++++++++++++++-
> >>   1 file changed, 120 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
> >> index 451ad1849b9d..002c879639db 100644
> >> --- a/drivers/net/ethernet/engleder/tsnep_main.c
> >> +++ b/drivers/net/ethernet/engleder/tsnep_main.c
> >> @@ -27,6 +27,7 @@
> >>   #include <linux/phy.h>
> >>   #include <linux/iopoll.h>
> >>   #include <linux/bpf.h>
> >> +#include <linux/bpf_trace.h>
> >>
> >>   #define TSNEP_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
> >>   #define TSNEP_HEADROOM ALIGN(max(TSNEP_SKB_PAD, XDP_PACKET_HEADROOM), 4)
> >> @@ -44,6 +45,9 @@
> >>   #define TSNEP_COALESCE_USECS_MAX     ((ECM_INT_DELAY_MASK >> ECM_INT_DELAY_SHIFT) * \
> >>                                    ECM_INT_DELAY_BASE_US + ECM_INT_DELAY_BASE_US - 1)
> >>
> >> +#define TSNEP_XDP_TX                BIT(0)
> >> +#define TSNEP_XDP_REDIRECT  BIT(1)
> >> +
> >>   enum {
> >>      __TSNEP_DOWN,
> >>   };
> >> @@ -625,6 +629,28 @@ static void tsnep_xdp_xmit_flush(struct tsnep_tx *tx)
> >>      iowrite32(TSNEP_CONTROL_TX_ENABLE, tx->addr + TSNEP_CONTROL);
> >>   }
> >>
> >> +static bool tsnep_xdp_xmit_back(struct tsnep_adapter *adapter,
> >> +                            struct xdp_buff *xdp,
> >> +                            struct netdev_queue *tx_nq, struct tsnep_tx *tx)
> >> +{
> >> +    struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp);
> >> +    bool xmit;
> >> +
> >> +    if (unlikely(!xdpf))
> >> +            return false;
> >> +
> >> +    __netif_tx_lock(tx_nq, smp_processor_id());
> >> +
> >> +    /* Avoid transmit queue timeout since we share it with the slow path */
> >> +    txq_trans_cond_update(tx_nq);
> >> +
> >> +    xmit = tsnep_xdp_xmit_frame_ring(xdpf, tx, TSNEP_TX_TYPE_XDP_TX);
> >> +
> >
> > Again the trans_cond_update should be after the xmit and only if it is
> > not indicating it completed the transmit.
>
> tsnep_xdp_xmit_frame_ring() only adds xpdf to the descriptor ring, so it
> cannot complete the transmit. Therefore and in line with your previous
> comment trans_cond_update() should be called here if xpdf is
> successfully placed in the descriptor ring. Is that right?

Yes, that is what I meant by "complete the transmit" is if it places
the xdpf on the descriptor ring then you can update this. Basically
the idea is we should be updating the timer any time a frame goes onto
the ring. It shouldn't be an unconditional update as a stalled ring
could then go undetected.

  reply	other threads:[~2023-01-10 22:30 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 19:15 [PATCH net-next v4 00/10] tsnep: XDP support Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 01/10] tsnep: Use spin_lock_bh for TX Gerhard Engleder
2023-01-10 15:49   ` Alexander H Duyck
2023-01-10 19:44     ` Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 02/10] tsnep: Forward NAPI budget to napi_consume_skb() Gerhard Engleder
2023-01-10 15:50   ` Alexander H Duyck
2023-01-09 19:15 ` [PATCH net-next v4 03/10] tsnep: Do not print DMA mapping error Gerhard Engleder
2023-01-10 15:53   ` Alexander H Duyck
2023-01-10 19:47     ` Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 04/10] tsnep: Add adapter down state Gerhard Engleder
2023-01-10 16:05   ` Alexander H Duyck
2023-01-10 20:16     ` Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 05/10] tsnep: Add XDP TX support Gerhard Engleder
2023-01-10 16:56   ` Alexander H Duyck
2023-01-10 21:07     ` Gerhard Engleder
2023-01-10 22:38       ` Alexander Duyck
2023-01-11 18:51         ` Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 06/10] tsnep: Substract TSNEP_RX_INLINE_METADATA_SIZE once Gerhard Engleder
2023-01-10 17:05   ` Alexander H Duyck
2023-01-09 19:15 ` [PATCH net-next v4 07/10] tsnep: Prepare RX buffer for XDP support Gerhard Engleder
2023-01-09 19:15 ` [PATCH net-next v4 08/10] tsnep: Add RX queue info " Gerhard Engleder
2023-01-10 17:29   ` Alexander H Duyck
2023-01-10 21:21     ` Gerhard Engleder
2023-01-10 22:27       ` Alexander Duyck
2023-01-09 19:15 ` [PATCH net-next v4 09/10] tsnep: Add XDP RX support Gerhard Engleder
2023-01-10 17:40   ` Alexander H Duyck
2023-01-10 21:28     ` Gerhard Engleder
2023-01-10 22:30       ` Alexander Duyck [this message]
2023-01-09 19:15 ` [PATCH net-next v4 10/10] tsnep: Support XDP BPF program setup Gerhard Engleder
2023-01-10 17:33   ` Alexander H Duyck
2023-01-10 21:38     ` Gerhard Engleder
2023-01-10 23:00       ` Alexander H Duyck
2023-01-11 18:58         ` Gerhard Engleder
2023-01-11  0:12       ` Jakub Kicinski
2023-01-11 19:11         ` Gerhard Engleder
2023-01-11 20:06           ` 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=CAKgT0UcEMDZXUeEVJdVTDOFRvG9uhkVZe252psyASiNN8XqqvQ@mail.gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gerhard@engleder-embedded.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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).