netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Mikityanskiy <maximmi@mellanox.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Magnus Karlsson" <magnus.karlsson@intel.com>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Saeed Mahameed" <saeedm@mellanox.com>,
	"Jonathan Lemon" <bsd@fb.com>,
	"Tariq Toukan" <tariqt@mellanox.com>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Maciej Fijalkowski" <maciejromanfijalkowski@gmail.com>
Subject: Re: [PATCH bpf-next v4 07/17] libbpf: Support drivers with non-combined channels
Date: Thu, 13 Jun 2019 14:01:39 +0000	[thread overview]
Message-ID: <0afd3ef2-d0e3-192b-095e-0f8ae8e6fb5d@mellanox.com> (raw)
In-Reply-To: <20190612132352.7ee27bf3@cakuba.netronome.com>

On 2019-06-12 23:23, Jakub Kicinski wrote:
> On Wed, 12 Jun 2019 15:56:48 +0000, Maxim Mikityanskiy wrote:
>> Currently, libbpf uses the number of combined channels as the maximum
>> queue number. However, the kernel has a different limitation:
>>
>> - xdp_reg_umem_at_qid() allows up to max(RX queues, TX queues).
>>
>> - ethtool_set_channels() checks for UMEMs in queues up to
>>    combined_count + max(rx_count, tx_count).
>>
>> libbpf shouldn't limit applications to a lower max queue number. Account
>> for non-combined RX and TX channels when calculating the max queue
>> number. Use the same formula that is used in ethtool.
>>
>> Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
>> Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
>> Acked-by: Saeed Mahameed <saeedm@mellanox.com>
> 
> I don't think this is correct.  max_tx tells you how many TX channels
> there can be, you can't add that to combined.  Correct calculations is:
> 
> max_num_chans = max(max_combined, max(max_rx, max_tx))

First of all, I'm aligning with the formula in the kernel, which is:

     curr.combined_count + max(curr.rx_count, curr.tx_count);

(see net/core/ethtool.c, ethtool_set_channels()).

The formula in libbpf should match it.

Second, the existing drivers have either combined channels or separate 
rx and tx channels. So, for the first kind of drivers, max_tx doesn't 
tell how many TX channels there can be, it just says 0, and max_combined 
tells how many TX and RX channels are supported. As max_tx doesn't 
include max_combined (and vice versa), we should add them up.

>>   tools/lib/bpf/xsk.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
>> index bf15a80a37c2..86107857e1f0 100644
>> --- a/tools/lib/bpf/xsk.c
>> +++ b/tools/lib/bpf/xsk.c
>> @@ -334,13 +334,13 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
>>   		goto out;
>>   	}
>>   
>> -	if (channels.max_combined == 0 || errno == EOPNOTSUPP)
>> +	ret = channels.max_combined + max(channels.max_rx, channels.max_tx);
>> +
>> +	if (ret == 0 || errno == EOPNOTSUPP)
>>   		/* If the device says it has no channels, then all traffic
>>   		 * is sent to a single stream, so max queues = 1.
>>   		 */
>>   		ret = 1;
>> -	else
>> -		ret = channels.max_combined;
>>   
>>   out:
>>   	close(fd);
> 


  parent reply	other threads:[~2019-06-13 15:07 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 15:56 [PATCH bpf-next v4 00/17] AF_XDP infrastructure improvements and mlx5e support Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 01/17] net/mlx5e: Attach/detach XDP program safely Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 02/17] xsk: Add API to check for available entries in FQ Maxim Mikityanskiy
2019-06-13 12:50   ` Björn Töpel
2019-06-12 15:56 ` [PATCH bpf-next v4 03/17] xsk: Add getsockopt XDP_OPTIONS Maxim Mikityanskiy
2019-06-13 12:50   ` Björn Töpel
2019-06-12 15:56 ` [PATCH bpf-next v4 04/17] libbpf: Support " Maxim Mikityanskiy
2019-06-13 12:51   ` Björn Töpel
2019-06-12 15:56 ` [PATCH bpf-next v4 05/17] xsk: Change the default frame size to 4096 and allow controlling it Maxim Mikityanskiy
2019-06-12 20:10   ` Jakub Kicinski
2019-06-13 14:01     ` Maxim Mikityanskiy
2019-06-13 17:29       ` Jakub Kicinski
2019-06-14 13:25         ` Maxim Mikityanskiy
2019-06-15  1:40           ` Jakub Kicinski
2019-06-18 12:00             ` Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 06/17] xsk: Return the whole xdp_desc from xsk_umem_consume_tx Maxim Mikityanskiy
2019-06-13 12:48   ` Björn Töpel
2019-06-12 15:56 ` [PATCH bpf-next v4 07/17] libbpf: Support drivers with non-combined channels Maxim Mikityanskiy
2019-06-12 20:23   ` Jakub Kicinski
2019-06-13 12:41     ` Björn Töpel
2019-06-13 17:34       ` Jakub Kicinski
2019-06-13 14:01     ` Maxim Mikityanskiy [this message]
2019-06-13 14:45       ` Maciej Fijalkowski
2019-06-14 13:25         ` Maxim Mikityanskiy
2019-06-14 17:15           ` Maciej Fijalkowski
2019-06-14 19:50             ` Björn Töpel
2019-06-18 12:00             ` Maxim Mikityanskiy
2019-06-13 18:09       ` Jakub Kicinski
2019-06-14 13:25         ` Maxim Mikityanskiy
2019-06-15  2:12           ` Jakub Kicinski
2019-06-12 15:56 ` [PATCH bpf-next v4 08/17] net/mlx5e: Replace deprecated PCI_DMA_TODEVICE Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 09/17] net/mlx5e: Calculate linear RX frag size considering XSK Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 10/17] net/mlx5e: Allow ICO SQ to be used by multiple RQs Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 11/17] net/mlx5e: Refactor struct mlx5e_xdp_info Maxim Mikityanskiy
2019-06-12 15:56 ` [PATCH bpf-next v4 12/17] net/mlx5e: Share the XDP SQ for XDP_TX between RQs Maxim Mikityanskiy
2019-06-12 15:57 ` [PATCH bpf-next v4 13/17] net/mlx5e: XDP_TX from UMEM support Maxim Mikityanskiy
2019-06-12 15:57 ` [PATCH bpf-next v4 14/17] net/mlx5e: Consider XSK in XDP MTU limit calculation Maxim Mikityanskiy
2019-06-12 15:57 ` [PATCH bpf-next v4 15/17] net/mlx5e: Encapsulate open/close queues into a function Maxim Mikityanskiy
2019-06-12 15:57 ` [PATCH bpf-next v4 16/17] net/mlx5e: Move queue param structs to en/params.h Maxim Mikityanskiy
2019-06-12 15:57 ` [PATCH bpf-next v4 17/17] net/mlx5e: Add XSK zero-copy support Maxim Mikityanskiy
2019-06-15 15:42   ` Jakub Kicinski
2019-06-18 12:00     ` Maxim Mikityanskiy
2019-06-12 19:10 ` [PATCH bpf-next v4 00/17] AF_XDP infrastructure improvements and mlx5e support Jonathan Lemon
2019-06-12 20:48 ` Jakub Kicinski
2019-06-13 12:58   ` Björn Töpel
2019-06-13 14:01     ` Maxim Mikityanskiy
2019-06-13 14:11       ` Björn Töpel
2019-06-13 14:53         ` Björn Töpel
2019-06-13 14:01   ` Maxim Mikityanskiy

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=0afd3ef2-d0e3-192b-095e-0f8ae8e6fb5d@mellanox.com \
    --to=maximmi@mellanox.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=bsd@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=kafai@fb.com \
    --cc=maciejromanfijalkowski@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=songliubraving@fb.com \
    --cc=tariqt@mellanox.com \
    --cc=yhs@fb.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).