From nobody Tue Jul 2 08:06:17 2024 X-Original-To: dev-commits-src-branches@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 4WCwTj6lFFz5Phm1; Tue, 02 Jul 2024 08:06:17 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WCwTj5TSCz4JPQ; Tue, 2 Jul 2024 08:06:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719907577; 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=pxU4tpeam6B9xWL3gnYdItVld6EX3IUQX0O3dwk+qCw=; b=AVl8wks3asHEHvd975EV92a6gfHh2vjdS0qX7rrv5hRGxDZSdh8zKoYAlVeg9p3aQZffK+ cfX5pMVUOqeH/cNyuAthodyxyn5p+ATfB9HEb8cJk3Gi0IqmX6YTDOQTT+cdjBpAUDP8Cp 4sAkl4CYBtILkn/DIFmsoMvPeGc+nDDAmpHc5I3PH1uTmj3fhAj/HLz9wANlAYyHlFofwJ qwNNAnth+6xFGxOSqAGNPoWsg+1WsOGo9tpiPAytVruciuUaAfhCvTQ4XtpZ4EvjO2LbGW V03QBDxPDYmuMrzvP97d8PRY2mo/fIku+6r6TOg0pwJ5A3LrxakJkgOzhICxYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719907577; a=rsa-sha256; cv=none; b=HlOjDDG1bSLBtURxkD9JYq7KZjs1adxy2vbpEgphZsX48CfI5n3tgKhLR2xTMsTD+0hgIp fH7o7MFDvn5St8+7I5MEJKpH4tqXmxOk1UoPaeDNvcgVwM8A1RYvdmGYb4/DIrXPXw1zmE i3WOFLwRPdZamRMmuX5IoKxF260M6Jlu24E9n8QjiExx2CrjwOBnN3E17A8AwfaeCGihRD brinRV7bpzaV0qBzsIyJ2XOtbxfgHJUaKbXQFt80frtUG5mOPrwHrI1OnXJhXut2oMB7el aKRNGfE08HLkjUsRmNJdsXyZMbCVdd72YwS3Bfd2eZ3BQ8jCU/c7AFe/lCqzYA== 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=1719907577; 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=pxU4tpeam6B9xWL3gnYdItVld6EX3IUQX0O3dwk+qCw=; b=waBPfajWPekXXmDNDAQIm53M5pWq8oDmEi8Cfn5bHLFMrNZ4kpNtEwj+cXF6ijaCKgdM7n becsg9oiYRAHQ227z3CGMCzSVQ3oIbCy9LX4Zz+OpC27RD1A/pk5U1/pbasYhLDRMENLTH TsNWjPwOi1vShLJ7VEh2w9T5B9nlzpV7vEt3oz5CMRs+THm36thI90JkfpEJ0B6lfjAZAM 4OtUqxvQQqkcZO/yPivVli8bKQCSx458+lN9Gb0OOwlhhSlY3qaLa2CSH38QGZ3lh+K8mc e/gkm08CS95wCrel5WFaNVcUjoKlNNBUN5j8uPsEIDRh8CwTsm5pg5dvNEXLIQ== 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 4WCwTj4bkfzgGQ; Tue, 2 Jul 2024 08:06:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46286HLq082701; Tue, 2 Jul 2024 08:06:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46286HKw082697; Tue, 2 Jul 2024 08:06:17 GMT (envelope-from git) Date: Tue, 2 Jul 2024 08:06:17 GMT Message-Id: <202407020806.46286HKw082697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 406415364308 - stable/14 - cxgbe: handle vlan PF restrictions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 406415364308dc11b220b0a89a414fda66a52148 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=406415364308dc11b220b0a89a414fda66a52148 commit 406415364308dc11b220b0a89a414fda66a52148 Author: Kristof Provost AuthorDate: 2024-05-30 13:59:09 +0000 Commit: Kristof Provost CommitDate: 2024-07-01 16:06:16 +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 (cherry picked from commit 1389314d53531e06c7ec02406b0addf7d77e7db7) --- 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 c18243e4b681..c428fd2720cd 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -11466,7 +11466,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; @@ -11478,9 +11478,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 1971c3b15c4f..7f4e80ca020d 100644 --- a/sys/dev/cxgbe/t4_iov.c +++ b/sys/dev/cxgbe/t4_iov.c @@ -30,8 +30,12 @@ #include #include #include +#include #include +#include #include +#include +#include #ifdef PCI_IOV #include @@ -258,6 +262,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) { @@ -337,14 +342,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); @@ -359,6 +365,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