From nobody Tue Dec 03 00:51:24 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 4Y2MXr69Bxz5fGp6; Tue, 03 Dec 2024 00:51:24 +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 4Y2MXr2Pp7z4TWb; Tue, 3 Dec 2024 00:51:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733187084; 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=43O7JijBqBqWmbmfG2vS1DQr7F4E0J+Rbn1QaYnuUF0=; b=AQ26yANs9lyiSHBn5uHtgLya36dY6qsEAI8E9Hss//ufjqP2kTOlxLznYwzh+la8Thoesu zb9qb/EK0gUdyrwKf8Q3RiwjPj6MHo3ZDRXjRLvJiwHkaDijuoinAUhqw5uxBo1Zbe1H0M lZbovcAin846D6NWmXV5GVJ8sy72z5m04sDUNntnZY01UtQBUwt/XGNbPM/IKWkCCZYSRl NkWIFBO/p+CX5IJN84NXecWR1E3dwYbGI4N4CcdAwts6UBqBzqcSoRBVvyIkMzEkYnk2Qe txwFdzOz0xo7K44ARjSw5yd0qDp+rAePmZrRqAsmafUJRYFWaShkjoSHmNnhRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733187084; 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=43O7JijBqBqWmbmfG2vS1DQr7F4E0J+Rbn1QaYnuUF0=; b=fk1nN11IpBftU8KXxTKJEyZTQsOVFhXDQbQO8aVLOCeKEvsacPQi6+ikPt3bvaML+VZ3m+ 9ASkbM8R1Pe1d5aWcpH05eAx/rG3nG8MOzi7Uc3CmBn4DuBf6BcWja2tcLoszk+Krj+46a zJK8aY8zFS83IE+0thUW8iPq754n/7FWdh72YSBKhlP+xnR7CsB5+Om9O0bpENzERaAAhR dOfG4EfRgJvqbAGPAqoF/Ezxz3h8I27A+t/8MFsBFtXTnkJIIm8MM0+RkrN4lv1PlT+IR5 gTAKrIqCuCEL0Q0ZLQE8D/Aurc92pYBHuwzmrnKuDNSf0m/306w+lIzNJwWssQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733187084; a=rsa-sha256; cv=none; b=Zhq7W+tbikooURTossNI3CqYgdivw9CoHEu1KUQ/xu/qEm6z+CrGSKRvsx/eRIi8BySFWL zu1mQelQk3cmuBRwU74Kn4UxDWltUqgDdUO21Zuo2qAfYCUXElUjdbWwrxAV1aezpa33U0 /F7Yll3NZwKW4EgEpRDJSVYTNkryaS6znFB4HHxYAJxANCzG+POhjSqAefhpDngbjGxmCe vxdtC9SEqGbrS9eAQDBLkmc/are5ast8JEhU9iYWWACsASAoYG53ZpLYXfY5KN7DdZwbJz g+sigfdHFssEz6ijeGDdOxlTZcowEjYYNkb+eK7NSXmtZdOZcWIRNPTwTinyvA== 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 4Y2MXr1bYPz117F; Tue, 3 Dec 2024 00:51:24 +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 4B30pOXa016202; Tue, 3 Dec 2024 00:51:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B30pOrE016199; Tue, 3 Dec 2024 00:51:24 GMT (envelope-from git) Date: Tue, 3 Dec 2024 00:51:24 GMT Message-Id: <202412030051.4B30pOrE016199@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 468d647a5a10 - stable/14 - mlx5e: Immediately initialize TLS send tags 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 468d647a5a10468378afdb74f2eeafc707a6d28e Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=468d647a5a10468378afdb74f2eeafc707a6d28e commit 468d647a5a10468378afdb74f2eeafc707a6d28e Author: Andrew Gallatin AuthorDate: 2024-10-23 19:16:19 +0000 Commit: Konstantin Belousov CommitDate: 2024-12-03 00:39:22 +0000 mlx5e: Immediately initialize TLS send tags (cherry picked from commit 81dbc22ce8b66759a9fc4ebdef5cfc7a6185af22) --- sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 84 +++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c index f2ed45826843..de0cd49eeab5 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c @@ -212,53 +212,62 @@ mlx5e_tls_cleanup(struct mlx5e_priv *priv) counter_u64_free(ptls->stats.arg[x]); } + +static int +mlx5e_tls_st_init(struct mlx5e_priv *priv, struct mlx5e_tls_tag *ptag) +{ + int err; + + /* try to open TIS, if not present */ + if (ptag->tisn == 0) { + err = mlx5_tls_open_tis(priv->mdev, 0, priv->tdn, + priv->pdn, &ptag->tisn); + if (err) { + MLX5E_TLS_STAT_INC(ptag, tx_error, 1); + return (err); + } + } + MLX5_SET(sw_tls_cntx, ptag->crypto_params, progress.pd, ptag->tisn); + + /* try to allocate a DEK context ID */ + err = mlx5_encryption_key_create(priv->mdev, priv->pdn, + MLX5_ADDR_OF(sw_tls_cntx, ptag->crypto_params, key.key_data), + MLX5_GET(sw_tls_cntx, ptag->crypto_params, key.key_len), + &ptag->dek_index); + if (err) { + MLX5E_TLS_STAT_INC(ptag, tx_error, 1); + return (err); + } + + MLX5_SET(sw_tls_cntx, ptag->crypto_params, param.dek_index, ptag->dek_index); + + ptag->dek_index_ok = 1; + + MLX5E_TLS_TAG_LOCK(ptag); + if (ptag->state == MLX5E_TLS_ST_INIT) + ptag->state = MLX5E_TLS_ST_SETUP; + MLX5E_TLS_TAG_UNLOCK(ptag); + return (0); +} + static void mlx5e_tls_work(struct work_struct *work) { struct mlx5e_tls_tag *ptag; struct mlx5e_priv *priv; - int err; ptag = container_of(work, struct mlx5e_tls_tag, work); priv = container_of(ptag->tls, struct mlx5e_priv, tls); switch (ptag->state) { case MLX5E_TLS_ST_INIT: - /* try to open TIS, if not present */ - if (ptag->tisn == 0) { - err = mlx5_tls_open_tis(priv->mdev, 0, priv->tdn, - priv->pdn, &ptag->tisn); - if (err) { - MLX5E_TLS_STAT_INC(ptag, tx_error, 1); - break; - } - } - MLX5_SET(sw_tls_cntx, ptag->crypto_params, progress.pd, ptag->tisn); - - /* try to allocate a DEK context ID */ - err = mlx5_encryption_key_create(priv->mdev, priv->pdn, - MLX5_ADDR_OF(sw_tls_cntx, ptag->crypto_params, key.key_data), - MLX5_GET(sw_tls_cntx, ptag->crypto_params, key.key_len), - &ptag->dek_index); - if (err) { - MLX5E_TLS_STAT_INC(ptag, tx_error, 1); - break; - } - - MLX5_SET(sw_tls_cntx, ptag->crypto_params, param.dek_index, ptag->dek_index); - - ptag->dek_index_ok = 1; - - MLX5E_TLS_TAG_LOCK(ptag); - if (ptag->state == MLX5E_TLS_ST_INIT) - ptag->state = MLX5E_TLS_ST_SETUP; - MLX5E_TLS_TAG_UNLOCK(ptag); + (void)mlx5e_tls_st_init(priv, ptag); break; case MLX5E_TLS_ST_RELEASE: /* try to destroy DEK context by ID */ if (ptag->dek_index_ok) - err = mlx5_encryption_key_destroy(priv->mdev, ptag->dek_index); + (void)mlx5_encryption_key_destroy(priv->mdev, ptag->dek_index); /* free tag */ mlx5e_tls_tag_zfree(ptag); @@ -439,8 +448,17 @@ mlx5e_tls_snd_tag_alloc(if_t ifp, /* reset state */ ptag->state = MLX5E_TLS_ST_INIT; - queue_work(priv->tls.wq, &ptag->work); - flush_work(&ptag->work); + /* + * Try to immediately init the tag. We may fail if the NIC's + * resources are tied up with send tags that are in the work + * queue, waiting to be freed. So if we fail, put ourselves + * on the queue so as to try again after resouces have been freed. + */ + error = mlx5e_tls_st_init(priv, ptag); + if (error != 0) { + queue_work(priv->tls.wq, &ptag->work); + flush_work(&ptag->work); + } return (0);