From nobody Sun Jan 23 19:50:33 2022 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 49B0B1980BFE; Sun, 23 Jan 2022 19:50:34 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JhkHY5XY3z3w6v; Sun, 23 Jan 2022 19:50:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642967434; 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=1QCdQhtw4/KhnJoefPfFfcnXVVxiirPZtQPo1IOaNSQ=; b=lZ+aKXQn2Te7PwAIEoYvWcbQe6Tr6fpGYGUQsOTJYTryofH/QcWouQcevs1g2ON+D3J6yv s2PLR9BiVRN+W3bdWQdtsX2piJMn2ETqtBMJeaDYVUW/2g1VpN5vJsNZXf0ZDd11Dk6/wn 7y5z5XzMpmTWL4j7rLjydvr1YDC+mnYZJoBZG08iMyllaZ71CRQqJgpBQ862iam+HjLC5G ZQkTT1mSRKSWg5m5dlDDHLnd+qy6ynI5coazLqn3c+MDO5xeURBLserS2KmwjIIBPnV9w5 5nrL9F0Sbj2OXWeoUyhBigqHjEbyODtfOTB9rad2VmULamlZy1LGGu9S03ZzfQ== 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 742FB158; Sun, 23 Jan 2022 19:50:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20NJoXjZ058354; Sun, 23 Jan 2022 19:50:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20NJoXR7058353; Sun, 23 Jan 2022 19:50:33 GMT (envelope-from git) Date: Sun, 23 Jan 2022 19:50:33 GMT Message-Id: <202201231950.20NJoXR7058353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: b168d0c850f3 - main - ena: rework tx req_id validation logic 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b168d0c850f34e8178d815ba3a87de2657a02ca9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642967434; 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=1QCdQhtw4/KhnJoefPfFfcnXVVxiirPZtQPo1IOaNSQ=; b=oDmRpce/LA8o4C/PT2oNRt6PF/1lhGb11ThFAts0bVu025in0S5LEQY4RQ+TOdc/gNeN4C PMOIYEzt2gKBBnrd2wZI72TTMegHBKNeHrJxKG4IuzXwOGfm2cEkID/OC3EuVu8FDolTQr CVqZaXseaUhayivVuIeEn7nNzas4uibn+xPt4XOztZ5OE8RkmCjM1G3cLgJSXd2pVsd2Vi IZpqCsU9rLjJQh1Gj4lG9dTspDkKgM1mT2sp5+0qOVfZp27daq/0cVW8PDhvDGAamSEswJ uazHz6oqS5r48F6W6F17ZKLM7Ht1xYvZBnDtvystGBiB1knSuzejzdD/fa/OAg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642967434; a=rsa-sha256; cv=none; b=qYpUQOfRKE568r8QLuTX7QEu40sw9axRrK65bxA5GQFC1elBpZr/aWrsOQavFQGTmC/KQy i9o5pf7/bSi5YzBPccYyqMD9/xZa56rwDeeGgzy1VGFG7zkPCaIMni62EF0gpzHQnRz76i df/xLPHdHQijgIc9R2tt6FFyeOy/FDINjI2EF6ZdhwfPuRu+R38wXVyKqHPZ6bJuFoLRcD 1W0iR2QnkWUB93kdC56Qm1rCbOIfJoWQ+okTQU0CdlOT6w/bIYUx06EG7Hg9mpVSoUt3On etfKMz0E7SDHANrFnSJs3gHv3mmd+bGY+owMenPSuAWkJfbHo58VPY9ZpMyl7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=b168d0c850f34e8178d815ba3a87de2657a02ca9 commit b168d0c850f34e8178d815ba3a87de2657a02ca9 Author: Artur Rojek AuthorDate: 2022-01-03 13:50:06 +0000 Commit: Marcin Wojtas CommitDate: 2022-01-23 19:38:12 +0000 ena: rework tx req_id validation logic Since `ena_com_tx_comp_req_id_get` already checks for `req_id` validity, the logic was exiting early, never giving `validate_tx_req_id` a chance to trigger device reset. Rewrite the logic so that device reset is called based on return value of `ena_com_tx_comp_req_id_get` instead. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. --- sys/dev/ena/ena_datapath.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index 3026671b6a19..c6798b3f7eb3 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -48,7 +48,8 @@ __FBSDID("$FreeBSD$"); static int ena_tx_cleanup(struct ena_ring *); static int ena_rx_cleanup(struct ena_ring *); -static inline int validate_tx_req_id(struct ena_ring *, uint16_t); +static inline int ena_get_tx_req_id(struct ena_ring *tx_ring, + struct ena_com_io_cq *io_cq, uint16_t *req_id); static void ena_rx_hash_mbuf(struct ena_ring *, struct ena_com_rx_ctx *, struct mbuf *); static struct mbuf* ena_rx_mbuf(struct ena_ring *, struct ena_com_rx_buf_info *, @@ -200,23 +201,27 @@ ena_qflush(if_t ifp) *********************************************************************/ static inline int -validate_tx_req_id(struct ena_ring *tx_ring, uint16_t req_id) +ena_get_tx_req_id(struct ena_ring *tx_ring, struct ena_com_io_cq *io_cq, + uint16_t *req_id) { struct ena_adapter *adapter = tx_ring->adapter; - struct ena_tx_buffer *tx_info = NULL; + int rc; - if (likely(req_id < tx_ring->ring_size)) { - tx_info = &tx_ring->tx_buffer_info[req_id]; - if (tx_info->mbuf != NULL) - return (0); - ena_log(adapter->pdev, ERR, - "tx_info doesn't have valid mbuf\n"); + rc = ena_com_tx_comp_req_id_get(io_cq, req_id); + if (rc == ENA_COM_TRY_AGAIN) + return (EAGAIN); + + if (unlikely(rc != 0)) { + ena_log(adapter->pdev, ERR, "Invalid req_id: %hu\n", *req_id); + counter_u64_add(tx_ring->tx_stats.bad_req_id, 1); + goto err; } - ena_log(adapter->pdev, ERR, "Invalid req_id: %hu\n", req_id); - counter_u64_add(tx_ring->tx_stats.bad_req_id, 1); + if (tx_ring->tx_buffer_info[*req_id].mbuf != NULL) + return (0); - /* Trigger device reset */ + ena_log(adapter->pdev, ERR, "tx_info doesn't have valid mbuf\n"); +err: ena_trigger_reset(adapter, ENA_REGS_RESET_INV_TX_REQ_ID); return (EFAULT); @@ -262,11 +267,7 @@ ena_tx_cleanup(struct ena_ring *tx_ring) struct ena_tx_buffer *tx_info; struct mbuf *mbuf; - rc = ena_com_tx_comp_req_id_get(io_cq, &req_id); - if (unlikely(rc != 0)) - break; - - rc = validate_tx_req_id(tx_ring, req_id); + rc = ena_get_tx_req_id(tx_ring, io_cq, &req_id); if (unlikely(rc != 0)) break;