diff options
author | jhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-29 22:22:27 +0000 |
---|---|---|
committer | jhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-29 22:22:27 +0000 |
commit | 6827902a8b49cc028af7ada3c07bef9196873c76 (patch) | |
tree | eb6083969a829d8a015dd3bf23858f3c5c6dd7fe | |
parent | b933960dac38216b3ccc8adb54caae124bc6eca2 (diff) | |
download | freebsd-6827902a8b49cc028af7ada3c07bef9196873c76.tar.gz freebsd-6827902a8b49cc028af7ada3c07bef9196873c76.tar.bz2 |
Use public interfaces to manage the nested rate limit send tag.
Each TLS send tag in mlx5 contains a nested rate limit send tag.
Previously, the driver was calling internal functions to manage the
nested tag. Calling free methods directly instead of m_snd_tag_rele()
leaked send tag references and references on the ifp. Changes to use
the ifp methods for the nested tag for other methods are more cosmetic
but do simplify the code.
Reviewed by: gallatin, hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26996
git-svn-id: http://svn.freebsd.org/base/head@367149 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
-rw-r--r-- | sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 49 |
1 files changed, 15 insertions, 34 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 9c64d28f7db..8f1242826c9 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c @@ -280,7 +280,7 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, struct m_snd_tag **ppmt) { - struct if_snd_tag_alloc_rate_limit rl_params; + union if_snd_tag_alloc_params rl_params; struct mlx5e_priv *priv; struct mlx5e_tls_tag *ptag; const struct tls_session_params *en; @@ -377,29 +377,17 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp, goto failure; } + memset(&rl_params, 0, sizeof(rl_params)); + rl_params.hdr = params->hdr; switch (params->hdr.type) { #if defined(RATELIMIT) && defined(IF_SND_TAG_TYPE_TLS_RATE_LIMIT) case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: - memset(&rl_params, 0, sizeof(rl_params)); - rl_params.hdr = params->tls_rate_limit.hdr; rl_params.hdr.type = IF_SND_TAG_TYPE_RATE_LIMIT; rl_params.max_rate = params->tls_rate_limit.max_rate; - - error = mlx5e_rl_snd_tag_alloc(ifp, - container_of(&rl_params, union if_snd_tag_alloc_params, rate_limit), - &ptag->rl_tag); - if (error) - goto failure; break; #endif case IF_SND_TAG_TYPE_TLS: - memset(&rl_params, 0, sizeof(rl_params)); - rl_params.hdr = params->tls.hdr; rl_params.hdr.type = IF_SND_TAG_TYPE_UNLIMITED; - - error = mlx5e_ul_snd_tag_alloc(ifp, - container_of(&rl_params, union if_snd_tag_alloc_params, unlimited), - &ptag->rl_tag); if (error) goto failure; break; @@ -408,6 +396,10 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp, goto failure; } + error = ifp->if_snd_tag_alloc(ifp, &rl_params, &ptag->rl_tag); + if (error) + goto failure; + /* store pointer to mbuf tag */ MPASS(ptag->tag.refcount == 0); m_snd_tag_init(&ptag->tag, ifp, params->hdr.type); @@ -427,7 +419,7 @@ int mlx5e_tls_snd_tag_modify(struct m_snd_tag *pmt, union if_snd_tag_modify_params *params) { #if defined(RATELIMIT) && defined(IF_SND_TAG_TYPE_TLS_RATE_LIMIT) - struct if_snd_tag_rate_limit_params rl_params; + union if_snd_tag_modify_params rl_params; struct mlx5e_tls_tag *ptag = container_of(pmt, struct mlx5e_tls_tag, tag); int error; @@ -437,9 +429,9 @@ mlx5e_tls_snd_tag_modify(struct m_snd_tag *pmt, union if_snd_tag_modify_params * #if defined(RATELIMIT) && defined(IF_SND_TAG_TYPE_TLS_RATE_LIMIT) case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: memset(&rl_params, 0, sizeof(rl_params)); - rl_params.max_rate = params->tls_rate_limit.max_rate; - error = mlx5e_rl_snd_tag_modify(ptag->rl_tag, - container_of(&rl_params, union if_snd_tag_modify_params, rate_limit)); + rl_params.rate_limit.max_rate = params->tls_rate_limit.max_rate; + error = ptag->rl_tag->ifp->if_snd_tag_modify(ptag->rl_tag, + &rl_params); return (error); #endif default: @@ -457,11 +449,10 @@ mlx5e_tls_snd_tag_query(struct m_snd_tag *pmt, union if_snd_tag_query_params *pa switch (pmt->type) { #if defined(RATELIMIT) && defined(IF_SND_TAG_TYPE_TLS_RATE_LIMIT) case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: - error = mlx5e_rl_snd_tag_query(ptag->rl_tag, params); - break; #endif case IF_SND_TAG_TYPE_TLS: - error = mlx5e_ul_snd_tag_query(ptag->rl_tag, params); + error = ptag->rl_tag->ifp->if_snd_tag_query(ptag->rl_tag, + params); break; default: error = EOPNOTSUPP; @@ -477,18 +468,8 @@ mlx5e_tls_snd_tag_free(struct m_snd_tag *pmt) container_of(pmt, struct mlx5e_tls_tag, tag); struct mlx5e_priv *priv; - switch (pmt->type) { -#if defined(RATELIMIT) && defined(IF_SND_TAG_TYPE_TLS_RATE_LIMIT) - case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: - mlx5e_rl_snd_tag_free(ptag->rl_tag); - break; -#endif - case IF_SND_TAG_TYPE_TLS: - mlx5e_ul_snd_tag_free(ptag->rl_tag); - break; - default: - break; - } + MPASS(ptag->rl_tag->refcount == 1); + m_snd_tag_rele(ptag->rl_tag); MLX5E_TLS_TAG_LOCK(ptag); ptag->state = MLX5E_TLS_ST_FREED; |