From: Jie Liu <liujie5@linkdatatechnology.com>
To: stephen@networkplumber.org
Cc: dev@dpdk.org, Jie Liu <liujie5@linkdatatechnology.com>
Subject: [PATCH v3 06/14] net/sxe: add filter function
Date: Mon, 7 Jul 2025 07:58:11 -0400 [thread overview]
Message-ID: <20250707115819.12826-6-liujie5@linkdatatechnology.com> (raw)
In-Reply-To: <20250707115819.12826-1-liujie5@linkdatatechnology.com>
Add filter function.
Signed-off-by: Jie Liu <liujie5@linkdatatechnology.com>
---
drivers/net/sxe/pf/sxe.h | 4 +
drivers/net/sxe/pf/sxe_filter.c | 191 ++++++++++++++++++++++++++++++++
drivers/net/sxe/pf/sxe_filter.h | 29 +++++
drivers/net/sxe/pf/sxe_main.c | 1 +
4 files changed, 225 insertions(+)
diff --git a/drivers/net/sxe/pf/sxe.h b/drivers/net/sxe/pf/sxe.h
index 4b7e853923..6458372ce4 100644
--- a/drivers/net/sxe/pf/sxe.h
+++ b/drivers/net/sxe/pf/sxe.h
@@ -46,6 +46,10 @@ struct sxe_adapter {
struct sxe_irq_context irq_ctxt;
struct sxe_vlan_context vlan_ctxt;
+ struct sxe_mac_filter_context mac_filter_ctxt;
+#ifdef RTE_ADAPTER_HAVE_FNAV_CONF
+ struct rte_eth_fdir_conf fnav_conf;
+#endif
struct sxe_phy_context phy_ctxt;
bool rx_batch_alloc_allowed;
diff --git a/drivers/net/sxe/pf/sxe_filter.c b/drivers/net/sxe/pf/sxe_filter.c
index c1b28a858a..c48ff1b1ea 100644
--- a/drivers/net/sxe/pf/sxe_filter.c
+++ b/drivers/net/sxe/pf/sxe_filter.c
@@ -78,6 +78,47 @@ static void sxe_default_mac_addr_get(struct sxe_adapter *adapter)
rte_ether_addr_copy(&mac_addr, &adapter->mac_filter_ctxt.fc_mac_addr);
}
+static u8 sxe_sw_uc_entry_add(struct rte_eth_dev *eth_dev, u8 index,
+ u8 *mac_addr)
+{
+ u8 i, pool;
+ struct sxe_adapter *adapter = eth_dev->data->dev_private;
+ struct sxe_uc_addr_table *uc_table = adapter->mac_filter_ctxt.uc_addr_table;
+
+ pool = sxe_vf_num_get(eth_dev);
+ for (i = 0; i < SXE_UC_ENTRY_NUM_MAX; i++) {
+ if (!uc_table[i].used) {
+ uc_table[i].pool_idx = pool;
+ uc_table[i].used = true;
+ uc_table[i].rar_idx = i;
+ uc_table[i].original_index = index;
+ uc_table[i].type = SXE_PF;
+ rte_memcpy(uc_table[i].addr, mac_addr, SXE_MAC_ADDR_LEN);
+ break;
+ }
+ }
+
+ return i;
+}
+
+static u8 sxe_sw_uc_entry_del(struct sxe_adapter *adapter, u8 index)
+{
+ u8 i;
+ struct sxe_uc_addr_table *uc_table = adapter->mac_filter_ctxt.uc_addr_table;
+
+ for (i = 0; i < SXE_UC_ENTRY_NUM_MAX; i++) {
+ if (!uc_table[i].used || uc_table[i].type != SXE_PF)
+ continue;
+
+ if (uc_table[i].original_index == index) {
+ uc_table[i].used = false;
+ break;
+ }
+ }
+
+ return i;
+}
+
s32 sxe_mac_addr_init(struct rte_eth_dev *eth_dev)
{
struct sxe_adapter *adapter = eth_dev->data->dev_private;
@@ -145,6 +186,156 @@ s32 sxe_mac_addr_init(struct rte_eth_dev *eth_dev)
goto l_out;
}
+static void sxe_pf_promisc_mac_update(struct rte_eth_dev *dev, bool enable)
+{
+ struct sxe_adapter *adapter = dev->data->dev_private;
+ struct sxe_uc_addr_table *uc_table = adapter->mac_filter_ctxt.uc_addr_table;
+ u16 pf_pool = sxe_vf_num_get(dev);
+ s32 i;
+
+ for (i = 0; i < SXE_UC_ENTRY_NUM_MAX; i++) {
+ if (uc_table[i].used && uc_table[i].type != SXE_PF) {
+ if (enable)
+ sxe_hw_uc_addr_pool_enable(&adapter->hw,
+ uc_table[i].rar_idx, pf_pool);
+ else
+ sxe_hw_uc_addr_pool_del(&adapter->hw,
+ uc_table[i].rar_idx, pf_pool);
+ }
+ }
+}
+
+s32 sxe_promiscuous_enable(struct rte_eth_dev *dev)
+{
+ struct sxe_adapter *adapter = dev->data->dev_private;
+ struct sxe_hw *hw = &adapter->hw;
+ u32 flt_ctrl;
+ u32 vm_l2_ctrl = 0;
+ u16 vf_num;
+
+ flt_ctrl = sxe_hw_rx_mode_get(hw);
+ PMD_LOG_DEBUG(DRV, "read flt_ctrl=0x%x", flt_ctrl);
+
+ flt_ctrl |= (SXE_FCTRL_UPE | SXE_FCTRL_MPE);
+
+ vf_num = sxe_vf_num_get(dev);
+ if (vf_num != 0) {
+ vm_l2_ctrl = sxe_hw_pool_rx_mode_get(hw, vf_num) |
+ SXE_VMOLR_ROMPE | SXE_VMOLR_MPE;
+ sxe_hw_pool_rx_mode_set(hw, vm_l2_ctrl, vf_num);
+
+ sxe_pf_promisc_mac_update(dev, true);
+ }
+
+ PMD_LOG_DEBUG(DRV, "write flt_ctrl=0x%x vmolr=0x%x", flt_ctrl, vm_l2_ctrl);
+ sxe_hw_rx_mode_set(hw, flt_ctrl);
+ adapter->mac_filter_ctxt.promiscuous_mode = true;
+
+ return 0;
+}
+
+s32 sxe_promiscuous_disable(struct rte_eth_dev *dev)
+{
+ struct sxe_adapter *adapter = dev->data->dev_private;
+ struct sxe_hw *hw = &adapter->hw;
+ u32 flt_ctrl;
+ u32 vm_l2_ctrl = 0;
+ u16 vf_num;
+
+ flt_ctrl = sxe_hw_rx_mode_get(hw);
+ PMD_LOG_DEBUG(DRV, "read flt_ctrl=0x%x", flt_ctrl);
+
+ flt_ctrl &= (~SXE_FCTRL_UPE);
+ if (dev->data->all_multicast == 1)
+ flt_ctrl |= SXE_FCTRL_MPE;
+ else
+ flt_ctrl &= (~SXE_FCTRL_MPE);
+
+ vf_num = sxe_vf_num_get(dev);
+ if (vf_num != 0) {
+ vm_l2_ctrl = sxe_hw_pool_rx_mode_get(hw, vf_num);
+ if (dev->data->all_multicast == 0) {
+ vm_l2_ctrl &= ~SXE_VMOLR_MPE;
+ if ((sxe_hw_mc_filter_get(hw) & SXE_MCSTCTRL_MFE) == 0)
+ vm_l2_ctrl &= ~SXE_VMOLR_ROMPE;
+ }
+ sxe_hw_pool_rx_mode_set(hw, vm_l2_ctrl, vf_num);
+ sxe_pf_promisc_mac_update(dev, false);
+ }
+
+ PMD_LOG_DEBUG(DRV, "write flt_ctrl=0x%x vmolr=0x%x", flt_ctrl, vm_l2_ctrl);
+ sxe_hw_rx_mode_set(hw, flt_ctrl);
+ adapter->mac_filter_ctxt.promiscuous_mode = false;
+
+ return 0;
+}
+
+s32 sxe_allmulticast_enable(struct rte_eth_dev *dev)
+{
+ struct sxe_adapter *adapter = dev->data->dev_private;
+ struct sxe_hw *hw = &adapter->hw;
+ u32 flt_ctrl;
+ u32 vm_l2_ctrl = 0;
+ u16 vf_num;
+
+ flt_ctrl = sxe_hw_rx_mode_get(hw);
+ PMD_LOG_DEBUG(DRV, "read flt_ctrl=0x%x", flt_ctrl);
+
+ flt_ctrl |= SXE_FCTRL_MPE;
+
+ PMD_LOG_DEBUG(DRV, "write flt_ctrl=0x%x", flt_ctrl);
+ sxe_hw_rx_mode_set(hw, flt_ctrl);
+
+ vf_num = sxe_vf_num_get(dev);
+ if (vf_num != 0) {
+ vm_l2_ctrl = sxe_hw_pool_rx_mode_get(hw, vf_num) |
+ SXE_VMOLR_MPE | SXE_VMOLR_ROMPE;
+ sxe_hw_pool_rx_mode_set(hw, vm_l2_ctrl, vf_num);
+ }
+
+ PMD_LOG_DEBUG(DRV, "write flt_ctrl=0x%x vmolr=0x%x",
+ flt_ctrl, vm_l2_ctrl);
+
+ return 0;
+}
+
+s32 sxe_allmulticast_disable(struct rte_eth_dev *dev)
+{
+ struct sxe_adapter *adapter = dev->data->dev_private;
+ struct sxe_hw *hw = &adapter->hw;
+ u32 flt_ctrl;
+ u32 vm_l2_ctrl = 0;
+ u16 vf_num;
+
+ if (dev->data->promiscuous == 1) {
+ PMD_LOG_DEBUG(DRV, "promiscuous is enable, allmulticast must be enabled.");
+ goto l_out;
+ }
+
+ flt_ctrl = sxe_hw_rx_mode_get(hw);
+ PMD_LOG_DEBUG(DRV, "read flt_ctrl=0x%x", flt_ctrl);
+
+ flt_ctrl &= (~SXE_FCTRL_MPE);
+
+ vf_num = sxe_vf_num_get(dev);
+ if (vf_num != 0) {
+ vm_l2_ctrl = sxe_hw_pool_rx_mode_get(hw, vf_num) &
+ (~SXE_VMOLR_MPE);
+ if ((sxe_hw_mc_filter_get(hw) & SXE_MCSTCTRL_MFE) == 0)
+ vm_l2_ctrl &= ~SXE_VMOLR_ROMPE;
+
+ sxe_hw_pool_rx_mode_set(hw, vm_l2_ctrl, vf_num);
+ } else {
+ sxe_hw_rx_mode_set(hw, flt_ctrl);
+ }
+
+ PMD_LOG_DEBUG(DRV, "write flt_ctrl=0x%x vmolr=0x%x",
+ flt_ctrl, vm_l2_ctrl);
+
+l_out:
+ return 0;
+}
+
s32 sxe_mac_addr_add(struct rte_eth_dev *dev,
struct rte_ether_addr *mac_addr,
u32 index, u32 pool)
diff --git a/drivers/net/sxe/pf/sxe_filter.h b/drivers/net/sxe/pf/sxe_filter.h
index aab6838e2d..b8c67f8d42 100644
--- a/drivers/net/sxe/pf/sxe_filter.h
+++ b/drivers/net/sxe/pf/sxe_filter.h
@@ -21,6 +21,27 @@ struct sxe_adapter;
RTE_ALIGN((SXE_HW_TXRX_RING_NUM_MAX / (sizeof(u32) * BYTE_BIT_NUM)), \
sizeof(u32))
+struct sxe_vlan_context {
+ u32 vlan_hash_table[SXE_VFT_TBL_SIZE];
+ u32 strip_bitmap[SXE_VLAN_STRIP_BITMAP_SIZE];
+ u32 vlan_table_size;
+};
+
+enum sxe_uc_addr_src_type {
+ SXE_PF = 0,
+ SXE_VF,
+ SXE_VF_MACVLAN
+};
+
+struct sxe_uc_addr_table {
+ u8 rar_idx;
+ u8 pool_idx;
+ u8 type;
+ u8 original_index;
+ bool used;
+ u8 addr[SXE_MAC_ADDR_LEN];
+};
+
struct sxe_mac_filter_context {
struct rte_ether_addr def_mac_addr;
struct rte_ether_addr cur_mac_addr;
@@ -37,6 +58,14 @@ struct sxe_mac_filter_context {
s32 sxe_mac_addr_init(struct rte_eth_dev *eth_dev);
+s32 sxe_promiscuous_enable(struct rte_eth_dev *dev);
+
+s32 sxe_promiscuous_disable(struct rte_eth_dev *dev);
+
+s32 sxe_allmulticast_enable(struct rte_eth_dev *dev);
+
+s32 sxe_allmulticast_disable(struct rte_eth_dev *dev);
+
s32 sxe_mac_addr_add(struct rte_eth_dev *dev,
struct rte_ether_addr *mac_addr,
u32 rar_idx, u32 pool);
diff --git a/drivers/net/sxe/pf/sxe_main.c b/drivers/net/sxe/pf/sxe_main.c
index cc3145c09b..700934b378 100644
--- a/drivers/net/sxe/pf/sxe_main.c
+++ b/drivers/net/sxe/pf/sxe_main.c
@@ -195,6 +195,7 @@ s32 sxe_hw_reset(struct sxe_hw *hw)
goto l_end;
}
+ sxe_hw_uc_addr_clear(hw);
l_end:
return ret;
}
--
2.18.4
next prev parent reply other threads:[~2025-07-07 11:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-25 2:36 [PATCH 01/13] net/sxe: add base driver directory and doc Jie Liu
2025-04-25 2:36 ` [PATCH 02/13] net/sxe: add ethdev probe and remove Jie Liu
2025-04-26 16:11 ` Stephen Hemminger
2025-04-26 16:11 ` Stephen Hemminger
2025-04-26 16:15 ` Stephen Hemminger
2025-04-26 16:17 ` Stephen Hemminger
2025-04-25 2:36 ` [PATCH 03/13] net/sxe: add tx rx setup and data path Jie Liu
2025-04-26 16:02 ` Stephen Hemminger
2025-04-26 16:20 ` Stephen Hemminger
2025-04-25 2:36 ` [PATCH 04/13] net/sxe: add link, flow ctrl, mac ops, mtu ops function Jie Liu
2025-04-25 2:36 ` [PATCH 05/13] net/sxe: support vlan filter Jie Liu
2025-04-25 2:36 ` [PATCH 06/13] net/sxe: add mac layer filter function Jie Liu
2025-04-25 2:36 ` [PATCH 07/13] net/sxe: support rss offload Jie Liu
2025-04-25 2:36 ` [PATCH 08/13] net/sxe: add dcb function Jie Liu
2025-04-25 2:36 ` [PATCH 09/13] net/sxe: support ptp Jie Liu
2025-04-25 2:36 ` [PATCH 10/13] net/sxe: add xstats function Jie Liu
2025-04-25 2:36 ` [PATCH 11/13] net/sxe: add custom cmd led ctrl Jie Liu
2025-04-25 2:36 ` [PATCH 12/13] net/sxe: add simd function Jie Liu
2025-04-25 2:36 ` [PATCH 13/13] net/sxe: add virtual function Jie Liu
2025-04-26 15:57 ` [PATCH 01/13] net/sxe: add base driver directory and doc Stephen Hemminger
2025-04-26 15:59 ` Stephen Hemminger
2025-04-26 16:23 ` Stephen Hemminger
2025-04-26 17:07 ` Stephen Hemminger
2025-04-26 17:08 ` Stephen Hemminger
2025-07-04 2:53 ` [PATCH v2 01/14] net/sxe: add base driver directory and doc Adding a minimum maintainable directory structure for the network driver and request maintenance of the sxe driver Jie Liu
2025-07-07 11:58 ` [PATCH v3 01/14] net/sxe: add base driver directory and doc Jie Liu
2025-07-07 11:58 ` [PATCH v3 02/14] net/sxe: add ethdev probe and remove Jie Liu
2025-07-07 14:57 ` Stephen Hemminger
2025-07-07 11:58 ` [PATCH v3 03/14] net/sxe: add tx rx setup and data path Jie Liu
2025-07-07 11:58 ` [PATCH v3 04/14] net/sxe: add link, flow ctrl, mac ops, mtu ops function Jie Liu
2025-07-07 11:58 ` [PATCH v3 05/14] net/sxe: support vlan filter Jie Liu
2025-07-07 11:58 ` Jie Liu [this message]
2025-07-07 11:58 ` [PATCH v3 07/14] net/sxe: support rss offload Jie Liu
2025-07-07 11:58 ` [PATCH v3 08/14] net/sxe: add dcb function Jie Liu
2025-07-07 11:58 ` [PATCH v3 09/14] net/sxe: support ptp Jie Liu
2025-07-07 11:58 ` [PATCH v3 10/14] net/sxe: add xstats function Jie Liu
2025-07-07 11:58 ` [PATCH v3 11/14] net/sxe: add custom cmd led ctrl Jie Liu
2025-07-07 11:58 ` [PATCH v3 12/14] net/sxe: add simd function Jie Liu
2025-07-07 11:58 ` [PATCH v3 13/14] net/sxe: add virtual function Jie Liu
2025-07-07 11:58 ` [PATCH v3 14/14] net/sxe: add Solve compilation problems Jie Liu
2025-07-07 15:03 ` Stephen Hemminger
2025-07-07 15:56 ` Stephen Hemminger
2025-07-07 14:58 ` [PATCH v3 01/14] net/sxe: add base driver directory and doc Stephen Hemminger
2025-07-07 15:00 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250707115819.12826-6-liujie5@linkdatatechnology.com \
--to=liujie5@linkdatatechnology.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).