Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71016CE8D50 for ; Fri, 14 Nov 2025 16:03:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 39EC7611B1; Fri, 14 Nov 2025 16:03:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Hv_GWkXjoqMr; Fri, 14 Nov 2025 16:03:35 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2F4B8607EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1763136215; bh=bte06RvP1Ns3uJUbnsCYNwVEAvBdal+RTPg/GP86gGU=; h=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=k3vVFbxfIIBE0yZcdej4iZ6V6xuNu8XRnhaChLahdEwnA+i0KMmTe2UtB/qNvxMTy nvZQVRthDXRB7lcbPGAHe9ojEHz5XMtu6pPrPajiC/612nMvYiobm2lnDCx7RtTaMA u5K7K69Z9pUtJHYxoZzdrHcwFtzr0B0agO0F00cJbo9iMByFBYDv2MF/yLi0V/qq9i +0EHAu/fZUjHDVPb8PaG+Vu3P1xE7jLUCj3EcjbKCJwC6h+ObXXZ01IX95JQ8aNPpO HXUP8RvcSTZYQMN6gQYS2IDZYZ4vzqwx0IQ8XNq/mLEKsB4hxN+6qGy+y90LjLRwf0 SsViXAqF/rJ+A== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 2F4B8607EF; Fri, 14 Nov 2025 16:03:35 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists1.osuosl.org (Postfix) with ESMTP id E977DD5 for ; Fri, 14 Nov 2025 16:03:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DA68B4111B for ; Fri, 14 Nov 2025 16:03:33 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id WBf1TgxcZqAe for ; Fri, 14 Nov 2025 16:03:33 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=205.220.165.32; helo=mx0a-00069f02.pphosted.com; envelope-from=gregory.herrero@oracle.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org CA4FA41119 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CA4FA41119 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by smtp4.osuosl.org (Postfix) with ESMTPS id CA4FA41119 for ; Fri, 14 Nov 2025 16:03:32 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AECuFdI000348; Fri, 14 Nov 2025 16:03:28 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4adr8uhdy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Nov 2025 16:03:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AEEYTWu022109; Fri, 14 Nov 2025 16:03:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4a9vadpv9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Nov 2025 16:03:27 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AEG3IZD029266; Fri, 14 Nov 2025 16:03:27 GMT Received: from oracle (dhcp-10-154-173-166.vpn.oracle.com [10.154.173.166]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4a9vadpv0s-2; Fri, 14 Nov 2025 16:03:26 +0000 From: gregory.herrero@oracle.com To: aleksandr.loktionov@intel.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gregory Herrero Date: Fri, 14 Nov 2025 17:03:04 +0100 Message-ID: <20251114160304.2576306-2-gregory.herrero@oracle.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251114160304.2576306-1-gregory.herrero@oracle.com> References: <20251114160304.2576306-1-gregory.herrero@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-14_04,2025-11-13_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511140129 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTEzMDE3OCBTYWx0ZWRfX8OMqO2mhG4Fa zsKtH5bI9Dq/Jy4eDfczc/o8RoT7kIwnYwuhAxN0ZHCobL1ohdfdSTMmjZGE+6lUPXGIBhJgiFh RNwPGd6U4V9P1pfyvzDNlkdCIF6D4G3zh6PrmgtQUG4I/PqThyxFzCwNl5WqJGzXCTUssU99w8w 9mdGU++6VUUUML3MwEdehrYcySBixAC4OgO4drVL6Nuymw+10DSFFcnqsLF/Ko58huTE+NgIgJK pf1hVJR2XyO8dmBwF49zaAime183ZCfXnjaAIRngwMsRLjouybMEuZ2EV3O4NmhQGVvM2Nj8157 iM/xAviIJKTRy7WpXWwJTE6DB4JhA/IHi9FcKZGblGnjiBRgrdzVDwmflWxXnTVtcL0xUKzXOsV qNcogqgUJkiWYoRwzfN6t2G7X9/emQ== X-Proofpoint-ORIG-GUID: BUMw4X2x_zQxi5VwPb3LmPctTwbwx19T X-Authority-Analysis: v=2.4 cv=FKAWBuos c=1 sm=1 tr=0 ts=691752d0 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=9o2BAfuAlkXtMw4cUEAA:9 X-Proofpoint-GUID: BUMw4X2x_zQxi5VwPb3LmPctTwbwx19T X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=bte06 RvP1Ns3uJUbnsCYNwVEAvBdal+RTPg/GP86gGU=; b=G24IlMxMxLaydliB0hUlF 6KKP9cmuZr+NSd7HptSQstJt49HMcJL6wOTEnVE4bsjcD72c3sWXrotypeV/sIzZ pvFO52bBQQzplparMYw7jEPKWOx+ciuXXC8Ohzljn8orTgT/pCOHFv271jYtPSs4 XXlZxwUC7AGw+KGI3bUn3i79kASTDkuhcFCPb3h1X2/Oc65LYVO8EovTsqvjYP1f YiXYrMo9U18Fvv9wedDAxW4H5wPJAd++3jB9jsagDtzKnFAUr/HVYE93EiNitNSM VFPQnb2SBI132FWv7bXkbEv76zLN0/OwHUKrIt5VwA+fditOgXGUopA//kHd2zo9 A== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=reject dis=none) header.from=oracle.com X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2025-04-25 header.b=G24IlMxM Subject: [Intel-wired-lan] [PATCH v3 1/1] i40e: validate ring_len parameter against hardware-specific values X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Gregory Herrero The maximum number of descriptors supported by the hardware is hardware dependent and can be retrieved using i40e_get_max_num_descriptors(). Move this function to a shared header and use it when checking for valid ring_len parameter rather than using hardcoded value. Cast info->ring_len to u32 in i40e_config_vsi_tx_queue() as it's u16 in struct virtchnl_txq_info. By fixing an over-acceptance issue, behavior change could be seen where ring_len could now be rejected while configuring rx and tx queues if its size is larger than the hardware-specific maximum number of descriptors. Fixes: 55d225670def ("i40e: add validation for ring_len param") Signed-off-by: Gregory Herrero --- drivers/net/ethernet/intel/i40e/i40e.h | 17 +++++++++++++++++ drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ------------ .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 801a57a925da..a953cce008f4 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -1418,4 +1418,21 @@ static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf) return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL; } +/** + * i40e_get_max_num_descriptors - get maximum number of descriptors for this hardware. + * @pf: pointer to a PF + * + * Return: u32 value corresponding to the maximum number of descriptors. + **/ +static inline u32 i40e_get_max_num_descriptors(const struct i40e_pf *pf) +{ + const struct i40e_hw *hw = &pf->hw; + + switch (hw->mac.type) { + case I40E_MAC_XL710: + return I40E_MAX_NUM_DESCRIPTORS_XL710; + default: + return I40E_MAX_NUM_DESCRIPTORS; + } +} #endif /* _I40E_H_ */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c index 86c72596617a..61c39e881b00 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c @@ -2013,18 +2013,6 @@ static void i40e_get_drvinfo(struct net_device *netdev, drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN; } -static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf) -{ - struct i40e_hw *hw = &pf->hw; - - switch (hw->mac.type) { - case I40E_MAC_XL710: - return I40E_MAX_NUM_DESCRIPTORS_XL710; - default: - return I40E_MAX_NUM_DESCRIPTORS; - } -} - static void i40e_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, struct kernel_ethtool_ringparam *kernel_ring, diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 081a4526a2f0..5ecc9bb908f9 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -656,7 +656,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id, /* ring_len has to be multiple of 8 */ if (!IS_ALIGNED(info->ring_len, 8) || - info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) { + (u32)info->ring_len > i40e_get_max_num_descriptors(pf)) { ret = -EINVAL; goto error_context; } @@ -726,7 +726,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id, /* ring_len has to be multiple of 32 */ if (!IS_ALIGNED(info->ring_len, 32) || - info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) { + info->ring_len > i40e_get_max_num_descriptors(pf)) { ret = -EINVAL; goto error_param; } -- 2.51.0