From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58799C00454 for ; Tue, 10 Dec 2019 21:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D740214D8 for ; Tue, 10 Dec 2019 21:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576012397; bh=+dVhmFBSY3GbhTVxM3STKjRvyQehONRqDjgD14b1w0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DlJOLJqvsHAQlJCfGPvivuKZvvk7GbvtAg3sO1Yam9M4II8LXticHAVGyNgRZ7+wh yEs1KdQbjxgrK6Roux+9eLQZIMjdtTJ1fumptaUaPL8fmwQMfGStnGsZ8fkqJ4nLXN srAuxAv5t12cL7s9dryoUDj9KZz5OPs9ei+I1z68= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729256AbfLJVNQ (ORCPT ); Tue, 10 Dec 2019 16:13:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbfLJVNN (ORCPT ); Tue, 10 Dec 2019 16:13:13 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C4E3222C4; Tue, 10 Dec 2019 21:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576012392; bh=+dVhmFBSY3GbhTVxM3STKjRvyQehONRqDjgD14b1w0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5VxBckK+rYhBdvGfbn9KJZTXY4X7AWbL8/IweVcFpBauewjCJYFNKjM03nzVCh7j Eft/Z4j3Y3fYcyHlRbFJ6mBvQKhQIqnEAxAhUopdwPSfwPURXSVKInkqqHThY3d91K MqZwz2fnIcr4b8iqTJzpJnenL4eqtqO0p/4BK3wA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luigi Rizzo , Alexei Starovoitov , Jakub Kicinski , Magnus Karlsson , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 313/350] net-af_xdp: Use correct number of channels from ethtool Date: Tue, 10 Dec 2019 16:06:58 -0500 Message-Id: <20191210210735.9077-274-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191210210735.9077-1-sashal@kernel.org> References: <20191210210735.9077-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luigi Rizzo [ Upstream commit 3de88c9113f88c04abda339f1aa629397bf89e02 ] Drivers use different fields to report the number of channels, so take the maximum of all data channels (rx, tx, combined) when determining the size of the xsk map. The current code used only 'combined' which was set to 0 in some drivers e.g. mlx4. Tested: compiled and run xdpsock -q 3 -r -S on mlx4 Signed-off-by: Luigi Rizzo Signed-off-by: Alexei Starovoitov Reviewed-by: Jakub Kicinski Acked-by: Magnus Karlsson Link: https://lore.kernel.org/bpf/20191119001951.92930-1-lrizzo@google.com Signed-off-by: Sasha Levin --- tools/lib/bpf/xsk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index a73b79d293337..70f9e10de286e 100644 --- a/tools/lib/bpf/xsk.c +++ b/tools/lib/bpf/xsk.c @@ -344,13 +344,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) goto out; } - if (err || channels.max_combined == 0) + if (err) { /* 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; + } else { + /* Take the max of rx, tx, combined. Drivers return + * the number of channels in different ways. + */ + ret = max(channels.max_rx, channels.max_tx); + ret = max(ret, (int)channels.max_combined); + } out: close(fd); -- 2.20.1