svn commit: r367149 - head/sys/dev/mlx5/mlx5_en

John Baldwin jhb at FreeBSD.org
Thu Oct 29 22:22:28 UTC 2020


Author: jhb
Date: Thu Oct 29 22:22:27 2020
New Revision: 367149
URL: https://svnweb.freebsd.org/changeset/base/367149

Log:
  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

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c	Thu Oct 29 22:18:56 2020	(r367148)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c	Thu Oct 29 22:22:27 2020	(r367149)
@@ -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 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 i
 	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;


More information about the svn-src-head mailing list