From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: Saeed Mahameed <saeed@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net,
kuba@kernel.org, edumazet@google.com, pabeni@redhat.com,
ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
john.fastabend@gmail.com
Subject: Re: [PATCH net-next v2 2/6] tsnep: Add XDP TX support
Date: Fri, 9 Dec 2022 09:02:10 +0100 [thread overview]
Message-ID: <082a47a9-74b2-1800-8c91-e38c73abc89f@engleder-embedded.com> (raw)
In-Reply-To: <Y5KcJ+VliAl0aR0l@x130>
On 09.12.22 03:23, Saeed Mahameed wrote:
>> +static int tsnep_xdp_tx_map(struct xdp_frame *xdpf, struct tsnep_tx *tx,
>> + struct skb_shared_info *shinfo, int count,
>> + bool dma_map)
>> +{
>> + struct device *dmadev = tx->adapter->dmadev;
>> + skb_frag_t *frag;
>> + unsigned int len;
>> + struct tsnep_tx_entry *entry;
>> + void *data;
>> + struct page *page;
>> + dma_addr_t dma;
>> + int map_len = 0;
>> + int i;
>> +
>> + frag = NULL;
>> + len = xdpf->len;
>> + for (i = 0; i < count; i++) {
>> + entry = &tx->entry[(tx->write + i) % TSNEP_RING_SIZE];
>> + if (dma_map) {
>
> wouldn't it have made more sense if you passed TSNEP_TX_TYPE instead of
> bool dma_map ?
> here and in tsnep_xdp_xmit_frame_ring as well..
I will give it a try.
>> +/* This function requires __netif_tx_lock is held by the caller. */
>> +static int tsnep_xdp_xmit_frame_ring(struct xdp_frame *xdpf,
>> + struct tsnep_tx *tx, bool dma_map)
>> +{
>> + struct skb_shared_info *shinfo =
>> xdp_get_shared_info_from_frame(xdpf);
>> + unsigned long flags;
>> + int count = 1;
>> + struct tsnep_tx_entry *entry;
>> + int length;
>> + int i;
>> + int retval;
>
> Maciiej already commented on this, and i agree with him, the whole series
> needs some work on rev xmas tree variable declaration, code will look much
> neater.
So far I ordered the variable declaration by variable usage with common
variables like i and retval at the end. I will take a look an that.
>> +
>> + if (unlikely(xdp_frame_has_frags(xdpf)))
>> + count += shinfo->nr_frags;
>> +
>> + spin_lock_irqsave(&tx->lock, flags);
>> +
>> + if (tsnep_tx_desc_available(tx) < (MAX_SKB_FRAGS + 1 + count)) {
>> + /* prevent full TX ring due to XDP */
>> + spin_unlock_irqrestore(&tx->lock, flags);
>> +
>> + return -EBUSY;
>
> You don't really do anything with the retval, so just return a boolean.
Will be changed.
>> + }
>> +
>> + entry = &tx->entry[tx->write];
>> + entry->xdpf = xdpf;
>> +
>> + retval = tsnep_xdp_tx_map(xdpf, tx, shinfo, count, dma_map);
>> + if (retval < 0) {
>> + tsnep_tx_unmap(tx, tx->write, count);
>> + entry->xdpf = NULL;
>> +
>> + tx->dropped++;
>> +
>> + spin_unlock_irqrestore(&tx->lock, flags);
>> +
>> + netdev_err(tx->adapter->netdev, "XDP TX DMA map failed\n");
>
> please avoid printing in data path, find other means to expose such info.
> stats
> tracepoints
> debug_message rate limited, etc ..
I will improve that.
Gerhard
next prev parent reply other threads:[~2022-12-09 8:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 5:40 [PATCH net-next v2 0/6] tsnep: XDP support Gerhard Engleder
2022-12-08 5:40 ` [PATCH net-next v2 1/6] tsnep: Add adapter down state Gerhard Engleder
2022-12-08 5:40 ` [PATCH net-next v2 2/6] tsnep: Add XDP TX support Gerhard Engleder
2022-12-08 14:10 ` Maciej Fijalkowski
2022-12-08 19:57 ` Gerhard Engleder
2022-12-09 2:23 ` Saeed Mahameed
2022-12-09 8:02 ` Gerhard Engleder [this message]
2022-12-08 5:40 ` [PATCH net-next v2 3/6] tsnep: Support XDP BPF program setup Gerhard Engleder
2022-12-09 0:43 ` Saeed Mahameed
2022-12-09 8:06 ` Gerhard Engleder
2022-12-21 20:19 ` Gerhard Engleder
2022-12-08 5:40 ` [PATCH net-next v2 4/6] tsnep: Prepare RX buffer for XDP support Gerhard Engleder
2022-12-09 0:46 ` Saeed Mahameed
2022-12-08 5:40 ` [PATCH net-next v2 5/6] tsnep: Add RX queue info " Gerhard Engleder
2022-12-08 12:59 ` Maciej Fijalkowski
2022-12-08 20:32 ` Gerhard Engleder
2022-12-09 0:53 ` Saeed Mahameed
2022-12-09 8:11 ` Gerhard Engleder
2022-12-08 5:40 ` [PATCH net-next v2 6/6] tsnep: Add XDP RX support Gerhard Engleder
2022-12-08 13:40 ` Maciej Fijalkowski
2022-12-08 22:12 ` Gerhard Engleder
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=082a47a9-74b2-1800-8c91-e38c73abc89f@engleder-embedded.com \
--to=gerhard@engleder-embedded.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeed@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