From: John Fastabend <john.fastabend@gmail.com>
To: William Tu <u9012063@gmail.com>
Cc: Brenden Blanco <bblanco@plumgrid.com>,
David Miller <davem@davemloft.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
john.r.fastabend@intel.com,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
xiyou.wangcong@gmail.com
Subject: Re: [net-next PATCH] e1000: add initial XDP support
Date: Sun, 28 Aug 2016 22:36:59 -0700 [thread overview]
Message-ID: <57C3C9FB.3030005@gmail.com> (raw)
In-Reply-To: <CALDO+SZRutKYtL3O71FZJ_=_gsz+LH0_XWdhgqA49OYSXa-K+g@mail.gmail.com>
On 16-08-28 08:56 AM, William Tu wrote:
> Hi,
>
> Reading through the patch, I found some minor typos below.
>
> On Sat, Aug 27, 2016 at 12:11 AM, John Fastabend
> <john.fastabend@gmail.com> wrote:
>> From: Alexei Starovoitov <ast@fb.com>
>>
>> This patch adds initial support for XDP on e1000 driver. Note e1000
>> driver does not support page recycling in general which could be
>> added as a further improvement. However for XDP_DROP and XDP_XMIT
>
> I think you mean XDP_PASS instead of XDP_XMIT?
>
I really meant XDP_TX but see Or's note and next revision will have
XDP_DROP only here.
>> the xdp code paths will recycle pages.
>>
>> This patch includes the rcu_read_lock/rcu_read_unlock pair noted by
>> Brenden Blanco in another pending patch.
>>
>> net/mlx4_en: protect ring->xdp_prog with rcu_read_lock
>>
>> CC: William Tu <u9012063@gmail.com>
>> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>> ---
>> drivers/net/ethernet/intel/e1000/e1000.h | 1
>> drivers/net/ethernet/intel/e1000/e1000_main.c | 168 ++++++++++++++++++++++++-
>> 2 files changed, 165 insertions(+), 4 deletions(-)
>>
>> +static void e1000_xmit_raw_frame(struct e1000_rx_buffer *rx_buffer_info,
>> + unsigned int len,
>> + struct net_device *netdev,
>> + struct e1000_adapter *adapter)
>> +{
>> + struct netdev_queue *txq = netdev_get_tx_queue(netdev, 0);
>> + struct e1000_hw *hw = &adapter->hw;
>> + struct e1000_tx_ring *tx_ring;
>> +
>> + if (len > E1000_MAX_DATA_PER_TXD)
>> + return;
>> +
>> + /* e1000 only support a single txq at the moment so the queue is being
>> + * shared with stack. To support this requires locking to ensure the
>> + * stack and XPD are not running at the same time. Devices would
>> + * multiple queues should allocate a separate queue space.
>> + */
>
> XPD --> XDP
> Devices would --> with?
Yep typo.
>
>> + HARD_TX_LOCK(netdev, txq, smp_processor_id());
>> +
>> + tx_ring = adapter->tx_ring;
>> +
>> + if (E1000_DESC_UNUSED(tx_ring) < 2)
>> + return;
>> +
>> + e1000_tx_map_rxpage(tx_ring, rx_buffer_info, len);
>> +
>> + e1000_tx_queue(adapter, tx_ring, 0/*tx_flags*/, 1);
>> +
>> + writel(tx_ring->next_to_use, hw->hw_addr + tx_ring->tdt);
>> + mmiowb();
>> +
>> + HARD_TX_UNLOCK(netdev, txq);
>> +}
>> +
>> #define NUM_REGS 38 /* 1 based count */
>> static void e1000_regdump(struct e1000_adapter *adapter)
>> {
>> @@ -4142,6 +4240,22 @@ static struct sk_buff *e1000_alloc_rx_skb(struct e1000_adapter *adapter,
>> return skb;
>> }
>>
>> +static inline int e1000_call_bpf(struct bpf_prog *prog, void *data,
>> + unsigned int length)
>> +{
>> + struct xdp_buff xdp;
>> + int ret;
>> +
>> + xdp.data = data;
>> + xdp.data_end = data + length;
>> +
>> + rcu_read_lock();
>> + ret = BPF_PROG_RUN(prog, (void *)&xdp);
>> + rcu_read_unlock();
>> +
>> + return ret;
>> +}
>> +
>> /**
>> * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
>> * @adapter: board private structure
>> @@ -4160,12 +4274,15 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
>> struct pci_dev *pdev = adapter->pdev;
>> struct e1000_rx_desc *rx_desc, *next_rxd;
>> struct e1000_rx_buffer *buffer_info, *next_buffer;
>> + struct bpf_prog *prog;
>> u32 length;
>> unsigned int i;
>> int cleaned_count = 0;
>> bool cleaned = false;
>> unsigned int total_rx_bytes = 0, total_rx_packets = 0;
>>
>> + rcu_read_lock(); /* rcu lock needed here to protect xdp programs */
>> + prog = READ_ONCE(adapter->prog);
>
> If having rcu_read_lock() here, do we still need another in e1000_call_bpf()?
nope good catch. Thanks for the review!
prev parent reply other threads:[~2016-08-29 5:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-27 7:11 [net-next PATCH] e1000: add initial XDP support John Fastabend
2016-08-28 5:55 ` Or Gerlitz
2016-08-29 5:33 ` John Fastabend
2016-08-28 12:23 ` Jamal Hadi Salim
2016-08-29 8:30 ` Jesper Dangaard Brouer
2016-08-29 10:53 ` Jamal Hadi Salim
2016-08-29 13:39 ` Jesper Dangaard Brouer
2016-08-29 15:55 ` Jesper Dangaard Brouer
2016-08-30 12:13 ` Jamal Hadi Salim
2016-08-30 13:31 ` Jesper Dangaard Brouer
2016-09-01 21:35 ` John Fastabend
2016-09-01 19:33 ` John Fastabend
2016-08-28 15:56 ` William Tu
2016-08-29 5:36 ` John Fastabend [this message]
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=57C3C9FB.3030005@gmail.com \
--to=john.fastabend@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bblanco@plumgrid.com \
--cc=davem@davemloft.net \
--cc=john.r.fastabend@intel.com \
--cc=netdev@vger.kernel.org \
--cc=u9012063@gmail.com \
--cc=xiyou.wangcong@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.