From patchwork Mon Feb 5 22:31:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546343 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 2C9BE1EB5E for ; Mon, 5 Feb 2024 22:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172338; cv=none; b=t15u9NZvJiT8WT3oVhV9xJ6Iva3a1lWVgXQV561D/Jfc3BmzwRItp/YJmu5kvlLAp2k9oUV9uIJyRO8X2pzPvjhHeh5U+2t2ZfdAjzXBvJJjiCPj3XywzhKdwA877JCTQPV0oJ4ObI5D3ZxGnKZwYFgZaE/kKraqbS22JABD2K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172338; c=relaxed/simple; bh=JnigXIaq1Nfvh4Ijo15SxBEBkM4aS7QQvC4NaLbIhkQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JhnO2Pk4O3TPaOl4qR7IjVXL7HRfNtTiHHTTRBSNyiFslWes2d/MMB6ZjRos+d4Xl2VdAyP6gT13Rz7pkaXO9Y5Sqsc5kkS9riE2KMIOcdkXihjYmhx9Oj+O3jCXGgko4BQLmgj4zKtqApWUfbxPazermY23V6Z1gpc69igji5g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=aUS+kUkc; arc=none smtp.client-ip=209.85.160.169 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="aUS+kUkc" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-42a8a3973c5so32566191cf.2 for ; Mon, 05 Feb 2024 14:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172336; x=1707777136; 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=3BhzPHAywNtM9wPFrPzWI7VapCg5UhyEDdeAiFdihN8=; b=aUS+kUkcH213r7kuKYoltVIAtWn0mtsDtLypxgfwPaHUxAO1tEId+VSeH8t6s7zxP/ dM+rlH+ESyLnk5fLkGVc0joPkiN+/+b/TB/ByWd32+bpNRZvKFCPfi9k6+DgjjfIHY5T V9BSS/Ph/GSuQssN9JkY71IOSaXi6/UfqvQQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172336; x=1707777136; 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=3BhzPHAywNtM9wPFrPzWI7VapCg5UhyEDdeAiFdihN8=; b=vVVp6Eb6FpaUOVPaeNHL8OuVUi03IdzipLPEzmKB82uBjaBoStzZiPmxSsKmPZNKe4 e5oad18VWf02MIV6kUlO4MqcF0O6FRVlbs0syDHArFah52vZ6xdTkekpSP75U15drtLw Mm2q7tXWTE34sMm8ZZlp7TMfrvsaCE1DbtL/EI6xhHFdZSgKcTYGXOf00XOuI8PVe/ur I3ozRqpqyQO+WiwomKLycPQwZ/HxO6TbYdWG8dSsZqWW6UHzQFxbEC+GgMsp2KGnCeCG oAUGW/tDLGVy46aopXgUItGnalqucshJcHmjOUIjq6n2MtLatVAWxl2OW6SoSHHBDmTe V6+A== X-Gm-Message-State: AOJu0YwHTpsnoo0ILiuTJaY+VN2QO9llhVZvxtSa8NRkuTffJSHWaDng FK5QCzQGJGksCr5hrh31y2aNDF5ZjfPMn1AL38orQdtAgyrVc0GmJcC3pTSzBQ== X-Google-Smtp-Source: AGHT+IGTRepGstnLrGnP19SGnABNvnJsPo9t/26toj8rLluL7wzpu4wxkKzGCt/+quUozJMqeqs3Gw== X-Received: by 2002:a05:622a:16:b0:42a:a9e1:7384 with SMTP id x22-20020a05622a001600b0042aa9e17384mr682792qtw.50.1707172335842; Mon, 05 Feb 2024 14:32:15 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVmAfR3ucv5tsqW2OBk3vP7EZglscUzT1d92w+i38jnQ7TAtkMNob9bu+RC764IU/+f0HWfDs/MKp7Pwdg1ekN+Qe3PYFYMZ6LUD5lZ/9i6oMGrNRAOot/9FuA63apLbKYtvPFz7H6wBIB1fweznicHmVGMMn5QvVHisSjp31u9y3YILhxc9kDv50DSxZTk/Bp+00t/vw5pMIG29gFrMsNNpL0= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:15 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 01/13] bnxt_en: Use firmware provided maximum filter counts. Date: Mon, 5 Feb 2024 14:31:50 -0800 Message-Id: <20240205223202.25341-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 While individual filter structures are allocated as needed, there is an array to keep track of the software filter IDs that we allocate ahead of time. Rather than relying on a fixed maximum filter count to allocate this array, get the maximum from the firmware when available. Move these filter related maximum counts queried from the firmware to the bnxt_hw_resc struct. If the firmware is not providing these maximum counts, fall back to the hard-coded constant. Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 13 +++++----- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index fde32b32fa81..91ecf514b924 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4840,7 +4840,7 @@ static int bnxt_alloc_ntp_fltrs(struct bnxt *bp) INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); bp->ntp_fltr_count = 0; - bp->ntp_fltr_bmap = bitmap_zalloc(BNXT_MAX_FLTR, GFP_KERNEL); + bp->ntp_fltr_bmap = bitmap_zalloc(bp->max_fltr, GFP_KERNEL); if (!bp->ntp_fltr_bmap) rc = -ENOMEM; @@ -5480,7 +5480,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, int bit_id; bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, - BNXT_MAX_FLTR, 0); + bp->max_fltr, 0); if (bit_id < 0) return -ENOMEM; fltr->base.sw_id = (u16)bit_id; @@ -8709,6 +8709,13 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); + hw_resc->max_encap_records = le32_to_cpu(resp->max_encap_records); + hw_resc->max_decap_records = le32_to_cpu(resp->max_decap_records); + hw_resc->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); + hw_resc->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); + hw_resc->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); + hw_resc->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); + if (BNXT_PF(bp)) { struct bnxt_pf_info *pf = &bp->pf; @@ -8717,12 +8724,6 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); pf->first_vf_id = le16_to_cpu(resp->first_vf_id); pf->max_vfs = le16_to_cpu(resp->max_vfs); - pf->max_encap_records = le32_to_cpu(resp->max_encap_records); - pf->max_decap_records = le32_to_cpu(resp->max_decap_records); - pf->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); - pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); - pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); - pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); bp->flags &= ~BNXT_FLAG_WOL_CAP; if (flags & FUNC_QCAPS_RESP_FLAGS_WOL_MAGICPKT_SUPPORTED) bp->flags |= BNXT_FLAG_WOL_CAP; @@ -13899,7 +13900,7 @@ int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr, int bit_id; spin_lock_bh(&bp->ntp_fltr_lock); - bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, BNXT_MAX_FLTR, 0); + bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, bp->max_fltr, 0); if (bit_id < 0) { spin_unlock_bh(&bp->ntp_fltr_lock); return -ENOMEM; @@ -14669,6 +14670,7 @@ void bnxt_print_device_info(struct bnxt *bp) static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { + struct bnxt_hw_resc *hw_resc; struct net_device *dev; struct bnxt *bp; int rc, max_irqs; @@ -14827,6 +14829,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto init_err_pci_clean; + hw_resc = &bp->hw_resc; + bp->max_fltr = hw_resc->max_rx_em_flows + hw_resc->max_rx_wm_flows + + BNXT_L2_FLTR_MAX_FLTR; + /* Older firmware may not report these filters properly */ + if (bp->max_fltr < BNXT_MAX_FLTR) + bp->max_fltr = BNXT_MAX_FLTR; bnxt_init_l2_fltr_tbl(bp); bnxt_set_rx_skb_mode(bp, false); bnxt_set_tpa_flags(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index b2cb3e77559d..4bd1cf01d99e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1281,6 +1281,12 @@ struct bnxt_hw_resc { u16 max_nqs; u16 max_irqs; u16 resv_irqs; + u32 max_encap_records; + u32 max_decap_records; + u32 max_tx_em_flows; + u32 max_tx_wm_flows; + u32 max_rx_em_flows; + u32 max_rx_wm_flows; }; #if defined(CONFIG_BNXT_SRIOV) @@ -1315,12 +1321,6 @@ struct bnxt_pf_info { u16 active_vfs; u16 registered_vfs; u16 max_vfs; - u32 max_encap_records; - u32 max_decap_records; - u32 max_tx_em_flows; - u32 max_tx_wm_flows; - u32 max_rx_em_flows; - u32 max_rx_wm_flows; unsigned long *vf_event_bmap; u16 hwrm_cmd_req_pages; u8 vf_resv_strategy; @@ -2428,6 +2428,7 @@ struct bnxt { unsigned long *ntp_fltr_bmap; int ntp_fltr_count; + int max_fltr; #define BNXT_L2_FLTR_MAX_FLTR 1024 #define BNXT_L2_FLTR_HASH_SIZE 32 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 481b835a7703..1c8610386404 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1077,7 +1077,7 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) struct flow_keys *fkeys; int rc = -EINVAL; - if (fs->location >= BNXT_NTP_FLTR_MAX_FLTR) + if (fs->location >= bp->max_fltr) return rc; rcu_read_lock(); @@ -1521,7 +1521,7 @@ static int bnxt_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, case ETHTOOL_GRXCLSRLCNT: cmd->rule_cnt = bp->ntp_fltr_count; - cmd->data = BNXT_NTP_FLTR_MAX_FLTR | RX_CLS_LOC_SPECIAL; + cmd->data = bp->max_fltr | RX_CLS_LOC_SPECIAL; break; case ETHTOOL_GRXCLSRLALL: From patchwork Mon Feb 5 22:31:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546344 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 9B4C417EF for ; Mon, 5 Feb 2024 22:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172340; cv=none; b=LEvAVUhvbHYnZVb5NKZpirxXmOzP22U25NrjWXDSbHW2N/oYdAhkLryO2uwal76EbivJFkOTqkQIkZyDLVEPMhsb6xEGhnqLck9UetPPlmRBgeBM8j1o+l8mS4F8tprquv3gdKt9W3P68MJ+gyd6NmOq7Pq2tKbbtaZEChRqEzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172340; c=relaxed/simple; bh=USstlF9AF09uFw/m0UkzN5M17NuAlDATjQPowT6nXy0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=FSjn6f1uEdyKforFJIVc3XTa/CEfV6aG4TaoSbQYLzsQM+jDWKtpk0hUZOyfayj2ZPL+lpFn5h2OnnfZa8AYUIbc5mi/0wY7V+8mVu9Gn4Wro4YR1f5tMndGxp4HzA/ilejoLSF+1vehUY+6xEuRQ6pmNm+tA8Emvob/I39viWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=aU6kT2E1; arc=none smtp.client-ip=209.85.210.50 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="aU6kT2E1" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e13cfc0b2fso2727217a34.2 for ; Mon, 05 Feb 2024 14:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172337; x=1707777137; 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=NItPsgaHvg3rOLJjy8ztFaCxrZ0ediYjA7YPu+zpX3I=; b=aU6kT2E1eu0FEPykT0GqoF98rYi1/1Z7XnQQ8C4CED9C1f8ogM69cu2zE9Xhpbx4M+ cYeBfTQY39eumPDJn4/YxxgnNKiISlA5k2VOLUsTe8ieaydG/I2h5jIuDUHPNLFIwrvE ue/RZRWpMZV6gQ/e9+YoQffZXRnuWSSMKqc7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172337; x=1707777137; 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=NItPsgaHvg3rOLJjy8ztFaCxrZ0ediYjA7YPu+zpX3I=; b=QZVFXBfvZuFgFPvD0VOk2WgCvM8oKFIY7VCSPuO8oAAWQZRhvHlqVdTN38PSE7AnCv loNl5aS+EC4SRPV0P7+yYSGJy/BotLAZIZUmdqrAL7X7GTeWQsK1vSBu0kWl8ilHh+U1 sFZdy3BAbqociG4PBS7eqaZ+GrmBbJGV0ZxUnP6ZZwr9ayyMImJuk4xKlJ+U4+DC7Ase VUpF2rizS44LSXKJoWtEy75L6BcO7HQKls+sCwaZjKVKmSa5KJgYNbNpV9T7w3RN5KTQ kT9nmWbx71tE/SEKSt43ZmAcdEyIU3c9ZkNteUnzQhvCQv/4PSrBkM3fzY41+OLU6jLO RaIw== X-Gm-Message-State: AOJu0YwTAa9HOHpwh2c9589h/G6K7t0ja+vr/7j2rmcNo9jekOk0r4X2 hDAZIaFzd54ntJ+YIvAQxYcJLKr0fvu+s9Lvs9eieSTAJbFPNgoyUSjEWrrhBfPq0BuJjfG0fgQ = X-Google-Smtp-Source: AGHT+IFVuXPv20TPX6KHC9O4FWrBL/rIlOgGDizqTxXWVmsQ2PD8LBgYniVFuQTRKwYHrgiw1pSt+w== X-Received: by 2002:a9d:7993:0:b0:6dc:1cf:2fef with SMTP id h19-20020a9d7993000000b006dc01cf2fefmr614728otm.15.1707172337575; Mon, 05 Feb 2024 14:32:17 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUm/pOogs/e7VCnpCDxGhE0fmYjPwRx4Qf49Ue+hW2knhCjPih68YUeqQcnzGdx3A5ParVQi9oop9sgQoFAXLKa0Uu6hWopQ397MyM4+1ySYApGP2ceyYgOHWpxs4ViHIzoygCWl/mJSsMeZrUAd2c3oKOrdIJ96CN/iHFZaVA9x1FrPJZMff83N+VVlWZNnZcBBQ6sJVEbOBgFT+GzXXBe0dU= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:16 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 02/13] bnxt_en: Add ethtool -N support for ether filters. Date: Mon, 5 Feb 2024 14:31:51 -0800 Message-Id: <20240205223202.25341-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 Add ETHTOOL_SRXCLSRLINS and ETHTOOL_SRXCLSRLDEL support for inserting and deleting L2 ether filter rules. Destination MAC address and optional VLAN are supported for each filter entry. This is currently only supported on older BCM573XX and BCM574XX chips only. Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 34 +++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 69 ++++++++++++++++++- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 91ecf514b924..3cc3504181c7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5519,6 +5519,40 @@ static struct bnxt_l2_filter *bnxt_alloc_l2_filter(struct bnxt *bp, return fltr; } +struct bnxt_l2_filter *bnxt_alloc_new_l2_filter(struct bnxt *bp, + struct bnxt_l2_key *key, + u16 flags) +{ + struct bnxt_l2_filter *fltr; + u32 idx; + int rc; + + idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & + BNXT_L2_FLTR_HASH_MASK; + spin_lock_bh(&bp->ntp_fltr_lock); + fltr = __bnxt_lookup_l2_filter(bp, key, idx); + if (fltr) { + fltr = ERR_PTR(-EEXIST); + goto l2_filter_exit; + } + fltr = kzalloc(sizeof(*fltr), GFP_ATOMIC); + if (!fltr) { + fltr = ERR_PTR(-ENOMEM); + goto l2_filter_exit; + } + fltr->base.flags = flags; + rc = bnxt_init_l2_filter(bp, fltr, key, idx); + if (rc) { + spin_unlock_bh(&bp->ntp_fltr_lock); + bnxt_del_l2_filter(bp, fltr); + return ERR_PTR(rc); + } + +l2_filter_exit: + spin_unlock_bh(&bp->ntp_fltr_lock); + return fltr; +} + static u16 bnxt_vf_target_id(struct bnxt_pf_info *pf, u16 vf_idx) { #ifdef CONFIG_BNXT_SRIOV diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 4bd1cf01d99e..21721b8748bc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2646,6 +2646,9 @@ int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size, bool async_only); int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr); +struct bnxt_l2_filter *bnxt_alloc_new_l2_filter(struct bnxt *bp, + struct bnxt_l2_key *key, + u16 flags); int bnxt_hwrm_l2_filter_free(struct bnxt *bp, struct bnxt_l2_filter *fltr); int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr); int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 1c8610386404..2d8e847e8fdd 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1152,6 +1152,58 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) return rc; } +static int bnxt_add_l2_cls_rule(struct bnxt *bp, + struct ethtool_rx_flow_spec *fs) +{ + u32 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); + u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); + struct ethhdr *h_ether = &fs->h_u.ether_spec; + struct ethhdr *m_ether = &fs->m_u.ether_spec; + struct bnxt_l2_filter *fltr; + struct bnxt_l2_key key; + u16 vnic_id; + u8 flags; + int rc; + + if (BNXT_CHIP_P5_PLUS(bp)) + return -EOPNOTSUPP; + + if (!is_broadcast_ether_addr(m_ether->h_dest)) + return -EINVAL; + ether_addr_copy(key.dst_mac_addr, h_ether->h_dest); + key.vlan = 0; + if (fs->flow_type & FLOW_EXT) { + struct ethtool_flow_ext *m_ext = &fs->m_ext; + struct ethtool_flow_ext *h_ext = &fs->h_ext; + + if (m_ext->vlan_tci != htons(0xfff) || !h_ext->vlan_tci) + return -EINVAL; + key.vlan = ntohs(h_ext->vlan_tci); + } + + if (vf) { + flags = BNXT_ACT_FUNC_DST; + vnic_id = 0xffff; + vf--; + } else { + flags = BNXT_ACT_RING_DST; + vnic_id = bp->vnic_info[ring + 1].fw_vnic_id; + } + fltr = bnxt_alloc_new_l2_filter(bp, &key, flags); + if (IS_ERR(fltr)) + return PTR_ERR(fltr); + + fltr->base.fw_vnic_id = vnic_id; + fltr->base.rxq = ring; + fltr->base.vf_idx = vf; + rc = bnxt_hwrm_l2_filter_alloc(bp, fltr); + if (rc) + bnxt_del_l2_filter(bp, fltr); + else + fs->location = fltr->base.sw_id; + return rc; +} + #define IPV4_ALL_MASK ((__force __be32)~0) #define L4_PORT_ALL_MASK ((__force __be16)~0) @@ -1335,7 +1387,7 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd) return -EINVAL; flow_type &= ~FLOW_EXT; if (flow_type == ETHER_FLOW) - rc = -EOPNOTSUPP; + rc = bnxt_add_l2_cls_rule(bp, fs); else rc = bnxt_add_ntuple_cls_rule(bp, fs); return rc; @@ -1346,11 +1398,22 @@ static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd) struct ethtool_rx_flow_spec *fs = &cmd->fs; struct bnxt_filter_base *fltr_base; struct bnxt_ntuple_filter *fltr; + u32 id = fs->location; rcu_read_lock(); + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, id); + if (fltr_base) { + struct bnxt_l2_filter *l2_fltr; + + l2_fltr = container_of(fltr_base, struct bnxt_l2_filter, base); + rcu_read_unlock(); + bnxt_hwrm_l2_filter_free(bp, l2_fltr); + bnxt_del_l2_filter(bp, l2_fltr); + return 0; + } fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, - BNXT_NTP_FLTR_HASH_SIZE, - fs->location); + BNXT_NTP_FLTR_HASH_SIZE, id); if (!fltr_base) { rcu_read_unlock(); return -ENOENT; From patchwork Mon Feb 5 22:31:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546345 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 2EACB41746 for ; Mon, 5 Feb 2024 22:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172341; cv=none; b=TOZoYkdAaIdAIjRZOfutfDgjpH70Mc0w0CKw7UfAKmhb4NDvwHSxMMX+3qbtbOcRxTLMzN7g+seDz00WtFteWbsRmaYnE6WwOPAe4s+1SJEdN3RpeV+nu/q8qGcLD9gM9P87gaLugOKZjRGIst1xqYPRN8QtoY3Pa73nly8LCh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172341; c=relaxed/simple; bh=KhqOVtn0nvtmIhPJR3UQui/tjKKWd4Ht/3vN7k78Q4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tyrKdTxatMuFAk3qkEmitO/0rhPcH4HWwdzTllMhIvCla1rfYtxCma1HBEO9+vnhypRwxDzdzTfag2M6wAOo4K0b9CzrD7JJpryE+o00VZ3wE/ZU9BshEC9rwdUzDfQL1n0Ojr29/oPn9WEDXYR9F8ByzKJ6U3MKZGJ1XH+/vc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=fTLjb5zJ; arc=none smtp.client-ip=209.85.210.47 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="fTLjb5zJ" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6e14b858785so3199383a34.0 for ; Mon, 05 Feb 2024 14:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172339; x=1707777139; 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=V/n6wG2nL+MfKB6pnX8UOLwYoNxtUZuVinAHTc4Vw70=; b=fTLjb5zJEPpCtyBd/vr3zCYPSR3PptGHjPCruiksmXLkJXgBHKhJoISPduVrirGmMB dLYaUo+eebKq3UcC9TlI34GVC9XuHxA71i2FXBll1HkwMfQm2nMKtNRetSCqgUuW1u4L TV0Kjk9dkfvDFnPk7Lvzw+DvkUsKq3PocUsrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172339; x=1707777139; 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=V/n6wG2nL+MfKB6pnX8UOLwYoNxtUZuVinAHTc4Vw70=; b=Xk0K9Nibiatek9MhzRYvKYYjJJc0qHScIxF6j+M4L0/h2ApqmVlnTQyXO4b7tdxUE8 704l/N3OpSJDkI7e0B+9uZTFiojs6p3yM5QJYuKryMbjlEW0uuadgBy5mDEpi4Jui4+Q D82UXNZsYieSR94hvgRwKyZynQWrHJlaTa4kKY6I0EB53WnPM+Fq9Q7zz3xBmFUlIb3E toBkc0SBCPo0bbb+0nkzbj7SfXrWfWws//3W3gkMpNQ3Lf+6db0a+Tkz0GUpw+Fn05xv /MZQh+/spdRFUAsrfZDUxZBAI6gKSV5AuWPf0eVk09QZEe+Iho46eHOPoSAMJofG2iHM f4qA== X-Gm-Message-State: AOJu0YzbsKVIaXOWXe9ETZVOBeoLYfhY2GQgmKW0TnPMMUuAEwx1xqW1 i6NoGq8eyBbtT+5uDFZb14o/S8vfxmJ22ahRzDvFPEo4ytpatqXX/xV+JhHvi9ct5D14KeL7ixg = X-Google-Smtp-Source: AGHT+IHWpCKOa7sbFBLFaGJE1A5RBk0DSbVYrOt8AMWJxXArrmcuL5P2TejXK/XgEvD/BitgWYOy5A== X-Received: by 2002:a9d:6299:0:b0:6dc:5d73:d744 with SMTP id x25-20020a9d6299000000b006dc5d73d744mr1077023otk.23.1707172339026; Mon, 05 Feb 2024 14:32:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUwoWma2G7eCPfTznX+nH6IeLlb9TTys8YodM+84MMJDvmLdQRR3gkgX8G5JrXYp1HrlTeGog+nro5aehlh3QCq50PqAEfdGP9kTnDZhOGPREDj/Vc1MHA/4USrKtghTlsp+oRa4kZ62YeT3hrqDL/Rez8HmySRDMrQ6HgOOzvMi2B966I7IbBq5+/KDjeps487bjpWSe1HyyEtJU0rF2V9e5U= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:18 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 03/13] bnxt_en: Support ethtool -n to display ether filters. Date: Mon, 5 Feb 2024 14:31:52 -0800 Message-Id: <20240205223202.25341-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 Implement ETHTOOL_GRXCLSRULE for the user defined ether filters. Use the common functions to walk the L2 filter hash table. Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 3cc3504181c7..da298f4512b5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5484,6 +5484,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, if (bit_id < 0) return -ENOMEM; fltr->base.sw_id = (u16)bit_id; + bp->ntp_fltr_count++; } head = &bp->l2_fltr_hash_tbl[idx]; hlist_add_head_rcu(&fltr->base.hash, head); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 2d8e847e8fdd..4d4dd2b231b8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1058,11 +1058,17 @@ static struct bnxt_filter_base *bnxt_get_one_fltr_rcu(struct bnxt *bp, static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd, u32 *rule_locs) { + u32 count; + cmd->data = bp->ntp_fltr_count; rcu_read_lock(); + count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, rule_locs, 0, + cmd->rule_cnt); cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, - rule_locs, 0, cmd->rule_cnt); + rule_locs, count, + cmd->rule_cnt); rcu_read_unlock(); return 0; @@ -1081,6 +1087,36 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) return rc; rcu_read_lock(); + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, + fs->location); + if (fltr_base) { + struct ethhdr *h_ether = &fs->h_u.ether_spec; + struct ethhdr *m_ether = &fs->m_u.ether_spec; + struct bnxt_l2_filter *l2_fltr; + struct bnxt_l2_key *l2_key; + + l2_fltr = container_of(fltr_base, struct bnxt_l2_filter, base); + l2_key = &l2_fltr->l2_key; + fs->flow_type = ETHER_FLOW; + ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); + eth_broadcast_addr(m_ether->h_dest); + if (l2_key->vlan) { + struct ethtool_flow_ext *m_ext = &fs->m_ext; + struct ethtool_flow_ext *h_ext = &fs->h_ext; + + fs->flow_type |= FLOW_EXT; + m_ext->vlan_tci = htons(0xfff); + h_ext->vlan_tci = htons(l2_key->vlan); + } + if (fltr_base->flags & BNXT_ACT_RING_DST) + fs->ring_cookie = fltr_base->rxq; + if (fltr_base->flags & BNXT_ACT_FUNC_DST) + fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << + ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; + rcu_read_unlock(); + return 0; + } fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, fs->location); From patchwork Mon Feb 5 22:31:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546346 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.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 CDED817EF for ; Mon, 5 Feb 2024 22:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172343; cv=none; b=ABTN4cAcwMJw6mT9l0v2zwjKTn/e0HlurqLF79TD+nnu5ASPPZBzphu1lJ3RdjyMECL4uZdO3q4VTeQGwL5yi5sKGWPDS4SEskBauNUBWUJ8lf3cF9IhvrbF45FdafL6hxBIVgn//FX46sxk/Xr4I3tcg/y+AhXhdlqCC66LeR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172343; c=relaxed/simple; bh=WKra8p2fqYMlqtLSZoUFOtSyguXv13pjw2NH64rtT4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=J410gcNhaLXFz1n5log69lwaczJEMkLQClFtq2Z99mS4tjJTr9MdpLQQOjfgMCBrMyeIMqsGhaMb5gM8Ollz3aThjJ/rlWFtZa1vWw0cu2J4AKM0Hxc6tmZwSXXw9Y6xnhm7DeGbLphEQPXatfxt0Aj6JOJzjt3plOqAb9cUsFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=QhI8R56+; arc=none smtp.client-ip=209.85.210.44 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="QhI8R56+" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e1352dd653so3216164a34.2 for ; Mon, 05 Feb 2024 14:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172341; x=1707777141; 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=Uw4RFxhrxsRKs5AE2lrmv9T0z4jNi03EtnU+f4LrWOk=; b=QhI8R56+2WoYzAOtiEyf6wpTZkmIUkAtZtfOGKf5DbFJr01c1eS1LB5WoE+EkTmQcg o/NHe5Svv9Z131JNE/gz/6FdGnIAVc5QYSkygIjcOt1fJdgRhvIKJMiWdyvf/YltHNIo Q5mSk+ifspnBINHJ42AEvJcCrSrs32QbV7Z8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172341; x=1707777141; 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=Uw4RFxhrxsRKs5AE2lrmv9T0z4jNi03EtnU+f4LrWOk=; b=Mhr/cesScLZN+n/g5AonjxgSXE8NYxAqqJMPnDFYqzRNJRYNoSLt4A+t+qWgPt/R6l IUQTBg5J7Qzz/xt4L3/faHi0Ltj+0JVzx/VqTA724h3Jzl3DtN359Fwe7CXJn7UYry4g V2TPKZ0L42lUGpTazcbgHV5L7oyYStu+0puRgwRo9ay4rCU0gZxU6l7hr+gTvegmeIEn 0tBjpruLAXBmsD1TqqHJ5PUVwboNTY77+Q6NqN8k0xD/Wy2RpZqjeVqCiZv/ShWK+z3C eqKZi8OcMwH+UmIOWRKFcwJWefAjz4cYeb5Hs6RTrZ2g0z1vwrl2XIGt09oB1M9A12y9 ja+g== X-Gm-Message-State: AOJu0YyTeU+CWijTdK8k+x7G25Xkw51krPYD2brmbblmHC6noMd4ucsB ZjFx+HtoEi5GC7iYHGk0ACJojvig5Y5JsZXvB/N+1GnA56NzMU5wtIuUwxoCVg== X-Google-Smtp-Source: AGHT+IG9Upm+WQgNuq5FktZF9JERt4HIoEOKnrielwU4FWACtOVpIp4hGBWf8R33hjsY3Pj0Y3wc3A== X-Received: by 2002:a05:6830:2011:b0:6e1:1492:3653 with SMTP id e17-20020a056830201100b006e114923653mr1075324otp.5.1707172340663; Mon, 05 Feb 2024 14:32:20 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWjoiagjpiFRvza9zItAeAWRfzCrVhBzy+Vnf/vTBrTDhy68Nlac1n9hCTHnCOoYz2TnVXDOdp8u5wNWqC9eqzrWuieiYf0KWcy2SKI9tkHbapTc2UV6bgx6UZWuI1m3rEksCjVlJ6odxBLYIAbshmo0rc4u0cjUn7eUisAc4JtNiDQOrKiTwqoJKgCmyYtgEGIPZ8JRGu7ZQfcv7BHLi9I8CfdrMVgTmB2EZoq+sLfW7rd2AOm6JfEhIG2 Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:20 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com, Edwin Peer Subject: [PATCH net-next 04/13] bnxt_en: implement fully specified 5-tuple masks Date: Mon, 5 Feb 2024 14:31:53 -0800 Message-Id: <20240205223202.25341-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Edwin Peer Support subfield masking for IP addresses and ports. Previously, only entire fields could be included or excluded in NTUPLE filters. Reviewed-by: Pavan Chebbi Signed-off-by: Edwin Peer Signed-off-by: Michael Chan Reviewed-by: Michal Swiatkowski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 141 ++++++++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 19 +-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 142 +++++------------- 3 files changed, 134 insertions(+), 168 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index da298f4512b5..dc54cc0ab075 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -246,6 +246,49 @@ static const u16 bnxt_async_events_arr[] = { static struct workqueue_struct *bnxt_pf_wq; +#define BNXT_IPV6_MASK_ALL {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} +#define BNXT_IPV6_MASK_NONE {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} + +const struct bnxt_flow_masks BNXT_FLOW_MASK_NONE = { + .ports = { + .src = 0, + .dst = 0, + }, + .addrs = { + .v6addrs = { + .src = BNXT_IPV6_MASK_NONE, + .dst = BNXT_IPV6_MASK_NONE, + }, + }, +}; + +const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL = { + .ports = { + .src = cpu_to_be16(0xffff), + .dst = cpu_to_be16(0xffff), + }, + .addrs = { + .v6addrs = { + .src = BNXT_IPV6_MASK_ALL, + .dst = BNXT_IPV6_MASK_ALL, + }, + }, +}; + +const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL = { + .ports = { + .src = cpu_to_be16(0xffff), + .dst = cpu_to_be16(0xffff), + }, + .addrs = { + .v4addrs = { + .src = cpu_to_be32(0xffffffff), + .dst = cpu_to_be32(0xffffffff), + }, + }, +}; + static bool bnxt_vf_pciid(enum board_idx idx) { return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF || @@ -5690,6 +5733,7 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, { struct hwrm_cfa_ntuple_filter_alloc_output *resp; struct hwrm_cfa_ntuple_filter_alloc_input *req; + struct bnxt_flow_masks *masks = &fltr->fmasks; struct flow_keys *keys = &fltr->fkeys; struct bnxt_l2_filter *l2_fltr; struct bnxt_vnic_info *vnic; @@ -5722,25 +5766,15 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, req->ethertype = htons(ETH_P_IPV6); req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV6; - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) { - *(struct in6_addr *)&req->src_ipaddr[0] = - keys->addrs.v6addrs.src; - bnxt_fill_ipv6_mask(req->src_ipaddr_mask); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) { - *(struct in6_addr *)&req->dst_ipaddr[0] = - keys->addrs.v6addrs.dst; - bnxt_fill_ipv6_mask(req->dst_ipaddr_mask); - } + *(struct in6_addr *)&req->src_ipaddr[0] = keys->addrs.v6addrs.src; + *(struct in6_addr *)&req->src_ipaddr_mask[0] = masks->addrs.v6addrs.src; + *(struct in6_addr *)&req->dst_ipaddr[0] = keys->addrs.v6addrs.dst; + *(struct in6_addr *)&req->dst_ipaddr_mask[0] = masks->addrs.v6addrs.dst; } else { - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) { - req->src_ipaddr[0] = keys->addrs.v4addrs.src; - req->src_ipaddr_mask[0] = cpu_to_be32(0xffffffff); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) { - req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; - req->dst_ipaddr_mask[0] = cpu_to_be32(0xffffffff); - } + req->src_ipaddr[0] = keys->addrs.v4addrs.src; + req->src_ipaddr_mask[0] = masks->addrs.v4addrs.src; + req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; + req->dst_ipaddr_mask[0] = masks->addrs.v4addrs.dst; } if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); @@ -5748,14 +5782,10 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_ANYTUNNEL; } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_PORT) { - req->src_port = keys->ports.src; - req->src_port_mask = cpu_to_be16(0xffff); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_PORT) { - req->dst_port = keys->ports.dst; - req->dst_port_mask = cpu_to_be16(0xffff); - } + req->src_port = keys->ports.src; + req->src_port_mask = masks->ports.src; + req->dst_port = keys->ports.dst; + req->dst_port_mask = masks->ports.dst; resp = hwrm_req_hold(bp, req); rc = hwrm_req_send(bp, req); @@ -13955,45 +13985,39 @@ int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr, static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1, struct bnxt_ntuple_filter *f2) { + struct bnxt_flow_masks *masks1 = &f1->fmasks; + struct bnxt_flow_masks *masks2 = &f2->fmasks; struct flow_keys *keys1 = &f1->fkeys; struct flow_keys *keys2 = &f2->fkeys; - if (f1->ntuple_flags != f2->ntuple_flags) - return false; - if (keys1->basic.n_proto != keys2->basic.n_proto || keys1->basic.ip_proto != keys2->basic.ip_proto) return false; if (keys1->basic.n_proto == htons(ETH_P_IP)) { - if (((f1->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) && - keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src) || - ((f1->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) && - keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst)) + if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || + masks1->addrs.v4addrs.src != masks2->addrs.v4addrs.src || + keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst || + masks1->addrs.v4addrs.dst != masks2->addrs.v4addrs.dst) return false; } else { - if (((f1->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) && - memcmp(&keys1->addrs.v6addrs.src, - &keys2->addrs.v6addrs.src, - sizeof(keys1->addrs.v6addrs.src))) || - ((f1->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) && - memcmp(&keys1->addrs.v6addrs.dst, - &keys2->addrs.v6addrs.dst, - sizeof(keys1->addrs.v6addrs.dst)))) + if (!ipv6_addr_equal(&keys1->addrs.v6addrs.src, + &keys2->addrs.v6addrs.src) || + !ipv6_addr_equal(&masks1->addrs.v6addrs.src, + &masks2->addrs.v6addrs.src) || + !ipv6_addr_equal(&keys1->addrs.v6addrs.dst, + &keys2->addrs.v6addrs.dst) || + !ipv6_addr_equal(&masks1->addrs.v6addrs.dst, + &masks2->addrs.v6addrs.dst)) return false; } - if (((f1->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_PORT) && - keys1->ports.src != keys2->ports.src) || - ((f1->ntuple_flags & BNXT_NTUPLE_MATCH_DST_PORT) && - keys1->ports.dst != keys2->ports.dst)) - return false; - - if (keys1->control.flags == keys2->control.flags && - f1->l2_fltr == f2->l2_fltr) - return true; - - return false; + return keys1->ports.src == keys2->ports.src && + masks1->ports.src == masks2->ports.src && + keys1->ports.dst == keys2->ports.dst && + masks1->ports.dst == masks2->ports.dst && + keys1->control.flags == keys2->control.flags && + f1->l2_fltr == f2->l2_fltr; } struct bnxt_ntuple_filter * @@ -14058,10 +14082,13 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, rc = -EPROTONOSUPPORT; goto err_free; } - if (fkeys->basic.n_proto == htons(ETH_P_IPV6) && - bp->hwrm_spec_code < 0x10601) { - rc = -EPROTONOSUPPORT; - goto err_free; + new_fltr->fmasks = BNXT_FLOW_IPV4_MASK_ALL; + if (fkeys->basic.n_proto == htons(ETH_P_IPV6)) { + if (bp->hwrm_spec_code < 0x10601) { + rc = -EPROTONOSUPPORT; + goto err_free; + } + new_fltr->fmasks = BNXT_FLOW_IPV6_MASK_ALL; } flags = fkeys->control.flags; if (((flags & FLOW_DIS_ENCAPSULATION) && @@ -14069,9 +14096,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, rc = -EPROTONOSUPPORT; goto err_free; } - new_fltr->l2_fltr = l2_fltr; - new_fltr->ntuple_flags = BNXT_NTUPLE_MATCH_ALL; idx = bnxt_get_ntp_filter_idx(bp, fkeys, skb); rcu_read_lock(); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 21721b8748bc..aae180fa63b7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1355,19 +1355,20 @@ struct bnxt_filter_base { struct rcu_head rcu; }; +struct bnxt_flow_masks { + struct flow_dissector_key_ports ports; + struct flow_dissector_key_addrs addrs; +}; + +extern const struct bnxt_flow_masks BNXT_FLOW_MASK_NONE; +extern const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL; +extern const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL; + struct bnxt_ntuple_filter { struct bnxt_filter_base base; struct flow_keys fkeys; + struct bnxt_flow_masks fmasks; struct bnxt_l2_filter *l2_fltr; - u32 ntuple_flags; -#define BNXT_NTUPLE_MATCH_SRC_IP 1 -#define BNXT_NTUPLE_MATCH_DST_IP 2 -#define BNXT_NTUPLE_MATCH_SRC_PORT 4 -#define BNXT_NTUPLE_MATCH_DST_PORT 8 -#define BNXT_NTUPLE_MATCH_ALL (BNXT_NTUPLE_MATCH_SRC_IP | \ - BNXT_NTUPLE_MATCH_DST_IP | \ - BNXT_NTUPLE_MATCH_SRC_PORT | \ - BNXT_NTUPLE_MATCH_DST_PORT) u32 flow_id; }; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 4d4dd2b231b8..b3fd32ff963a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1080,6 +1080,7 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) (struct ethtool_rx_flow_spec *)&cmd->fs; struct bnxt_filter_base *fltr_base; struct bnxt_ntuple_filter *fltr; + struct bnxt_flow_masks *fmasks; struct flow_keys *fkeys; int rc = -EINVAL; @@ -1127,6 +1128,7 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base); fkeys = &fltr->fkeys; + fmasks = &fltr->fmasks; if (fkeys->basic.n_proto == htons(ETH_P_IP)) { if (fkeys->basic.ip_proto == IPPROTO_TCP) fs->flow_type = TCP_V4_FLOW; @@ -1135,22 +1137,14 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) else goto fltr_err; - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) { - fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; - fs->m_u.tcp_ip4_spec.ip4src = cpu_to_be32(~0); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) { - fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; - fs->m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(~0); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_PORT) { - fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; - fs->m_u.tcp_ip4_spec.psrc = cpu_to_be16(~0); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_PORT) { - fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; - fs->m_u.tcp_ip4_spec.pdst = cpu_to_be16(~0); - } + fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; + fs->m_u.tcp_ip4_spec.ip4src = fmasks->addrs.v4addrs.src; + fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; + fs->m_u.tcp_ip4_spec.ip4dst = fmasks->addrs.v4addrs.dst; + fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; + fs->m_u.tcp_ip4_spec.psrc = fmasks->ports.src; + fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; + fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst; } else { if (fkeys->basic.ip_proto == IPPROTO_TCP) fs->flow_type = TCP_V6_FLOW; @@ -1159,24 +1153,18 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) else goto fltr_err; - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_IP) { - *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = - fkeys->addrs.v6addrs.src; - bnxt_fill_ipv6_mask(fs->m_u.tcp_ip6_spec.ip6src); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_IP) { - *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6dst[0] = - fkeys->addrs.v6addrs.dst; - bnxt_fill_ipv6_mask(fs->m_u.tcp_ip6_spec.ip6dst); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_SRC_PORT) { - fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; - fs->m_u.tcp_ip6_spec.psrc = cpu_to_be16(~0); - } - if (fltr->ntuple_flags & BNXT_NTUPLE_MATCH_DST_PORT) { - fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; - fs->m_u.tcp_ip6_spec.pdst = cpu_to_be16(~0); - } + *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = + fkeys->addrs.v6addrs.src; + *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6src[0] = + fmasks->addrs.v6addrs.src; + *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6dst[0] = + fkeys->addrs.v6addrs.dst; + *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6dst[0] = + fmasks->addrs.v6addrs.dst; + fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; + fs->m_u.tcp_ip6_spec.psrc = fmasks->ports.src; + fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; + fs->m_u.tcp_ip6_spec.pdst = fmasks->ports.dst; } fs->ring_cookie = fltr->base.rxq; @@ -1240,19 +1228,6 @@ static int bnxt_add_l2_cls_rule(struct bnxt *bp, return rc; } -#define IPV4_ALL_MASK ((__force __be32)~0) -#define L4_PORT_ALL_MASK ((__force __be16)~0) - -static bool ipv6_mask_is_full(__be32 mask[4]) -{ - return (mask[0] & mask[1] & mask[2] & mask[3]) == IPV4_ALL_MASK; -} - -static bool ipv6_mask_is_zero(__be32 mask[4]) -{ - return !(mask[0] | mask[1] | mask[2] | mask[3]); -} - static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, struct ethtool_rx_flow_spec *fs) { @@ -1260,6 +1235,7 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, u32 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); struct bnxt_ntuple_filter *new_fltr, *fltr; struct bnxt_l2_filter *l2_fltr; + struct bnxt_flow_masks *fmasks; u32 flow_type = fs->flow_type; struct flow_keys *fkeys; u32 idx; @@ -1278,6 +1254,7 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, l2_fltr = bp->vnic_info[0].l2_filters[0]; atomic_inc(&l2_fltr->refcnt); new_fltr->l2_fltr = l2_fltr; + fmasks = &new_fltr->fmasks; fkeys = &new_fltr->fkeys; rc = -EOPNOTSUPP; @@ -1291,32 +1268,14 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, if (flow_type == UDP_V4_FLOW) fkeys->basic.ip_proto = IPPROTO_UDP; fkeys->basic.n_proto = htons(ETH_P_IP); - - if (ip_mask->ip4src == IPV4_ALL_MASK) { - fkeys->addrs.v4addrs.src = ip_spec->ip4src; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_SRC_IP; - } else if (ip_mask->ip4src) { - goto ntuple_err; - } - if (ip_mask->ip4dst == IPV4_ALL_MASK) { - fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_DST_IP; - } else if (ip_mask->ip4dst) { - goto ntuple_err; - } - - if (ip_mask->psrc == L4_PORT_ALL_MASK) { - fkeys->ports.src = ip_spec->psrc; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_SRC_PORT; - } else if (ip_mask->psrc) { - goto ntuple_err; - } - if (ip_mask->pdst == L4_PORT_ALL_MASK) { - fkeys->ports.dst = ip_spec->pdst; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_DST_PORT; - } else if (ip_mask->pdst) { - goto ntuple_err; - } + fkeys->addrs.v4addrs.src = ip_spec->ip4src; + fmasks->addrs.v4addrs.src = ip_mask->ip4src; + fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; + fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; + fkeys->ports.src = ip_spec->psrc; + fmasks->ports.src = ip_mask->psrc; + fkeys->ports.dst = ip_spec->pdst; + fmasks->ports.dst = ip_mask->pdst; break; } case TCP_V6_FLOW: @@ -1329,40 +1288,21 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, fkeys->basic.ip_proto = IPPROTO_UDP; fkeys->basic.n_proto = htons(ETH_P_IPV6); - if (ipv6_mask_is_full(ip_mask->ip6src)) { - fkeys->addrs.v6addrs.src = - *(struct in6_addr *)&ip_spec->ip6src; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_SRC_IP; - } else if (!ipv6_mask_is_zero(ip_mask->ip6src)) { - goto ntuple_err; - } - if (ipv6_mask_is_full(ip_mask->ip6dst)) { - fkeys->addrs.v6addrs.dst = - *(struct in6_addr *)&ip_spec->ip6dst; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_DST_IP; - } else if (!ipv6_mask_is_zero(ip_mask->ip6dst)) { - goto ntuple_err; - } - - if (ip_mask->psrc == L4_PORT_ALL_MASK) { - fkeys->ports.src = ip_spec->psrc; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_SRC_PORT; - } else if (ip_mask->psrc) { - goto ntuple_err; - } - if (ip_mask->pdst == L4_PORT_ALL_MASK) { - fkeys->ports.dst = ip_spec->pdst; - new_fltr->ntuple_flags |= BNXT_NTUPLE_MATCH_DST_PORT; - } else if (ip_mask->pdst) { - goto ntuple_err; - } + fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; + fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; + fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; + fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; + fkeys->ports.src = ip_spec->psrc; + fmasks->ports.src = ip_mask->psrc; + fkeys->ports.dst = ip_spec->pdst; + fmasks->ports.dst = ip_mask->pdst; break; } default: rc = -EOPNOTSUPP; goto ntuple_err; } - if (!new_fltr->ntuple_flags) + if (!memcmp(&BNXT_FLOW_MASK_NONE, fmasks, sizeof(*fmasks))) goto ntuple_err; idx = bnxt_get_ntp_filter_idx(bp, fkeys, NULL); From patchwork Mon Feb 5 22:31:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546347 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 DD86417552 for ; Mon, 5 Feb 2024 22:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172345; cv=none; b=aB/0kxpsUy+Jypu9Hk11jVlbD3asjvlQmaCVnNvRWNqAATYZj947C9pQg0kX9hYDiL7TBiwNrZUJAlWfEk+9/D07cSHL/HTLjNaHr98lW3n3mjjGI7S3r8sfK3OYABRNasi44cOOID8ejZl8FIAmLwG5uSjaaz8DVrwF0VIpijk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172345; c=relaxed/simple; bh=tJZXnu/qRp5nLcD+RRWVPilcbS3jRneUVt2SJd6Jnew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qBuFHittNWdoUYCUcjdK5LjcCpYCJiUdGGfADeg40HQag9W2uVRD+GGJhLqRXKxHPBvgc1T9XNihtroIaswUWPYQssI0P7zoF3cXIhJjHIOSw3QrG6tz3Lcs7iAYc69A6Dyc5cHCdQXbsBNqRbRGOwJKbOe2Uy21BV7Di34cWo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=RcSqpxKC; arc=none smtp.client-ip=209.85.160.178 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="RcSqpxKC" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-42a4516ec46so35679971cf.0 for ; Mon, 05 Feb 2024 14:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172343; x=1707777143; 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=uxBXJjQne4Y0nPfa9UXE/uXKqXiOkLASCfuYgXm9WJA=; b=RcSqpxKC9QZ5+plVk4VKjiO1HzXQOJY1Hg+YJ4eC2DhzeuhBxBm/UVHEYy5hwfXgjs ju0C9Db2pnazfvLqIarSFTkHv8yifncnmnmrf7sMQh/e1KTmUfD0S3bhKlqj57qbISGD P9+V7EJSPNyojdfq5Q9Q4pQHtaRwxpMbppBMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172343; x=1707777143; 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=uxBXJjQne4Y0nPfa9UXE/uXKqXiOkLASCfuYgXm9WJA=; b=I9oFAblqz69YUUpnG1giBxTQVih+h2482UuSfZVfGQxTEBY0q0WIg+kpxZDRLSZcEx u571sDsoBdZYlBYlECnzBqoDbqa0Lwzwmetk3k5YMZtDSIwfCvPULiSoDNVIgjBF/w3B 1jvyCQrETZpNSDvA20HsDPvVL0SfaO21fM1LcA/BEOWKInR/bRgQQT+tUnwlOuoHOd79 BoKPxRYoeo1f7DbexPr77lEKdj5zNdOMPLiBtpVkp9IiK7qyQqtIsi4JMno9WByH4QCm mCrVudVMqv5gE60GSE+9fKrirnkb1x+mal61lat1Fj57a0t8C8Q4uLnsGEY1SNOGKm02 J06A== X-Gm-Message-State: AOJu0YzeBkziShvSLP0qRozNP8yP7658YLg6dHGiOpbbXi97DAcYWs/X 60uy6aEaqmsYQ73F1yWvq+vgwJ6rFtLZfiTR+z73ewcpoIFRL4blUFMLZDSBRA== X-Google-Smtp-Source: AGHT+IHFfSTLhh1SRBsXYY+RZ/yukSgwaeogM6CrpI9KT406tLe5QZEV+UajMYaeAv9WLwYiYFQ27Q== X-Received: by 2002:a05:622a:349:b0:42b:fac1:8141 with SMTP id r9-20020a05622a034900b0042bfac18141mr2057015qtw.7.1707172342547; Mon, 05 Feb 2024 14:32:22 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU6paz0aOO8jaCPJULjDo/v5VAm56gXa4plD+ySYGK6gxZsBCcBwwHc02ThjKs+mVM7ngnf6alUfURfPyZjHZnGX5t41BH4IzAypshX8r4J93Q8eF7n//GYoMVRMFaJ8wWp81d6MhOPA6o6271OjP5cggBoyGCoJyTA2XpOsN4LP5eC9EKrwwcVbX+s+Pu1c6cqDbMv4Bx8/G1v7yWuP73lqj2j5sBt9xApPh2MElr1qgrBqxquWvH8pLi6Kw== Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:21 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com, Vikas Gupta Subject: [PATCH net-next 05/13] bnxt_en: Enhance ethtool ntuple support for ip flows besides TCP/UDP Date: Mon, 5 Feb 2024 14:31:54 -0800 Message-Id: <20240205223202.25341-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Vikas Gupta Enable flow type ipv4/ipv6 1) for protocols ICMPV4 and ICMPV6. 2) for wildcard match. Wildcard matches to TCP/UDP/ICMP. Note that, IPPROTO_RAW(255) i.e. a reserved protocol considered for a wildcard. Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 + drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 124 +++++++++++++++--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.h | 2 + 4 files changed, 113 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index dc54cc0ab075..ea9c33e328cf 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -8891,6 +8891,10 @@ static int bnxt_hwrm_cfa_adv_flow_mgnt_qcaps(struct bnxt *bp) CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_RFS_RING_TBL_IDX_V2_SUPPORTED) bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; + if (flags & + CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_RX_EXT_IP_PROTO_SUPPORTED) + bp->fw_cap |= BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO; + hwrm_cfa_adv_qcaps_exit: hwrm_req_drop(bp, req); return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index aae180fa63b7..16f18c70c7bb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2302,6 +2302,7 @@ struct bnxt { #define BNXT_FW_CAP_PRE_RESV_VNICS BIT_ULL(35) #define BNXT_FW_CAP_BACKING_STORE_V2 BIT_ULL(36) #define BNXT_FW_CAP_VNIC_TUNNEL_TPA BIT_ULL(37) + #define BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO BIT_ULL(38) u32 fw_dbg_cap; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index b3fd32ff963a..b6bc14b5d1bb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1130,28 +1130,50 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) fkeys = &fltr->fkeys; fmasks = &fltr->fmasks; if (fkeys->basic.n_proto == htons(ETH_P_IP)) { - if (fkeys->basic.ip_proto == IPPROTO_TCP) + if (fkeys->basic.ip_proto == IPPROTO_ICMP || + fkeys->basic.ip_proto == IPPROTO_RAW) { + fs->flow_type = IP_USER_FLOW; + fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; + if (fkeys->basic.ip_proto == IPPROTO_ICMP) + fs->h_u.usr_ip4_spec.proto = IPPROTO_ICMP; + else + fs->h_u.usr_ip4_spec.proto = IPPROTO_RAW; + fs->m_u.usr_ip4_spec.proto = BNXT_IP_PROTO_FULL_MASK; + } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { fs->flow_type = TCP_V4_FLOW; - else if (fkeys->basic.ip_proto == IPPROTO_UDP) + } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { fs->flow_type = UDP_V4_FLOW; - else + } else { goto fltr_err; + } fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; fs->m_u.tcp_ip4_spec.ip4src = fmasks->addrs.v4addrs.src; fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; fs->m_u.tcp_ip4_spec.ip4dst = fmasks->addrs.v4addrs.dst; - fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; - fs->m_u.tcp_ip4_spec.psrc = fmasks->ports.src; - fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; - fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst; + if (fs->flow_type == TCP_V4_FLOW || + fs->flow_type == UDP_V4_FLOW) { + fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; + fs->m_u.tcp_ip4_spec.psrc = fmasks->ports.src; + fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; + fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst; + } } else { - if (fkeys->basic.ip_proto == IPPROTO_TCP) + if (fkeys->basic.ip_proto == IPPROTO_ICMPV6 || + fkeys->basic.ip_proto == IPPROTO_RAW) { + fs->flow_type = IPV6_USER_FLOW; + if (fkeys->basic.ip_proto == IPPROTO_ICMPV6) + fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_ICMPV6; + else + fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_RAW; + fs->m_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_FULL_MASK; + } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { fs->flow_type = TCP_V6_FLOW; - else if (fkeys->basic.ip_proto == IPPROTO_UDP) + } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { fs->flow_type = UDP_V6_FLOW; - else + } else { goto fltr_err; + } *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = fkeys->addrs.v6addrs.src; @@ -1161,10 +1183,13 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) fkeys->addrs.v6addrs.dst; *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6dst[0] = fmasks->addrs.v6addrs.dst; - fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; - fs->m_u.tcp_ip6_spec.psrc = fmasks->ports.src; - fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; - fs->m_u.tcp_ip6_spec.pdst = fmasks->ports.dst; + if (fs->flow_type == TCP_V6_FLOW || + fs->flow_type == UDP_V6_FLOW) { + fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; + fs->m_u.tcp_ip6_spec.psrc = fmasks->ports.src; + fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; + fs->m_u.tcp_ip6_spec.pdst = fmasks->ports.dst; + } } fs->ring_cookie = fltr->base.rxq; @@ -1228,6 +1253,28 @@ static int bnxt_add_l2_cls_rule(struct bnxt *bp, return rc; } +static bool bnxt_verify_ntuple_ip4_flow(struct ethtool_usrip4_spec *ip_spec, + struct ethtool_usrip4_spec *ip_mask) +{ + if (ip_mask->l4_4_bytes || ip_mask->tos || + ip_spec->ip_ver != ETH_RX_NFC_IP4 || + ip_mask->proto != BNXT_IP_PROTO_FULL_MASK || + (ip_spec->proto != IPPROTO_RAW && ip_spec->proto != IPPROTO_ICMP)) + return false; + return true; +} + +static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec, + struct ethtool_usrip6_spec *ip_mask) +{ + if (ip_mask->l4_4_bytes || ip_mask->tclass || + ip_mask->l4_proto != BNXT_IP_PROTO_FULL_MASK || + (ip_spec->l4_proto != IPPROTO_RAW && + ip_spec->l4_proto != IPPROTO_ICMPV6)) + return false; + return true; +} + static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, struct ethtool_rx_flow_spec *fs) { @@ -1247,6 +1294,18 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, if ((flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf) return -EOPNOTSUPP; + if (flow_type == IP_USER_FLOW) { + if (!bnxt_verify_ntuple_ip4_flow(&fs->h_u.usr_ip4_spec, + &fs->m_u.usr_ip4_spec)) + return -EOPNOTSUPP; + } + + if (flow_type == IPV6_USER_FLOW) { + if (!bnxt_verify_ntuple_ip6_flow(&fs->h_u.usr_ip6_spec, + &fs->m_u.usr_ip6_spec)) + return -EOPNOTSUPP; + } + new_fltr = kzalloc(sizeof(*new_fltr), GFP_KERNEL); if (!new_fltr) return -ENOMEM; @@ -1259,6 +1318,18 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, rc = -EOPNOTSUPP; switch (flow_type) { + case IP_USER_FLOW: { + struct ethtool_usrip4_spec *ip_spec = &fs->h_u.usr_ip4_spec; + struct ethtool_usrip4_spec *ip_mask = &fs->m_u.usr_ip4_spec; + + fkeys->basic.ip_proto = ip_spec->proto; + fkeys->basic.n_proto = htons(ETH_P_IP); + fkeys->addrs.v4addrs.src = ip_spec->ip4src; + fmasks->addrs.v4addrs.src = ip_mask->ip4src; + fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; + fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; + break; + } case TCP_V4_FLOW: case UDP_V4_FLOW: { struct ethtool_tcpip4_spec *ip_spec = &fs->h_u.tcp_ip4_spec; @@ -1278,6 +1349,18 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, fmasks->ports.dst = ip_mask->pdst; break; } + case IPV6_USER_FLOW: { + struct ethtool_usrip6_spec *ip_spec = &fs->h_u.usr_ip6_spec; + struct ethtool_usrip6_spec *ip_mask = &fs->m_u.usr_ip6_spec; + + fkeys->basic.ip_proto = ip_spec->l4_proto; + fkeys->basic.n_proto = htons(ETH_P_IPV6); + fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; + fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; + fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; + fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; + break; + } case TCP_V6_FLOW: case UDP_V6_FLOW: { struct ethtool_tcpip6_spec *ip_spec = &fs->h_u.tcp_ip6_spec; @@ -1349,6 +1432,15 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd) if (fs->location != RX_CLS_LOC_ANY) return -EINVAL; + flow_type = fs->flow_type; + if ((flow_type == IP_USER_FLOW || + flow_type == IPV6_USER_FLOW) && + !(bp->fw_cap & BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO)) + return -EOPNOTSUPP; + if (flow_type & (FLOW_MAC_EXT | FLOW_RSS)) + return -EINVAL; + flow_type &= ~FLOW_EXT; + ring = ethtool_get_flow_spec_ring(fs->ring_cookie); vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); if (BNXT_VF(bp) && vf) @@ -1358,10 +1450,6 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd) if (!vf && ring >= bp->rx_nr_rings) return -EINVAL; - flow_type = fs->flow_type; - if (flow_type & (FLOW_MAC_EXT | FLOW_RSS)) - return -EINVAL; - flow_type &= ~FLOW_EXT; if (flow_type == ETHER_FLOW) rc = bnxt_add_l2_cls_rule(bp, fs); else diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h index a8ecef8ab82c..f9e36ac80c40 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h @@ -43,6 +43,8 @@ struct bnxt_led_cfg { #define BNXT_PXP_REG_LEN 0x3110 +#define BNXT_IP_PROTO_FULL_MASK 0xFF + extern const struct ethtool_ops bnxt_ethtool_ops; u32 bnxt_get_rxfh_indir_size(struct net_device *dev); From patchwork Mon Feb 5 22:31:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546348 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 4978D487A5 for ; Mon, 5 Feb 2024 22:32:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172346; cv=none; b=D+I707m7Ll2Ll3WWTKQDCDlc3Jh5X/RI1Nc/XT+IvzSeCnSfo6LxKqoKgENkSdMYdphttseiAi7GKbdg3A6193y65KVlMy6Vvs6Pp/N2J60xZ7i3PqT5KJiO1cxqB9nskYhM9baQbwKx9UBulP+t83aFUDCQ0PpStQdvksh6Lv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172346; c=relaxed/simple; bh=+IVAGghXC7MDXjB3JRyq6K7+RKDv7KlY4g+ID0BAVrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MTmmhcuPBfCgOc3vU6Q844f1eDnnyXYDySkjIjTyfDGKH9oPDenF3bqLC+39ekvZdfYk+7BIvlWQlo2iG2q1KAN7nj4QXHasbj2ydITllV/9FLwQBA2QdNDrUjujfUhZGse1C3tOL3eZ+EbOzndcBgNUVh0ycJC0sfJJd4/33Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Q79EjVOF; arc=none smtp.client-ip=209.85.210.41 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="Q79EjVOF" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6e12b58a3beso100781a34.1 for ; Mon, 05 Feb 2024 14:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172344; x=1707777144; 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=gbPvw9NEMjt40TQEUkS4b8CFQKhnAMhrkFnx4+gMy38=; b=Q79EjVOF4PVkGS+Fxd/g/q1G1P/rrB90cHoIMq6Aflw9j6LYgc6rAyhY2BBhX3c8ne hjbHgbEuje2KKs83j4fcAX56GZ+OitH07btFfhH+mX+HoSchhYogUirb0RE+gSO/ds4l tPnE5jUfE/FVlCbF+jkeR2dy2vua8YknsJXYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172344; x=1707777144; 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=gbPvw9NEMjt40TQEUkS4b8CFQKhnAMhrkFnx4+gMy38=; b=OZ6fdepoj9wo33oFkhGNqoMYjWXR1FQBLwINYRYMjptiyTjWd8ET4g3T6WIbp1eONj DWtlMQNx2RvOCOGre5+2jepJuCF3eAd8wqCInaZcGTi2o3zm04VTfz6rEbtNJHqwBsLv sAL1M9Pf/hzlYIu0Sd5N2NAIU3mSUB6PyZteXComOTticvyQgk4C1CpJw76+jeJHpnF1 TRPGF29XnFnNHs4H3BSwhSkVh8ejbboWH2jcvoXDgxc7RHBfLo0gG5ut+ZmbWqewhSYo ALWgOzzcKNwuu5PIJhS1LzbkAXhwcjHlRf7fsR4Rn1HNRnI4OFPGIeMgtQrcJtdKrVu/ d1Aw== X-Gm-Message-State: AOJu0Yz2/jbvsTCLlLx747EAj/ycG9boV273/Z5b+GJV8eMdCjMUlQfY fVKq/sUeQcCYswylSMnqSCEsU5DhiGGMWYB4QFQGs5qYetEUU67uPUTpsTO71Q== X-Google-Smtp-Source: AGHT+IFiTFezWmwgR07k6zz1TVfWr9+veXWPpDd/aTxi92MiS8lUdMjGHjqsUtmIFkp1L+Od4xPsdA== X-Received: by 2002:a05:6830:22f3:b0:6e2:7941:f62f with SMTP id t19-20020a05683022f300b006e27941f62fmr927769otc.31.1707172344210; Mon, 05 Feb 2024 14:32:24 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVtwb3z/Zee+xQ32Ck5WrLfR1yVxJAb6U8eM+fq8oFp5/22tLXuGp1u+0HzNMmw1HDh9+TdskXL56ASIj5c5MdQzQJkIBr4rcwgcKKxBQMF4zTxDialbTLEiQE0nw13PFmuLzZcPK+/g9Ve0O5fYBBflv4Fm8t0LPwEytVIC0rezr2HHkBTDtN6nyHE+BDoV8nU0T/hX5FBqlpO9yCeF3khtdNhIu7VFsEbyInhXOz/3l7mcYq/1af3qZHvdg== Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:23 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com, Vikas Gupta Subject: [PATCH net-next 06/13] bnxt_en: Add drop action support for ntuple Date: Mon, 5 Feb 2024 14:31:55 -0800 Message-Id: <20240205223202.25341-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Vikas Gupta Add drop action for protocols TCP/UDP/ICMP 1) Drop action for TCP/UDP is supported via flow type tcp4/udp4/tcp6/udp6. 2) Drop action for ICMPV4/ICMPV6/wildcard is supported via flow type ipv4/ipv6. Reviewed-by: Andy Gospodarek Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index ea9c33e328cf..382b4a559c9c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5747,8 +5747,9 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, l2_fltr = fltr->l2_fltr; req->l2_filter_id = l2_fltr->base.filter_id; - - if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { + if (fltr->base.flags & BNXT_ACT_DROP) { + flags = CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DROP; + } else if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { flags = CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DEST_RFS_RING_IDX; req->dst_id = cpu_to_le16(fltr->base.rxq); } else { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index b6bc14b5d1bb..6721c4a88453 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1192,7 +1192,10 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) } } - fs->ring_cookie = fltr->base.rxq; + if (fltr->base.flags & BNXT_ACT_DROP) + fs->ring_cookie = RX_CLS_FLOW_DISC; + else + fs->ring_cookie = fltr->base.rxq; rc = 0; fltr_err: @@ -1398,8 +1401,11 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp, } rcu_read_unlock(); - new_fltr->base.rxq = ring; new_fltr->base.flags = BNXT_ACT_NO_AGING; + if (fs->ring_cookie == RX_CLS_FLOW_DISC) + new_fltr->base.flags |= BNXT_ACT_DROP; + else + new_fltr->base.rxq = ring; __set_bit(BNXT_FLTR_VALID, &new_fltr->base.state); rc = bnxt_insert_ntp_filter(bp, new_fltr, idx); if (!rc) { @@ -1441,6 +1447,9 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd) return -EINVAL; flow_type &= ~FLOW_EXT; + if (fs->ring_cookie == RX_CLS_FLOW_DISC && flow_type != ETHER_FLOW) + return bnxt_add_ntuple_cls_rule(bp, fs); + ring = ethtool_get_flow_spec_ring(fs->ring_cookie); vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); if (BNXT_VF(bp) && vf) From patchwork Mon Feb 5 22:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546349 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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 91D2748CCF for ; Mon, 5 Feb 2024 22:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172349; cv=none; b=X/SQqN+ZbsuYzH/1uV5QcXhn0j7IYzfGcaz1Ls57/yboSPfUARVWpy8oYSKkQzcEET/LUAx9A1JUK6vViXyWBnMq/xAkNiT5YMhQPcjkmFPD6IgOQ6N6kG+c3PnUn4pPIE3IYezHoTUPPnsxTQI3L2tgIJ911g065VNGw/137hE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172349; c=relaxed/simple; bh=AB1bCTPf3UZDfPkZCqaa0Pp9gCGzt538ekc7sJ41Vzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MsT/MSAN5VtXRv2F/ekpXXY5vPu9f/+9f4htgYw2Y/8kzUjeupclw2cuuFjm6fL9QbE8fJlt1GUx7b1xgFK54+QbU67OiYZipZsBo3XwvlFm1aev/4DZIqLkhDi13f1k8N7P8nxGnEKVcbdI3MqDJVVBxaIGp9fBwGxaO39MqbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=f8W6d6IB; arc=none smtp.client-ip=209.85.160.175 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="f8W6d6IB" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-42c2591e7aaso11101001cf.0 for ; Mon, 05 Feb 2024 14:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172346; x=1707777146; 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=dN3r1Dcnc91l419zFgMLk79fNtTm5YA98Xwn1Qudldw=; b=f8W6d6IBcPz6OKvdm6hdBp3Wxo7zNp4u5WwG3oMfquuKoquWj2V0xeypA4W8P+ER8M Ovj1BbM7xo4cW25KP6Eld5XaSbKBGOTk5q0SfrwTYv5aXryigd34VVwZRkAssLmrd9tA 3fIVpwaoRXOww1QnVso8sY+Sd50t/k91bMKZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172346; x=1707777146; 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=dN3r1Dcnc91l419zFgMLk79fNtTm5YA98Xwn1Qudldw=; b=OBMYbcwLbcd+peBgtylsFkyY+cjh3FviucThTV7dbvp6grtQfkC75WWXOzmE6zfZE4 le8BiwRle53YBfb7tiN2lvp8/avgF9v7CVQPW6gI0PC6eWxF/ygY0quxaHgz8kHYZpiw Teq+JW+1ESoUQeZUvQZim2nJvz6TnElmC20fW58a9mIygiAEs8pczG6JUPz4OYWu0z9H E1XprFwUSAala7gQmR3HzePjd41DVti8tJBYWllVgN3GZkeyYOJaCK6pUHF1gPk3k38u nfkWiTYyKGzw2jsAnJSdiSTd6GzoYRTFwpgWQSfuWTzyyXeNNyLn5VyHTeX2p91zG9V3 q35Q== X-Gm-Message-State: AOJu0YxL9m3/1vha90GbHXz5rqAPcoz90Evg79QOMQIYpme3fvzdG98P ODaqqnHk6tUfI9sH1UV5I2K+U23EeN5UYXuw7yM0PryowBvb6FEgOW3GRarCjQ== X-Google-Smtp-Source: AGHT+IHR+VAY4O4r4YkZS8QGQGOhmCsebrUYxDEWtqSMw8tWFD/p9LLrV0cIo5x8cA7b9CRHu//mJg== X-Received: by 2002:ac8:4e86:0:b0:42a:995d:13d1 with SMTP id 6-20020ac84e86000000b0042a995d13d1mr777645qtp.43.1707172346320; Mon, 05 Feb 2024 14:32:26 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWXyYgxSd0vL0sPDyxFZQp+xTunIXq0lLfz1JzVARLbg6DCIiue7lL6xwro6pbwdE8eJdcJplZ/WldURkWvNS4e0svuGBbzO4gNjHx3eE615D7hetFJhSjkUoRUBTYaqBTfEIZcKIiojJUEeMIwMvRhBgB8zPURwqUMN4vljpxlImNVcN87g2JH3Y7ZnaQHNGhzc4J43VRv0wGbRx/KxTmkVe0= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:25 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 07/13] bnxt_en: Add separate function to delete the filter structure Date: Mon, 5 Feb 2024 14:31:56 -0800 Message-Id: <20240205223202.25341-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Since we are going to do filter deletion at multiple places in the upcoming patches, add a function that does the deletion. Future patches add more code into this function. Since we are passing the address of the filter base to free the entire filter structure, add a comment to make sure that the base is always at the beginning of the structure. Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++---------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 382b4a559c9c..d39de72bffea 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4841,6 +4841,16 @@ static void bnxt_clear_ring_indices(struct bnxt *bp) } } +static void bnxt_del_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) +{ + hlist_del(&fltr->hash); + if (fltr->flags) { + clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); + bp->ntp_fltr_count--; + } + kfree(fltr); +} + static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) { int i; @@ -4858,10 +4868,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) bnxt_del_l2_filter(bp, fltr->l2_fltr); if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) continue; - hlist_del(&fltr->base.hash); - clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); - bp->ntp_fltr_count--; - kfree(fltr); + bnxt_del_fltr(bp, &fltr->base); } } if (!all) @@ -4904,12 +4911,7 @@ static void bnxt_free_l2_filters(struct bnxt *bp, bool all) hlist_for_each_entry_safe(fltr, tmp, head, base.hash) { if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) continue; - hlist_del(&fltr->base.hash); - if (fltr->base.flags) { - clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); - bp->ntp_fltr_count--; - } - kfree(fltr); + bnxt_del_fltr(bp, &fltr->base); } } } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 16f18c70c7bb..d070e3ac9739 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1365,6 +1365,7 @@ extern const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL; extern const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL; struct bnxt_ntuple_filter { + /* base filter must be the first member */ struct bnxt_filter_base base; struct flow_keys fkeys; struct bnxt_flow_masks fmasks; @@ -1395,6 +1396,7 @@ struct bnxt_ipv6_tuple { #define BNXT_L2_KEY_SIZE (sizeof(struct bnxt_l2_key) / 4) struct bnxt_l2_filter { + /* base filter must be the first member */ struct bnxt_filter_base base; struct bnxt_l2_key l2_key; atomic_t refcnt; From patchwork Mon Feb 5 22:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546350 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 3583FBE66 for ; Mon, 5 Feb 2024 22:32:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172350; cv=none; b=XlYX3tCYLuK5VooSVXwdxxjMoa2fyQf8cH36ZTaXDuZF9nOJyypn7BUcSLSrZarAiGQFqcuE4rdVR/RUo3kcZf96Dx6n8BlLqn7LBkpS7ObYQCN4KHHzfXojQJwUsho35HDBiCJ5KJ+yO46P1u8+ryOyEz8OvWqNASApfG8GH1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172350; c=relaxed/simple; bh=cjauYpdUoG91mbBQY8DfeRAcWS0TyX2ffWuk/RiLnuY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HwXRSnVzL05ejS71JDORKP3ZyFPqZDjPy1W5bh/jrKSCCdzCBUQhKmLOwLDQm/Y97kLsibykd7gia1b7ckiThi/jplybCZQ50WQvfeXh04svLyDLbnA8NTJeABV2zz2U5SianmniY6Jkea098Ev7q7jsm9C9tjAYUe2YQ3LwcFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=NBgtxnyU; arc=none smtp.client-ip=209.85.167.180 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="NBgtxnyU" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3bba50cd318so4113860b6e.0 for ; Mon, 05 Feb 2024 14:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172348; x=1707777148; 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=oK4+kWXxklj9dqNQ/n9BQVndrHgiGL9o2jbYXxXYzuU=; b=NBgtxnyUsI0b2qE2Jjye4ecy/siBdAJssYWpdhV5uiZ1JJf+mwnP0Gi6kacJ/Gytd5 uRYOtn7XrOiNkcE7qZ17KDNS2Dnl6eWm4OY9YEh6KmWqXh5qwtF/EIYcC5RNPsMPwa1L 42ZNjS0uWs4RC0s5VvG7+EQF1rA6ismKVwZPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172348; x=1707777148; 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=oK4+kWXxklj9dqNQ/n9BQVndrHgiGL9o2jbYXxXYzuU=; b=aaqv5Cxm5/M89l3w4K5tixo5SW4nQlRPy3X2VZr8/KKNnnIdNoCWfjAo8+qi+5s4DB 85z/iyM6o8Y9Fxyx/ynTFODU91IqWAZCQCBZdkz9wzuHmoAHzqBFE4UATCkBLOHJFJxz ox4c3bAyw54VNQ7xzOkJfJMMPiGgjLZ4cuokCpW2g0qJgS76TmZUQQrm/R/OzOURSjUB l4H204iFCuPMrUI3fyIlAirM/sAsKxeNUtGQM6VTU/42wNXXAkKQX9EXgjhfESLBqwdC QgUZSUk5PES5Pl8IwmvmoCHk9ioNpVxvtMaMd9HtGvmHMWsiQBvM4DBN0HBna7i6a1G4 uFkA== X-Gm-Message-State: AOJu0YwOko/l4Ydy3d9qngkV3U0tpuVjayUUkxZcfKwdd3zeOsegHmoo 4nTJy2owgw4lmWHbA5aDmpSi+IEVtCunxP+DPxGB0yKMZ7zwCPzrE0YYjgngGg== X-Google-Smtp-Source: AGHT+IEcY8Ol/BIL/Jbc9K4sdETb3/awhPI7EHXKVf/uYUCXEbJhkKPPYOc8tW04c0qeo3Dc01VSWw== X-Received: by 2002:a05:6808:120a:b0:3bf:d0ee:9873 with SMTP id a10-20020a056808120a00b003bfd0ee9873mr670141oil.3.1707172347970; Mon, 05 Feb 2024 14:32:27 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXGEfzuQ6y6LKDLwsI69gn32bqEbJdbRZw/1FYvY6hvnaxm/9T314R97m9GgMpODkR2j5j6aQ9euoqkpO2mwv9XhKu9Oj3rPnHAhp5p+wbcHUf2gNNXxQEkjMpqD+JDBOA2Uv402cOSYcQVxkUvhoSlBLM22Oy0q79tJrxZkierxIqNTybIrYsi+A3CZWBhG94WazBJf5Jd0qb0DtqT/YH35jc= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:27 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 08/13] bnxt_en: Save user configured filters in a lookup list Date: Mon, 5 Feb 2024 14:31:57 -0800 Message-Id: <20240205223202.25341-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Driver needs to maintain a lookup list of all the user configured filters. This is required in order to reconfigure these filters upon interface toggle. We can look up this list to follow the order with which they should be re-applied. Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 +++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index d39de72bffea..b5bd88f33028 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4841,9 +4841,26 @@ static void bnxt_clear_ring_indices(struct bnxt *bp) } } +void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) +{ + u8 type = fltr->type, flags = fltr->flags; + + INIT_LIST_HEAD(&fltr->list); + if ((type == BNXT_FLTR_TYPE_L2 && flags & BNXT_ACT_RING_DST) || + (type == BNXT_FLTR_TYPE_NTUPLE && flags & BNXT_ACT_NO_AGING)) + list_add_tail(&fltr->list, &bp->usr_fltr_list); +} + +void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) +{ + if (!list_empty(&fltr->list)) + list_del_init(&fltr->list); +} + static void bnxt_del_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) { hlist_del(&fltr->hash); + bnxt_del_one_usr_fltr(bp, fltr); if (fltr->flags) { clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); bp->ntp_fltr_count--; @@ -5387,6 +5404,7 @@ void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr) return; } hlist_del_rcu(&fltr->base.hash); + bnxt_del_one_usr_fltr(bp, &fltr->base); if (fltr->base.flags) { clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); bp->ntp_fltr_count--; @@ -5533,6 +5551,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, } head = &bp->l2_fltr_hash_tbl[idx]; hlist_add_head_rcu(&fltr->base.hash, head); + bnxt_insert_usr_fltr(bp, &fltr->base); set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); atomic_set(&fltr->refcnt, 1); return 0; @@ -13984,6 +14003,7 @@ int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr, head = &bp->ntp_fltr_hash_tbl[idx]; hlist_add_head_rcu(&fltr->base.hash, head); set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); + bnxt_insert_usr_fltr(bp, &fltr->base); bp->ntp_fltr_count++; spin_unlock_bh(&bp->ntp_fltr_lock); return 0; @@ -14138,6 +14158,7 @@ void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr) return; } hlist_del_rcu(&fltr->base.hash); + bnxt_del_one_usr_fltr(bp, &fltr->base); bp->ntp_fltr_count--; spin_unlock_bh(&bp->ntp_fltr_lock); bnxt_del_l2_filter(bp, fltr->l2_fltr); @@ -14954,6 +14975,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto init_err_dl; + INIT_LIST_HEAD(&bp->usr_fltr_list); + rc = register_netdev(dev); if (rc) goto init_err_cleanup; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index d070e3ac9739..a6b6db1546cc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1334,6 +1334,7 @@ struct bnxt_pf_info { struct bnxt_filter_base { struct hlist_node hash; + struct list_head list; __le64 filter_id; u8 type; #define BNXT_FLTR_TYPE_NTUPLE 1 @@ -2442,6 +2443,8 @@ struct bnxt { u32 hash_seed; u64 toeplitz_prefix; + struct list_head usr_fltr_list; + /* To protect link related settings during link changes and * ethtool settings changes. */ @@ -2646,6 +2649,8 @@ u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx); void bnxt_set_tpa_flags(struct bnxt *bp); void bnxt_set_ring_params(struct bnxt *); int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); +void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); +void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size, bool async_only); int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); From patchwork Mon Feb 5 22:31:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546351 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 57417495EC for ; Mon, 5 Feb 2024 22:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172351; cv=none; b=bq55HL+nkH3AIqwUgFgt61EQb7O/oQi05dDaYvl/CEx+eHIfs95giOjEVEVixsebKSDtZ1ApA20iBKg4m8n9LdUCyY2n736HrpkIQsaWBVTfSAsWXerQciqX3DFbww2nu2ZVSh15XyXdpiCM/AJmJo17TckL9NTEw2AF29L8Uu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172351; c=relaxed/simple; bh=FvpcaLmOA+jG0GknFtXeV3grMzA1eqxGbaIs2hGNys8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gn5balY7+D4EURlhGazJXaUjVPUrOCkAi2ho9WwBf9mg8H4Y/gZXR6TRLMDKA0vh/zjfk/vE+k0YePSCoaubYKoeegoQOUDNDEzAofRKwGHmBHBr1rmf0hJys54ugAMhSIAjxfloAZULtaBn6XMXzO9yT/CH+utPpPz5Mw4fXr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=WJkxFQXx; arc=none smtp.client-ip=209.85.160.54 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="WJkxFQXx" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-206689895bfso3552416fac.1 for ; Mon, 05 Feb 2024 14:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172349; x=1707777149; 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=163O1PqAYKjSice25W0181UZYQuvv3Rgf2sWEbp9b68=; b=WJkxFQXx59J5IOZ6CIf5LmRtXQG3hRIexCcMW+WccV+paKdtmXV8MbEg5tuXSchvMr nGmV1r72eYuqaYZ+cf9dCmaUsm+vrnYBUDFRZRgpAWOi6SYAwSdYWeXjUHqXApMF505J nyNxoRBkWyhWNaxNoKgY6EjYLRraGK8BbP5AY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172349; x=1707777149; 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=163O1PqAYKjSice25W0181UZYQuvv3Rgf2sWEbp9b68=; b=nccJfAD9e8QCtMaovBt6JaNtzmly/nTCUamPgsMWZBCvoHBZAiv3vUGsN7m/ffyjI+ anH+S2+QkMKiiRiruS1cObAwD82EO5h3GlIaNXJD3T/NTMHrAW2SDgVIP/A2laCI8kI6 0PkA0Hh86iXhMKclLUbgBjQTotgsZ7tsvDik/gQzmjWpKDJsFGXP4RB7rTrMBZ9BhbbP e1mY04noWgXi6OU/K2Sg2gv+KXEUPzcejFSMv7WQortUI0A5CyWGxfHnp6tnL/xSBF4Q PYYFgoR5JguCiZW3m4y8AJIQlbys6FZxPDdDHExUfHjjPAlMOULXDHuW8piq2eMWAFlA Vwtg== X-Gm-Message-State: AOJu0Yw1DvHaV9Kgv0zx8Al2pi/fGM/BCvKZ7p3v+FzFkT4JKHdGF8WN h/gzai0LrQtYjJ8wvgDdL6ynKYdYxtIpS2xDdlvLAneu86zKxYnvtAqnompGlg== X-Google-Smtp-Source: AGHT+IHEZHvSt03R2DUwZQjvCCgHJEtVnSYUbdd5BQpO1EkVJTSAXpB3JIgWqL+Hp4ExxyfTtHJBQQ== X-Received: by 2002:a05:6871:7516:b0:219:7e3f:1372 with SMTP id ny22-20020a056871751600b002197e3f1372mr1108450oac.26.1707172349459; Mon, 05 Feb 2024 14:32:29 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUcUpWRUF0rEtt3E4KyNFjkixEEesMuKm8XO+Wdwc+J3RAEIGY0lABmxhBwa2bRHPisq28H/8hzG0UoJxxzJnt1mNN3/54cPoFgwwBvnVfkk/MRLWXSKiHnNjIVSWAmdROhLFaJ/0ZL6fOFoaqGcpMj2jBQS1gIKH5Wrva22WFVTBJgTBxVvuluhgZoXATitPRwZOxDro/DSVtNSjOWy+eYdI0= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:29 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 09/13] bnxt_en: Retain user configured filters when closing Date: Mon, 5 Feb 2024 14:31:58 -0800 Message-Id: <20240205223202.25341-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Driver should not free user created filters from its memory when closing since we are going to reconfigure them when we open again. If the "all" parameter is false, do not free user configured filters in bnxt_free_ntp_fltrs() and bnxt_free_l2_filters(). Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b5bd88f33028..41e1c6d2c127 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4883,7 +4883,8 @@ 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)) + if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || + !list_empty(&fltr->base.list))) continue; bnxt_del_fltr(bp, &fltr->base); } @@ -4926,7 +4927,8 @@ static void bnxt_free_l2_filters(struct bnxt *bp, bool all) head = &bp->l2_fltr_hash_tbl[i]; hlist_for_each_entry_safe(fltr, tmp, head, base.hash) { - if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) + if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || + !list_empty(&fltr->base.list))) continue; bnxt_del_fltr(bp, &fltr->base); } @@ -5851,7 +5853,8 @@ static void bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) struct bnxt_l2_filter *fltr = vnic->l2_filters[j]; bnxt_hwrm_l2_filter_free(bp, fltr); - bnxt_del_l2_filter(bp, fltr); + if (list_empty(&fltr->base.list)) + bnxt_del_l2_filter(bp, fltr); } vnic->uc_filter_count = 0; } From patchwork Mon Feb 5 22:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546352 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 A26354BA80 for ; Mon, 5 Feb 2024 22:32:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172354; cv=none; b=LAH4oAvgsL3ipQCokF/z7P0y55f453NNLHJS4tMbEe1rRfR4HmhrL0hhDItB+TiQRhqmYkiqMyCjAbvtZewC2Pi+JZOsFX5EaMUu/UqP/8zX2tb3+ycsx7xgNPwVNrL1xsYrCdZzHXv1X0dWzDvCf43raImEi23DQNBX7ASgA4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172354; c=relaxed/simple; bh=f0TEZ5auIr0f0fohuO8R/b0ggk+wHLZ9m9udsxReF/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=CSP/Hwlsdi4EP08JGz6Ta8loGWHsLvafwDP04B7CUb6oHqqusHQI7AczgVuT14uKL/0qNfUtOILmypmdsg6CqUk3Umk6h7dGhcHBJGx60YmpDVITW7tGXf2+Ex0c3gSFb2uq17f40oUOdTr05aWQ4alRs7VztS3q+0IsP1excy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=a1YxH1xz; arc=none smtp.client-ip=209.85.160.178 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="a1YxH1xz" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-42a8a3973c5so32567671cf.2 for ; Mon, 05 Feb 2024 14:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172351; x=1707777151; 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=Fc8bhShRns3Ka7XRAkANVdn5e6SVlv1KopwcmAiBS9E=; b=a1YxH1xzSYetXWQBs0NwZXiJ+A4nM2k3ehpyX7EQFlFFCuay5ZaGVYDqpf986DaW2/ mjSIQl6lfe2e2y/HYd153oXM7NJHnVLMKRI0s1QwMUsZaTJeyzBluLHpioFS8RVhtxwC aPTz6ACnOy2HQft2LSJ3E8kT3Rwq0m5dcgrP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172351; x=1707777151; 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=Fc8bhShRns3Ka7XRAkANVdn5e6SVlv1KopwcmAiBS9E=; b=PycFVAHFaBWP7dyAEd0IDoElokiFWpiLJbbIpH0RnYTjNJLdgfigdSfIps6xjtVEG1 Easf09DWfJuhJm49k9X9T5rvcjmxZCmrzLspBgCfEYmoIc2pmJasaLHfNPtdY0UIPZsX iA0ccSJQwZf9NrcU1tZhIP8hJYqEIQ3jeMqac62rHBuhRiXImHPjNQ3KOo41sgtIxahp pn+ZzSu03vcmGQnvbYpGWGgQSAwljMEG36TeJJGuEY8CwzRQXVculowKvAJtcJ+3zb24 7J+QqDOuIbf5otCVEhhjd6mJoXRw0EW08516UnQE+1ep7aIkla6Sqmy4njPnLELxk3f9 3GlA== X-Gm-Message-State: AOJu0YyadUMIVvWAS0UD9IU06q8G4FC+scbvVbe/nzSLF0/Cm1wDB9/U rIbDFnmS2mG+AZsfxOFCDZ2S7iMECGvhxQZRbcA+yemB3JZJFfvb7+157bpWsg== X-Google-Smtp-Source: AGHT+IEVgbduH1iOLKgc1nadVlsVA7uNVeG+I6bR6ZP7h9YQBBA9JqEkttHNcO4PduuUlX5uDrohOQ== X-Received: by 2002:ac8:764a:0:b0:42a:b2b1:a800 with SMTP id i10-20020ac8764a000000b0042ab2b1a800mr474421qtr.26.1707172351210; Mon, 05 Feb 2024 14:32:31 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCULNlRIcXuzS1AiGcEijukubzXm4W/vI9MEQD9z8RtWORwWQFZS1X8H+XhZblLHsIdMU3NHuErioTeYEk2K13UDRus3Uexr3GOtj6ywGcxI8AXeyqSQ5shehw40NL6LFhO6k3e1Ma6u/P6/1A7Gc8Bv8T+kCHClcd1+j5qqtbrA6X4iF7QvRarnkl7L/9DcTb7HHC9Ie4yuvZBBssKZXmQeqVM= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:30 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 10/13] bnxt_en: Restore all the user created L2 and ntuple filters Date: Mon, 5 Feb 2024 14:31:59 -0800 Message-Id: <20240205223202.25341-11-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Walk the usr_fltr_list and call firmware to add these filters when we open the NIC. This will restore all user created filters after reset. Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 40 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 41e1c6d2c127..a6e2b65c45ce 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5853,8 +5853,7 @@ static void bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) struct bnxt_l2_filter *fltr = vnic->l2_filters[j]; bnxt_hwrm_l2_filter_free(bp, fltr); - if (list_empty(&fltr->base.list)) - bnxt_del_l2_filter(bp, fltr); + bnxt_del_l2_filter(bp, fltr); } vnic->uc_filter_count = 0; } @@ -11537,6 +11536,42 @@ static int bnxt_reinit_after_abort(struct bnxt *bp) return rc; } +static void bnxt_cfg_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) +{ + struct bnxt_ntuple_filter *ntp_fltr; + struct bnxt_l2_filter *l2_fltr; + + if (list_empty(&fltr->list)) + return; + + if (fltr->type == BNXT_FLTR_TYPE_NTUPLE) { + ntp_fltr = container_of(fltr, struct bnxt_ntuple_filter, base); + l2_fltr = bp->vnic_info[0].l2_filters[0]; + atomic_inc(&l2_fltr->refcnt); + ntp_fltr->l2_fltr = l2_fltr; + if (bnxt_hwrm_cfa_ntuple_filter_alloc(bp, ntp_fltr)) { + bnxt_del_ntp_filter(bp, ntp_fltr); + netdev_err(bp->dev, "restoring previously configured ntuple filter id %d failed\n", + fltr->sw_id); + } + } else if (fltr->type == BNXT_FLTR_TYPE_L2) { + l2_fltr = container_of(fltr, struct bnxt_l2_filter, base); + if (bnxt_hwrm_l2_filter_alloc(bp, l2_fltr)) { + bnxt_del_l2_filter(bp, l2_fltr); + netdev_err(bp->dev, "restoring previously configured l2 filter id %d failed\n", + fltr->sw_id); + } + } +} + +static void bnxt_cfg_usr_fltrs(struct bnxt *bp) +{ + struct bnxt_filter_base *usr_fltr, *tmp; + + list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) + bnxt_cfg_one_usr_fltr(bp, usr_fltr); +} + static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { int rc = 0; @@ -11623,6 +11658,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) bnxt_vf_reps_open(bp); bnxt_ptp_init_rtc(bp, true); bnxt_ptp_cfg_tstamp_filters(bp); + bnxt_cfg_usr_fltrs(bp); return 0; open_err_irq: From patchwork Mon Feb 5 22:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546353 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 1C1D11DA58 for ; Mon, 5 Feb 2024 22:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172355; cv=none; b=eXHZySTTvhS+7d0ivBXQDIAFF+h0Mt0W/RVdkmlNh/CvrIb0HxmeZPooBXFEy7wZrAnHdSNeH73YoFgei+C15IJ3+2JS2d/pQALdbgzYKc53BKeynfd/h/83uWfgFVTRM7Q7O6E+SCv2Le95xnY9+fnPoBIut6efKVj4sYgDmyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172355; c=relaxed/simple; bh=MAXuPCl2sFn1NUP0oXPJ8AAyQ7T0v1qHVHSFmGeCBPk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sZiY1WAKd6+T67yn8FAAo4fRZ0dNdXsLQ0g65laCKCcjAlSR1g1Mp3JEkjtgLuLri5q23VgCxeUaydo7PVIr99HRSbwg+E0G9QvnrmiOYmds5zJfY80hNUeZYUS9KEK5JR0CSyO+CQjKiZgB7eqhuC9dQqPDoVUbyaLeLUXraXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=QqJ0GTQb; arc=none smtp.client-ip=209.85.160.179 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="QqJ0GTQb" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-42a9c21f9ecso29327811cf.0 for ; Mon, 05 Feb 2024 14:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172353; x=1707777153; 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=d72hnexSFBoKXOTEfV0exTKLLP0xzu0ruuF+i1GK1W0=; b=QqJ0GTQbVzocoQX031hPVOMvhMjcpMPbkI5qcBhderuWmRw/5HPSlMSBvTBDlMjtfn hvjnhohm2cLYFqmG/9P/M+72sYb5MEFF97XNMv6m4hrlFRjyB0wspdcHFlh6O4anR/Js NS1XfYaCtSxd/umlpd85s+06c9Ye4GSDDja2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172353; x=1707777153; 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=d72hnexSFBoKXOTEfV0exTKLLP0xzu0ruuF+i1GK1W0=; b=Due+x0PR9HHQdmUbRJJ31eqGys1LovYKcWFRbeFOYLxTCnoCo/H3TNkSLcfbvg8jdU xxQ8lpOMGUtri6zHPG1+CcLECcVyeqtNsJPzLDh3AsUrO4BntEcAn0LsHdK6Dx8UCOcA jnhiY21bsP+5YzYWeJvwT9Rg0IwQdRzSsQozVN+mn65zI0KNdYMHMdAIuK/42U0OQbYM k+amO9V5wpwBlZ0E91wSxypzaUTYfETK1Rt/Qh8dzsOzno0FMs78GE2w/dX7DI+b/QuH TtP8ToewOKBq1aO9ShzbTyL3mw6P/E9827ruBkRiF77i6Z1WGDdaZoMtKmmYrIG8fRQx Jjnw== X-Gm-Message-State: AOJu0YyOqanBLatvErltRODTx9caVj5D3GIVSnBijr0zT4iWnPJBUjjl ImrGirSKj1JJ2i3a4zZVt5Jl/RsM33PZX9aTIvCzUwx26CGzNvmFHTZLGJSv0w== X-Google-Smtp-Source: AGHT+IFO8Lu0MA9f6cAnJHMx+TNgd/6YuXfQY45FHsJg73LK+9RNVNKOo1wbPcy61Hfzq3lkhFIFdQ== X-Received: by 2002:ac8:59cf:0:b0:42b:fd4a:e13d with SMTP id f15-20020ac859cf000000b0042bfd4ae13dmr649576qtf.55.1707172352837; Mon, 05 Feb 2024 14:32:32 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVQURLqNjfVDGaK6LO40iXhl6ki1L2N+5dbjxhnCBs2ZbUm+k+XCISduegLOvXQGY2Sm/XvET9vGoe+iSvqwkug9Gh1hSzAS4WxLkPo5rvl8uTyk0QduYliQrAoVosrDDrES1z0p/fy1E7FUIjlXKNFFAgWxBqJrfTOffXdkxO3fKV8gxDlryqANEBZ6K1qCNY05z+AW1KxPhRMmzo+BDh7bcI= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:32 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 11/13] bnxt_en: Add support for user configured RSS key Date: Mon, 5 Feb 2024 14:32:00 -0800 Message-Id: <20240205223202.25341-12-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Store the user configured or generated Toeplitz key in bp->rss_hash_key. The key stays constant across ifdown/ifup unless updated by the user. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 6 ++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index a6e2b65c45ce..27941ade894a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4246,9 +4246,23 @@ static void bnxt_init_vnics(struct bnxt *bp) u8 *key = (void *)vnic->rss_hash_key; int k; + if (!bp->rss_hash_key_valid && + !bp->rss_hash_key_updated) { + get_random_bytes(bp->rss_hash_key, + HW_HASH_KEY_SIZE); + bp->rss_hash_key_updated = true; + } + + memcpy(vnic->rss_hash_key, bp->rss_hash_key, + HW_HASH_KEY_SIZE); + + if (!bp->rss_hash_key_updated) + continue; + + bp->rss_hash_key_updated = false; + bp->rss_hash_key_valid = true; + bp->toeplitz_prefix = 0; - get_random_bytes(vnic->rss_hash_key, - HW_HASH_KEY_SIZE); for (k = 0; k < 8; k++) { bp->toeplitz_prefix <<= 8; bp->toeplitz_prefix |= key[k]; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index a6b6db1546cc..28091889615b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2222,6 +2222,10 @@ struct bnxt { #define BNXT_RSS_CAP_NEW_RSS_CAP BIT(2) #define BNXT_RSS_CAP_RSS_TCAM BIT(3) + u8 rss_hash_key[HW_HASH_KEY_SIZE]; + u8 rss_hash_key_valid:1; + u8 rss_hash_key_updated:1; + u16 max_mtu; u8 max_tc; u8 max_lltc; /* lossless TCs */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 6721c4a88453..9b5382412db3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1755,8 +1755,10 @@ static int bnxt_set_rxfh(struct net_device *dev, if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; - if (rxfh->key) - return -EOPNOTSUPP; + if (rxfh->key) { + memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE); + bp->rss_hash_key_updated = true; + } if (rxfh->indir) { u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(dev); From patchwork Mon Feb 5 22:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546354 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 C7ACA4C3B3 for ; Mon, 5 Feb 2024 22:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172357; cv=none; b=Pik155ca2Nf643S085uIxSwqXM6eb438gox3pXBYX9NAHVUGVewfJVp2PTjNTJSvLYgf16QtDPeeNYvNv0koFnCdadM02vLPwXsZdOHzPQQINxVxbzXPKA8zYM3XHgvgm8stqIUWrR5KP1ClaOO4g64xVVRa3QN4WHGJ6wASgAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172357; c=relaxed/simple; bh=ktVDGR7ONs7scaNDMRGszVRzIOVxcB3ku8G25VeKGCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=J5kLEXen1CR2U8Uy8YJL3rvbZEgWUnHdo8Ex5cjiArypZYMbYN1uA92NBkcRD/G9toBgt7cgmGBPECP+dvm8OHpWZSSivVF4dZ+jYw42+IoRY1cXYEyjs9+oFi+Yx2pIcjwpxrDB18GCbOPMch72Wav8BtVxB1OlqrkwpuYzJvY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=G8zPIdZL; arc=none smtp.client-ip=209.85.160.176 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="G8zPIdZL" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-42aa4a9d984so39678511cf.1 for ; Mon, 05 Feb 2024 14:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172355; x=1707777155; 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=+AoTE08B6eLPYHIh2ussWG9aKTsBgmpFsYPqmnLHNSc=; b=G8zPIdZL1+LgCgo3dRYEHQRf9ZOv020dgxMPKDZpTMTrTvlu5UHe7c0+wKSSwvPeaj NcNxplnKk/MaLxz1wj5Tq3JZsd1ba1bh6auVtODSA/XWPSDdlHGGfyShYztyrsRhQuUA vIDSFjcgrJb3tH8+4+Iyv1S7P/W1C/pGOpqMA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172355; x=1707777155; 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=+AoTE08B6eLPYHIh2ussWG9aKTsBgmpFsYPqmnLHNSc=; b=ojX8dpDp1tx7WIXOR6f01QrXcliMv3BE5PyHBB2QxcnUwNG573vAxPlGQcaxkbDlWe GouTAFOUEddwwT3QT92M6iZLn6zelqZeITE5ukq6JZzvSpfzJFnXnkqre2XBL0LMr1ZL 42g4W2j4cXtUTkw9dKsR8VDv2S1D1dc48USNe32XGHeGZe3706ObPmyCotc/1ynwaS9y 2U4mK6TF1AznjhUV9g83G7Mi1BDezUh8p5h726DHQN7SYxn3jYyKjz388UfsBQGgijn0 Gt0a7h8qdvbRwUnZRFN6CdbBL/zqL95OJ/J7+2Bo3qnOn4WEnQbfAnhWEJNcXaNUGMSs OqmA== X-Gm-Message-State: AOJu0YxSkTlRN2r+jJAc7gWFE469UOU6MLriQGfYPDjGx1e1Ioo8v10X 2xi7pklMCkw8BdHluzJnPGw1IhVszHKEPJkgse4TebXclzEJ4McMmnDqwgidiA== X-Google-Smtp-Source: AGHT+IEBOjWuQKsJSs6gddMOTHrr5YPR5ISP64EEMst4E0pZGGLV/N5VI2VOx6n2klKKe2eKp8KYUw== X-Received: by 2002:ac8:5287:0:b0:42a:b73d:447e with SMTP id s7-20020ac85287000000b0042ab73d447emr501658qtn.15.1707172354450; Mon, 05 Feb 2024 14:32:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUIAT41ZOOynnSHxJRNi4AKjG0mCCo78Fr/8EPOXKxJuLnskdXjO0Jn2s/sv6PyI94btBE8rIKGdiCNko77JzlhTBAoCe0gSy9Q6BdpmKyMJ1pM9NRAjKVEwlw8T6lk7in7muaZhfbuPZ53kGEO3NWYhZ06ZAtatSOt91oWY5Gy0aYkka6cv4OX1So4AxefhO55y+6LK5KwysIjdAiYM6NB/Go= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:33 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 12/13] bnxt_en: Invalidate user filters when needed Date: Mon, 5 Feb 2024 14:32:01 -0800 Message-Id: <20240205223202.25341-13-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi The cached user filters slated to be reapplied need to be cleared if configured MAC changes, RSS key changes, number of rings changes, or ntuple is disabled. Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 14 ++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 27941ade894a..856fda0c4c1a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4871,6 +4871,17 @@ void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) list_del_init(&fltr->list); } +void bnxt_clear_usr_fltrs(struct bnxt *bp, bool all) +{ + struct bnxt_filter_base *usr_fltr, *tmp; + + list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) { + if (!all && usr_fltr->type == BNXT_FLTR_TYPE_L2) + continue; + bnxt_del_one_usr_fltr(bp, usr_fltr); + } +} + static void bnxt_del_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) { hlist_del(&fltr->hash); @@ -12414,6 +12425,8 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features) if (features & NETIF_F_NTUPLE) flags |= BNXT_FLAG_RFS; + else + bnxt_clear_usr_fltrs(bp, true); changes = flags ^ bp->flags; if (changes & BNXT_FLAG_TPA) { @@ -13911,6 +13924,7 @@ static int bnxt_change_mac_addr(struct net_device *dev, void *p) return rc; eth_hw_addr_set(dev, addr->sa_data); + bnxt_clear_usr_fltrs(bp, true); if (netif_running(dev)) { bnxt_close_nic(bp, false, false); rc = bnxt_open_nic(bp, false, false); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 28091889615b..2b2f051ee085 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2655,6 +2655,7 @@ void bnxt_set_ring_params(struct bnxt *); int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode); void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr); +void bnxt_clear_usr_fltrs(struct bnxt *bp, bool all); int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size, bool async_only); int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 9b5382412db3..a0962026a85f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -968,6 +968,7 @@ static int bnxt_set_channels(struct net_device *dev, return -EINVAL; } + bnxt_clear_usr_fltrs(bp, true); if (netif_running(dev)) { if (BNXT_PF(bp)) { /* TODO CHIMP_FW: Send message to all VF's @@ -1769,7 +1770,7 @@ static int bnxt_set_rxfh(struct net_device *dev, if (pad) memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); } - + bnxt_clear_usr_fltrs(bp, false); if (netif_running(bp->dev)) { bnxt_close_nic(bp, false, false); rc = bnxt_open_nic(bp, false, false); From patchwork Mon Feb 5 22:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546355 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 371391866 for ; Mon, 5 Feb 2024 22:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172361; cv=none; b=q34izqheeX6rRG5B8ijYqJX7qtKxUDJzXU1zrBc+PBA9wDHdL3/vbDaN0f3Ji/va02IDjVjK4y0d6aKHhU64paurWZk3n3xCCwwTUaRHCWIh/RYyYeHD0j+voLSjFbroFs5lGx11hxd+A9TT2gyzSVsTXD0oJETBUbRHRR4hL0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172361; c=relaxed/simple; bh=VQk9XRSsmHh6nkdCOC0iOzREAkSsEYCRAyrqNvbWZ3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sdrA8vVw4OlL0igtoFOKYXeV5BSxo7uVCr6X4hyb7Cjx50c9wEtLfpbaPpKZHs4uGW5O7kijdwnDgbBj72fkDuAKrwTluIX+gODxjrKzYhR5ij28ciEWWjEJdOMTqdphq3s0KDErK+eDAjvKlj1ROhgZvv0SPzT+eUSgoVyRr7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=E1D5DCID; arc=none smtp.client-ip=209.85.160.50 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="E1D5DCID" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-20503dc09adso3350719fac.2 for ; Mon, 05 Feb 2024 14:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172356; x=1707777156; 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=rLxIQhQ5iKlKsfQeuMKkhQswIjZSvYbF7Gza5GZXivo=; b=E1D5DCIDp63pT2RgfY4mHS+ik47OUT0TNlTpoTZ7TB9er9Fe8pVmfeJ+SddWfam8g+ e6gEAy5Dp6qkIk5fqjUFXLiSTIHzwxa/CnIgz0xrism1LfRBz3WRatTuKMjD98p0F+t7 f92QM0rbcuVwZRL8/UJvxk9o3yZB9eepg7ijc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172356; x=1707777156; 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=rLxIQhQ5iKlKsfQeuMKkhQswIjZSvYbF7Gza5GZXivo=; b=GrpXzXaVOKKFeirWQYFBuJ8Fn2zXCKeDgMEK9mwCq99mMn/5/zBbW9/G9eNuXFD1g1 ewGPssb8/lDC5/pTSynSvqyrBKGY1OkbsYrDRLVkAP21K6ORuD0R0cUFXCNoVbeAXWaL 8xeWzUJs5vORXFB/C+leCSvukKxFaZX0jsDGomCZQUgTM9+nuwTTUztZgHjimD5g0Zvb FE1nIezQlPxr4TFnyCTAAv3787/CrGfZvgBsRzv8zlrPBzOihbzXIIE6y6/rjb1sadx0 uw59FfOUh7u2aMuwNeL6RxpPaS8dK0eXlyc92NYx6tWHivl21Q+LGU9oZoKXG92RSdK6 CB7Q== X-Gm-Message-State: AOJu0Yy8u4e5z3obL5WfHlCa8VN5mciiY6vI7RNXF7detqbe5qYaeY1K JRqTsZDTQolG3xZkUzkRKG50VCTRauhoGg7l4edo0D0vXugGRkuOwupxkI5aew== X-Google-Smtp-Source: AGHT+IGfu+hHRI+KiQ7mhYBhkqxOulopSo4N/hMcaWyxGgJr8Np8gpNLhaFCrIgW61xlmK2NZWhnYQ== X-Received: by 2002:a05:6870:171a:b0:219:3db5:b540 with SMTP id h26-20020a056870171a00b002193db5b540mr574067oae.41.1707172356132; Mon, 05 Feb 2024 14:32:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWBGMHARt7CfrY5TPsW5YOuLDK+iwtLxo21I3SaHY3VfGrpiYuT25WoaSEe5C4JyzNKaD6qwxrkWuS5V2kpI/pIlLG7vXEFbPEb6dSjpClVObFpAMV0ZY4fnmBJzA2be6e66E5W6pQvnYOr9iX7FoL+LhhYKNh3nd3cB3UBg+l/ER9xU5YZO1iNbd2kQlhTSDWZ0Vv98+GTNFik3mPXyMIykKhmVHxbLIQ3uAOEOxU7koP5QYGJc4z7rGW+i3Ct Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:35 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com, Ajit Khaparde Subject: [PATCH net-next 13/13] bnxt_en: Add RSS support for IPSEC headers Date: Mon, 5 Feb 2024 14:32:02 -0800 Message-Id: <20240205223202.25341-14-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Ajit Khaparde IPSec uses two distinct protocols, Authentication Header (AH) and Encapsulating Security Payload (ESP). Add support to configure RSS based on AH and ESP headers. This functionality will be enabled based on the capabilities indicated by the firmware in HWRM_VNIC_QCAPS. Signed-off-by: Ajit Khaparde Signed-off-by: Michael Chan --- Cc: Ajit Khaparde --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 34 +++++++++++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 856fda0c4c1a..0c471ddad747 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6099,10 +6099,13 @@ static void __bnxt_hwrm_vnic_set_rss(struct bnxt *bp, struct hwrm_vnic_rss_cfg_input *req, struct bnxt_vnic_info *vnic) { - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { bnxt_fill_hw_rss_tbl_p5(bp, vnic); - else + if (bp->flags & BNXT_FLAG_CHIP_P7) + req->flags |= VNIC_RSS_CFG_REQ_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT; + } else { bnxt_fill_hw_rss_tbl(bp, vnic); + } if (bp->rss_hash_delta) { req->hash_type = cpu_to_le32(bp->rss_hash_delta); @@ -6465,6 +6468,14 @@ static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp) } if (flags & VNIC_QCAPS_RESP_FLAGS_HW_TUNNEL_TPA_CAP) bp->fw_cap |= BNXT_FW_CAP_VNIC_TUNNEL_TPA; + if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_IPSEC_AH_SPI_IPV4_CAP) + bp->rss_cap |= BNXT_RSS_CAP_AH_V4_RSS_CAP; + if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_IPSEC_AH_SPI_IPV6_CAP) + bp->rss_cap |= BNXT_RSS_CAP_AH_V6_RSS_CAP; + if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_IPSEC_ESP_SPI_IPV4_CAP) + bp->rss_cap |= BNXT_RSS_CAP_ESP_V4_RSS_CAP; + if (flags & VNIC_QCAPS_RESP_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP) + bp->rss_cap |= BNXT_RSS_CAP_ESP_V6_RSS_CAP; } hwrm_req_drop(bp, req); return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 2b2f051ee085..60bdd0673ec8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2221,6 +2221,10 @@ struct bnxt { #define BNXT_RSS_CAP_UDP_RSS_CAP BIT(1) #define BNXT_RSS_CAP_NEW_RSS_CAP BIT(2) #define BNXT_RSS_CAP_RSS_TCAM BIT(3) +#define BNXT_RSS_CAP_AH_V4_RSS_CAP BIT(4) +#define BNXT_RSS_CAP_AH_V6_RSS_CAP BIT(5) +#define BNXT_RSS_CAP_ESP_V4_RSS_CAP BIT(6) +#define BNXT_RSS_CAP_ESP_V6_RSS_CAP BIT(7) u8 rss_hash_key[HW_HASH_KEY_SIZE]; u8 rss_hash_key_valid:1; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index a0962026a85f..f3ec5b96a5d0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1533,8 +1533,14 @@ static int bnxt_grxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd) cmd->data |= RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; fallthrough; - case SCTP_V4_FLOW: case AH_ESP_V4_FLOW: + if (bp->rss_hash_cfg & + (VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV4 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV4)) + cmd->data |= RXH_IP_SRC | RXH_IP_DST | + RXH_L4_B_0_1 | RXH_L4_B_2_3; + fallthrough; + case SCTP_V4_FLOW: case AH_V4_FLOW: case ESP_V4_FLOW: case IPV4_FLOW: @@ -1552,8 +1558,14 @@ static int bnxt_grxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd) cmd->data |= RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; fallthrough; - case SCTP_V6_FLOW: case AH_ESP_V6_FLOW: + if (bp->rss_hash_cfg & + (VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV6 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV6)) + cmd->data |= RXH_IP_SRC | RXH_IP_DST | + RXH_L4_B_0_1 | RXH_L4_B_2_3; + fallthrough; + case SCTP_V6_FLOW: case AH_V6_FLOW: case ESP_V6_FLOW: case IPV6_FLOW: @@ -1600,6 +1612,24 @@ static int bnxt_srxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd) rss_hash_cfg &= ~VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6; if (tuple == 4) rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6; + } else if (cmd->flow_type == AH_ESP_V4_FLOW) { + if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V4_RSS_CAP) || + !(bp->rss_cap & BNXT_RSS_CAP_ESP_V4_RSS_CAP))) + return -EINVAL; + rss_hash_cfg &= ~(VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV4 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV4); + if (tuple == 4) + rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV4 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV4; + } else if (cmd->flow_type == AH_ESP_V6_FLOW) { + if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V6_RSS_CAP) || + !(bp->rss_cap & BNXT_RSS_CAP_ESP_V6_RSS_CAP))) + return -EINVAL; + rss_hash_cfg &= ~(VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV6 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV6); + if (tuple == 4) + rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_AH_SPI_IPV6 | + VNIC_RSS_CFG_REQ_HASH_TYPE_ESP_SPI_IPV6; } else if (tuple == 4) { return -EINVAL; }