From nobody Mon Jun 17 21:42:24 2024 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 4W33JJ4Z7dz5LxcS; Mon, 17 Jun 2024 21:42:24 +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 4W33JJ2NGmz4XGC; Mon, 17 Jun 2024 21:42:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718660544; 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=YpMUiY55knibtJR57kW/LADXg0o37n2kz4iMMBuj+/E=; b=LQe1TgttMuAzSjeb3U7o8QqB+w0RL17KmbXDlfFcEPGGnux5htKAhFJ0RTWl8iBQJc1A/m NM7z02zMC0oWVKaBwoqOPacu26Z9pm7+5XT+eJTA2lNUjMQNqaT7Txh65qXFaiEah2o8mg ne1QnwU+9CN4JLsGPmmLDPMGX/GZyH/OIIkCWdqlHK/YnyY8v7R3ohAQEByREvrjFQ0OJh b7wup59mC3VTVnYay/WKyW0rq1kylyS8F+dqdeosY8DkZnl92uWmlzW5tIFaiOSIA5XMb8 JzVozfK2Q+9ViWKViQdF6HeFlGB4Q05tyUDZaUL1+wWwy3gQt6EUk4cwVHaDjQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718660544; a=rsa-sha256; cv=none; b=EM8QI5FpxKZLhSWZPgHm1vBeRHD2b80vxJs/GAR/CPTP5YIKwtWpK69tcr1NRoSCIu2hy3 CIDl5T+tZlSayHQJo1aPmhUJb8pLq//rv3jda1q9NbKr8P9g0JvGLhnDRAvLFLhHECWLPT zP3gL5ZCjm90sYvEeM/oO/rH0mP8kiZKrod1WtgyGbMdrWDF6jJuXLyAS4SXWo9z8PYtS0 e2JUIfPorSlIYCkL3vro4a2b7IjO194TZGSkPp5j8YNi1a5PDp6RiU5nP6l+TjIt3u2BZs yCgrtEBrMAhfL+8AB4AE47S0g5dHgIYjmNtQG+mMZBEqjhZNWRnf7u0nh/RuFA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718660544; 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=YpMUiY55knibtJR57kW/LADXg0o37n2kz4iMMBuj+/E=; b=K0H9Zfc5Sh26ofjuqaV1I3yD+8TS3ZOKQ+f5IwwnTJylaixsoe86aUHyT6hdVgXrNp+FVu yPK5v4aXTL697C9iukPYrNMtYp5sZCmHopptIoWQN9wgC44kROgIa92SoitpTLZZYY8ZqX j1xG1HsnZQqcqnvZcBAglBDOVhmqIZ5BnD1r347Ue1/ZVwjV1dMrrw6lyQvIq2y4xPMkOy pIebxrE28rdjcLSJ85vynzEsHjO9lUvPkGoZ/FtBMGNNrTw9koHS/Ksz15wCCwIorKEbWU xwsz0/CTF5vFLZ0jGLtASiSwYY3K98rpIiQ7Ih8HWRfBEdB0F8Caf60LiAEH9A== 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 4W33JJ1zctzY4n; Mon, 17 Jun 2024 21:42:24 +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 45HLgOEb027566; Mon, 17 Jun 2024 21:42:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45HLgOs8027563; Mon, 17 Jun 2024 21:42:24 GMT (envelope-from git) Date: Mon, 17 Jun 2024 21:42:24 GMT Message-Id: <202406172142.45HLgOs8027563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 1389314d5353 - main - cxgbe: handle vlan PF restrictions 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1389314d53531e06c7ec02406b0addf7d77e7db7 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1389314d53531e06c7ec02406b0addf7d77e7db7 commit 1389314d53531e06c7ec02406b0addf7d77e7db7 Author: Kristof Provost AuthorDate: 2024-05-30 13:59:09 +0000 Commit: Kristof Provost CommitDate: 2024-06-17 21:42:08 +0000 cxgbe: handle vlan PF restrictions Co-Authored-by: Navdeep Parhar MFC after: 2 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D45428 --- sys/dev/cxgbe/common/t4_hw.c | 7 ++++--- sys/dev/cxgbe/t4_iov.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 3d22673d34c1..07940a44f66e 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -11377,7 +11377,7 @@ out: * @vlan: The vlanid to be set * */ -int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf, +int t4_set_vlan_acl(struct adapter *adap, unsigned int pf, unsigned int vf, u16 vlan) { struct fw_acl_vlan_cmd vlan_cmd; @@ -11389,9 +11389,10 @@ int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf, F_FW_CMD_REQUEST | F_FW_CMD_WRITE | F_FW_CMD_EXEC | - V_FW_ACL_VLAN_CMD_PFN(adap->pf) | + V_FW_ACL_VLAN_CMD_PFN(pf) | V_FW_ACL_VLAN_CMD_VFN(vf)); - vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd)); + vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd) | + V_FW_ACL_VLAN_CMD_PMASK(1 << pf)); /* Drop all packets that donot match vlan id */ vlan_cmd.dropnovlan_fm = (enable ? (F_FW_ACL_VLAN_CMD_DROPNOVLAN | diff --git a/sys/dev/cxgbe/t4_iov.c b/sys/dev/cxgbe/t4_iov.c index 7b5e0cb1af4e..eef41d6398df 100644 --- a/sys/dev/cxgbe/t4_iov.c +++ b/sys/dev/cxgbe/t4_iov.c @@ -29,8 +29,12 @@ #include #include #include +#include #include +#include #include +#include +#include #ifdef PCI_IOV #include @@ -257,6 +261,7 @@ t4iov_attach_child(device_t dev) pf_schema = pci_iov_schema_alloc_node(); vf_schema = pci_iov_schema_alloc_node(); pci_iov_schema_add_unicast_mac(vf_schema, "mac-addr", 0, NULL); + pci_iov_schema_add_vlan(vf_schema, "vlan", 0, 0); error = pci_iov_attach_name(dev, pf_schema, vf_schema, "%s", device_get_nameunit(pdev)); if (error) { @@ -336,14 +341,15 @@ t4iov_add_vf(device_t dev, uint16_t vfnum, const struct nvlist *config) size_t size; int rc; + sc = device_get_softc(dev); + MPASS(sc->sc_attached); + MPASS(sc->sc_main != NULL); + adap = device_get_softc(sc->sc_main); + if (nvlist_exists_binary(config, "mac-addr")) { mac = nvlist_get_binary(config, "mac-addr", &size); bcopy(mac, ma, ETHER_ADDR_LEN); - sc = device_get_softc(dev); - MPASS(sc->sc_attached); - MPASS(sc->sc_main != NULL); - adap = device_get_softc(sc->sc_main); if (begin_synchronized_op(adap, NULL, SLEEP_OK | INTR_OK, "t4vfma") != 0) return (ENXIO); @@ -358,6 +364,29 @@ t4iov_add_vf(device_t dev, uint16_t vfnum, const struct nvlist *config) } } + if (nvlist_exists_number(config, "vlan")) { + uint16_t vlan = nvlist_get_number(config, "vlan"); + + /* We can't restrict to VID 0 */ + if (vlan == DOT1Q_VID_NULL) + return (ENOTSUP); + + if (vlan == VF_VLAN_TRUNK) + vlan = DOT1Q_VID_NULL; + + if (begin_synchronized_op(adap, NULL, SLEEP_OK | INTR_OK, + "t4vfvl") != 0) + return (ENXIO); + rc = t4_set_vlan_acl(adap, sc->pf, vfnum + 1, vlan); + end_synchronized_op(adap, 0); + if (rc != 0) { + device_printf(dev, + "Failed to set VF%d VLAN to %d, rc = %d\n", + vfnum, vlan, rc); + return (rc); + } + } + return (0); } #endif