From nobody Thu Oct 31 16:01:34 2024 X-Original-To: dev-commits-src-all@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 4XfTJH17tmz5bx2S; Thu, 31 Oct 2024 16:01:35 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XfTJG6TPtz4TDX; Thu, 31 Oct 2024 16:01:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390494; 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=B+NkBaTZyYHvL08r5+5i9RP2mpQCmfV3dSTkejMOkWc=; b=RRIT0gsLcs2+K5J7JkxVJKOGIw+/61bfGd/YvHsfNCeFxWzdLyW6yFpsDwxPpeuaj1WEpD ALOswuSaeJIT+K9H0/skt+b/TdT0hxvj3dgoyQtHudEnbm82sf9PW5j6TgeJ2gg6PthU/u 49CMlZ012Fiz3OEcN9AS2TpCpRMKkooBBRnlaAf9PF4pZhcF0KxuORqzI1N5MaEG+IuKtx Bzxm0cwXN5NzC4N6VDlnRib6ewKuXZf6NEEDfK9837ItHSc/0JKNX2qPJWzDvz0N8xQvws jEXePKjqQ9EaocvmTnXVqd3Lbt2yTMn93BorEsTh9Y1z2MEGxMFJnvQlLumHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390494; 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=B+NkBaTZyYHvL08r5+5i9RP2mpQCmfV3dSTkejMOkWc=; b=p0bPils+mE9eOuqJtH9sYjEOYoKhgicbzVDNWcnP7x9pY0fmywdwgzoPwZqnxUDI1m5q8w MUMIIYbQVVcgYl3ex/4pNrKitu3yMtGPI8g+VNUdTJs3JFHbAFs+9BvANR/8nOdM9uswxG RNYTR22LjAdC0kZRRG48yKKuSglak1KQjJy8D7APcVZRML7pFlS/lF6Ka1JV60Xr7yPefy INK9sut+J+20v/chzQkM/FeWcRKEyaLRaQBCaI3h2RHFOv9JOyRerzbtm1c1w2k6q1jgEh XTrX6s0dXggvnGVSAhpVn05AMhRjBK21e1KE4U1F1yskqdhdMjz0HuGdJf6RoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730390494; a=rsa-sha256; cv=none; b=kU5CJgQHR5tuiZJY26ZmRdpIGyo/XBXNMHjIGxqN6X8155UIehk0SAHtisO7+R71de+N2y 84NRI5QNgB5WiRBrhCDhHNHMZ+lffOaXPoVrMMTmSngiY7J2R6PLvi7eBIrbYPyRwWPns2 +6p7Oan1fLHJYs5kDxBxMUNRZLGbzyGJkY1nLfMD6EhMqJCrSxF6x67uhYYcerg+7vnB+m BpXh8DDBGU0K5SoO5pDFWlH11ULmwQJtjN3WOdCyo1EOdBdWGIIVdpnfd7LGECIB0O/dr9 nkWlxZ+zujRHHSuXkKHR37eFN/Bh1VYAjuz5iQLwzi4fwsEsxHGamBl11jHrng== 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 4XfTJG5zlrzjgy; Thu, 31 Oct 2024 16:01:34 +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 49VG1Yuo070479; Thu, 31 Oct 2024 16:01:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VG1Ypc070476; Thu, 31 Oct 2024 16:01:34 GMT (envelope-from git) Date: Thu, 31 Oct 2024 16:01:34 GMT Message-Id: <202410311601.49VG1Ypc070476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Osama Abboud Subject: git: b47eb2848ad8 - stable/14 - ena: Properly unmap last socket chain in netmap List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: osamaabb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b47eb2848ad8537c5213b036e81f1c8f9dd81a25 Auto-Submitted: auto-generated The branch stable/14 has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=b47eb2848ad8537c5213b036e81f1c8f9dd81a25 commit b47eb2848ad8537c5213b036e81f1c8f9dd81a25 Author: Osama Abboud AuthorDate: 2024-08-07 06:24:20 +0000 Commit: Osama Abboud CommitDate: 2024-10-31 14:54:11 +0000 ena: Properly unmap last socket chain in netmap In case ena_com_prepare_tx() fails within the netmap tx flow, the driver will unmap the last socket chain. Currently, the driver unmaps the wrong socket within ena_netmap_unmap_last_socket_chain(). Illustration of the flow: 1- ena_netmap_tx_frames() 2- ena_netmap_tx_frame() 3- ena_netmap_tx_map_slots() 3.1- Map slot 3.2- Advance to the next socket 4- ena_com_prepare_tx() 4.1- ena_com_prepare_tx() fails 5- ena_netmap_unmap_last_socket_chain() In step 5, where the driver unmaps the socket, the netmap index already points at the next entry, meaning we're unmapping the wrong socket in case ena_com_prepare_tx() fails. In order to fix that, the driver should first update the netmap index to point at the previous entry and only then update the socket parameters. Approved by: cperciva (mentor) Sponsored by: Amazon, Inc. (cherry picked from commit f236e544a2ff685ae151f3232e3785a6a9aab035) --- sys/dev/ena/ena_netmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ena/ena_netmap.c b/sys/dev/ena/ena_netmap.c index 0666d7deb827..f14a4a9539d1 100644 --- a/sys/dev/ena/ena_netmap.c +++ b/sys/dev/ena/ena_netmap.c @@ -783,10 +783,10 @@ ena_netmap_unmap_last_socket_chain(struct ena_netmap_ctx *ctx, /* Next, retain the sockets back to the userspace */ n = nm_info->sockets_used; while (n--) { + ctx->nm_i = nm_prev(ctx->nm_i, ctx->lim); ctx->slots[ctx->nm_i].buf_idx = nm_info->socket_buf_idx[n]; ctx->slots[ctx->nm_i].flags = NS_BUF_CHANGED; nm_info->socket_buf_idx[n] = 0; - ctx->nm_i = nm_prev(ctx->nm_i, ctx->lim); } nm_info->sockets_used = 0; }