From nobody Fri Nov 4 22:55:52 2022 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 4N3wvr6qbgz4h0KY; Fri, 4 Nov 2022 22:55:52 +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 4N3wvr5lRfz40Lk; Fri, 4 Nov 2022 22:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667602552; 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=01BI7TV7ZXFwN739g1s1NxghsrchvNbcVVloDrffPNg=; b=fYT0voUMegVe6RjgpZTgAT+m8NkLBh9Ov0v/kqutTrxn9/Xdw/EoRxt1KengDlYWx8cD3C mFRWZskVwbJoBUhQ07yeiFzybXy3yNSqQI5J5UzTWkWaCLWy594vEM+JGJ/ESzcC9V7anX SZNRruPCHmn/qw7UzQnVsqwK13Zn2p3FGcJTcma7uajkw9pc0Ot/X5phQIFSa/PisDm8w3 ZycIEmx8e7PTLErJN1hdNrCKuSAX0PhoB429qqo2zs8Ri0kRsAAdWMeoC3KwUBtmPy7WpC gZ9YAxDOhcs3m6RRilcC+IriDgIaOZjaU/m8YcygelfRNCwS9kig9dqb0W6y5Q== 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 4N3wvr3pLgzJyp; Fri, 4 Nov 2022 22:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A4MtqDb032694; Fri, 4 Nov 2022 22:55:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A4MtqVv032693; Fri, 4 Nov 2022 22:55:52 GMT (envelope-from git) Date: Fri, 4 Nov 2022 22:55:52 GMT Message-Id: <202211042255.2A4MtqVv032693@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 91fcacc35597 - main - if_bnxt: Add support for VLAN on Thor 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91fcacc355971f74aa26fc7861020dc3a2a2d717 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667602552; 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=01BI7TV7ZXFwN739g1s1NxghsrchvNbcVVloDrffPNg=; b=REfewK/CB+Zclxdv/KkK9MJdZSG7eTGL6GHiS68erGfd1V/+2EjLNZtcxCNJWeowOMRl3c 2GTD1HrbF+mFZ+0ITT6kgwWi+LH3rUrPLUCWo4R7Y5gMaZUZQLjMgdsCTG9wa4E6aTjNzi Ppj8PVL2da/AoJ1wgysuYyKeqXLaLc5+nUf8vrOoXQdmfzXJDC6rPEN0vV4Uy6ycmEQuDC YDBq0r1huZDxAtCQaHuENrr/1Sz8K70r2V4PyK3ujr89PhDfwKOKz22LNOCY1pnPCh3yck j41UBSdmJJOvKLt5h3JkDtsBDpIGFv4Q2lykBP1C8aoDXUXq4g3EJo8BdjZtJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667602552; a=rsa-sha256; cv=none; b=pyxoqtIQjAHXpjTLS/7LX0Rll02egWEG7okIiMwYE4Bu2u6m5RtzI4kpwLmDmeUvR6vjix RrFktCXBePboSqq6F+gPV4Ie43Mo54isKoHLiEh3WkES/4pL6BheNILOTbFc/HkA76f5lu b+sfPNNVbj1zJm9oFAPXobV0De/3DuPdOicdY4n4C0u8gXo7x578PbYx9DyNlZePmVNPs2 8AxRPu1x9THOOjhhigYjdOjEVeTkOO+QLUJMcUlfMnZ30bgpkphUKg94oaaL4sd2M6qz+p KkuXKtJf3jzfcYnFUlq5ub6trxsYcVzl3JwG6lCGfFJi6E5uxu6sbRTcyN2oMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=91fcacc355971f74aa26fc7861020dc3a2a2d717 commit 91fcacc355971f74aa26fc7861020dc3a2a2d717 Author: Sumit Saxena AuthorDate: 2022-11-04 22:24:32 +0000 Commit: Warner Losh CommitDate: 2022-11-04 22:24:32 +0000 if_bnxt: Add support for VLAN on Thor Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36443 --- sys/dev/bnxt/bnxt.h | 3 +- sys/dev/bnxt/bnxt_hwrm.c | 110 ++++++++++++++++++++++++++++------------------- sys/dev/bnxt/bnxt_hwrm.h | 7 ++- sys/dev/bnxt/if_bnxt.c | 7 ++- 4 files changed, 74 insertions(+), 53 deletions(-) diff --git a/sys/dev/bnxt/bnxt.h b/sys/dev/bnxt/bnxt.h index 9638ad78fb6d..4cf93f1c7eeb 100644 --- a/sys/dev/bnxt/bnxt.h +++ b/sys/dev/bnxt/bnxt.h @@ -396,7 +396,7 @@ struct bnxt_vf_info { struct bnxt_vlan_tag { SLIST_ENTRY(bnxt_vlan_tag) next; - uint16_t tpid; + uint64_t filter_id; uint16_t tag; }; @@ -419,7 +419,6 @@ struct bnxt_vnic_info { #define BNXT_VNIC_FLAG_VLAN_STRIP 0x04 uint64_t filter_id; - uint32_t flow_id; uint16_t rss_id; uint32_t rss_hash_type; diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_hwrm.c index ebcfc5ef03ff..40c47ffe372c 100644 --- a/sys/dev/bnxt/bnxt_hwrm.c +++ b/sys/dev/bnxt/bnxt_hwrm.c @@ -1379,64 +1379,29 @@ bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) { struct hwrm_cfa_l2_set_rx_mask_input req = {0}; - struct bnxt_vlan_tag *tag; - uint32_t *tags; - uint32_t num_vlan_tags = 0; - uint32_t i; uint32_t mask = vnic->rx_mask; - int rc; - - SLIST_FOREACH(tag, &vnic->vlan_tags, next) - num_vlan_tags++; - - if (num_vlan_tags) { - if (!(mask & - HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN)) { - if (!vnic->vlan_only) - mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN; - else - mask |= - HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY; - } - if (vnic->vlan_tag_list.idi_vaddr) { - iflib_dma_free(&vnic->vlan_tag_list); - vnic->vlan_tag_list.idi_vaddr = NULL; - } - rc = iflib_dma_alloc(softc->ctx, 4 * num_vlan_tags, - &vnic->vlan_tag_list, BUS_DMA_NOWAIT); - if (rc) - return rc; - tags = (uint32_t *)vnic->vlan_tag_list.idi_vaddr; - i = 0; - SLIST_FOREACH(tag, &vnic->vlan_tags, next) { - tags[i] = htole32((tag->tpid << 16) | tag->tag); - i++; - } - } bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_SET_RX_MASK); req.vnic_id = htole32(vnic->id); req.mask = htole32(mask); req.mc_tbl_addr = htole64(vnic->mc_list.idi_paddr); req.num_mc_entries = htole32(vnic->mc_list_count); - req.vlan_tag_tbl_addr = htole64(vnic->vlan_tag_list.idi_paddr); - req.num_vlan_tags = htole32(num_vlan_tags); return hwrm_send_message(softc, &req, sizeof(req)); } int -bnxt_hwrm_free_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) +bnxt_hwrm_l2_filter_free(struct bnxt_softc *softc, uint64_t filter_id) { struct hwrm_cfa_l2_filter_free_input req = {0}; int rc = 0; - if (vnic->filter_id == -1) + if (filter_id == -1) return rc; bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_CFA_L2_FILTER_FREE); - req.l2_filter_id = htole64(vnic->filter_id); + req.l2_filter_id = htole64(filter_id); BNXT_HWRM_LOCK(softc); rc = _hwrm_send_message(softc, &req, sizeof(req)); @@ -1449,16 +1414,40 @@ fail: } int -bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) +bnxt_hwrm_free_filter(struct bnxt_softc *softc) +{ + struct bnxt_vnic_info *vnic = &softc->vnic_info; + struct bnxt_vlan_tag *tag; + int rc = 0; + + rc = bnxt_hwrm_l2_filter_free(softc, softc->vnic_info.filter_id); + if (rc) + goto end; + + SLIST_FOREACH(tag, &vnic->vlan_tags, next) { + rc = bnxt_hwrm_l2_filter_free(softc, tag->filter_id); + if (rc) + goto end; + tag->filter_id = -1; + } + +end: + return rc; +} + +int +bnxt_hwrm_l2_filter_alloc(struct bnxt_softc *softc, uint16_t vlan_tag, + uint64_t *filter_id) { struct hwrm_cfa_l2_filter_alloc_input req = {0}; struct hwrm_cfa_l2_filter_alloc_output *resp; + struct bnxt_vnic_info *vnic = &softc->vnic_info; uint32_t enables = 0; int rc = 0; - if (vnic->filter_id != -1) { - device_printf(softc->dev, - "Attempt to re-allocate l2 ctx filter\n"); + if (*filter_id != -1) { + device_printf(softc->dev, "Attempt to re-allocate l2 ctx " + "filter (fid: 0x%lx)\n", *filter_id); return EDOOFUS; } @@ -1469,6 +1458,17 @@ bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID; + + if (vlan_tag != 0xffff) { + enables |= + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN | + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK | + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS; + req.l2_ivlan_mask = 0xffff; + req.l2_ivlan = vlan_tag; + req.num_vlans = 1; + } + req.enables = htole32(enables); req.dst_id = htole16(vnic->id); memcpy(req.l2_addr, if_getlladdr(iflib_get_ifp(softc->ctx)), @@ -1480,14 +1480,34 @@ bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic) if (rc) goto fail; - vnic->filter_id = le64toh(resp->l2_filter_id); - vnic->flow_id = le64toh(resp->flow_id); - + *filter_id = le64toh(resp->l2_filter_id); fail: BNXT_HWRM_UNLOCK(softc); return (rc); } +int +bnxt_hwrm_set_filter(struct bnxt_softc *softc) +{ + struct bnxt_vnic_info *vnic = &softc->vnic_info; + struct bnxt_vlan_tag *tag; + int rc = 0; + + rc = bnxt_hwrm_l2_filter_alloc(softc, 0xffff, &vnic->filter_id); + if (rc) + goto end; + + SLIST_FOREACH(tag, &vnic->vlan_tags, next) { + rc = bnxt_hwrm_l2_filter_alloc(softc, tag->tag, + &tag->filter_id); + if (rc) + goto end; + } + +end: + return rc; +} + int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic, uint32_t hash_type) diff --git a/sys/dev/bnxt/bnxt_hwrm.h b/sys/dev/bnxt/bnxt_hwrm.h index ad308f0bbbdd..8033ddb50136 100644 --- a/sys/dev/bnxt/bnxt_hwrm.h +++ b/sys/dev/bnxt/bnxt_hwrm.h @@ -70,8 +70,11 @@ int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc, int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *gr); int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic); -int bnxt_hwrm_set_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic); -int bnxt_hwrm_free_filter(struct bnxt_softc *softc, struct bnxt_vnic_info *vnc); +int bnxt_hwrm_set_filter(struct bnxt_softc *softc); +int bnxt_hwrm_free_filter(struct bnxt_softc *softc); +int bnxt_hwrm_l2_filter_alloc(struct bnxt_softc *softc, uint16_t vlan_tag, + uint64_t *filter_id); +int bnxt_hwrm_l2_filter_free(struct bnxt_softc *softc, uint64_t filter_id); int bnxt_hwrm_rss_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic, uint32_t hash_type); int bnxt_cfg_async_cr(struct bnxt_softc *softc); diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c index c63b47da4a89..bc6dd1c2b1c5 100644 --- a/sys/dev/bnxt/if_bnxt.c +++ b/sys/dev/bnxt/if_bnxt.c @@ -653,7 +653,6 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, /* And finally, the VNIC */ softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE; - softc->vnic_info.flow_id = (uint16_t)HWRM_NA_SIGNATURE; softc->vnic_info.filter_id = -1; softc->vnic_info.def_ring_grp = (uint16_t)HWRM_NA_SIGNATURE; softc->vnic_info.cos_rule = (uint16_t)HWRM_NA_SIGNATURE; @@ -1649,7 +1648,7 @@ bnxt_hwrm_resource_free(struct bnxt_softc *softc) if (rc) goto fail; } - rc = bnxt_hwrm_free_filter(softc, &softc->vnic_info); + rc = bnxt_hwrm_free_filter(softc); if (rc) goto fail; @@ -1850,7 +1849,7 @@ skip_def_cp_ring: rc = bnxt_hwrm_vnic_set_hds(softc, &softc->vnic_info); if (rc) goto fail; - rc = bnxt_hwrm_set_filter(softc, &softc->vnic_info); + rc = bnxt_hwrm_set_filter(softc); if (rc) goto fail; @@ -2406,7 +2405,7 @@ bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag) if (new_tag == NULL) return; new_tag->tag = vtag; - new_tag->tpid = 8100; + new_tag->filter_id = -1; SLIST_INSERT_HEAD(&softc->vnic_info.vlan_tags, new_tag, next); };