From nobody Fri Jan 14 07:38:51 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 DCDB31956167; Fri, 14 Jan 2022 07:38:51 +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 4JZtTR5KNpz3tsk; Fri, 14 Jan 2022 07:38:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642145931; 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=3I2FdqnGWhUD4SxpNejVVQ1cFmL4G0ixF2EJRdgEw+8=; b=kpwKp9NF+oj5c0q6THqsU8Ik0P1Tp5XhVpLZFJn5H0mAs8qAwsbPJYe9ByMIf/3IOoBqA4 J3OnmFlwV+7zrQQry5A0Kygxi/KP9QCdKp4VX0PbxI2uiAvdna58+sPkCO140/98NeTSvI tE/cMWduhvOON24VbYuPR2Vu0IloGhn8ec60R3sMZCbKwsNgM6glaKg28Xt+Td8qdrmLu2 7qWqc/uDhmwYTolVyyDVg47z4fqkbZC5ay7PX8zUnhEwVxXhtC+mVlXIaZOpv9S3ZHcuqB QJgCI+HNdUYI19GxNp1ge0dLrecBkIptBx/DqLpxNjX12HmsEnw+6C+JM0MjKw== 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 961EF757B; Fri, 14 Jan 2022 07:38:51 +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 20E7cpVY043929; Fri, 14 Jan 2022 07:38:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20E7cpXQ043927; Fri, 14 Jan 2022 07:38:51 GMT (envelope-from git) Date: Fri, 14 Jan 2022 07:38:51 GMT Message-Id: <202201140738.20E7cpXQ043927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: aa108bc7c5c1 - main - mana: Add RX fencing 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: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa108bc7c5c172b2aee140ce8b12f38194ab468e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642145931; 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=3I2FdqnGWhUD4SxpNejVVQ1cFmL4G0ixF2EJRdgEw+8=; b=GM1J5a78sGCZtpT/VyZkqNFv8T4rY14xYuKztsgvr5nARPub8uMJ48Fg/iSCjF78uf2vqz bKTJouHm1WUVvm9qTsTu10+92nUn/FM+qPItDcWu/9YyLlBhWf2Fk9h+LKH/k5nCImx1xo h7azEQNnZtBRI8e5K60kev4b0G+jE+s8toudV/DNJS2E32oiNGn9WhEz+jAYCnDI10i6Mx +fQd/FlMSA2nitodI9gzBXSFzCnPt/9tQ8SaLjhzG/4FVAjxHDIDMNO6rOwYRPPklOOwbO LVXWP4SUAcsDGPevAkxy7uhV5z+ghvieiv74pAcX2VpUKzgpxk6jAjYVOjE8Xw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642145931; a=rsa-sha256; cv=none; b=Z+PZAs6TT+Kd01LLI/FbfxboeHS2/6iRLNqFOyGfywtLMjVXAqap2ny7AgKIajpPZZ61pj Q/xY+aPHfg+B8r7CsRy9dJ+fk0ghWZ7RUKUR9bmi/pKPS/cC06h6Cr9954aeyJWRqsorAX 1d+ZNvzVhd9fHyvBjWzs2Asc/fHTRBoA062wRu3N+6sbxwn+fl9/QxK1KpaBVeZThLjoGO 3QY+ylcVKiPUdiR5Z7ZAYaUtliQ4wQlkn5V3FLbptxnvPn/D+eCMQHi4lrrO4oe0qE7Csk b7zd+ssiZYxv5a1T6CA69opHUPCDyZWO1Mi5hJw8Li94z1rEDaU2OyoJVrApCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=aa108bc7c5c172b2aee140ce8b12f38194ab468e commit aa108bc7c5c172b2aee140ce8b12f38194ab468e Author: Wei Hu AuthorDate: 2022-01-13 09:47:44 +0000 Commit: Wei Hu CommitDate: 2022-01-14 07:34:39 +0000 mana: Add RX fencing RX fencing allows the driver to know that any prior change to the RQs has finished, e.g. when the RQs are disabled/enabled or the hashkey/indirection table are changed, RX fencing is required. Remove the previous 'sleep' workaround and add the real support for RX fencing as the PF driver supports the MANA_FENCE_RQ request now (any old PF driver not supporting the request won't be used in production). MFC after: 2 weeks Sponsored by: Microsoft --- sys/dev/mana/mana.h | 2 ++ sys/dev/mana/mana_en.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/sys/dev/mana/mana.h b/sys/dev/mana/mana.h index da551102c246..7402685bd17c 100644 --- a/sys/dev/mana/mana.h +++ b/sys/dev/mana/mana.h @@ -414,6 +414,8 @@ struct mana_rxq { mana_handle_t rxobj; + struct completion fence_event; + struct mana_cq rx_cq; struct ifnet *ndev; diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index bba6e8a4aeb5..171b530e5350 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -1221,6 +1221,63 @@ out: return err; } +static int +mana_fence_rq(struct mana_port_context *apc, struct mana_rxq *rxq) +{ + struct mana_fence_rq_resp resp = {}; + struct mana_fence_rq_req req = {}; + int err; + + init_completion(&rxq->fence_event); + + mana_gd_init_req_hdr(&req.hdr, MANA_FENCE_RQ, + sizeof(req), sizeof(resp)); + req.wq_obj_handle = rxq->rxobj; + + err = mana_send_request(apc->ac, &req, sizeof(req), &resp, + sizeof(resp)); + if (err) { + if_printf(apc->ndev, "Failed to fence RQ %u: %d\n", + rxq->rxq_idx, err); + return err; + } + + err = mana_verify_resp_hdr(&resp.hdr, MANA_FENCE_RQ, sizeof(resp)); + if (err || resp.hdr.status) { + if_printf(apc->ndev, "Failed to fence RQ %u: %d, 0x%x\n", + rxq->rxq_idx, err, resp.hdr.status); + if (!err) + err = EPROTO; + + return err; + } + + if (wait_for_completion_timeout(&rxq->fence_event, 10 * hz)) { + if_printf(apc->ndev, "Failed to fence RQ %u: timed out\n", + rxq->rxq_idx); + return ETIMEDOUT; + } + + return 0; +} + +static void +mana_fence_rqs(struct mana_port_context *apc) +{ + unsigned int rxq_idx; + struct mana_rxq *rxq; + int err; + + for (rxq_idx = 0; rxq_idx < apc->num_queues; rxq_idx++) { + rxq = apc->rxqs[rxq_idx]; + err = mana_fence_rq(apc, rxq); + + /* In case of any error, use sleep instead. */ + if (err) + gdma_msleep(100); + } +} + static int mana_move_wq_tail(struct gdma_queue *wq, uint32_t num_units) { @@ -1564,7 +1621,7 @@ mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq, return; case CQE_RX_OBJECT_FENCE: - if_printf(ndev, "RX Fencing is unsupported\n"); + complete(&rxq->fence_event); return; default: @@ -2368,6 +2425,7 @@ int mana_config_rss(struct mana_port_context *apc, enum TRI_STATE rx, bool update_hash, bool update_tab) { uint32_t queue_idx; + int err; int i; if (update_tab) { @@ -2377,7 +2435,13 @@ int mana_config_rss(struct mana_port_context *apc, enum TRI_STATE rx, } } - return mana_cfg_vport_steering(apc, rx, true, update_hash, update_tab); + err = mana_cfg_vport_steering(apc, rx, true, update_hash, update_tab); + if (err) + return err; + + mana_fence_rqs(apc); + + return 0; } static int @@ -2532,9 +2596,6 @@ mana_dealloc_queues(struct ifnet *ndev) return err; } - /* TODO: Implement RX fencing */ - gdma_msleep(1000); - mana_destroy_vport(apc); return 0;