From owner-svn-src-all@freebsd.org Thu Oct 29 22:22:28 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6424F45FB9B; Thu, 29 Oct 2020 22:22:28 +0000 (UTC) (envelope-from jhb@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMg1024g2z4QwB; Thu, 29 Oct 2020 22:22:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B89CCEAA; Thu, 29 Oct 2020 22:22:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09TMMS4o082445; Thu, 29 Oct 2020 22:22:28 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09TMMSNO082444; Thu, 29 Oct 2020 22:22:28 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202010292222.09TMMSNO082444@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 29 Oct 2020 22:22:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367149 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 367149 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 22:22:28 -0000 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;