From nobody Thu Jan 19 03:52:18 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 4Ny7xG5Z70z2svJ9; Thu, 19 Jan 2023 03:52:18 +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 4Ny7xG4XLSz3hsg; Thu, 19 Jan 2023 03:52:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674100338; 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=GLkIbd7NaXQyXqwLTbDjZqWlXlEPyhKiLNY0LVcUScU=; b=UurUy9nZzWSQ542yzdyBx25QQ13qS4HopAIUK9spMhL/h9+0eBQ6LmKP2bbkEiDYQ10ALw U8ddP5Jty3PT1A5z8uo7VqZVRnYtmyE5uE7jEmmyYBVADtOcWEeJO5Uh3LLGRTuu3cz4E7 V0Ij3WbXOHJhQ8yz6CWKDeuOVwFahVxTBLuPlAOkzH+Mt2MHycGdl5WMo2Hb+5Ss/56dpG WpMzvgWe4117rarx4GiGVIhYL8KLw/hkAcUX9piUbRASUZb4oEW7GGVJmGhO74t7hbd4z6 0Z70/+obEmGcp1L7lt4p6trj7yWjyO6qVD9qzU/Waonx1cqujtDBjgJjcYDyYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674100338; 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=GLkIbd7NaXQyXqwLTbDjZqWlXlEPyhKiLNY0LVcUScU=; b=RfW3/GO6OI1ZX8IYVcKoWVumAl5XsPu+rhkUPgYF2WVUMfr0vYvb9s/eXVZvqJODReQ/Js 5IO1izUALTvxLd8dD3/7OJa7uFwdDZVyhskXBg3SjraXnLsOX6voD6DKOBEQ4alQpHsX+4 Z6FNfuH4nvXURfxhHX8rYBwqCukM+pCTgOaC462kJwGe+1pdX4otcg83pEGby/3Zl6dtf1 2M1cd6XXlntFvjrb9RWPplmNABt3RMUurHEPnHZWqkkYDM5rD5st6gzyttHr0bDzB3UkHY tOXjLQ6e5dsu70ikxLk0uWH5JdDwLXL+Z+BxEuxtz1td6GbRFFAWfsLjcsUtrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674100338; a=rsa-sha256; cv=none; b=MjaELr1swdFMfwS/tQa5IoANMmu5OhlCRBDhpqp8IxShBbxpVOF2jsDxZhjg9fw+5ePmvY m5E/9dOyXg0TdbiOVX3DeVVbqqLnP7YBBtxyjBgmB05YajEFb0aVWYafBmErnjn+gVWXmj zgz0YyuWjzEFB34GxzbtX206UFtPYCah7b6l18L8YMWhDMdTSCyOJ6odBwOaxDGQn7pq8b WbihcZUN4GwiuL9U5yWqVITmp11FPvvVGlUnB7R7ChKrdcynqFr/eiI4MgoGaNlith4R2U sEsOfwxnno8tGJpr3Ohl7dBgOPs6ebD+ajFNkzC9OvzNLaOOK4OEVJBKEPUrsA== 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 4Ny7xG3Nv9zc4L; Thu, 19 Jan 2023 03:52:18 +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 30J3qICU023177; Thu, 19 Jan 2023 03:52:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30J3qIO3023176; Thu, 19 Jan 2023 03:52:18 GMT (envelope-from git) Date: Thu, 19 Jan 2023 03:52:18 GMT Message-Id: <202301190352.30J3qIO3023176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 2db35273502b - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 2db35273502b3c35aa653effc5c97618567367ab Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2db35273502b3c35aa653effc5c97618567367ab commit 2db35273502b3c35aa653effc5c97618567367ab Author: Sumit Saxena AuthorDate: 2022-11-04 22:24:32 +0000 Commit: Warner Losh CommitDate: 2023-01-19 01:00:06 +0000 if_bnxt: Add support for VLAN on Thor Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36443 (cherry picked from commit 91fcacc355971f74aa26fc7861020dc3a2a2d717) --- 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); };