From nobody Thu Feb 24 13:04:26 2022 X-Original-To: dev-commits-src-branches@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 94C2519E0133; Thu, 24 Feb 2022 13:04:27 +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 4K4CmC1Xt7z4VmJ; Thu, 24 Feb 2022 13:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645707867; 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=oBg7ZdaTq5xjiQajy7L3atQ5De8Jgb9zz96rsvpa1dI=; b=hZ9RYfCVVoN7U1bE4DOPfiEDMaClOoCwTqaZ0/fKL70KL3jUVjc2WSfKdNXKDsWLno4Gio j/I+1hTD8Rqme9tgG9lQg0wFe/b7irNaEM7qEa7q/ijRTl+vc27vlqibg0cpgrlbfdlt5J 1J7uSZ27/sVQMgdlLqX8NA+FXv8zewjTYsCayi1iyyZtMvruyq6F/l/079T7Y68rwMa8Z6 h+MnRPix7+6cH94ShV90lzTPQcFmeH2viFI5M/vqOc6Xii9KdgtzkpAxSbu8ulDeqhlLHB dJdNwRlTkkaKODyWGGtSc0bgrs2r1+JsspwzwrzgjzMoEkPFwdKBwnWWpIjreA== 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 D42C2481C; Thu, 24 Feb 2022 13:04:26 +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 21OD4QY2044147; Thu, 24 Feb 2022 13:04:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21OD4Q8R044146; Thu, 24 Feb 2022 13:04:26 GMT (envelope-from git) Date: Thu, 24 Feb 2022 13:04:26 GMT Message-Id: <202202241304.21OD4Q8R044146@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: ecafc181ed0a - stable/12 - ena: rework tx req_id validation logic List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/12 X-Git-Reftype: branch X-Git-Commit: ecafc181ed0ada77844e2c8b090f964e6e6540df Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645707867; 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=oBg7ZdaTq5xjiQajy7L3atQ5De8Jgb9zz96rsvpa1dI=; b=ma0nkQptcYKVqBsfhfSHA8uTxV4w8ISKIm4A0oAOCt4DqpZ5IPJKPdtthZ1dJZOcYpF/Ga 1tun3bZDCvHV3igmJFHhcf1S6JiH4+Z3WeG7XRwQQGLtlApkO3ZZzfuXkY/PaHwBPBMVsU SPAgFeVJY4G1LM8guIFltlmRkJZBpTnI/wj1aBtlzO5SPTb+/BvR9+A695hztVxyxTwyM3 NXK04wCDRTGC6lFlsiEs1mkmbC2huhP3IPOnezpDY5biMjm/A/YkrkeFK9NY5HGHwj43Tk Wzm8g4sIxN/tlUuqfSazy1uPA49rsJ+2CRx0X7XuMxDWvxMgj4MooKUAc+8F6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645707867; a=rsa-sha256; cv=none; b=XM179tps0rR5c6Oy9kiLHpkUiOeWtCSNr8I5y7CcUbVebON1ztldgz0pkU5HaonJMqc+kF iLmA24GrBj+oGigSNu5ZWVI+YzunKnSs+uvTSTbAuQkK2WY8tKshL9bjcItHubtnij8kyL /mpu8qtPysCEOVIz50LgX4JFVeAs+cwij1TRgF9/cII8KrKZbQlNYuqq8yb3Wi6S9Iqbcm 3VeAwPP6/ig50aLfAiRcd2O6hKB9pq8FJDLtkdA4/mF2t8Jw+juI3BAt1Ut+2v3L8tgeMU rbEgVsZToTs0S1G5VP3EiOgrHkVya57b/y2+fGK4v/dGwHGz8kJz3HEGtjWpKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=ecafc181ed0ada77844e2c8b090f964e6e6540df commit ecafc181ed0ada77844e2c8b090f964e6e6540df Author: Artur Rojek AuthorDate: 2022-01-03 13:50:06 +0000 Commit: Marcin Wojtas CommitDate: 2022-02-24 13:04:04 +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. (cherry picked from commit b168d0c850f34e8178d815ba3a87de2657a02ca9) --- 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 023a0d54693e..bf305944ab22 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -49,7 +49,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 *, @@ -201,23 +202,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); @@ -263,11 +268,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;