Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2998063rwe; Mon, 29 Aug 2022 04:16:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+kN3bOCsuwjuvbmzvYSNVOCWeJ29Bwmh9S/K/uRRPBCDooCHG/6yR4g6MpU2lGff1Qggb X-Received: by 2002:a17:907:2701:b0:741:51eb:2338 with SMTP id w1-20020a170907270100b0074151eb2338mr6224335ejk.501.1661771793844; Mon, 29 Aug 2022 04:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661771793; cv=none; d=google.com; s=arc-20160816; b=blGb5pQ4X++aXjg8hmhgW9f+HUXNntM+Xvds8ssBvQhupz66iPf/LAW0ZSLf9q1ioq PSPm4xptMNuU23a+Ey9WiA0RGZOZz2iwvWOC36vybNWdbqflqZ73nYdwlJNACZMIW2rQ V7zt03R+t1x2bGbS8Co5NZIAYItprhJt+A07xBVVJc16/ebt5le84KMYMGJU4Us6l1fH DU/0vioWmCi+0vKaCZ5Ycye4PSc1vE40kaX+CI7IUik0GSnnNmdVMNdFkthROlvhL+cP lKZnMNPmp821WSpXe9htUU/sCkjoAfwptvmPZMkfJkeZ7vCLYzwktWiK6b8scaDeIupe sarA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kh5r+N91bWymcCqYDKDjrjoBibt4L7PlZbqTh+XX8Po=; b=jGr5nQcuO+NnBd1/Fho1MMIrAmjusBmw2U0+pLJ/9Vn4hBG9BzQNyYYa0hjvrWFaMn kuZ8Yc6sTpKUaI7TtgatFdi3k0EGLLnZUsMQamYzqUW5pcnx6VMcgIzTuEkwzwtkDbBE QEyRn49Z/TWQ7ZocgNmDe/MmuiiAxdU/Cl7CJ8In2oo744jvtTYJRHMmzb3CcaxgXDiy 3FiCBihObqNJucWKdm9/PwT+HDEVi/bys9jTwh8KJtrjkkG8ZgSOgUezkbojIb8MpGgd NWUBviOvKRITuNiVsX8sXRz7QUbBuSjkfOsy9ddY1qit8nl9kuGFFYEOVikO3jEgXcnX S6jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=efeLh3Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a056402274100b0044884549409si1746425edd.356.2022.08.29.04.16.07; Mon, 29 Aug 2022 04:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=efeLh3Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbiH2LFR (ORCPT + 99 others); Mon, 29 Aug 2022 07:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbiH2LEp (ORCPT ); Mon, 29 Aug 2022 07:04:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A920965561; Mon, 29 Aug 2022 04:03:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE9F4611B3; Mon, 29 Aug 2022 11:02:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF349C433D7; Mon, 29 Aug 2022 11:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661770976; bh=ppS9l44tHEoQsdyx5V2kZGJrCq/NhHjcBSKkEb2/fGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=efeLh3CbivcPjfBbY8KNgGgYblie5JlGh48m4/KMyDMblL0NYyOmZqa0CEG2qUQ8c +//4RlqoIbcCd+0MZzqYAxYjbvbdBPjgMmsQhgXzl4BknSgxVblev0Qx9SJQQeDxRv XwX646G2OzogcUuONa+UIKboDadbL1skRo1PUaKk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Lobakin , Maciej Fijalkowski , Daniel Borkmann , Magnus Karlsson , Sasha Levin Subject: [PATCH 5.15 042/136] ice: xsk: Force rings to be sized to power of 2 Date: Mon, 29 Aug 2022 12:58:29 +0200 Message-Id: <20220829105806.324347516@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105804.609007228@linuxfoundation.org> References: <20220829105804.609007228@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maciej Fijalkowski [ Upstream commit 296f13ff3854535009a185aaf8e3603266d39d94 ] With the upcoming introduction of batching to XSK data path, performance wise it will be the best to have the ring descriptor count to be aligned to power of 2. Check if ring sizes that user is going to attach the XSK socket fulfill the condition above. For Tx side, although check is being done against the Tx queue and in the end the socket will be attached to the XDP queue, it is fine since XDP queues get the ring->count setting from Tx queues. Suggested-by: Alexander Lobakin Signed-off-by: Maciej Fijalkowski Signed-off-by: Daniel Borkmann Reviewed-by: Alexander Lobakin Acked-by: Magnus Karlsson Link: https://lore.kernel.org/bpf/20220125160446.78976-3-maciej.fijalkowski@intel.com Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_xsk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index 5581747947e57..0348cc4265034 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -321,6 +321,13 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) bool if_running, pool_present = !!pool; int ret = 0, pool_failure = 0; + if (!is_power_of_2(vsi->rx_rings[qid]->count) || + !is_power_of_2(vsi->tx_rings[qid]->count)) { + netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n"); + pool_failure = -EINVAL; + goto failure; + } + if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi); if (if_running) { @@ -343,6 +350,7 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) netdev_err(vsi->netdev, "ice_qp_ena error = %d\n", ret); } +failure: if (pool_failure) { netdev_err(vsi->netdev, "Could not %sable buffer pool, error = %d\n", pool_present ? "en" : "dis", pool_failure); -- 2.35.1