From nobody Tue Apr 29 17:15:13 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Zn6QB24DLz5vHm9; Tue, 29 Apr 2025 17:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zn6QB18Kwz3Zcc; Tue, 29 Apr 2025 17:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745946914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0r8b2+hgC5YVoSfCSiGp6j6vPmdOETG7x7Uw4FImKH0=; b=Ba6/UXNAE6XsIQEGoxSomDVxH//iAdu14bjb+Imlizrd7cJT7qAHc4ScbNmXJX8Jjk8jqR +6/St9dhFhoOkt7Vb2IR36Y4XJfMXqjjjW02+FKC/HIEMlS5Si/a6ocfHFWfWxt16DcCI+ Up7NwwehThUGckkvYn0Gtg8JBU627d4r0ObwtTf01VwUnpA3blOuzGhUGWaG5aT7de9kj/ oEFoV9SBc+ppPa4e5KJaEdpZPY8zC8GjuqR8+lRPXzWAHDhOwFVbUFtdGIYRUJaCVrh2IC fnJjCuXE6x5pgfpmmV0yustK9wpLvDQvmS5Gcu05e7DO/wmRu53qpZBIFpcfBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745946914; a=rsa-sha256; cv=none; b=NPyW4qAxnXBfigh2HKo11+zy0CmYiPoi019Nq4VjsopTA6z2MSq5/NGUVNL0FdB0Y4b+dp yflRZWevWLtyp/7ff2moRaKdRxLg0f08aZzBcec1uej5MPwABQ0YHR2UbKJYMUhSTnRCi6 aMI2fRQu1oym1HRIjm19eVZVHPKIO4jRMhgDhC43oh/ErM5LAq7FK3YNBx2By7+axm3i7z mJch6KzGWxSL5RL1/zs9MzbxUGxjivFOjFI2Q+2kiuQFo3t39rqXg/n9l3gPWVSmvDFTvV jj/tMyIb9/yeOTlXRbyqRSy6ZGPcWq6mXHaaNIeSXykzzzpSXf25Pa/7SlqL5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745946914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0r8b2+hgC5YVoSfCSiGp6j6vPmdOETG7x7Uw4FImKH0=; b=wWtAGpYkpoO0lBhgvtmYWFAewVJuTtPW+VZDRVlw8qYni1rEf8FcXHT6W1AYJyd77zXRsj 3sBBvysTek8f1JCVCWp2XXFJ1K21xDIzaHbBaysBzW2DSbdKSR6bfaGFAHeLvO0DifmB3Q 6xqclc85tPRfD1VL22sXhnoLsvLHWfZ7grhqpWCJS9QgtTis9dblYXgCOTOr3Afd8L9Xva Isg3lTHsyqzc8lB3kr3cy4Iq0sYM2v6BCvHL8gaubz38Ageg4RJV4dKVrtXdWgGikXm++A w6jVINBl8KrdC+7mXbwBdvFI3Jooo2R4heGOGAxfwmcqkRHtNyQA76q5TyXxJw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Zn6QB0WQ7zTg9; Tue, 29 Apr 2025 17:15:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53THFDR0079813; Tue, 29 Apr 2025 17:15:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53THFDlb079810; Tue, 29 Apr 2025 17:15:13 GMT (envelope-from git) Date: Tue, 29 Apr 2025 17:15:13 GMT Message-Id: <202504291715.53THFDlb079810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Arthur Kiyanovski Subject: git: 56c45700f2ae - main - ena: Fix misconfiguration when requesting regular LLQ List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: akiyano X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 56c45700f2ae15755358f2da8266247613c564df Auto-Submitted: auto-generated The branch main has been updated by akiyano: URL: https://cgit.FreeBSD.org/src/commit/?id=56c45700f2ae15755358f2da8266247613c564df commit 56c45700f2ae15755358f2da8266247613c564df Author: David Arinzon AuthorDate: 2025-04-22 10:54:18 +0000 Commit: Arthur Kiyanovski CommitDate: 2025-04-29 17:00:06 +0000 ena: Fix misconfiguration when requesting regular LLQ Patch 0a33c047a443 introduced new values to hw.ena.force_large_llq_header. The default value of 2 means no preference, while 0 and 1 act as the previous false and true respectively, which allowed forcefully setting regular or large LLQ. There are 2 ways to force the driver to select regular LLQ: 1. Setting hw.ena.force_large_llq_header = 0 via sysctl. 2. Turning on ena express, which makes the recommendation by the FW to be regular LLQ. When the device supports large LLQ but the driver is forced to regular LLQ, llq_config->llq_ring_entry_size_value is never initialized and since it is a variable allocated on the stack, it stays garbage. Since this variable is involved in calculating max_entries_in_tx_burst, it could cause the maximum burst size to be zero. This causes the driver to ignore the real maximum burst size of the device, leading to driver resets in devices that have a maximum burst size (Nitro v4 and on. see [1] for more information). In case the garbage value is 0, the calculation of max_entries_in_tx_burst divides by 0 and causes kernel panic. The patch modifies the logic to take into account all use-cases and ensure that the relevant fields are properly initialized. [1]: https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html Fixes: 0a33c047a443 ("ena: Support LLQ entry size recommendation from device") Approved by: cperciva (mentor) MFC after: 3 days Sponsored by: Amazon, Inc. Differential Revision: https://reviews.freebsd.org/D50040 --- sys/dev/ena/ena.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index f0b6cec1bb61..af158b5aea1d 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -2759,22 +2759,41 @@ static inline void ena_set_llq_configurations(struct ena_llq_configurations *llq_config, struct ena_admin_feature_llq_desc *llq, struct ena_adapter *adapter) { + bool use_large_llq; + llq_config->llq_header_location = ENA_ADMIN_INLINE_HEADER; llq_config->llq_stride_ctrl = ENA_ADMIN_MULTIPLE_DESCS_PER_ENTRY; llq_config->llq_num_decs_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_2; - if ((llq->entry_size_ctrl_supported & ENA_ADMIN_LIST_ENTRY_SIZE_256B) != 0) { - if ((ena_force_large_llq_header == ENA_LLQ_HEADER_SIZE_POLICY_LARGE) || - (ena_force_large_llq_header == ENA_LLQ_HEADER_SIZE_POLICY_DEFAULT && - llq->entry_size_recommended == ENA_ADMIN_LIST_ENTRY_SIZE_256B)) { - llq_config->llq_ring_entry_size = - ENA_ADMIN_LIST_ENTRY_SIZE_256B; - llq_config->llq_ring_entry_size_value = 256; - adapter->llq_policy = ENA_ADMIN_LIST_ENTRY_SIZE_256B; - } + + switch (ena_force_large_llq_header) + { + case ENA_LLQ_HEADER_SIZE_POLICY_REGULAR: + use_large_llq = false; + break; + case ENA_LLQ_HEADER_SIZE_POLICY_LARGE: + use_large_llq = true; + break; + case ENA_LLQ_HEADER_SIZE_POLICY_DEFAULT: + use_large_llq = + (llq->entry_size_recommended == ENA_ADMIN_LIST_ENTRY_SIZE_256B); + break; + default: + use_large_llq = false; + ena_log(adapter->pdev, WARN, + "force_large_llq_header should have values [0-2]\n"); + break; + } + + if (!(llq->entry_size_ctrl_supported & ENA_ADMIN_LIST_ENTRY_SIZE_256B)) + use_large_llq = false; + + if (use_large_llq) { + llq_config->llq_ring_entry_size = ENA_ADMIN_LIST_ENTRY_SIZE_256B; + llq_config->llq_ring_entry_size_value = 256; + adapter->llq_policy = ENA_ADMIN_LIST_ENTRY_SIZE_256B; } else { - llq_config->llq_ring_entry_size = - ENA_ADMIN_LIST_ENTRY_SIZE_128B; + llq_config->llq_ring_entry_size = ENA_ADMIN_LIST_ENTRY_SIZE_128B; llq_config->llq_ring_entry_size_value = 128; adapter->llq_policy = ENA_ADMIN_LIST_ENTRY_SIZE_128B; }