From nobody Tue Jul 02 08:06:16 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 4WCwTj0zl6z5PhZl; 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 4WCwTh4zvlz4Hv8; Tue, 2 Jul 2024 08:06:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719907576; 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=EvKusVxuh4UdHOJMqEqc331UShOH5q/pFQQw+QUO8Hw=; b=tZ8CySHsUnMY9p3wFzIyQ5OVbcqo1Ogn6I6LjX+8lMr2ZAzDCy64D9RLs6qAWh7hWgslrH kWo3HKoXw1yoemdjFPSMzMSsOKujTYOmd9dUQZn85O1OaxgoGc8No3zmQVjLx9t7HGIY9c Ol/rvSBnWRkeJc7Mp2Xc8eelaO0lRa32jVq85IkYxmEHLP8I1EfSwdv9wq+7nvKhCTdHQi T7huzM6s11OIku5gLwESxSTiNCIUjfr/RweEkyQnzDdq+V/eGUklhSg2zCj8d0+RA/3vs0 IP+E6vLlDrCAekKrxUOjWpBt1WzM4fd73ddJ7B45ATgBRI5A+BkTMCOgW8inVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719907576; a=rsa-sha256; cv=none; b=q2LRwlUSYecbStWmAEgnZ/wd89MQ1RKNDdoPmd1aO3Sld2bh0QdlrzpiI3WvxaYH62T7jD aO+91ZysPFkxn01+tPuizGzcW9rkCiNWeCfxdkSINbOpKjfpCL4T0ayXQXG+L2QFUnevPv bdZwV+vnTO3NDQM8pNuVjmnuPww3MZO0/3sjPNP9SrcJ4P7XBRBwNWxbiylHak7NiHirO8 /DTaFl/oxgsI4es+vkPaDzf6McSv/zeeVeKpxF81Py1uejpYAWgPoBrnYJYTeNb+lXTXt0 u7Kf+nFck+ns0DzdBIfetWhSGfygrY4QWtj5MXQ3S8MLVogZHquN7BmaHM21Ew== 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=1719907576; 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=EvKusVxuh4UdHOJMqEqc331UShOH5q/pFQQw+QUO8Hw=; b=mTphM9vf9SU3tZKpUz36ZHhF6bAx10tXD4qZl7ZRLSKZZXESjTkQDQ7o3agIshvItrXu3F MCU85Ge0baJTaiN3sk6BLkUq2GgpubbbK0HWCOJ+tb7O7iPhnuh2vMEFPPzZ0qwosxcWVo 3uQNwHA4ocBf+OSdm9BmM+vR3gpwD8EFJGrUuQeBKr72xCA/MKYXBd7nFnXUPL/WXYUBS5 mZNTcl3ldCi5Zj91TkeytA2bRVbFDZVdtQdbmjgQfn928upER+5lIF/fI8kEb9go1G0UPU KjnPeZCcsDi8DUpNiR0RmQ30AZcTw0kTQ2YMC8wPPcsr0nedRM0ZKc1g+/alXQ== 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 4WCwTh4WsbzgcF; Tue, 2 Jul 2024 08:06:16 +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 46286GgM082654; Tue, 2 Jul 2024 08:06:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46286GZ0082651; Tue, 2 Jul 2024 08:06:16 GMT (envelope-from git) Date: Tue, 2 Jul 2024 08:06:16 GMT Message-Id: <202407020806.46286GZ0082651@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: f0f1580cab27 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f0f1580cab2738b734d956eae9c551b9678cd4d5 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f0f1580cab2738b734d956eae9c551b9678cd4d5 commit f0f1580cab2738b734d956eae9c551b9678cd4d5 Author: Kristof Provost AuthorDate: 2024-05-30 13:59:09 +0000 Commit: Kristof Provost CommitDate: 2024-07-02 07:45:53 +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 b063bda233b9..6409f3e3f994 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 == 0) + return (ENOTSUP); + + if (vlan == VF_VLAN_TRUNK) + vlan = 0; + + 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