From patchwork Sat Dec 23 04:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13503904 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35E9C469E for ; Sat, 23 Dec 2023 04:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="bGCGuJUR" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-67f8a5ed1a0so11116956d6.2 for ; Fri, 22 Dec 2023 20:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703305361; x=1703910161; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=kcsTa7bRud7e3sZv2VpHzDuK9M7W9RmOTUL9cMcaBKc=; b=bGCGuJUR7iOuOI6v+EWiVAYr7XGKM0DDOAfdVHhqm5Bb4aeghKMP1aELO3yhgjsLam eDLEYwvBGjcfSL8zdSukrhMGqRn6IRzqIufA6CDa0jgQj0Az4naojKsdqrtjq6hvvq9n Z/+S49mC2NVyROAxd4/w8f9v6g7JWG0hRbAF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703305361; x=1703910161; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kcsTa7bRud7e3sZv2VpHzDuK9M7W9RmOTUL9cMcaBKc=; b=HTLhwzhxHM6ZWG1B1FXFMJGzGV7ReA2Jcw03P7wN1WvbKieGfyrVvF+PjbOywnFqck zxy3hS0F3KFvXlehtcqsvGt5XRfuAzK9LdH9xW5kOjm3Bnv7CZqBIxTsJ9gO/o1xAikN us/MvIJM9hgRd5tAZBf8hTAwl1x7hVV2G1NWi2zmAhs6r5uF/4Az0EV4TI2K8HB8ZFEs q9gk6AGiBTa1HDQQ/x3V4BYQ6SKZjzcyBtBHRk2ODy3q1SKN0Mpw4CVIQ1YmZOnTz68F NoGj+GhAuLfXxy4Gq6srigMahRDx2XMtEC83uEanW2IGktwrcpxiUYQiaWbEWTyGlTP3 Ki4Q== X-Gm-Message-State: AOJu0YyrG+HtUxXvCxatSCb8QwkHdRAa6JzEDItJ6mb/7lavTk21NkwB gqwv42WlciJqKiwpRb6dNnmuEt7cwzcNT5DkJJFS3gygGA== X-Google-Smtp-Source: AGHT+IFmF/QwTNShr/BtSFwMqcNwO1wU6+9JhYvHV0g8e2AM5LLgSjVYuXoUupqhCYVkN6nWR5q18Q== X-Received: by 2002:a05:6214:1d03:b0:67f:2fde:1678 with SMTP id e3-20020a0562141d0300b0067f2fde1678mr3623274qvd.42.1703305360912; Fri, 22 Dec 2023 20:22:40 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id ek5-20020ad45985000000b0067f8046a1acsm1299916qvb.144.2023.12.22.20.22.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2023 20:22:40 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com Subject: [PATCH net-next v2 03/13] bnxt_en: Re-structure the bnxt_ntuple_filter structure. Date: Fri, 22 Dec 2023 20:22:00 -0800 Message-Id: <20231223042210.102485-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231223042210.102485-1-michael.chan@broadcom.com> References: <20231223042210.102485-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org With the new bnxt_l2_filter structure, we can now re-structure the bnxt_ntuple_filter structure to point to the bnxt_l2_filter structure. We eliminate the L2 ether address info from the ntuple filter structure as we can get the information from the L2 filter structure. Note that the source L2 MAC address is no longer used. Reviewed-by: Vasundhara Volam Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 62 ++++++++++++++--------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 8e9a02629450..62e4f35c6f0f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4804,6 +4804,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) head = &bp->ntp_fltr_hash_tbl[i]; hlist_for_each_entry_safe(fltr, tmp, head, base.hash) { + bnxt_del_l2_filter(bp, fltr->l2_fltr); if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) continue; hlist_del(&fltr->base.hash); @@ -5373,6 +5374,20 @@ static struct bnxt_l2_filter *bnxt_lookup_l2_filter(struct bnxt *bp, return fltr; } +#ifdef CONFIG_RFS_ACCEL +static struct bnxt_l2_filter * +bnxt_lookup_l2_filter_from_key(struct bnxt *bp, struct bnxt_l2_key *key) +{ + struct bnxt_l2_filter *fltr; + u32 idx; + + idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & + BNXT_L2_FLTR_HASH_MASK; + fltr = bnxt_lookup_l2_filter(bp, key, idx); + return fltr; +} +#endif + static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, struct bnxt_l2_key *key, u32 idx) { @@ -5432,7 +5447,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, #define BNXT_NTP_FLTR_FLAGS \ (CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_L2_FILTER_ID | \ CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_ETHERTYPE | \ - CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_MACADDR | \ CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_IPADDR_TYPE | \ CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR | \ CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR_MASK | \ @@ -5463,7 +5477,7 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, if (rc) return rc; - l2_fltr = bp->vnic_info[0].l2_filters[fltr->l2_fltr_idx]; + l2_fltr = fltr->l2_fltr; req->l2_filter_id = l2_fltr->base.filter_id; @@ -5478,7 +5492,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, req->enables = cpu_to_le32(BNXT_NTP_FLTR_FLAGS); req->ethertype = htons(ETH_P_IP); - memcpy(req->src_macaddr, fltr->src_mac_addr, ETH_ALEN); req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; req->ip_protocol = keys->basic.ip_proto; @@ -13730,8 +13743,7 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1, if (keys1->ports.ports == keys2->ports.ports && keys1->control.flags == keys2->control.flags && - ether_addr_equal(f1->src_mac_addr, f2->src_mac_addr) && - ether_addr_equal(f1->dst_mac_addr, f2->dst_mac_addr)) + f1->l2_fltr == f2->l2_fltr) return true; return false; @@ -13744,29 +13756,32 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, struct bnxt_ntuple_filter *fltr, *new_fltr; struct flow_keys *fkeys; struct ethhdr *eth = (struct ethhdr *)skb_mac_header(skb); - int rc = 0, idx, bit_id, l2_idx = 0; + struct bnxt_l2_filter *l2_fltr; + int rc = 0, idx, bit_id; struct hlist_head *head; u32 flags; - if (!ether_addr_equal(dev->dev_addr, eth->h_dest)) { - struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; - int off = 0, j; + if (ether_addr_equal(dev->dev_addr, eth->h_dest)) { + l2_fltr = bp->vnic_info[0].l2_filters[0]; + atomic_inc(&l2_fltr->refcnt); + } else { + struct bnxt_l2_key key; - netif_addr_lock_bh(dev); - for (j = 0; j < vnic->uc_filter_count; j++, off += ETH_ALEN) { - if (ether_addr_equal(eth->h_dest, - vnic->uc_list + off)) { - l2_idx = j + 1; - break; - } - } - netif_addr_unlock_bh(dev); - if (!l2_idx) + ether_addr_copy(key.dst_mac_addr, eth->h_dest); + key.vlan = 0; + l2_fltr = bnxt_lookup_l2_filter_from_key(bp, &key); + if (!l2_fltr) + return -EINVAL; + if (l2_fltr->base.flags & BNXT_ACT_FUNC_DST) { + bnxt_del_l2_filter(bp, l2_fltr); return -EINVAL; + } } new_fltr = kzalloc(sizeof(*new_fltr), GFP_ATOMIC); - if (!new_fltr) + if (!new_fltr) { + bnxt_del_l2_filter(bp, l2_fltr); return -ENOMEM; + } fkeys = &new_fltr->fkeys; if (!skb_flow_dissect_flow_keys(skb, fkeys, 0)) { @@ -13793,8 +13808,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, goto err_free; } - memcpy(new_fltr->dst_mac_addr, eth->h_dest, ETH_ALEN); - memcpy(new_fltr->src_mac_addr, eth->h_source, ETH_ALEN); + new_fltr->l2_fltr = l2_fltr; idx = skb_get_hash_raw(skb) & BNXT_NTP_FLTR_HASH_MASK; head = &bp->ntp_fltr_hash_tbl[idx]; @@ -13819,9 +13833,9 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, new_fltr->base.sw_id = (u16)bit_id; new_fltr->flow_id = flow_id; - new_fltr->l2_fltr_idx = l2_idx; new_fltr->base.rxq = rxq_index; new_fltr->base.type = BNXT_FLTR_TYPE_NTUPLE; + new_fltr->base.flags = BNXT_ACT_RING_DST; hlist_add_head_rcu(&new_fltr->base.hash, head); bp->ntp_fltr_count++; spin_unlock_bh(&bp->ntp_fltr_lock); @@ -13831,6 +13845,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, return new_fltr->base.sw_id; err_free: + bnxt_del_l2_filter(bp, l2_fltr); kfree(new_fltr); return rc; } @@ -13871,6 +13886,7 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp) hlist_del_rcu(&fltr->base.hash); bp->ntp_fltr_count--; spin_unlock_bh(&bp->ntp_fltr_lock); + bnxt_del_l2_filter(bp, fltr->l2_fltr); synchronize_rcu(); clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); kfree(fltr); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 77c7084e47cd..72e99f2a5c68 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1355,10 +1355,8 @@ struct bnxt_filter_base { struct bnxt_ntuple_filter { struct bnxt_filter_base base; - u8 dst_mac_addr[ETH_ALEN]; - u8 src_mac_addr[ETH_ALEN]; struct flow_keys fkeys; - u8 l2_fltr_idx; + struct bnxt_l2_filter *l2_fltr; u32 flow_id; };