add features to bnge
Vikas Gupta
maintainerv3 cover add features to bnge
Hi,
This series adds ntuple filter, RSS context, and flow steering support to bnge driver.
Patch 2 is a pure refactor (no functional change) that relocates the filter and VNIC related code into the appropriate files. Patch 7 drops the refcount usage from L2 filters, also with no functional change. The subsequent patches then add the ethtool commands for configuring ntuple flows and RSS contexts.
Thanks,
Vikas
v2->v3:
- Build fix.
- Addressed comments from Sashiko
https://sashiko.dev/#/patchset/20260908093053.2596020-1-vikas.gupta%40broadcom.com
Below Sashiko comments are not valid:
Patch-8:
Comment under bnge_toeplitz().
Explanation: bnge_toeplitz() is not used for aRFS.
Patch-9:
Comment regarding bnge_clear_usr_fltrs().
Explanation:
Both bnge_clear_usr_fltrs() (only invoked while the interface is down) and bnge_grxclsrule() execute under the netdev instance lock, so they are serialized and never touch the filter list at the same time.
Patch-10:
Comment "Does this direct dereference of the MAC header need a linearization ...".
Explanation: ndo_rx_flow_steer runs on the RX path
after eth_type_trans(), which already accesses and pulls the Ethernet header.
Comment Related to bnge_cfg_ntp_filters().
Explanation:
bnge_cfg_ntp_filters() runs from bnge_sp_task(), which holds the netdev instance lock while executing.v1->v2:
- Build fixes.
- Addressed comments from Sashiko
https://sashiko.dev/#/patchset/20260814011435.194631-1-vikas.gupta%40broadcom.com
Vikas Gupta (11):
bnge: update HSI
bnge: restructure VNIC and filter code
bnge: add NTUPLE/ARFS VNIC
bnge: add helper functions for multi RSS contexts
bnge: add RXFH ethtool support
bnge: add ethtool support to manage RSS contexts
bnge: remove refcount from L2 filter
bnge: add NTUPLE filter infrastructure
bnge: add NTUPLE filter support in ethtool
bnge: add aRFS flow steering ndo support
bnge: add cpu_rmap support for IRQ affinity
drivers/net/ethernet/broadcom/bnge/Makefile | 4 +- drivers/net/ethernet/broadcom/bnge/bnge.h | 20 +- .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 1030 +++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_filter.c | 684 +++++++++++ .../net/ethernet/broadcom/bnge/bnge_filter.h | 123 ++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 155 ++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 10 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 420 ++++--- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 91 +- .../net/ethernet/broadcom/bnge/bnge_resc.c | 115 +- .../net/ethernet/broadcom/bnge/bnge_resc.h | 1 + .../net/ethernet/broadcom/bnge/bnge_vnic.c | 284 +++++ .../net/ethernet/broadcom/bnge/bnge_vnic.h | 91 ++ include/linux/bnge/hsi.h | 136 ++- 14 files changed, 2868 insertions(+), 296 deletions(-) create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_filter.c create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_filter.h create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_vnic.c create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_vnic.h
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 1/11 bnge: update HSI
Update HSI to support future patches implementing multi-RSS and NTUPLE-related features.
--- include/linux/bnge/hsi.h | 136 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 1 deletion(-)
include/linux/bnge/hsi.h +135 -1
@@ -8607,6 +8607,7 @@ struct hwrm_cfa_l2_filter_alloc_input {#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_MIRROR_VNIC_ID 0x10000UL#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_NUM_VLANS 0x20000UL#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_T_NUM_VLANS 0x40000UL +#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_RFS_RING_TBL_IDX 0x80000ULu8 l2_addr[6 ];u8 num_vlans;u8 t_num_vlans;
@@ -8663,7 +8664,8 @@ struct hwrm_cfa_l2_filter_alloc_input {#define CFA_L2_FILTER_ALLOC_REQ_PRI_HINT_MIN 0x4UL#define CFA_L2_FILTER_ALLOC_REQ_PRI_HINT_LAST CFA_L2_FILTER_ALLOC_REQ_PRI_HINT_MINu8 unused_5; -__le32 unused_6; +__le16 rfs_ring_tbl_idx; +__le16 unused_6;__le64 l2_filter_id_hint; };
@@ -8900,6 +8902,95 @@ struct hwrm_cfa_tunnel_filter_free_output {u8 valid; }; +/* hwrm_cfa_ntuple_filter_alloc_input (size:1024b/128B) */ +struct hwrm_cfa_ntuple_filter_alloc_input { +__le16 req_type; +__le16 cmpl_ring; +__le16 seq_id; +__le16 target_id; +__le64 resp_addr; +__le32 flags; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_LOOPBACK 0x1UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DROP 0x2UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_METER 0x4UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DEST_FID 0x8UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_ARP_REPLY 0x10UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DEST_RFS_RING_IDX 0x20UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_NO_L2_CONTEXT 0x40UL +__le32 enables; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_L2_FILTER_ID 0x1UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_ETHERTYPE 0x2UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_TUNNEL_TYPE 0x4UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_MACADDR 0x8UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_IPADDR_TYPE 0x10UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR 0x20UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR_MASK 0x40UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_IPADDR 0x80UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_IPADDR_MASK 0x100UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_IP_PROTOCOL 0x200UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_PORT 0x400UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_PORT_MASK 0x800UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_PORT 0x1000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_PORT_MASK 0x2000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_PRI_HINT 0x4000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_NTUPLE_FILTER_ID 0x8000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_ID 0x10000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_MIRROR_VNIC_ID 0x20000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_DST_MACADDR 0x40000UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_RFS_RING_TBL_IDX 0x80000UL +__le64 l2_filter_id; +u8 src_macaddr[6 ]; +__be16 ethertype; +u8 ip_addr_type; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_UNKNOWN 0x0UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4 0x4UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV6 0x6UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_LAST CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV6 +u8 ip_protocol; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_UNKNOWN 0x0UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_TCP 0x6UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_UDP 0x11UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_ICMP 0x1UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_ICMPV6 0x3aUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_RSVD 0xffUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_LAST CFA_NTUPLE_FILTER_ALLOC_REQ_IP_PROTOCOL_RSVD +__le16 dst_id; +__le16 rfs_ring_tbl_idx; +u8 tunnel_type; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_NONTUNNEL 0x0UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_VXLAN 0x1UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_NVGRE 0x2UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_L2GRE 0x3UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_IPIP 0x4UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_GENEVE 0x5UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_MPLS 0x6UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_STT 0x7UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_IPGRE 0x8UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_VXLAN_V4 0x9UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_IPGRE_V1 0xaUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_L2_ETYPE 0xbUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_VXLAN_GPE_V6 0xcUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_VXLAN_GPE 0x10UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_ANYTUNNEL 0xffUL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_LAST CFA_NTUPLE_FILTER_ALLOC_REQ_TUNNEL_TYPE_ANYTUNNEL +u8 pri_hint; +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_NO_PREFER 0x0UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_ABOVE 0x1UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_BELOW 0x2UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_HIGHEST 0x3UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_LOWEST 0x4UL +#define CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_LAST CFA_NTUPLE_FILTER_ALLOC_REQ_PRI_HINT_LOWEST +__be32 src_ipaddr[4 ]; +__be32 src_ipaddr_mask[4 ]; +__be32 dst_ipaddr[4 ]; +__be32 dst_ipaddr_mask[4 ]; +__be16 src_port; +__be16 src_port_mask; +__be16 dst_port; +__be16 dst_port_mask; +__le64 ntuple_filter_id_hint; +}; +/* hwrm_cfa_ntuple_filter_alloc_output (size:192b/24B) */ struct hwrm_cfa_ntuple_filter_alloc_output {__le16 error_code;
@@ -9014,6 +9105,49 @@ struct hwrm_cfa_ntuple_filter_cfg_output {u8 valid; }; +/* hwrm_cfa_adv_flow_mgnt_qcaps_input (size:256b/32B) */ +struct hwrm_cfa_adv_flow_mgnt_qcaps_input { +__le16 req_type; +__le16 cmpl_ring; +__le16 seq_id; +__le16 target_id; +__le64 resp_addr; +__le32 unused_0[4 ]; +}; + +/* hwrm_cfa_adv_flow_mgnt_qcaps_output (size:128b/16B) */ +struct hwrm_cfa_adv_flow_mgnt_qcaps_output { +__le16 error_code; +__le16 req_type; +__le16 seq_id; +__le16 resp_len; +__le32 flags; +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_FLOW_HND_16BIT_SUPPORTED 0x1UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_FLOW_HND_64BIT_SUPPORTED 0x2UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_FLOW_BATCH_DELETE_SUPPORTED 0x4UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_FLOW_RESET_ALL_SUPPORTED 0x8UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_DEST_FUNC_SUPPORTED 0x10UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_TX_EEM_FLOW_SUPPORTED 0x20UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_RX_EEM_FLOW_SUPPORTED 0x40UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_FLOW_COUNTER_ALLOC_SUPPORTED 0x80UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_RFS_RING_TBL_IDX_SUPPORTED 0x100UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_UNTAGGED_VLAN_SUPPORTED 0x200UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_XDP_SUPPORTED 0x400UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_L2_HEADER_SOURCE_FIELDS_SUPPORTED 0x800UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_RX_ARP_SUPPORTED 0x1000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_RFS_RING_TBL_IDX_V2_SUPPORTED 0x2000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_RX_ETHERTYPE_IP_SUPPORTED 0x4000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_TRUFLOW_CAPABLE 0x8000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_L2_FILTER_TRAFFIC_TYPE_L2_ROCE_SUPPORTED 0x10000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_LAG_SUPPORTED 0x20000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_NO_L2CTX_SUPPORTED 0x40000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NIC_FLOW_STATS_SUPPORTED 0x80000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_NTUPLE_FLOW_RX_EXT_IP_PROTO_SUPPORTED 0x100000UL +#define CFA_ADV_FLOW_MGNT_QCAPS_RESP_FLAGS_RFS_RING_TBL_IDX_V3_SUPPORTED 0x200000UL +u8 unused_0[3 ]; +u8 valid; +}; +/* hwrm_tunnel_dst_port_alloc_input (size:192b/24B) */ struct hwrm_tunnel_dst_port_alloc_input {__le16 req_type;
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerRe: [net-next, v3 01/11] bnge: update HSI
Quoted 2 lines · On Thu, 17 Sep 2026 12:15:38 +0530 Vikas Gupta wrote:
Update HSI to support future patches implementing multi-RSS and NTUPLE-related features.
I'll apply this patch, no point wasting ML BW on reposting it
Vikas Gupta
maintainerPATCH v3 2/11 bnge: restructure VNIC and filter code
In reply to Vikas GuptaMove VNIC and L2 filter code out of bnge_netdev.c into dedicated bnge_vnic.c/h and bnge_filter.c/h files in preparation for multi-VNIC, RSS context, and NTUPLE filter support.
This is a code reorganization with no functional change, which helps centralize the functions into their respective modules.
--- drivers/net/ethernet/broadcom/bnge/Makefile | 4 +- drivers/net/ethernet/broadcom/bnge/bnge.h | 7 - .../net/ethernet/broadcom/bnge/bnge_filter.c | 113 ++++++++++++ .../net/ethernet/broadcom/bnge/bnge_filter.h | 54 ++++++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 2 + .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 2 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 170 +----------------- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 72 -------- .../net/ethernet/broadcom/bnge/bnge_resc.c | 31 +--- .../net/ethernet/broadcom/bnge/bnge_vnic.c | 100 +++++++++++ .../net/ethernet/broadcom/bnge/bnge_vnic.h | 62 +++++++ 11 files changed, 345 insertions(+), 272 deletions(-) create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_filter.c create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_filter.h create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_vnic.c create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_vnic.h
drivers/net/ethernet/broadcom/bnge/Makefile +3 -1
@@ -12,4 +12,6 @@ bng_en-y := bnge_core.o \ bnge_ethtool.o \ bnge_auxr.o \ bnge_txrx.o \ - bnge_link.o + bnge_link.o \ + bnge_vnic.o \ + bnge_filter.o
drivers/net/ethernet/broadcom/bnge/bnge.h +0 -7
@@ -163,13 +163,6 @@ struct bnge_dev {#define BNGE_L2_FLTR_MAX_FLTR 1024u32 *rss_indir_tbl; -#define BNGE_RSS_TABLE_ENTRIES 64 -#define BNGE_RSS_TABLE_SIZE (BNGE_RSS_TABLE_ENTRIES * 4) -#define BNGE_RSS_TABLE_MAX_TBL 8 -#define BNGE_MAX_RSS_TABLE_SIZE \ - (BNGE_RSS_TABLE_SIZE * BNGE_RSS_TABLE_MAX_TBL) -#define BNGE_MAX_RSS_TABLE_ENTRIES \ - (BNGE_RSS_TABLE_ENTRIES * BNGE_RSS_TABLE_MAX_TBL)u16 rss_indir_tbl_entries;u32 rss_cap;
drivers/net/ethernet/broadcom/bnge/bnge_filter.c new file +113 -0
113 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_filter.h new file +54 -0
54 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +2 -0
@@ -15,6 +15,8 @@#include "bnge_rmem.h" #include "bnge_resc.h" #include "bnge_netdev.h" +#include "bnge_vnic.h" +#include "bnge_filter.h" static const u16 bnge_async_events_arr[] = {ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE ,
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h +2 -0
@@ -4,6 +4,8 @@#ifndef _BNGE_HWRM_LIB_H_#define _BNGE_HWRM_LIB_H_ +struct bnge_l2_filter ; +#define BNGE_PLC_EN_JUMBO_THRES_VALID \ VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID#define BNGE_PLC_EN_HDS_THRES_VALID \
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +2 -168
182 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +0 -72
86 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_resc.c +7 -24
@@ -11,6 +11,7 @@#include "bnge_hwrm.h" #include "bnge_hwrm_lib.h" #include "bnge_resc.h" +#include "bnge_vnic.h" static u16 bnge_num_tx_to_cp (struct bnge_dev *bd,u16 tx) {
@@ -186,13 +187,13 @@ int bnge_cal_nr_rss_ctxs(u16 rx_rings) BNGE_RSS_TABLE_ENTRIES); } -static u16 bnge_rss_ctxs_in_use (struct bnge_dev *bd, -struct bnge_hw_rings *hwr) +static u16 bnge_get_total_rss_ctxs (struct bnge_dev *bd, +struct bnge_hw_rings *hwr) {return bnge_cal_nr_rss_ctxs (hwr->grp); } -static u16 bnge_get_total_vnics (struct bnge_dev *bd,u16 rx_rings) +static u16 bnge_get_total_vnics (struct bnge_dev *bd) {return 1 ; }
@@ -203,24 +204,6 @@ u32 bnge_get_rxfh_indir_size(struct bnge_dev *bd)BNGE_RSS_TABLE_ENTRIES ; } -static void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd) -{ -u16 max_entries, pad; -u32 *rss_indir_tbl; -int i; - - max_entries =bnge_get_rxfh_indir_size (bd); - rss_indir_tbl = &bd->rss_indir_tbl[0 ]; - -for (i =0 ; i < max_entries; i++) - rss_indir_tbl[i] =ethtool_rxfh_indir_default (i, - bd->rx_nr_rings); - - pad = bd->rss_indir_tbl_entries - max_entries; -if (pad) -memset (&rss_indir_tbl[i],0 , pad *sizeof (*rss_indir_tbl)); -} -static void bnge_copy_reserved_rings (struct bnge_dev *bd,struct bnge_hw_rings *hwr) {
@@ -253,7 +236,7 @@ static bool bnge_need_reserve_rings(struct bnge_dev *bd)if (hw_resc->resv_tx_rings != bd->tx_nr_rings)return true; - vnic =bnge_get_total_vnics (bd, rx); + vnic =bnge_get_total_vnics (bd);if (bnge_is_agg_reqd (bd)) rx <<=1 ;
@@ -299,12 +282,12 @@ int bnge_reserve_rings(struct bnge_dev *bd) sh = true; hwr.cmpl = hwr.rx + hwr.tx; - hwr.vnic =bnge_get_total_vnics (bd, hwr.rx); + hwr.vnic =bnge_get_total_vnics (bd);if (bnge_is_agg_reqd (bd)) hwr.rx <<=1 ; hwr.grp = bd->rx_nr_rings; - hwr.rss_ctx =bnge_rss_ctxs_in_use (bd, &hwr); + hwr.rss_ctx =bnge_get_total_rss_ctxs (bd, &hwr); hwr.stat =bnge_func_stat_ctxs_demand (bd); old_rx_rings = bd->hw_resc.resv_rx_rings;
drivers/net/ethernet/broadcom/bnge/bnge_vnic.c new file +100 -0
100 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_vnic.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 3/11 bnge: add NTUPLE/ARFS VNIC
In reply to Vikas GuptaInitialize the second VNIC, which is specifically used for the NTUPLE/ARFS feature. This VNIC helps support the aRFS/NTUPLE functionality. With this change, the total number of VNICs becomes 2. Add bnge_set_dflt_rfs() to configure the default NTUPLE feature state at netdev allocation time.
Also, allocate and configure the ARFS VNIC.
--- drivers/net/ethernet/broadcom/bnge/bnge.h | 11 ++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 1 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 66 +++++++++++++++-- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 1 + .../net/ethernet/broadcom/bnge/bnge_resc.c | 73 ++++++++++++++++++- .../net/ethernet/broadcom/bnge/bnge_resc.h | 1 + .../net/ethernet/broadcom/bnge/bnge_vnic.c | 33 ++++++++- .../net/ethernet/broadcom/bnge/bnge_vnic.h | 7 +- 8 files changed, 181 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge.h +8 -3
@@ -63,9 +63,8 @@ enum {BNGE_FW_CAP_THRESHOLD_TEMP_SUPPORTED =BIT_ULL (21 ),BNGE_FW_CAP_DFLT_VLAN_TPID_PCP =BIT_ULL (22 ),BNGE_FW_CAP_VNIC_TUNNEL_TPA =BIT_ULL (23 ), -BNGE_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO =BIT_ULL (24 ), -BNGE_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 =BIT_ULL (25 ), - BNGE_FW_CAP_VNIC_RE_FLUSH = BIT_ULL(26), +BNGE_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 =BIT_ULL (24 ), + BNGE_FW_CAP_VNIC_RE_FLUSH = BIT_ULL(25), }; enum {
@@ -74,6 +73,7 @@ enum {BNGE_EN_STRIP_VLAN =BIT_ULL (2 ),BNGE_EN_SHARED_CHNL =BIT_ULL (3 ),BNGE_EN_UDP_GSO_SUPP =BIT_ULL (4 ), + BNGE_EN_ARFS_CAP = BIT_ULL(5), };#define BNGE_EN_ROCE (BNGE_EN_ROCE_V1 | BNGE_EN_ROCE_V2)
@@ -218,6 +218,11 @@ static inline bool bnge_is_roce_en(struct bnge_dev *bd)return bd->flags &BNGE_EN_ROCE ; } +static inline bool bnge_is_arfs_cap (struct bnge_dev *bd) +{ +return bd->flags &BNGE_EN_ARFS_CAP ; +} +static inline bool bnge_is_agg_reqd (struct bnge_dev *bd) {if (bd->netdev) {
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h +1 -0
@@ -67,4 +67,5 @@ int bnge_hwrm_shutdown_link(struct bnge_dev *bd);int bnge_hwrm_port_qstats (struct bnge_dev *bd,u8 flags);int bnge_hwrm_port_qstats_ext (struct bnge_dev *bd,u8 flags);int bnge_hwrm_func_qstat_ext (struct bnge_dev *bd,struct bnge_stats_mem *stats); +int bnge_hwrm_cfa_adv_flow_mgnt_qcaps (struct bnge_dev *bd);#endif /* _BNGE_HWRM_LIB_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +61 -5
115 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +1 -0
@@ -152,6 +152,7 @@ enum {BNGE_NET_EN_GRO =BIT (0 ),BNGE_NET_EN_LRO =BIT (1 ),BNGE_NET_EN_JUMBO =BIT (2 ), + BNGE_NET_EN_NTUPLE = BIT(3), };#define BNGE_NET_EN_TPA (BNGE_NET_EN_GRO | BNGE_NET_EN_LRO)
drivers/net/ethernet/broadcom/bnge/bnge_resc.c +72 -1
101 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_resc.h +1 -0
@@ -75,6 +75,7 @@ void bnge_aux_init_dflt_config(struct bnge_dev *bd);u32 bnge_get_rxfh_indir_size (struct bnge_dev *bd);int bnge_cal_nr_rss_ctxs (u16 rx_rings);bool bnge_aux_has_enough_resources (struct bnge_dev *bd); +bool bnge_arfs_capable (struct bnge_dev *bd,bool new_rss_ctx);static inline u32 bnge_adjust_pow_two (u32 total_ent,u16 ent_per_blk)
drivers/net/ethernet/broadcom/bnge/bnge_vnic.c +32 -1
@@ -42,7 +42,11 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic)for (i =0 ; i < tbl_size; i++) {u16 ring_id, j; - j = bd->rss_indir_tbl[i]; +if (vnic->flags &BNGE_VNIC_NTUPLE_FLAG ) + j =ethtool_rxfh_indir_default (i, bd->rx_nr_rings); +else + j = bd->rss_indir_tbl[i]; + rxr = &bn->rx_ring[j]; ring_id = rxr->rx_ring_struct.fw_ring_id;
@@ -98,3 +102,30 @@ int bnge_setup_vnic(struct bnge_net *bn, struct bnge_vnic_info *vnic) }return rc; } + +static int bnge_alloc_and_setup_vnic (struct bnge_net *bn, +struct bnge_vnic_info *vnic, +u16 rx_rings) +{ +int rc; + + rc =bnge_hwrm_vnic_alloc (bn->bd, vnic, rx_rings); +if (rc) { +netdev_err (bn->netdev,"hwrm vnic %u alloc failure rc: %d\n" , + vnic->vnic_id, rc); +return rc; + } + +/* If bnge_setup_vnic() fails, the VNIC allocated above is not freed +* here; the caller (bnge_open_core) unwinds via its err_out path, +*/ +return bnge_setup_vnic (bn, vnic); +} + +int bnge_alloc_rfs_vnic (struct bnge_net *bn) +{ +struct bnge_vnic_info *vnic; + + vnic = &bn->vnic_info[BNGE_VNIC_NTUPLE ]; +return bnge_alloc_and_setup_vnic (bn, vnic, bn->bd->rx_nr_rings); +}
drivers/net/ethernet/broadcom/bnge/bnge_vnic.h +5 -2
@@ -21,13 +21,15 @@ struct bnge_l2_filter;#define BNGE_MAX_UC_ADDRS 4enum { -BNGE_VNIC_DEFAULT =0 +BNGE_VNIC_DEFAULT =0 , +BNGE_VNIC_NTUPLE =1 };enum {BNGE_VNIC_RSS_FLAG =BIT (0 ),BNGE_VNIC_MCAST_FLAG =BIT (1 ), -BNGE_VNIC_UCAST_FLAG =BIT (2 ) +BNGE_VNIC_UCAST_FLAG =BIT (2 ), +BNGE_VNIC_NTUPLE_FLAG =BIT (3 ) };struct bnge_vnic_info {
@@ -59,4 +61,5 @@ int bnge_hwrm_vnic_rss_cfg(struct bnge_net *bn, struct bnge_vnic_info *vnic);int bnge_setup_vnic (struct bnge_net *bn,struct bnge_vnic_info *vnic);void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd); +int bnge_alloc_rfs_vnic (struct bnge_net *bn);#endif /* _BNGE_VNIC_H_ */
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 4/11 bnge: add helper functions for multi RSS contexts
In reply to Vikas GuptaAdd infrastructure for creating, modifying, and deleting user-defined RSS contexts. This helps the next patch implement commands for ethtool. For each user RSS context, a VNIC is allocated.
--- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 2 + .../net/ethernet/broadcom/bnge/bnge_resc.c | 2 +- .../net/ethernet/broadcom/bnge/bnge_vnic.c | 113 ++++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_vnic.h | 15 +++ 4 files changed, 131 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +2 -0
@@ -371,6 +371,8 @@ struct bnge_net {u8 pri2cos_idx[8 ];bool pri2cos_valid; + +u16 num_rss_ctx; };#define BNGE_DEFAULT_RX_RING_SIZE 511
drivers/net/ethernet/broadcom/bnge/bnge_resc.c +1 -1
@@ -213,7 +213,7 @@ static u16 bnge_get_total_vnics(struct bnge_dev *bd)struct bnge_net *bn =netdev_priv (bd->netdev);if (bn->priv_flags &BNGE_NET_EN_NTUPLE ) -return 2 ; +return 2 + bn->num_rss_ctx; }else if (bnge_is_arfs_cap (bd)) {return 2 ; }
drivers/net/ethernet/broadcom/bnge/bnge_vnic.c +113 -0
116 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_vnic.h +15 -0
@@ -56,10 +56,25 @@ struct bnge_vnic_info {u32 vnic_id; }; +struct bnge_rss_ctx { +struct bnge_vnic_info vnic; +u32 index; +}; +void bnge_fill_hw_rss_tbl (struct bnge_net *bn,struct bnge_vnic_info *vnic);int bnge_hwrm_vnic_rss_cfg (struct bnge_net *bn,struct bnge_vnic_info *vnic);int bnge_setup_vnic (struct bnge_net *bn,struct bnge_vnic_info *vnic);void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd);int bnge_alloc_rfs_vnic (struct bnge_net *bn); +int bnge_alloc_vnic_rss_table (struct bnge_net *bn, +struct bnge_vnic_info *vnic); +struct bnge_rss_ctx *bnge_get_rss_ctx_from_index (struct bnge_net *bn,u32 idx); +void bnge_modify_rss (struct bnge_net *bn,struct ethtool_rxfh_context *ctx, +struct bnge_rss_ctx *rss_ctx, +const struct ethtool_rxfh_param *rxfh); +void bnge_del_one_rss_ctx (struct bnge_net *bn,struct bnge_rss_ctx *rss_ctx, +bool all); +void bnge_hwrm_realloc_rss_ctx_vnic (struct bnge_net *bn); +void bnge_clear_rss_ctxs (struct bnge_net *bn);#endif /* _BNGE_VNIC_H_ */
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 5/11 bnge: add RXFH ethtool support
In reply to Vikas GuptaIntroduce ethtool RXFH operations including get/set_rxfh for reading and programming the RSS hash key and indirection table.
Currently set_rxfh and set_rxfh_fields are supported only while the device is down. A future patch series will rework bnge_close_core()/bnge_open_core() so they can be driven safely from the ethtool path, adding full functionality by applying the configuration on a live device.
--- drivers/net/ethernet/broadcom/bnge/bnge.h | 1 + .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 276 ++++++++++++++++++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 2 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 17 +- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 2 + .../net/ethernet/broadcom/bnge/bnge_vnic.h | 1 + 6 files changed, 297 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge.h +1 -0
@@ -87,6 +87,7 @@ enum {BNGE_RSS_CAP_AH_V6_RSS_CAP =BIT (5 ),BNGE_RSS_CAP_ESP_V4_RSS_CAP =BIT (6 ),BNGE_RSS_CAP_ESP_V6_RSS_CAP =BIT (7 ), + BNGE_RSS_CAP_IPV6_FLOW_LABEL_RSS_CAP = BIT(8), };#define BNGE_MAX_QUEUE 8
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +276 -0
294 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +2 -0
@@ -676,6 +676,8 @@ int bnge_hwrm_vnic_qcaps(struct bnge_dev *bd) bd->rss_cap |=BNGE_RSS_CAP_ESP_V4_RSS_CAP ;if (flags &VNIC_QCAPS_RESP_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP ) bd->rss_cap |=BNGE_RSS_CAP_ESP_V6_RSS_CAP ; +if (flags &VNIC_QCAPS_RESP_FLAGS_RSS_IPV6_FLOW_LABEL_CAP ) + bd->rss_cap |=BNGE_RSS_CAP_IPV6_FLOW_LABEL_RSS_CAP ; }bnge_hwrm_req_drop (bd, req);
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +15 -2
@@ -772,6 +772,9 @@ static void bnge_free_tx_skbs(struct bnge_net *bn)u16 max_idx;int i; +if (!bn->tx_ring) +return ; + max_idx = bn->tx_nr_pages *TX_DESC_CNT ;for (i =0 ; i < bd->tx_nr_rings; i++) {struct bnge_tx_ring_info *txr = &bn->tx_ring[i];
@@ -883,6 +886,9 @@ static void bnge_free_rx_rings(struct bnge_net *bn)struct bnge_dev *bd = bn->bd;int i; +if (!bn->rx_ring) +return ; +bnge_free_tpa_info (bn);for (i =0 ; i < bd->rx_nr_rings; i++) {struct bnge_rx_ring_info *rxr = &bn->rx_ring[i];
@@ -1026,6 +1032,9 @@ static void bnge_free_tx_rings(struct bnge_net *bn)struct bnge_dev *bd = bn->bd;int i; +if (!bn->tx_ring) +return ; +for (i =0 ; i < bd->tx_nr_rings; i++) {struct bnge_tx_ring_info *txr = &bn->tx_ring[i];struct bnge_ring_struct *ring;
@@ -2723,7 +2732,7 @@ static int bnge_hwrm_if_change(struct bnge_dev *bd, bool up)return bnge_hwrm_req_send (bd, req); } -static int bnge_open_core (struct bnge_net *bn) +int bnge_open_core (struct bnge_net *bn) {struct bnge_dev *bd = bn->bd;int rc;
@@ -2993,10 +3002,14 @@ static void bnge_save_ring_stats(struct bnge_net *bn) } } -static void bnge_close_core (struct bnge_net *bn) +void bnge_close_core (struct bnge_net *bn) {struct bnge_dev *bd = bn->bd; +/* Already torn down (e.g. after a failed open/reconfiguration) */ +if (!bn->bnapi) +return ; +bnge_tx_disable (bn);clear_bit (BNGE_STATE_OPEN , &bd->state);
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +2 -0
@@ -579,4 +579,6 @@ int bnge_alloc_rx_netmem(struct bnge_net *bn, struct bnge_rx_ring_info *rxr, u16 prod, gfp_t gfp);void __bnge_queue_sp_work (struct bnge_net *bn);void bnge_copy_hw_masks (u64 *mask_arr,__le64 *hw_mask_arr,int count); +int bnge_open_core (struct bnge_net *bn); +void bnge_close_core (struct bnge_net *bn);#endif /* _BNGE_NETDEV_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_vnic.h +1 -0
@@ -15,6 +15,7 @@ struct bnge_l2_filter;#define BNGE_MAX_RSS_TABLE_ENTRIES \ (BNGE_RSS_TABLE_ENTRIES * BNGE_RSS_TABLE_MAX_TBL) +#define BNGE_MAX_ETH_RSS_CTX 32#define BNGE_MAX_CTX_PER_VNIC 8#define BNGE_MAX_MC_ADDRS 16
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 6/11 bnge: add ethtool support to manage RSS contexts
In reply to Vikas GuptaIntroduce ethtool callbacks to manage RSS contexts.
Each context allocates a dedicated VNIC with its own RSS indirection table and hash key, configured with TPA settings matching those of the default VNIC.
--- .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 163 ++++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_netdev.c | 9 + .../net/ethernet/broadcom/bnge/bnge_resc.c | 5 +- .../net/ethernet/broadcom/bnge/bnge_vnic.c | 31 +++- .../net/ethernet/broadcom/bnge/bnge_vnic.h | 14 +- 5 files changed, 214 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +163 -0
@@ -1004,6 +1004,166 @@ static u32 bnge_get_rx_ring_count(struct net_device *dev)return bd->rx_nr_rings; } +static int bnge_rxfh_context_check (struct bnge_net *bn, +const struct ethtool_rxfh_param *rxfh, +struct netlink_ext_ack *extack) +{ +if (rxfh->hfunc && rxfh->hfunc !=ETH_RSS_HASH_TOP ) { +NL_SET_ERR_MSG_MOD (extack,"RSS hash function not supported" ); +return -EOPNOTSUPP ; + } + +if (!(bn->priv_flags &BNGE_NET_EN_NTUPLE )) { +NL_SET_ERR_MSG_MOD (extack, +"Enable ntuple filtering before adding RSS contexts" ); +return -EOPNOTSUPP ; + } + +if (!netif_running (bn->netdev)) { +NL_SET_ERR_MSG_MOD (extack,"Unable to set RSS contexts when interface is down" ); +return -EAGAIN ; + } + +return 0 ; +} + +static int bnge_create_rxfh_context (struct net_device *dev, +struct ethtool_rxfh_context *ctx, +const struct ethtool_rxfh_param *rxfh, +struct netlink_ext_ack *extack) +{ +struct bnge_net *bn =netdev_priv (dev); +struct bnge_rss_ctx *rss_ctx; +struct bnge_vnic_info *vnic; +int rc; + + rc =bnge_rxfh_context_check (bn, rxfh, extack); +if (rc) +return rc; + +if (bn->num_rss_ctx >=BNGE_MAX_ETH_RSS_CTX ) { +NL_SET_ERR_MSG_FMT_MOD (extack,"Out of RSS contexts, maximum %u" , +BNGE_MAX_ETH_RSS_CTX ); +return -EINVAL ; + } + +if (!bnge_arfs_capable (bn->bd, true)) { +NL_SET_ERR_MSG_MOD (extack,"Out of hardware resources" ); +return -ENOMEM ; + } + + rss_ctx =ethtool_rxfh_context_priv (ctx); + + bn->num_rss_ctx++; + + vnic = &rss_ctx->vnic; + +bnge_init_vnic_mem (vnic); + + vnic->rss_ctx = ctx; + vnic->flags |=BNGE_VNIC_RSSCTX_FLAG ; + rc =bnge_alloc_vnic_rss_table (bn, vnic); +if (rc) + goto err_del_rss_ctx; + +/* Populate defaults in the context */ +bnge_set_dflt_rss_indir_tbl (bn->bd, ctx); + ctx->hfunc =ETH_RSS_HASH_TOP ; +memcpy (vnic->rss_hash_key, bn->rss_hash_key,HW_HASH_KEY_SIZE ); +memcpy (ethtool_rxfh_context_key (ctx), + bn->rss_hash_key,HW_HASH_KEY_SIZE ); + + rc =bnge_hwrm_vnic_alloc (bn->bd, vnic, bn->bd->rx_nr_rings); +if (rc) { +NL_SET_ERR_MSG_MOD (extack,"Unable to allocate VNIC" ); + goto err_del_rss_ctx; + } + + rc =bnge_hwrm_vnic_set_tpa (bn->bd, vnic, + bn->priv_flags &BNGE_NET_EN_TPA ); +if (rc) { +NL_SET_ERR_MSG_MOD (extack, +"Unable to set TPA settings to vnic" ); + goto err_del_rss_ctx; + } +bnge_modify_rss (bn, ctx, rss_ctx, rxfh); + + rc =bnge_setup_vnic (bn, vnic); +if (rc) { +NL_SET_ERR_MSG_MOD (extack,"Unable to setup vnic" ); + goto err_del_rss_ctx; + } + + rss_ctx->index = rxfh->rss_context; +return 0 ; + +err_del_rss_ctx: +bnge_del_one_rss_ctx (bn, rss_ctx, true); +return rc; +} + +static int bnge_modify_rxfh_context (struct net_device *dev, +struct ethtool_rxfh_context *ctx, +const struct ethtool_rxfh_param *rxfh, +struct netlink_ext_ack *extack) +{ +struct bnge_net *bn =netdev_priv (dev); +u8 old_key[HW_HASH_KEY_SIZE ]; +struct bnge_rss_ctx *rss_ctx; +u32 *old_indir =NULL ; +u32 tbl_size; +int rc; + + rc =bnge_rxfh_context_check (bn, rxfh, extack); +if (rc) +return rc; + + rss_ctx =ethtool_rxfh_context_priv (ctx); + tbl_size =bnge_get_rxfh_indir_size (bn->bd); + +/* Snapshot the software state so it can be restored if the hardware +* update fails, keeping the reported config consistent with the +* hardware. +*/ +if (rxfh->key) +memcpy (old_key, rss_ctx->vnic.rss_hash_key,HW_HASH_KEY_SIZE ); +if (rxfh->indir) { + old_indir =kmemdup (ethtool_rxfh_context_indir (ctx), + tbl_size *sizeof (*old_indir),GFP_KERNEL ); +if (!old_indir) +return -ENOMEM ; + } + +bnge_modify_rss (bn, ctx, rss_ctx, rxfh); + + rc =bnge_hwrm_vnic_rss_cfg (bn, &rss_ctx->vnic); +if (rc) { +if (rxfh->key) +memcpy (rss_ctx->vnic.rss_hash_key, old_key, +HW_HASH_KEY_SIZE ); +if (rxfh->indir) +memcpy (ethtool_rxfh_context_indir (ctx), old_indir, + tbl_size *sizeof (*old_indir)); + } + +kfree (old_indir); +return rc; +} + +static int bnge_remove_rxfh_context (struct net_device *dev, +struct ethtool_rxfh_context *ctx, +u32 rss_context, +struct netlink_ext_ack *extack) +{ +struct bnge_net *bn =netdev_priv (dev); +struct bnge_rss_ctx *rss_ctx; + + rss_ctx =ethtool_rxfh_context_priv (ctx); + +bnge_del_one_rss_ctx (bn, rss_ctx, true); +return 0 ; +} +static const struct ethtool_ops bnge_ethtool_ops = { .cap_link_lanes_supported =1 , .get_link_ksettings = bnge_get_link_ksettings,
@@ -1033,6 +1193,9 @@ static const struct ethtool_ops bnge_ethtool_ops = { .set_rxfh = bnge_set_rxfh, .get_rxfh_fields = bnge_get_rxfh_fields, .set_rxfh_fields = bnge_set_rxfh_fields, + .create_rxfh_context = bnge_create_rxfh_context, + .modify_rxfh_context = bnge_modify_rxfh_context, + .remove_rxfh_context = bnge_remove_rxfh_context, };void bnge_set_ethtool_ops (struct net_device *dev)
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +9 -0
@@ -2794,6 +2794,8 @@ int bnge_open_core(struct bnge_net *bn)/* Poll link status and check for SFP+ module status */ bnge_get_port_module_status (bn); +bnge_hwrm_realloc_rss_ctx_vnic (bn); +return 0 ; err_free_irq:
@@ -3015,7 +3017,10 @@ void bnge_close_core(struct bnge_net *bn)clear_bit (BNGE_STATE_OPEN , &bd->state);timer_delete_sync (&bn->timer); + +bnge_clear_rss_ctxs (bn);bnge_shutdown_nic (bn); +bnge_disable_napi (bn);/* Save ring stats before shutdown */
@@ -3149,6 +3154,10 @@ static int bnge_set_features(struct net_device *dev, netdev_features_t features)if (flags == bn->priv_flags)return 0 ; +if ((bn->priv_flags &BNGE_NET_EN_NTUPLE ) && + !(flags &BNGE_NET_EN_NTUPLE ) && bn->num_rss_ctx) +return -EBUSY ; + bn->priv_flags = flags;return 0 ;
drivers/net/ethernet/broadcom/bnge/bnge_resc.c +3 -2
@@ -352,8 +352,9 @@ int bnge_reserve_rings(struct bnge_dev *bd)if (!bnge_rings_ok (&hwr))return -ENOMEM ; -if (old_rx_rings != bd->hw_resc.resv_rx_rings) -bnge_set_dflt_rss_indir_tbl (bd); +if (old_rx_rings != bd->hw_resc.resv_rx_rings && + (!bd->netdev || !netif_is_rxfh_configured (bd->netdev))) +bnge_set_dflt_rss_indir_tbl (bd,NULL );if (!bnge_aux_registered (bd)) {u16 resv_msix, resv_ctx, aux_ctxs;
drivers/net/ethernet/broadcom/bnge/bnge_vnic.c +27 -4
@@ -12,21 +12,26 @@#include "bnge_filter.h" #include "bnge_ethtool.h" -void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd) +void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd, +struct ethtool_rxfh_context *rss_ctx) {u16 max_entries, pad;u32 *rss_indir_tbl;u16 i; max_entries =bnge_get_rxfh_indir_size (bd); - rss_indir_tbl = &bd->rss_indir_tbl[0 ]; + +if (rss_ctx) + rss_indir_tbl =ethtool_rxfh_context_indir (rss_ctx); +else + rss_indir_tbl = &bd->rss_indir_tbl[0 ];for (i =0 ; i < max_entries; i++) rss_indir_tbl[i] =ethtool_rxfh_indir_default (i, bd->rx_nr_rings); pad = bd->rss_indir_tbl_entries - max_entries; -if (pad) +if (pad && !rss_ctx)memset (&rss_indir_tbl[i],0 , pad *sizeof (*rss_indir_tbl)); }
@@ -44,6 +49,8 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic)if (vnic->flags &BNGE_VNIC_NTUPLE_FLAG ) j =ethtool_rxfh_indir_default (i, bd->rx_nr_rings); +else if (vnic->flags &BNGE_VNIC_RSSCTX_FLAG ) + j =ethtool_rxfh_context_indir (vnic->rss_ctx)[i];else j = bd->rss_indir_tbl[i];
@@ -155,7 +162,7 @@ void bnge_modify_rss(struct bnge_net *bn, struct ethtool_rxfh_context *ctx,for (i =0 ; i < tbl_size; i++) indir_tbl[i] = rxfh->indir[i]; pad = bd->rss_indir_tbl_entries - tbl_size; -if (pad) +if (pad && !rss_ctx)memset (&indir_tbl[i],0 , pad *sizeof (*indir_tbl)); } }
@@ -188,6 +195,10 @@ void bnge_hwrm_realloc_rss_ctx_vnic(struct bnge_net *bn)struct ethtool_rxfh_context *ctx;unsigned long context; +/* Erasing lost contexts touches netdev->ethtool->rss_ctx and calls +* ethtool_rxfh_context_lost(), which requires the ethtool rss_lock. +*/ +mutex_lock (&bn->netdev->ethtool->rss_lock);xa_for_each (&bn->netdev->ethtool->rss_ctx, context, ctx) {struct bnge_rss_ctx *rss_ctx =ethtool_rxfh_context_priv (ctx);struct bnge_vnic_info *vnic = &rss_ctx->vnic;
@@ -201,6 +212,7 @@ void bnge_hwrm_realloc_rss_ctx_vnic(struct bnge_net *bn)ethtool_rxfh_context_lost (bn->netdev, rss_ctx->index); } } +mutex_unlock (&bn->netdev->ethtool->rss_lock); }void bnge_clear_rss_ctxs (struct bnge_net *bn)
@@ -242,3 +254,14 @@ int bnge_alloc_vnic_rss_table(struct bnge_net *bn, vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size;return 0 ; } + +void bnge_init_vnic_mem (struct bnge_vnic_info *vnic) +{ +int i; + + vnic->fw_vnic_id =INVALID_HW_RING_ID ; + vnic->vnic_id =BNGE_VNIC_ID_INVALID ; + +for (i =0 ; i <BNGE_MAX_CTX_PER_VNIC ; i++) + vnic->fw_rss_cos_lb_ctx[i] =INVALID_HW_RING_ID ; +}
drivers/net/ethernet/broadcom/bnge/bnge_vnic.h +12 -2
@@ -21,6 +21,11 @@ struct bnge_l2_filter;#define BNGE_MAX_MC_ADDRS 16#define BNGE_MAX_UC_ADDRS 4 +#define BNGE_VNIC_ID_INVALID 0xffffffff + +struct ethtool_rxfh_context ; +struct ethtool_rxfh_param ; +enum {BNGE_VNIC_DEFAULT =0 ,BNGE_VNIC_NTUPLE =1
@@ -30,7 +35,8 @@ enum {BNGE_VNIC_RSS_FLAG =BIT (0 ),BNGE_VNIC_MCAST_FLAG =BIT (1 ),BNGE_VNIC_UCAST_FLAG =BIT (2 ), -BNGE_VNIC_NTUPLE_FLAG =BIT (3 ) +BNGE_VNIC_NTUPLE_FLAG =BIT (3 ), +BNGE_VNIC_RSSCTX_FLAG =BIT (4 ) }; struct bnge_vnic_info {
@@ -55,6 +61,8 @@ struct bnge_vnic_info {u32 flags;u32 vnic_id; + +struct ethtool_rxfh_context *rss_ctx; };struct bnge_rss_ctx {
@@ -66,7 +74,8 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic);int bnge_hwrm_vnic_rss_cfg (struct bnge_net *bn,struct bnge_vnic_info *vnic);int bnge_setup_vnic (struct bnge_net *bn,struct bnge_vnic_info *vnic); -void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd); +void bnge_set_dflt_rss_indir_tbl (struct bnge_dev *bd, +struct ethtool_rxfh_context *ctx);int bnge_alloc_rfs_vnic (struct bnge_net *bn);int bnge_alloc_vnic_rss_table (struct bnge_net *bn,struct bnge_vnic_info *vnic);
@@ -78,4 +87,5 @@ void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx, bool all);void bnge_hwrm_realloc_rss_ctx_vnic (struct bnge_net *bn);void bnge_clear_rss_ctxs (struct bnge_net *bn); +void bnge_init_vnic_mem (struct bnge_vnic_info *vnic);#endif /* _BNGE_VNIC_H_ */
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 7/11 bnge: remove refcount from L2 filter
In reply to Vikas GuptaA reference count was previously used under the assumption that any context holding the last reference could delete the L2 filter.
However, going forward, the filter will only be removed by the same context that created it, making refcount unnecessary.
The primary and secondary MAC addresses passed by the kernel are guaranteed to be distinct, so each results in a filter being created exactly once.
--- .../net/ethernet/broadcom/bnge/bnge_filter.c | 28 ++++--------------- .../net/ethernet/broadcom/bnge/bnge_filter.h | 1 - 2 files changed, 6 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge_filter.c +6 -22
@@ -13,8 +13,6 @@void bnge_del_l2_filter (struct bnge_net *bn,struct bnge_l2_filter *fltr) { -if (!refcount_dec_and_test (&fltr->refcnt)) -return ;hlist_del_rcu (&fltr->base.hlist);kfree_rcu (fltr, base.rcu); }
@@ -31,18 +29,17 @@ static void bnge_init_l2_filter(struct bnge_net *bn, head = &bn->l2_fltr_hash_tbl[idx];hlist_add_head_rcu (&fltr->base.hlist, head); -refcount_set (&fltr->refcnt,1 ); } -static struct bnge_l2_filter *__bnge_lookup_l2_filter (struct bnge_net *bn, -struct bnge_l2_key *key, -u32 idx) +struct bnge_l2_filter *bnge_lookup_l2_filter (struct bnge_net *bn, +struct bnge_l2_key *key, +u32 idx) {struct bnge_l2_filter *fltr;struct hlist_head *head; head = &bn->l2_fltr_hash_tbl[idx]; -hlist_for_each_entry_rcu (fltr, head, base.hlist) { +hlist_for_each_entry (fltr, head, base.hlist) {struct bnge_l2_key *l2_key = &fltr->l2_key; if (ether_addr_equal(l2_key->dst_mac_addr, key->dst_mac_addr) &&
@@ -52,20 +49,6 @@ static struct bnge_l2_filter *__bnge_lookup_l2_filter(struct bnge_net *bn,return NULL ; } -struct bnge_l2_filter *bnge_lookup_l2_filter (struct bnge_net *bn, -struct bnge_l2_key *key, -u32 idx) -{ -struct bnge_l2_filter *fltr; - -rcu_read_lock (); - fltr =__bnge_lookup_l2_filter (bn, key, idx); -if (fltr) -refcount_inc (&fltr->refcnt); -rcu_read_unlock (); -return fltr; -} -static struct bnge_l2_filter *bnge_alloc_l2_filter (struct bnge_net *bn,struct bnge_l2_key *key,gfp_t gfp)
@@ -75,9 +58,10 @@ static struct bnge_l2_filter *bnge_alloc_l2_filter(struct bnge_net *bn, idx =jhash2 (&key->filter_key,BNGE_L2_KEY_SIZE , bn->hash_seed) &BNGE_L2_FLTR_HASH_MASK ; + fltr =bnge_lookup_l2_filter (bn, key, idx);if (fltr) -return fltr; +return ERR_PTR (-EEXIST ); fltr =kzalloc_obj (*fltr, gfp);if (!fltr)
drivers/net/ethernet/broadcom/bnge/bnge_filter.h +0 -1
@@ -42,7 +42,6 @@ struct bnge_l2_filter {/* base filter must be the first member */ struct bnge_filter_base base;struct bnge_l2_key l2_key; -refcount_t refcnt; };void bnge_del_l2_filter (struct bnge_net *bn,struct bnge_l2_filter *fltr);
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 8/11 bnge: add NTUPLE filter infrastructure
In reply to Vikas GuptaAdd the core NTUPLE filter data structures and firmware command wrappers needed for flow rule management.
This helps further patches implement user-created NTUPLE rules as well as rules via kernel flow steering.
--- drivers/net/ethernet/broadcom/bnge/bnge.h | 1 - .../net/ethernet/broadcom/bnge/bnge_filter.c | 494 +++++++++++++++++- .../net/ethernet/broadcom/bnge/bnge_filter.h | 69 ++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 143 ++++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 7 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 14 + .../net/ethernet/broadcom/bnge/bnge_netdev.h | 13 + .../net/ethernet/broadcom/bnge/bnge_resc.c | 6 +- .../net/ethernet/broadcom/bnge/bnge_vnic.c | 17 + 9 files changed, 751 insertions(+), 13 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge.h +0 -1
@@ -161,7 +161,6 @@ struct bnge_dev {u16 tso_max_segs;int max_fltr; -#define BNGE_L2_FLTR_MAX_FLTR 1024u32 *rss_indir_tbl;u16 rss_indir_tbl_entries;
drivers/net/ethernet/broadcom/bnge/bnge_filter.c +488 -6
546 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_filter.h +68 -1
98 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +142 -1
159 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h +7 -0
@@ -13,6 +13,8 @@ struct bnge_l2_filter;#define BNGE_VNIC_CFG_ROCE_DUAL_MODE \ VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE +struct bnge_ntuple_filter ; +int bnge_hwrm_ver_get (struct bnge_dev *bd);int bnge_hwrm_func_reset (struct bnge_dev *bd);int bnge_hwrm_fw_set_time (struct bnge_dev *bd);
@@ -68,4 +70,9 @@ int bnge_hwrm_port_qstats(struct bnge_dev *bd, u8 flags);int bnge_hwrm_port_qstats_ext (struct bnge_dev *bd,u8 flags);int bnge_hwrm_func_qstat_ext (struct bnge_dev *bd,struct bnge_stats_mem *stats);int bnge_hwrm_cfa_adv_flow_mgnt_qcaps (struct bnge_dev *bd); + +int bnge_hwrm_cfa_ntuple_filter_alloc (struct bnge_dev *bd, +struct bnge_ntuple_filter *fltr); +int bnge_hwrm_cfa_ntuple_filter_free (struct bnge_dev *bd, +struct bnge_ntuple_filter *fltr);#endif /* _BNGE_HWRM_LIB_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +14 -0
@@ -1214,6 +1214,10 @@ static void bnge_free_core(struct bnge_net *bn)bnge_free_ring_stats (bn);bnge_free_ring_grps (bn);bnge_free_vnics (bn); + +/* Free non-user filters only */ +bnge_free_ntp_fltrs (bn, true); +kfree (bn->tx_ring_map); bn->tx_ring_map =NULL ;kfree (bn->tx_ring);
@@ -1302,6 +1306,10 @@ static int bnge_alloc_core(struct bnge_net *bn)bnge_init_stats (bn); + rc =bnge_fltrs_mem (bn); +if (rc) + goto err_free_core; + rc =bnge_alloc_vnics (bn);if (rc) goto err_free_core;
@@ -3428,6 +3436,9 @@ int bnge_netdev_alloc(struct bnge_dev *bd, int max_irqs) goto err_free_workq;spin_lock_init (&bn->stats_lock); +spin_lock_init (&bn->ntp_fltr_lock); +INIT_LIST_HEAD (&bn->usr_fltr_list); + netdev->request_ops_lock = true; rc =register_netdev (netdev);if (rc) {
@@ -3455,6 +3466,9 @@ void bnge_netdev_free(struct bnge_dev *bd)unregister_netdev (netdev); +bnge_free_ntp_fltrs (bn, false); +bnge_free_l2_filters (bn); +timer_shutdown_sync (&bn->timer);cancel_work_sync (&bn->sp_task); bn->sp_event =0 ;
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +13 -0
@@ -284,6 +284,9 @@ enum bnge_sp_event { BNGE_PERIODIC_STATS_SP_EVENT, }; +#define BNGE_NTP_FLTR_HASH_SIZE 512 +#define BNGE_NTP_FLTR_HASH_MASK (BNGE_NTP_FLTR_HASH_SIZE - 1) +struct bnge_net {struct bnge_dev *bd;struct net_device *netdev;
@@ -373,6 +376,16 @@ struct bnge_net {bool pri2cos_valid;u16 num_rss_ctx; + +struct list_head usr_fltr_list; +unsigned long *ntp_fltr_bmap; +unsigned long *l2_fltr_bmap; +int ntp_fltr_count; +int l2_fltr_count; +int user_fltr_count; + +struct hlist_head ntp_fltr_hash_tbl[BNGE_NTP_FLTR_HASH_SIZE ]; +spinlock_t ntp_fltr_lock;/* for hash table add, del */ };#define BNGE_DEFAULT_RX_RING_SIZE 511
drivers/net/ethernet/broadcom/bnge/bnge_resc.c +2 -4
@@ -12,6 +12,7 @@#include "bnge_hwrm_lib.h" #include "bnge_resc.h" #include "bnge_vnic.h" +#include "bnge_filter.h" static u16 bnge_num_tx_to_cp (struct bnge_dev *bd,u16 tx) {
@@ -634,7 +635,6 @@ bool bnge_arfs_capable(struct bnge_dev *bd, bool new_rss_ctx)int bnge_net_init_dflt_config (struct bnge_dev *bd) { -struct bnge_hw_resc *hw_resc;int rc; rc =bnge_alloc_rss_indir_tbl (bd);
@@ -648,9 +648,7 @@ int bnge_net_init_dflt_config(struct bnge_dev *bd)if (bnge_arfs_capable (bd, false)) bd->flags |=BNGE_EN_ARFS_CAP ; - hw_resc = &bd->hw_resc; - bd->max_fltr = hw_resc->max_rx_em_flows + hw_resc->max_rx_wm_flows + -BNGE_L2_FLTR_MAX_FLTR ; + bd->max_fltr =BNGE_MAX_NTUPLE_FLTRS ;return 0 ;
drivers/net/ethernet/broadcom/bnge/bnge_vnic.c +17 -0
@@ -171,8 +171,13 @@ void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx, bool all) {struct bnge_vnic_info *vnic = &rss_ctx->vnic; +struct bnge_filter_base *usr_fltr, *tmp; +struct bnge_ntuple_filter *ntp_fltr;int i; +/* freeing the VNIC first is fine, the other HW resources +* can be freed independently. +*/ bnge_hwrm_vnic_free_one (bn->bd, &rss_ctx->vnic);for (i =0 ; i <BNGE_MAX_CTX_PER_VNIC ; i++) {if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID )
@@ -182,6 +187,18 @@ void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx,if (!all)return ; +/* Delete all filters associated with this user RSS context */ +list_for_each_entry_safe (usr_fltr, tmp, &bn->usr_fltr_list, list_node) { +if ((usr_fltr->flags &BNGE_ACT_RSS_CTX ) && + usr_fltr->fw_vnic_id == rss_ctx->index) { + ntp_fltr =container_of (usr_fltr, + struct bnge_ntuple_filter, + base); +bnge_hwrm_cfa_ntuple_filter_free (bn->bd, ntp_fltr); +bnge_del_ntp_filter_rcu (bn, ntp_fltr); + } + } +if (vnic->rss_table) dma_free_coherent(bn->bd->dev, vnic->rss_table_size, vnic->rss_table,
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 9/11 bnge: add NTUPLE filter support in ethtool
In reply to Vikas GuptaIntroduce ethtool rx flow classification (rxnfc) operations for NTUPLE filter management.
Since with ethtool support user filters creation is supported, when interface is down clearing of filters which are in software remains intact.
--- .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 591 ++++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_filter.c | 60 ++ .../net/ethernet/broadcom/bnge/bnge_filter.h | 2 + .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 8 +- .../net/ethernet/broadcom/bnge/bnge_netdev.c | 4 + 5 files changed, 662 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +591 -0
@@ -15,6 +15,7 @@#include "bnge_resc.h" #include "bnge_ethtool.h" #include "bnge_hwrm_lib.h" +#include "bnge_filter.h" static int bnge_nway_reset (struct net_device *dev) {
@@ -1164,6 +1165,594 @@ static int bnge_remove_rxfh_context(struct net_device *dev,return 0 ; } +#define BNGE_IP_PROTO_FULL_MASK 0xFF +#define BNGE_IP_PROTO_WILDCARD 0x0 + +static u32 bnge_get_all_fltr_ids_rcu (struct bnge_net *bn, +struct hlist_head tbl[], +u32 tbl_size,u32 *ids,u32 start, +u32 id_cnt,u32 offset) +{ +u32 i, j = start; + +if (j >= id_cnt) +return j; + +for (i =0 ; i < tbl_size; i++) { +struct bnge_filter_base *fltr; +struct hlist_head *head; + + head = &tbl[i]; +hlist_for_each_entry_rcu (fltr, head, hlist) { +if (!fltr->flags || +test_bit (BNGE_FLTR_FW_DELETED , &fltr->state)) +continue ; + ids[j++] = fltr->sw_id + offset; +if (j == id_cnt) +return j; + } + } +return j; +} + +static struct bnge_filter_base *bnge_get_one_fltr_rcu (struct bnge_net *bn, +struct hlist_head tbl[], +u32 tbl_size,u32 id, +u32 offset) +{ +u32 i; + +for (i =0 ; i < tbl_size; i++) { +struct bnge_filter_base *fltr; +struct hlist_head *head; + + head = &tbl[i]; +hlist_for_each_entry_rcu (fltr, head, hlist) { +if (fltr->flags && fltr->sw_id + offset == id) +return fltr; + } + } +return NULL ; +} + +static int bnge_grxclsrlall (struct bnge_net *bn,struct ethtool_rxnfc *cmd, +u32 *rule_locs) +{ +u32 count; + + cmd->data = bn->user_fltr_count; +rcu_read_lock (); + count =bnge_get_all_fltr_ids_rcu (bn, bn->l2_fltr_hash_tbl, +BNGE_L2_FLTR_HASH_SIZE , rule_locs,0 , + cmd->rule_cnt,0 ); + cmd->rule_cnt =bnge_get_all_fltr_ids_rcu (bn, bn->ntp_fltr_hash_tbl, +BNGE_NTP_FLTR_HASH_SIZE , + rule_locs, count, + cmd->rule_cnt, +BNGE_MAX_L2_FLTRS ); +rcu_read_unlock (); + +return 0 ; +} + +static int bnge_grxclsrule (struct bnge_net *bn,struct ethtool_rxnfc *cmd) +{ +struct ethtool_rx_flow_spec *fs = + (struct ethtool_rx_flow_spec *)&cmd->fs; +struct bnge_filter_base *fltr_base; +struct bnge_ntuple_filter *fltr; +struct bnge_flow_masks *fmasks; +struct bnge_dev *bd = bn->bd; +struct flow_keys *fkeys; +int rc = -EINVAL ; + +if (fs->location >=BNGE_MAX_L2_FLTRS + bd->max_fltr) +return rc; + +rcu_read_lock (); + fltr_base =bnge_get_one_fltr_rcu (bn, bn->l2_fltr_hash_tbl, +BNGE_L2_FLTR_HASH_SIZE , + fs->location,0 ); +if (fltr_base) { +struct ethhdr *h_ether = &fs->h_u.ether_spec; +struct ethhdr *m_ether = &fs->m_u.ether_spec; +struct bnge_l2_filter *l2_fltr; +struct bnge_l2_key *l2_key; + + l2_fltr = container_of(fltr_base, struct bnge_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 &BNGE_ACT_RING_DST ) + fs->ring_cookie = fltr_base->rxq; +rcu_read_unlock (); +return 0 ; + } + fltr_base =bnge_get_one_fltr_rcu (bn, bn->ntp_fltr_hash_tbl, +BNGE_NTP_FLTR_HASH_SIZE , + fs->location,BNGE_MAX_L2_FLTRS ); +if (!fltr_base) { +rcu_read_unlock (); +return rc; + } + fltr = container_of(fltr_base, struct bnge_ntuple_filter, base); + + fkeys = &fltr->fkeys; + fmasks = &fltr->fmasks; +if (fkeys->basic.n_proto ==htons (ETH_P_IP )) { +if (fkeys->basic.ip_proto ==BNGE_IP_PROTO_WILDCARD ) { + fs->flow_type =IP_USER_FLOW ; + fs->h_u.usr_ip4_spec.ip_ver =ETH_RX_NFC_IP4 ; + fs->h_u.usr_ip4_spec.proto =BNGE_IP_PROTO_WILDCARD ; + fs->m_u.usr_ip4_spec.proto =0 ; + }else if (fkeys->basic.ip_proto ==IPPROTO_ICMP ) { + fs->flow_type =IP_USER_FLOW ; + fs->h_u.usr_ip4_spec.ip_ver =ETH_RX_NFC_IP4 ; + fs->h_u.usr_ip4_spec.proto =IPPROTO_ICMP ; + fs->m_u.usr_ip4_spec.proto =BNGE_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 ) { + fs->flow_type =UDP_V4_FLOW ; + }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; +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 ==BNGE_IP_PROTO_WILDCARD ) { + fs->flow_type =IPV6_USER_FLOW ; + fs->h_u.usr_ip6_spec.l4_proto = +BNGE_IP_PROTO_WILDCARD ; + fs->m_u.usr_ip6_spec.l4_proto =0 ; + }else if (fkeys->basic.ip_proto ==IPPROTO_ICMPV6 ) { + fs->flow_type =IPV6_USER_FLOW ; + fs->h_u.usr_ip6_spec.l4_proto =IPPROTO_ICMPV6 ; + fs->m_u.usr_ip6_spec.l4_proto = +BNGE_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 ) { + fs->flow_type =UDP_V6_FLOW ; + }else { + goto fltr_err; + } + +memcpy (fs->h_u.tcp_ip6_spec.ip6src, + &fkeys->addrs.v6addrs.src, +sizeof (struct in6_addr )); +memcpy (fs->m_u.tcp_ip6_spec.ip6src, + &fmasks->addrs.v6addrs.src, +sizeof (struct in6_addr )); +memcpy (fs->h_u.tcp_ip6_spec.ip6dst, + &fkeys->addrs.v6addrs.dst, +sizeof (struct in6_addr )); +memcpy (fs->m_u.tcp_ip6_spec.ip6dst, + &fmasks->addrs.v6addrs.dst, +sizeof (struct in6_addr )); + +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; + } + } + +if (fltr->base.flags &BNGE_ACT_DROP ) { + fs->ring_cookie =RX_CLS_FLOW_DISC ; + }else if (fltr->base.flags &BNGE_ACT_RSS_CTX ) { + fs->flow_type |=FLOW_RSS ; + cmd->rss_context = fltr->base.fw_vnic_id; + }else { + fs->ring_cookie = fltr->base.rxq; + } + rc =0 ; + +fltr_err: +rcu_read_unlock (); + +return rc; +} + +static bool bnge_verify_ntuple_ip4_flow (struct ethtool_usrip4_spec *ip_spec, +struct ethtool_usrip4_spec *ip_mask) +{ +u8 mproto = ip_mask->proto; +u8 sproto = ip_spec->proto; + +if (ip_mask->l4_4_bytes || ip_mask->tos || + ip_spec->ip_ver !=ETH_RX_NFC_IP4 || + (mproto && (mproto !=BNGE_IP_PROTO_FULL_MASK || + sproto !=IPPROTO_ICMP ))) +return false; +return true; +} + +static bool bnge_verify_ntuple_ip6_flow (struct ethtool_usrip6_spec *ip_spec, +struct ethtool_usrip6_spec *ip_mask) +{ +u8 mproto = ip_mask->l4_proto; +u8 sproto = ip_spec->l4_proto; + +if (ip_mask->l4_4_bytes || ip_mask->tclass || + (mproto && (mproto !=BNGE_IP_PROTO_FULL_MASK || + sproto !=IPPROTO_ICMPV6 ))) +return false; +return true; +} + +static int bnge_add_ntuple_cls_rule (struct bnge_net *bn, +struct ethtool_rxnfc *cmd) +{ +struct ethtool_rx_flow_spec *fs = &cmd->fs; +struct bnge_ntuple_filter *new_fltr, *fltr; +u32 flow_type = fs->flow_type &0xff ; +struct bnge_l2_filter *l2_fltr; +struct bnge_flow_masks *fmasks; +struct flow_keys *fkeys; +u32 idx; +int rc; + +if (!bn->vnic_info) +return -EAGAIN ; + +if (fs->flow_type & (FLOW_MAC_EXT |FLOW_EXT )) +return -EOPNOTSUPP ; + +if (fs->ring_cookie !=RX_CLS_FLOW_DISC && +ethtool_get_flow_spec_ring_vf (fs->ring_cookie)) +return -EOPNOTSUPP ; + +if (flow_type ==IP_USER_FLOW ) { +if (!bnge_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 (!bnge_verify_ntuple_ip6_flow (&fs->h_u.usr_ip6_spec, + &fs->m_u.usr_ip6_spec)) +return -EOPNOTSUPP ; + } + + new_fltr =kzalloc_obj (*new_fltr,GFP_KERNEL ); +if (!new_fltr) +return -ENOMEM ; + + l2_fltr = bn->vnic_info[BNGE_VNIC_DEFAULT ].l2_filters[0 ]; + new_fltr->l2_filter_id = l2_fltr->base.filter_id; + fmasks = &new_fltr->fmasks; + fkeys = &new_fltr->fkeys; + + 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_mask->proto ? ip_spec->proto + :BNGE_IP_PROTO_WILDCARD ; + 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; +struct ethtool_tcpip4_spec *ip_mask = &fs->m_u.tcp_ip4_spec; + +if (ip_mask->tos) + goto err_free_fltr; + + fkeys->basic.ip_proto =IPPROTO_TCP ; +if (flow_type ==UDP_V4_FLOW ) + fkeys->basic.ip_proto =IPPROTO_UDP ; + 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; + 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 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_mask->l4_proto ? ip_spec->l4_proto + :BNGE_IP_PROTO_WILDCARD ; + fkeys->basic.n_proto =htons (ETH_P_IPV6 ); + +memcpy (&fkeys->addrs.v6addrs.src, ip_spec->ip6src, +sizeof (struct in6_addr )); +memcpy (&fmasks->addrs.v6addrs.src, ip_mask->ip6src, +sizeof (struct in6_addr )); +memcpy (&fkeys->addrs.v6addrs.dst, ip_spec->ip6dst, +sizeof (struct in6_addr )); +memcpy (&fmasks->addrs.v6addrs.dst, ip_mask->ip6dst, +sizeof (struct in6_addr )); +break ; + } +case TCP_V6_FLOW : +case UDP_V6_FLOW : { +struct ethtool_tcpip6_spec *ip_spec = &fs->h_u.tcp_ip6_spec; +struct ethtool_tcpip6_spec *ip_mask = &fs->m_u.tcp_ip6_spec; + +if (ip_mask->tclass) + goto err_free_fltr; + + fkeys->basic.ip_proto =IPPROTO_TCP ; +if (flow_type ==UDP_V6_FLOW ) + fkeys->basic.ip_proto =IPPROTO_UDP ; + fkeys->basic.n_proto =htons (ETH_P_IPV6 ); + +memcpy (&fkeys->addrs.v6addrs.src, ip_spec->ip6src, +sizeof (struct in6_addr )); +memcpy (&fmasks->addrs.v6addrs.src, ip_mask->ip6src, +sizeof (struct in6_addr )); +memcpy (&fkeys->addrs.v6addrs.dst, ip_spec->ip6dst, +sizeof (struct in6_addr )); +memcpy (&fmasks->addrs.v6addrs.dst, ip_mask->ip6dst, +sizeof (struct in6_addr )); + + 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 err_free_fltr; + } +if (!memcmp (&BNGE_FLOW_MASK_NONE , fmasks,sizeof (*fmasks))) + goto err_free_fltr; + + idx =bnge_get_ntp_filter_idx (bn, fkeys,NULL ); +rcu_read_lock (); + fltr =bnge_lookup_ntp_filter_from_idx (bn, new_fltr, idx); +if (fltr) { +rcu_read_unlock (); + rc = -EEXIST ; + goto err_free_fltr; + } +rcu_read_unlock (); + + new_fltr->base.flags =BNGE_ACT_NO_AGING ; +if (fs->flow_type &FLOW_RSS ) { +struct bnge_rss_ctx *rss_ctx; + + new_fltr->base.fw_vnic_id =0 ; + new_fltr->base.flags |=BNGE_ACT_RSS_CTX ; + rss_ctx =bnge_get_rss_ctx_from_index (bn, cmd->rss_context); +if (rss_ctx) { + new_fltr->base.fw_vnic_id = rss_ctx->index; + }else { + rc = -EINVAL ; + goto err_free_fltr; + } + } +if (fs->ring_cookie ==RX_CLS_FLOW_DISC ) + new_fltr->base.flags |=BNGE_ACT_DROP ; +else + new_fltr->base.rxq =ethtool_get_flow_spec_ring (fs->ring_cookie); +__set_bit (BNGE_FLTR_VALID , &new_fltr->base.state); + rc =bnge_insert_ntp_filter (bn, new_fltr, idx); +if (!rc) { + rc =bnge_hwrm_cfa_ntuple_filter_alloc (bn->bd, new_fltr); +if (rc) { +bnge_del_ntp_filter_rcu (bn, new_fltr); +return rc; + } + fs->location =BNGE_MAX_L2_FLTRS + new_fltr->base.sw_id; +return 0 ; + } + +err_free_fltr: +kfree (new_fltr); +return rc; +} + +static int bnge_add_l2_cls_rule (struct bnge_net *bn, +struct ethtool_rx_flow_spec *fs) +{ +u32 ring =ethtool_get_flow_spec_ring (fs->ring_cookie); +struct ethhdr *h_ether = &fs->h_u.ether_spec; +struct ethhdr *m_ether = &fs->m_u.ether_spec; +struct bnge_l2_filter *fltr; +struct bnge_l2_key key; +u16 vnic_id; +u8 flags; +int rc; + +if (ethtool_get_flow_spec_ring_vf (fs->ring_cookie)) +return -EOPNOTSUPP ; + +if (!is_broadcast_ether_addr (m_ether->h_dest)) +return -EINVAL ; + +if (is_broadcast_ether_addr (h_ether->h_dest) || +is_multicast_ether_addr (h_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); + } + + flags =BNGE_ACT_RING_DST ; + vnic_id = bn->vnic_info[BNGE_VNIC_DEFAULT ].fw_vnic_id; + + fltr =bnge_alloc_user_l2_filter (bn, &key, flags); +if (IS_ERR (fltr)) +return PTR_ERR (fltr); + + fltr->base.fw_vnic_id = vnic_id; + fltr->base.rxq = ring; + rc =bnge_hwrm_l2_filter_alloc (bn->bd, fltr); +if (rc) +bnge_del_l2_filter_rcu (bn, fltr); +else + fs->location = fltr->base.sw_id; +return rc; +} + +static int bnge_srxclsrlins (struct bnge_net *bn,struct ethtool_rxnfc *cmd) +{ +struct ethtool_rx_flow_spec *fs = &cmd->fs; +struct bnge_dev *bd = bn->bd; +u32 ring, flow_type; +int rc; + +if (!netif_running (bn->netdev)) +return -EAGAIN ; +if (!(bn->priv_flags &BNGE_NET_EN_NTUPLE )) +return -EPERM ; +if (fs->location !=RX_CLS_LOC_ANY ) +return -EINVAL ; + + flow_type = fs->flow_type; + +if (flow_type &FLOW_MAC_EXT ) +return -EINVAL ; + + flow_type &= ~FLOW_EXT ; + +if (fs->ring_cookie ==RX_CLS_FLOW_DISC && flow_type !=ETHER_FLOW ) +return bnge_add_ntuple_cls_rule (bn, cmd); + + ring =ethtool_get_flow_spec_ring (fs->ring_cookie); +if (ring >= bd->rx_nr_rings) +return -EINVAL ; + +if (flow_type ==ETHER_FLOW ) + rc =bnge_add_l2_cls_rule (bn, fs); +else + rc =bnge_add_ntuple_cls_rule (bn, cmd); +return rc; +} + +static int bnge_srxclsrldel (struct bnge_net *bn,struct ethtool_rxnfc *cmd) +{ +struct ethtool_rx_flow_spec *fs = &cmd->fs; +struct bnge_filter_base *fltr_base; +struct bnge_ntuple_filter *fltr; +u32 id = fs->location; + +rcu_read_lock (); + fltr_base =bnge_get_one_fltr_rcu (bn, bn->l2_fltr_hash_tbl, +BNGE_L2_FLTR_HASH_SIZE , id,0 ); +if (fltr_base) { +struct bnge_l2_filter *l2_fltr; + + l2_fltr = container_of(fltr_base, struct bnge_l2_filter, base); +rcu_read_unlock (); +bnge_hwrm_l2_filter_free (bn->bd, l2_fltr); +bnge_del_l2_filter_rcu (bn, l2_fltr); +return 0 ; + } + fltr_base =bnge_get_one_fltr_rcu (bn, bn->ntp_fltr_hash_tbl, +BNGE_NTP_FLTR_HASH_SIZE , id, +BNGE_MAX_L2_FLTRS ); +if (!fltr_base) { +rcu_read_unlock (); +return -ENOENT ; + } + + fltr = container_of(fltr_base, struct bnge_ntuple_filter, base); +if (!(fltr->base.flags &BNGE_ACT_NO_AGING )) { +rcu_read_unlock (); +return -EINVAL ; + } +rcu_read_unlock (); +bnge_hwrm_cfa_ntuple_filter_free (bn->bd, fltr); +bnge_del_ntp_filter_rcu (bn, fltr); +return 0 ; +} + +static int bnge_get_rxnfc (struct net_device *dev,struct ethtool_rxnfc *cmd, +u32 *rule_locs) +{ +struct bnge_net *bn =netdev_priv (dev); +struct bnge_dev *bd = bn->bd; +int rc =0 ; + +switch (cmd->cmd) { +case ETHTOOL_GRXCLSRLCNT : + cmd->rule_cnt = bn->user_fltr_count; + cmd->data = bd->max_fltr |RX_CLS_LOC_SPECIAL ; +break ; + +case ETHTOOL_GRXCLSRLALL : + rc =bnge_grxclsrlall (bn, cmd, (u32 *)rule_locs); +break ; + +case ETHTOOL_GRXCLSRULE : + rc =bnge_grxclsrule (bn, cmd); +break ; + +default : + rc = -EOPNOTSUPP ; +break ; + } + +return rc; +} + +static int bnge_set_rxnfc (struct net_device *dev,struct ethtool_rxnfc *cmd) +{ +struct bnge_net *bn =netdev_priv (dev); +int rc; + +switch (cmd->cmd) { +case ETHTOOL_SRXCLSRLINS : + rc =bnge_srxclsrlins (bn, cmd); +break ; + +case ETHTOOL_SRXCLSRLDEL : + rc =bnge_srxclsrldel (bn, cmd); +break ; + +default : + rc = -EOPNOTSUPP ; +break ; + } +return rc; +} +static const struct ethtool_ops bnge_ethtool_ops = { .cap_link_lanes_supported =1 , .get_link_ksettings = bnge_get_link_ksettings,
@@ -1196,6 +1785,8 @@ static const struct ethtool_ops bnge_ethtool_ops = { .create_rxfh_context = bnge_create_rxfh_context, .modify_rxfh_context = bnge_modify_rxfh_context, .remove_rxfh_context = bnge_remove_rxfh_context, + .get_rxnfc = bnge_get_rxnfc, + .set_rxnfc = bnge_set_rxnfc, };void bnge_set_ethtool_ops (struct net_device *dev)
drivers/net/ethernet/broadcom/bnge/bnge_filter.c +60 -0
63 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_filter.h +2 -0
@@ -117,4 +117,6 @@ void bnge_del_ntp_filter(struct bnge_net *bn, struct bnge_ntuple_filter *nfltr);void bnge_del_ntp_filter_rcu (struct bnge_net *bn,struct bnge_ntuple_filter *fltr); +void bnge_cfg_usr_fltrs (struct bnge_net *bn); +void bnge_clear_usr_fltrs (struct bnge_net *bn);#endif /* _BNGE_FILTER_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +5 -3
@@ -906,15 +906,17 @@ int bnge_hwrm_l2_filter_alloc(struct bnge_dev *bd, struct bnge_l2_filter *fltr) {struct hwrm_cfa_l2_filter_alloc_output *resp;struct hwrm_cfa_l2_filter_alloc_input *req; +u32 flags;int rc; rc =bnge_hwrm_req_init (bd, req,HWRM_CFA_L2_FILTER_ALLOC );if (rc)return rc; - req->flags =cpu_to_le32 (CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX ); - - req->flags |=cpu_to_le32 (CFA_L2_FILTER_ALLOC_REQ_FLAGS_OUTERMOST ); + flags =CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX | +CFA_L2_FILTER_ALLOC_REQ_FLAGS_TRAFFIC_L2 | +CFA_L2_FILTER_ALLOC_REQ_FLAGS_OUTERMOST ; + req->flags =cpu_to_le32 (flags); req->dst_id =cpu_to_le16 (fltr->base.fw_vnic_id); req->enables = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_ENABLES_L2_ADDR |
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +4 -0
@@ -2803,6 +2803,7 @@ int bnge_open_core(struct bnge_net *bn)bnge_get_port_module_status (bn);bnge_hwrm_realloc_rss_ctx_vnic (bn); +bnge_cfg_usr_fltrs (bn);return 0 ;
@@ -3166,6 +3167,9 @@ static int bnge_set_features(struct net_device *dev, netdev_features_t features) !(flags & BNGE_NET_EN_NTUPLE) && bn->num_rss_ctx)return -EBUSY ; +if (!(flags &BNGE_NET_EN_NTUPLE )) +bnge_clear_usr_fltrs (bn); + bn->priv_flags = flags;return 0 ;
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 10/11 bnge: add aRFS flow steering ndo support
In reply to Vikas GuptaIntroduce the ndo_rx_flow_steer callback (bnge_rx_flow_steer) to support aRFS.
This callback creates an NTUPLE filter that steers matching packets to the appropriate RX queue. The implementation dissects flow keys from the SKB, creates an NTUPLE filter with the associated L2 filter, inserts it into the NTUPLE hash table, and schedules the sp_task workqueue via BNGE_RX_NTP_FLTR_SP_EVENT to program the filter in the firmware.
Add bnge_cfg_ntp_filters() called from the periodic timer via sp_task to handle deferred filter programming and expiration via rps_may_expire_flow().
--- .../net/ethernet/broadcom/bnge/bnge_filter.c | 45 ++++++++ .../net/ethernet/broadcom/bnge/bnge_filter.h | 1 + .../net/ethernet/broadcom/bnge/bnge_netdev.c | 105 ++++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_netdev.h | 1 + 4 files changed, 152 insertions(+)
drivers/net/ethernet/broadcom/bnge/bnge_filter.c +45 -0
@@ -637,3 +637,48 @@ void bnge_clear_usr_fltrs(struct bnge_net *bn) } } } + +void bnge_cfg_ntp_filters (struct bnge_net *bn) +{ +#ifdef CONFIG_RFS_ACCEL +struct bnge_ntuple_filter *fltr, *tmp; +LIST_HEAD (install_list); +LIST_HEAD (expire_list); +int i, rc; + +rcu_read_lock (); +for (i =0 ; i <BNGE_NTP_FLTR_HASH_SIZE ; i++) { +hlist_for_each_entry_rcu (fltr, &bn->ntp_fltr_hash_tbl[i], + base.hlist) { +if (test_bit (BNGE_FLTR_VALID , &fltr->base.state)) { +if (fltr->base.flags &BNGE_ACT_NO_AGING ) +continue ; +if (rps_may_expire_flow (bn->netdev, + fltr->base.rxq, + fltr->flow_id, + fltr->base.sw_id)) +list_add (&fltr->base.list_node, + &expire_list); + }else { +list_add (&fltr->base.list_node, &install_list); + } + } + } +rcu_read_unlock (); + +list_for_each_entry_safe (fltr, tmp, &install_list, base.list_node) { +list_del_init (&fltr->base.list_node); + rc =bnge_hwrm_cfa_ntuple_filter_alloc (bn->bd, fltr); +if (rc) +bnge_del_ntp_filter_rcu (bn, fltr); +else +set_bit (BNGE_FLTR_VALID , &fltr->base.state); + } + +list_for_each_entry_safe (fltr, tmp, &expire_list, base.list_node) { +list_del_init (&fltr->base.list_node); +bnge_hwrm_cfa_ntuple_filter_free (bn->bd, fltr); +bnge_del_ntp_filter_rcu (bn, fltr); + } +#endif +}
drivers/net/ethernet/broadcom/bnge/bnge_filter.h +1 -0
@@ -119,4 +119,5 @@ void bnge_del_ntp_filter_rcu(struct bnge_net *bn, struct bnge_ntuple_filter *fltr);void bnge_cfg_usr_fltrs (struct bnge_net *bn);void bnge_clear_usr_fltrs (struct bnge_net *bn); +void bnge_cfg_ntp_filters (struct bnge_net *bn);#endif /* _BNGE_FILTER_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +105 -0
129 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +1 -0
@@ -282,6 +282,7 @@ enum bnge_sp_event {BNGE_LINK_CFG_CHANGE_SP_EVENT ,BNGE_UPDATE_PHY_SP_EVENT ,BNGE_PERIODIC_STATS_SP_EVENT , + BNGE_RX_NTP_FLTR_SP_EVENT, };#define BNGE_NTP_FLTR_HASH_SIZE 512
Signature · 1 line
2.52.0
Vikas Gupta
maintainerPATCH v3 11/11 bnge: add cpu_rmap support for IRQ affinity
In reply to Vikas GuptaWhen CONFIG_RFS_ACCEL is enabled, allocate and populate a cpu_rmap for the RX IRQ vectors so that the kernel's aRFS infrastructure can correctly map flows to the RX queues serviced by the nearest CPU.
This ensures that NTUPLE rules created by the kernel steer packets to the optimal queue based on CPU/IRQ affinity.
--- .../net/ethernet/broadcom/bnge/bnge_netdev.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +34 -1
@@ -18,6 +18,7 @@#include <net/ip.h> #include <linux/skbuff.h> #include <net/page_pool/helpers.h> +#include <linux/cpu_rmap.h> #include "bnge.h" #include "bnge_hwrm.h"
@@ -2441,10 +2442,23 @@ static int bnge_setup_interrupts(struct bnge_net *bn) {struct net_device *dev = bn->netdev;struct bnge_dev *bd = bn->bd; +int rc;bnge_setup_msix (bn); -return netif_set_real_num_queues (dev, bd->tx_nr_rings, bd->rx_nr_rings); + rc =netif_set_real_num_queues (dev, bd->tx_nr_rings, bd->rx_nr_rings); +if (rc) +return rc; + +#ifdef CONFIG_RFS_ACCEL +if (bn->priv_flags &BNGE_NET_EN_NTUPLE ) { + dev->rx_cpu_rmap =alloc_irq_cpu_rmap (bd->rx_nr_rings); +if (!dev->rx_cpu_rmap) +return -ENOMEM ; + } +#endif + +return rc; }static void bnge_hwrm_resource_free (struct bnge_net *bn,bool close_path)
@@ -2460,6 +2474,11 @@ static void bnge_free_irq(struct bnge_net *bn)struct bnge_irq *irq;int i; +#ifdef CONFIG_RFS_ACCEL +free_irq_cpu_rmap (bn->netdev->rx_cpu_rmap); + bn->netdev->rx_cpu_rmap =NULL ; +#endif +for (i =0 ; i < bd->nq_nr_rings; i++) {int map_idx =bnge_cp_num_to_irq_num (bn, i);
@@ -2479,6 +2498,7 @@ static void bnge_free_irq(struct bnge_net *bn)static int bnge_request_irq (struct bnge_net *bn) { +struct cpu_rmap *rmap =NULL ;struct bnge_dev *bd = bn->bd;int i, rc;
@@ -2487,10 +2507,23 @@ static int bnge_request_irq(struct bnge_net *bn)netdev_err (bn->netdev,"bnge_setup_interrupts err: %d\n" , rc);return rc; } + +#ifdef CONFIG_RFS_ACCEL + rmap = bn->netdev->rx_cpu_rmap; +#endif +for (i =0 ; i < bd->nq_nr_rings; i++) {int map_idx =bnge_cp_num_to_irq_num (bn, i);struct bnge_irq *irq = &bd->irq_tbl[map_idx]; +if (IS_ENABLED (CONFIG_RFS_ACCEL ) && + rmap && bn->bnapi[i]->rx_ring) { + rc =irq_cpu_rmap_add (rmap, irq->vector); +if (rc) +netdev_warn (bn->netdev, +"failed adding irq rmap for ring %d\n" , i); + } + rc =request_irq (irq->vector, irq->handler,0 , irq->name, bn->bnapi[i]);if (rc)
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerQuoted 7 lines · On Thu, 17 Sep 2026 12:15:37 +0530 Vikas Gupta wrote:
This series adds ntuple filter, RSS context, and flow steering support to bnge driver.
Patch 2 is a pure refactor (no functional change) that relocates the filter and VNIC related code into the appropriate files. Patch 7 drops the refcount usage from L2 filters, also with no functional change. The subsequent patches then add the ethtool commands for configuring ntuple flows and RSS contexts.
Please look thru the review here:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]
We had 3 models enabled for some time and 3x the huge number of findings in this series seems to have choked the LLM's input limit on patch 9. So the review won't get emailed out. But the first finding already looks legit so..
Signature · 1 line
pw-bot: cr