From nobody Tue Oct 15 17:43:14 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 4XShJy4ff6z5YlcV; Tue, 15 Oct 2024 17:43: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 4XShJy3Crcz4ZX0; Tue, 15 Oct 2024 17:43:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729014194; 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=a6X9jxEW1J6IDmwArQcol5pV/9j6leDHeQAXSUSNTC8=; b=iPxcg6ctd9FebC48Sd2CQcE3kPbMvkCP7ASoWizkhUGqoFhTx+fYVkDYejp9JLHQT0agzd Fj0YZBLk8/Li+3Z2DjZ50Gf7YDRJT/ArX14lsdwOsLvLb0w2PM9YA9Oyg9tfEcoOmIq1/8 E7VlHsidIdj7sfiyMZQ4Q8zuzkJ0Vw2se/ijLm7y9k5Szc9SJViuJBZrprjxk93H9SegwF n0JCzmc6rJA5QApF3Rojm+V4GBcdQ3/AUryDFVyn1Pl/4YZ+gNjkW9KjfwYO77eUoeZg1i p55wxZTImhF5PEVuerKP7+DnMxoaC1M5ztYDRJMZqQfnm0QhZx0HRQ3nF4EFDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729014194; 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=a6X9jxEW1J6IDmwArQcol5pV/9j6leDHeQAXSUSNTC8=; b=s3YII4sjexAigOG/AvGdGOTdUg8zP2R2td9oS7nilT0LUsm9dKLXVxVY836xTGrEcupWBe 1PS2RNsooRt3K0selue3SO/C0LDu5ScMxmL91aaFW60Q7yZs46eOMqLGyHp6OYdxEL1sF7 Yt1mz+i7ab0RTlPA8q9lilboVDXKf3rbLHX+EKeQ0xz2CetlKpXZ9CTfKgOxWpJSGzk6kw QYkrNI3/gCl1AOG9lYqXb6gFhc2GobWZ6cXg3tpAoP7Qy9jI+F9gy5XoCe1uskEkhK5FoC YR0pB19Pf1QtrRN8eoBdObEC6QQNGVGRKYeM8xjmYejJXkSrH07F/kndlsKdnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729014194; a=rsa-sha256; cv=none; b=X3WwF5N1RuOq1Dv62TtPLodYKoVFncWZqwFOYpse3yBtsZIAmLXA52xo8tmvjTIDZ3vXmF Azrg3AwugWaJWhRe6gSOj7ZUx4krGGCrywd3BWLDhaCNW9HiDpOsYdlLK0UPcMtDJw3kwW +4oszeivESvqTUytTeM+dzNLO1Zqc/vP7Oy2gNoWT1qMWtTYgBBpwv5oNkiL10nqfQl7vg VULZayBQ+XzTszmp5Dwyjcx6BqReyIMiPfltAhIMM/iLCTIFFbi6zlkPoPgJZhhNQM+CTd Gq5l9uNvAvOCPTbvifSKbEYsCvbmUBCQlyg3Y/+AiHdSl1NsJH7QRe+Tb1097g== 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 4XShJy2r4hzX9V; Tue, 15 Oct 2024 17:43: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 49FHhEFw062447; Tue, 15 Oct 2024 17:43:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FHhEMf062444; Tue, 15 Oct 2024 17:43:14 GMT (envelope-from git) Date: Tue, 15 Oct 2024 17:43:14 GMT Message-Id: <202410151743.49FHhEMf062444@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Osama Abboud Subject: git: f236e544a2ff - main - 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/main X-Git-Reftype: branch X-Git-Commit: f236e544a2ff685ae151f3232e3785a6a9aab035 Auto-Submitted: auto-generated The branch main has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=f236e544a2ff685ae151f3232e3785a6a9aab035 commit f236e544a2ff685ae151f3232e3785a6a9aab035 Author: Osama Abboud AuthorDate: 2024-08-07 06:24:20 +0000 Commit: Osama Abboud CommitDate: 2024-10-15 17:38:32 +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) MFC after: 2 weeks Sponsored by: Amazon, Inc. --- 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; }