From: John Fastabend <john.fastabend@gmail.com>
To: Daniel Borkmann <dborkman@redhat.com>
Cc: netdev@vger.kernel.org, danny.zhou@intel.com,
nhorman@tuxdriver.com, john.ronciak@intel.com,
hannes@stressinduktion.org, brouer@redhat.com
Subject: Re: [RFC PATCH v2 2/2] net: ixgbe: implement af_packet direct queue mappings
Date: Tue, 13 Jan 2015 07:46:53 -0800 [thread overview]
Message-ID: <54B53DED.4040502@gmail.com> (raw)
In-Reply-To: <54B52B25.1070809@redhat.com>
On 01/13/2015 06:26 AM, Daniel Borkmann wrote:
> On 01/13/2015 05:35 AM, John Fastabend wrote:
> ...
>> +static int ixgbe_ndo_split_queue_pairs(struct net_device *dev,
>> + unsigned int start_from,
>> + unsigned int qpairs_num,
>> + struct sock *sk)
>> +{
>> + struct ixgbe_adapter *adapter = netdev_priv(dev);
>> + unsigned int qpair_index;
>
> We should probably return -EINVAL, still from within the setsockopt
> call when qpairs_num is 0?
yep,
>
>> + /* allocate whatever available qpairs */
>> + if (start_from == -1) {
>
> I guess we should define the notion of auto-select into a uapi
> define instead of -1, which might not be overly obvious.
Certainly not obvious should be defined in the UAPI.
>
> Anyway, extending Documentation/networking/packet_mmap.txt with
> API details/examples at least for a non-RFC version is encouraged. ;)
Yep for the non-RFC version I'll add an example to packet_mmap.txt
>
>> + unsigned int count = 0;
>> +
>> + for (qpair_index = adapter->num_rx_queues;
>> + qpair_index < MAX_RX_QUEUES;
>> + qpair_index++) {
>> + if (!adapter->user_queue_info[qpair_index].sk_handle) {
>> + count++;
>> + if (count == qpairs_num) {
>> + start_from = qpair_index - count + 1;
>> + break;
>> + }
>> + } else {
>> + count = 0;
>> + }
>> + }
>> + }
>> +
>> + /* otherwise the caller specified exact queues */
>> + if ((start_from > MAX_TX_QUEUES) ||
>> + (start_from > MAX_RX_QUEUES) ||
>> + (start_from + qpairs_num > MAX_TX_QUEUES) ||
>> + (start_from + qpairs_num > MAX_RX_QUEUES))
>> + return -EINVAL;
>
> Shouldn't this be '>=' if I see this correctly?
hmm I think this is correct the device allocates MAX_TX_QUEUES so the
queue space index is (0, MAX_TX_QUEUES - 1). So MAX_TX_QUEUES and
MAX_RX_QUEUES would be an invalid access below,
>
>> + /* If the qpairs are being used by the driver do not let user space
>> + * consume the queues. Also if the queue has already been allocated
>> + * to a socket do fail the request.
>> + */
>> + for (qpair_index = start_from;
>> + qpair_index < start_from + qpairs_num;
>> + qpair_index++) {
>> + if ((qpair_index < adapter->num_tx_queues) ||
>> + (qpair_index < adapter->num_rx_queues))
>> + return -EINVAL;
>> +
>> + if (adapter->user_queue_info[qpair_index].sk_handle)
>> + return -EBUSY;
>> + }
>> +
>> + /* remember the sk handle for each queue pair */
>> + for (qpair_index = start_from;
>> + qpair_index < start_from + qpairs_num;
>> + qpair_index++) {
>> + adapter->user_queue_info[qpair_index].sk_handle = sk;
>> + adapter->user_queue_info[qpair_index].num_of_regions = 0;
^^^^^^^^^^^^^^
(0, MAX_TX_QUEUES - 1)
@@ -673,6 +687,9 @@ Hunk #2, a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
struct ixgbe_adapter {
struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
+ /* Direct User Space Queues */
+ struct ixgbe_user_queue_info user_queue_info[MAX_RX_QUEUES];
+
>> + }
>> +
>> + return 0;
>> +}
>
> I guess many drivers would need to implement similar code, do you see
> a chance to move generic parts to the core, at least for some helper
> functions?
I'm not entirely sure about this. It depends on how the driver manages
its queue space. Many of the 10Gpbs devices it seems could use similar
logic so it might make sense. Other drivers might conjure the queues
out of some other bank of queues. If I'm looking @ the devices I have
here, i40e at least would manage the queues slightly different then this
I think.
>
> Thanks,
> Daniel
--
John Fastabend Intel Corporation
next prev parent reply other threads:[~2015-01-13 15:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 4:35 [RFC PATCH v2 1/2] net: af_packet support for direct ring access in user space John Fastabend
2015-01-13 4:35 ` [RFC PATCH v2 2/2] net: ixgbe: implement af_packet direct queue mappings John Fastabend
2015-01-13 12:05 ` Hannes Frederic Sowa
2015-01-13 14:26 ` Daniel Borkmann
2015-01-13 15:46 ` John Fastabend [this message]
2015-01-13 18:18 ` Daniel Borkmann
2015-01-13 18:58 ` Willem de Bruijn
2015-01-13 4:42 ` [RFC PATCH v2 1/2] net: af_packet support for direct ring access in user space John Fastabend
2015-01-13 12:35 ` Hannes Frederic Sowa
2015-01-13 13:21 ` Daniel Borkmann
2015-01-13 15:24 ` John Fastabend
2015-01-13 17:15 ` David Laight
2015-01-13 17:27 ` David Miller
2015-01-14 15:28 ` Zhou, Danny
2015-01-13 15:12 ` Daniel Borkmann
2015-01-13 15:58 ` John Fastabend
2015-01-13 16:05 ` Daniel Borkmann
2015-01-13 16:19 ` Neil Horman
2015-01-13 18:52 ` Willem de Bruijn
2015-01-14 15:26 ` Zhou, Danny
2015-01-14 20:35 ` David Miller
2015-01-17 17:35 ` John Fastabend
2015-01-18 22:02 ` Neil Horman
2015-01-19 21:45 ` Neil Horman
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=54B53DED.4040502@gmail.com \
--to=john.fastabend@gmail.com \
--cc=brouer@redhat.com \
--cc=danny.zhou@intel.com \
--cc=dborkman@redhat.com \
--cc=hannes@stressinduktion.org \
--cc=john.ronciak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.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).