From 78ae1e6e15a5c4b5e7d18610a1a0daf44589063c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 1 Sep 2020 12:21:17 +0000 Subject: [PATCH] Make hardware TLS send tag allocation synchronous in mlx5en(4). Previously the send tag was setup in the background, and all packets for the given send tag were dropped until ready. Change this to be blocking behaviour so that once the setsocketopt() for enabling TLS completes, the socket is ready to send packets. Do this by simply flushing the work request which does the needed firmware programming during send tag allocation. MFC after: 1 week Sponsored by: Mellanox Technologies // Nvidia --- sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 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 e60a197bc512..33b3e0884bc7 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c @@ -188,7 +188,7 @@ mlx5e_tls_work(struct work_struct *work) priv = container_of(ptag->tls, struct mlx5e_priv, tls); switch (ptag->state) { - case MLX5E_TLS_ST_SETUP: + 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, @@ -215,8 +215,8 @@ mlx5e_tls_work(struct work_struct *work) ptag->dek_index_ok = 1; MLX5E_TLS_TAG_LOCK(ptag); - if (ptag->state == MLX5E_TLS_ST_SETUP) - ptag->state = MLX5E_TLS_ST_TXRDY; + if (ptag->state == MLX5E_TLS_ST_INIT) + ptag->state = MLX5E_TLS_ST_SETUP; MLX5E_TLS_TAG_UNLOCK(ptag); break; @@ -413,6 +413,10 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp, MPASS(ptag->tag.m_snd_tag.refcount == 0); m_snd_tag_init(&ptag->tag.m_snd_tag, ifp); *ppmt = &ptag->tag.m_snd_tag; + + queue_work(priv->tls.wq, &ptag->work); + flush_work(&ptag->work); + return (0); failure: @@ -736,16 +740,11 @@ mlx5e_sq_tls_xmit(struct mlx5e_sq *sq, struct mlx5e_xmit_args *parg, struct mbuf MLX5E_TLS_TAG_LOCK(ptls_tag); switch (ptls_tag->state) { case MLX5E_TLS_ST_INIT: - queue_work(sq->priv->tls.wq, &ptls_tag->work); - ptls_tag->state = MLX5E_TLS_ST_SETUP; - ptls_tag->expected_seq = ~mb_seq; /* force setup */ MLX5E_TLS_TAG_UNLOCK(ptls_tag); return (MLX5E_TLS_FAILURE); - case MLX5E_TLS_ST_SETUP: - MLX5E_TLS_TAG_UNLOCK(ptls_tag); - return (MLX5E_TLS_FAILURE); - + ptls_tag->state = MLX5E_TLS_ST_TXRDY; + ptls_tag->expected_seq = ~mb_seq; /* force setup */ default: MLX5E_TLS_TAG_UNLOCK(ptls_tag); break;