From nobody Thu Oct 31 16:00:08 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 4XfTGd1fMBz5bwcT; Thu, 31 Oct 2024 16:00:09 +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 4XfTGc6VPHz4PKm; Thu, 31 Oct 2024 16:00:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390408; 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=Eh2Ltzn7YPt0LgJJxUkiDaU6ccsI1kK8voSVLXUZH8I=; b=vwArqJsazYBQktYaScozey5vkciR0QwSZ1oR3/VySdlatx0J88z/BgfcvhXkKlfx+l+aIl Uv4dr0RFpCO2UNOl0sELYk94OmO1fTarDFHwcsVZ11sdwR6gIOEFH2VJ9PknZaEUgBF2Ku yuoEOFWEsYGuf6OIjyOwCnjWIRZqxafCk8bPzS+azGcNde1cTesPUQVJ0rRk5UAGXMgC0U OUWpHVammbJHSghfTt1HF0IkJrCtl2biSe1d+Q5cMrRLoh/w4+awWf3GyiIwni4YyPnez+ DiRAtK7fjJ6/Cl7rODEELZAif3wJC9YL7MBcKu5xC6h/RZ7a41XXlxpI7dKMwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390408; 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=Eh2Ltzn7YPt0LgJJxUkiDaU6ccsI1kK8voSVLXUZH8I=; b=RccPYFohHjC1zRwo129MtTpV+Bw3yshOd8SE1dF5XrTxyjD3xuAX75i39cxQzjt26b8yey oCqoExa7E8Lna48hcUCpeteH0QePOSudkkHg3UPxQCWlQfzZmlhMsdE55jiVbXAeNLRhUB Xywe8kz3Q8S9KHxT7aA5cw0hZTaFHE3xzNzhWyzPaZZl8/yBRHWi8UT6/gGUvI3G8sJCcT NwgeMZcPiPH+Gne3UMISTzrfZ5YlHY2Wo48Iu/dg6Fk04jifivSDQk3i1oAepcNX+dj/Eb LcnIWMf4WOfJhof+piYi0Dyq8+1nhTXMiaUPW3OHAK7XwuHg3zx6xcQytwPhww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730390408; a=rsa-sha256; cv=none; b=inbNy9+vID61myMqBbYWCy4jij8w5dPrvQ/z/kQEIICY4eUNe8HjzAsCuNnLOAarUKTO4K NHfkSU3BBFhPsJ1zPQkKp44Eyttl2ZlGEiFU7qLL7682eYjfhZ1MpBPVl/iuKpA/gKtpOG yYdHkix1n2DDjrwrgi9YtLVinQM0AFWyjJ9aeYDIRbBhJXRrZSV0bjpgKmiGitRHnTrNzm 4KaV6QoLv4v3JsbkpmAiQtdk6ciN9UUFb1mqTC6As7Bg4n2lUOwHtal5Pa/SGhPdsnoHkZ 3BscKKFIvSr6j8GnXnIrs1kTimxBGALOAStbbLrRN8vvbXp/qwvk5f+Ak6uhDg== 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 4XfTGc65lyzjV7; Thu, 31 Oct 2024 16:00:08 +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 49VG08UD061625; Thu, 31 Oct 2024 16:00:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VG08uE061620; Thu, 31 Oct 2024 16:00:08 GMT (envelope-from git) Date: Thu, 31 Oct 2024 16:00:08 GMT Message-Id: <202410311600.49VG08uE061620@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: cd995601730a - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: cd995601730acb15c50044196fd8acc782e4cdbc Auto-Submitted: auto-generated The branch stable/13 has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=cd995601730acb15c50044196fd8acc782e4cdbc commit cd995601730acb15c50044196fd8acc782e4cdbc Author: Osama Abboud AuthorDate: 2024-08-07 06:24:20 +0000 Commit: Osama Abboud CommitDate: 2024-10-31 14:55:20 +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 54c8269be3b2..ae269cca853a 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; }