From nobody Thu Aug 17 11:47:06 2023 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 4RRNXB6XmKz4qZrr; Thu, 17 Aug 2023 11:47:06 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RRNXB5zkmz4YZ0; Thu, 17 Aug 2023 11:47:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692272826; 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=kRjtE6tAgop6NvAGE44/fRAMU44Ia3/eeW4XOy6vKFY=; b=Fkpwwoq9K6KwKlx7TX/DHLemTEvqbYfQ7P85A5hxIoYNKuceoMFcMw4SZlMI7LMbuE3x9k IK/haWdLca7Iu4jfwJOqYWV3xvEpA/MEbPiXbYBvJSpvU79L/5cmzDJGp//+y0Rizs8q4r qwd0Nj8mIzdtBxbg7NXBnq+GtR6A4iiy3BHYUKJ0RdFIaxGBJLakiXqnMqEXtXWfh8KGSV X9WgqWYScVjtq9m900XXA4+i4f+9WBm2bOXzKpRi5D6aDVTsCnGcFCkgc1R8Frb5E42/oX MNIPugX2V2PUQaGz/sYkcliRqILsM23ZOgkcbcfQxoWIb1A50oZ+a/W0OgSXgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692272826; 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=kRjtE6tAgop6NvAGE44/fRAMU44Ia3/eeW4XOy6vKFY=; b=kwSJt9WFSbjyZjdcOvePYDYixytx9bFlqlnwI57ZJvS1fEzcca5ve+ITP+Y4YnE8Y1UJpF sNU34QV8NVvfakL4B37JS7TNY5S94J44h2kjwBx+brWmFZKKByRXHyMbd3YqsYya4YKQzc /Ouo+N0kkC+oMmD33XtCJKMuYVF3EZ71ZL2UAjq7hgrvMUm+n+hESwYF9/aA2CeFF6jTnY mXtSinTtuHuBkJHF4UG8JBRphmv1Q64Byb+IE+ywpkpq8E0E1c73H5VvBnZZ3QbAStNvt8 ZASmnqIa8Hrt5RuzV5WzBzERtrKgT/Bl15xpucAHkEntHOPSJGTIwQxI4pb3dQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692272826; a=rsa-sha256; cv=none; b=vSUh42V6GAVcw5BReMjSaEihp861P0uIyG8Nvne6KXFzQ7/dGtwdU/2dwQmjp32vXqPAUx lm4AS+0mYBUaWZnmBRXma8bC44QG8Gdw9mGuY9pFEq+6tAc8snRB/Tv87xqkvKEx2eTrZq si+cUEi7zOKV2MMXC5o/VRuHMTjnCpGB9u3a8qeZHTvX9jsn4c9y5zQG95slflzJYdh3tw B/Kefq7TI3F7IMxfbO1HazrArW9Abp+lQbzl9CMyXOr/3NWnapQXSXNhbN0iTfakN8dN+Z l8SaH0tTbTEMQM0Q1ZtSz0w/+C77nYHHiPNAyp0hZCmECvMb6D3/Yp4pZqkYBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RRNXB4vyyzY37; Thu, 17 Aug 2023 11:47:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37HBl6xl063022; Thu, 17 Aug 2023 11:47:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37HBl6mb063019; Thu, 17 Aug 2023 11:47:06 GMT (envelope-from git) Date: Thu, 17 Aug 2023 11:47:06 GMT Message-Id: <202308171147.37HBl6mb063019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: 89e73359424a - main - ixl: fix multicast filters handling 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 89e73359424a338a7900a4854ad7439f5848ebb8 Auto-Submitted: auto-generated The branch main has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=89e73359424a338a7900a4854ad7439f5848ebb8 commit 89e73359424a338a7900a4854ad7439f5848ebb8 Author: Mateusz Pacuszka AuthorDate: 2023-08-17 11:30:54 +0000 Commit: Piotr Kubaj CommitDate: 2023-08-17 11:46:48 +0000 ixl: fix multicast filters handling Summary: Hardware supports up to 128 entries of multicast filters. If there is more, filters should be removed and multicast promiscuous enabled. In case user deletes the multicast address and overall count is less than 128, multicast promiscuous mode should be disabled and all the filters reapplied into the HW. Currently driver only enables multicast promiscuous mode and deletes the entries without any information to the user and it's not capable of reapplying the filters once count is less than 128. Address that by: 1. Add logging 2. Add logic in case multicast promiscuous is enabled and user lowers the number of multicast entries to <128. 3. Fix a bug where driver removes different MAC entries along with the one that's being deleted by the user. Reviewers: #intel_networking, erj Reviewed By: #intel_networking, erj Subscribers: imp, ae Differential Revision: https://reviews.freebsd.org/D40860 --- sys/dev/ixl/ixl_pf_main.c | 97 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 10 deletions(-) diff --git a/sys/dev/ixl/ixl_pf_main.c b/sys/dev/ixl/ixl_pf_main.c index 4f384e7191af..af253faeac7a 100644 --- a/sys/dev/ixl/ixl_pf_main.c +++ b/sys/dev/ixl/ixl_pf_main.c @@ -592,6 +592,15 @@ ixl_add_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) * Routines for multicast and vlan filter management. * *********************************************************************/ + +/** + * ixl_add_multi - Add multicast filters to the hardware + * @vsi: The VSI structure + * + * In case number of multicast filters in the IFP exceeds 127 entries, + * multicast promiscuous mode will be enabled and the filters will be removed + * from the hardware + */ void ixl_add_multi(struct ixl_vsi *vsi) { @@ -599,14 +608,20 @@ ixl_add_multi(struct ixl_vsi *vsi) struct i40e_hw *hw = vsi->hw; int mcnt = 0; struct ixl_add_maddr_arg cb_arg; + enum i40e_status_code status; IOCTL_DEBUGOUT("ixl_add_multi: begin"); mcnt = if_llmaddr_count(ifp); if (__predict_false(mcnt >= MAX_MULTICAST_ADDR)) { - i40e_aq_set_vsi_multicast_promiscuous(hw, - vsi->seid, TRUE, NULL); - /* delete all existing MC filters */ + status = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, + TRUE, NULL); + if (status != I40E_SUCCESS) + if_printf(ifp, "Failed to enable multicast promiscuous " + "mode, status: %s\n", i40e_stat_str(hw, status)); + else + if_printf(ifp, "Enabled multicast promiscuous mode\n"); + /* Delete all existing MC filters */ ixl_del_multi(vsi, true); return; } @@ -632,30 +647,92 @@ ixl_match_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) return (0); } +/** + * ixl_dis_multi_promisc - Disable multicast promiscuous mode + * @vsi: The VSI structure + * @vsi_mcnt: Number of multicast filters in the VSI + * + * Disable multicast promiscuous mode based on number of entries in the IFP + * and the VSI, then re-add multicast filters. + * + */ +static void +ixl_dis_multi_promisc(struct ixl_vsi *vsi, int vsi_mcnt) +{ + struct ifnet *ifp = vsi->ifp; + struct i40e_hw *hw = vsi->hw; + int ifp_mcnt = 0; + enum i40e_status_code status; + + ifp_mcnt = if_llmaddr_count(ifp); + /* + * Equal lists or empty ifp list mean the list has not been changed + * and in such case avoid disabling multicast promiscuous mode as it + * was not previously enabled. Case where multicast promiscuous mode has + * been enabled is when vsi_mcnt == 0 && ifp_mcnt > 0. + */ + if (ifp_mcnt == vsi_mcnt || ifp_mcnt == 0 || + ifp_mcnt >= MAX_MULTICAST_ADDR) + return; + + status = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, + FALSE, NULL); + if (status != I40E_SUCCESS) { + if_printf(ifp, "Failed to disable multicast promiscuous " + "mode, status: %s\n", i40e_stat_str(hw, status)); + + return; + } + + if_printf(ifp, "Disabled multicast promiscuous mode\n"); + + ixl_add_multi(vsi); +} + +/** + * ixl_del_multi - Delete multicast filters from the hardware + * @vsi: The VSI structure + * @all: Bool to determine if all the multicast filters should be removed + * + * In case number of multicast filters in the IFP drops to 127 entries, + * multicast promiscuous mode will be disabled and the filters will be reapplied + * to the hardware. + */ void ixl_del_multi(struct ixl_vsi *vsi, bool all) { - struct ixl_ftl_head to_del; + int to_del_cnt = 0, vsi_mcnt = 0; if_t ifp = vsi->ifp; struct ixl_mac_filter *f, *fn; - int mcnt = 0; + struct ixl_ftl_head to_del; IOCTL_DEBUGOUT("ixl_del_multi: begin"); LIST_INIT(&to_del); /* Search for removed multicast addresses */ LIST_FOREACH_SAFE(f, &vsi->ftl, ftle, fn) { - if ((f->flags & IXL_FILTER_MC) == 0 || - (!all && (if_foreach_llmaddr(ifp, ixl_match_maddr, f) == 0))) + if ((f->flags & IXL_FILTER_MC) == 0) + continue; + + /* Count all the multicast filters in the VSI for comparison */ + vsi_mcnt++; + + if (!all && if_foreach_llmaddr(ifp, ixl_match_maddr, f) != 0) continue; LIST_REMOVE(f, ftle); LIST_INSERT_HEAD(&to_del, f, ftle); - mcnt++; + to_del_cnt++; } - if (mcnt > 0) - ixl_del_hw_filters(vsi, &to_del, mcnt); + if (to_del_cnt > 0) { + ixl_del_hw_filters(vsi, &to_del, to_del_cnt); + return; + } + + ixl_dis_multi_promisc(vsi, vsi_mcnt); + + IOCTL_DEBUGOUT("ixl_del_multi: end"); } void