From: Wei Fang <wei.fang@nxp.com>
To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, christophe.leroy@csgroup.eu
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev
Subject: [PATCH net-next 10/13] net: enetc: move generic VLAN hash filter functions to enetc_pf_common.c
Date: Fri, 3 Jan 2025 14:06:06 +0800 [thread overview]
Message-ID: <20250103060610.2233908-11-wei.fang@nxp.com> (raw)
In-Reply-To: <20250103060610.2233908-1-wei.fang@nxp.com>
Since the VLAN hash filter of ENETC v1 and v4 is the basically same, the
only difference is the offset of the VLAN hash filter registers. So, the
.set_si_vlan_hash_filter() hook is added to struct enetc_pf_ops to set
the registers of the corresponding platform. In addition, the common VLAN
hash filter functions enetc_vlan_rx_add_vid() and enetc_vlan_rx_del_vid()
are moved to enetc_pf_common.c.
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
.../net/ethernet/freescale/enetc/enetc_pf.c | 34 ++-----------------
.../net/ethernet/freescale/enetc/enetc_pf.h | 1 +
.../freescale/enetc/enetc_pf_common.c | 34 +++++++++++++++++++
.../freescale/enetc/enetc_pf_common.h | 2 ++
4 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index c0aaf6349b0b..d9c1ebd180db 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -215,43 +215,12 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev)
enetc_port_wr(hw, ENETC_PSIPMR, psipmr);
}
-static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx,
- unsigned long hash)
+static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx, u64 hash)
{
enetc_port_wr(hw, ENETC_PSIVHFR0(si_idx), lower_32_bits(hash));
enetc_port_wr(hw, ENETC_PSIVHFR1(si_idx), upper_32_bits(hash));
}
-static int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid)
-{
- struct enetc_ndev_priv *priv = netdev_priv(ndev);
- struct enetc_si *si = priv->si;
- struct enetc_hw *hw = &si->hw;
- int idx;
-
- __set_bit(vid, si->active_vlans);
-
- idx = enetc_vid_hash_idx(vid);
- if (!__test_and_set_bit(idx, si->vlan_ht_filter))
- enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter);
-
- return 0;
-}
-
-static int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid)
-{
- struct enetc_ndev_priv *priv = netdev_priv(ndev);
- struct enetc_si *si = priv->si;
- struct enetc_hw *hw = &si->hw;
-
- if (__test_and_clear_bit(vid, si->active_vlans)) {
- enetc_refresh_vlan_ht_filter(si);
- enetc_set_vlan_ht_filter(hw, 0, *si->vlan_ht_filter);
- }
-
- return 0;
-}
-
static void enetc_set_loopback(struct net_device *ndev, bool en)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
@@ -971,6 +940,7 @@ static const struct enetc_pf_ops enetc_pf_ops = {
.enable_psfp = enetc_psfp_enable,
.set_rss_key = enetc_set_rss_key,
.get_rss_key = enetc_get_rss_key,
+ .set_si_vlan_hash_filter = enetc_set_vlan_ht_filter,
};
static int enetc_pf_probe(struct pci_dev *pdev,
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
index d56b381b9da9..7a0fa5fba8bf 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
@@ -39,6 +39,7 @@ struct enetc_pf_ops {
int (*enable_psfp)(struct enetc_ndev_priv *priv);
void (*set_rss_key)(struct enetc_hw *hw, const u8 *key);
void (*get_rss_key)(struct enetc_hw *hw, u8 *key);
+ void (*set_si_vlan_hash_filter)(struct enetc_hw *hw, int si, u64 hash);
};
struct enetc_pf {
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
index a737a7f8c79e..9f812c1af7a3 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
@@ -343,5 +343,39 @@ void enetc_phylink_destroy(struct enetc_ndev_priv *priv)
}
EXPORT_SYMBOL_GPL(enetc_phylink_destroy);
+int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid)
+{
+ struct enetc_ndev_priv *priv = netdev_priv(ndev);
+ struct enetc_pf *pf = enetc_si_priv(priv->si);
+ struct enetc_si *si = priv->si;
+ struct enetc_hw *hw = &si->hw;
+ int idx;
+
+ __set_bit(vid, si->active_vlans);
+
+ idx = enetc_vid_hash_idx(vid);
+ if (!__test_and_set_bit(idx, si->vlan_ht_filter))
+ pf->ops->set_si_vlan_hash_filter(hw, 0, *si->vlan_ht_filter);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(enetc_vlan_rx_add_vid);
+
+int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid)
+{
+ struct enetc_ndev_priv *priv = netdev_priv(ndev);
+ struct enetc_pf *pf = enetc_si_priv(priv->si);
+ struct enetc_si *si = priv->si;
+ struct enetc_hw *hw = &si->hw;
+
+ if (__test_and_clear_bit(vid, si->active_vlans)) {
+ enetc_refresh_vlan_ht_filter(si);
+ pf->ops->set_si_vlan_hash_filter(hw, 0, *si->vlan_ht_filter);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(enetc_vlan_rx_del_vid);
+
MODULE_DESCRIPTION("NXP ENETC PF common functionality driver");
MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h
index 48f55ee743ad..253310859ca1 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.h
@@ -12,6 +12,8 @@ void enetc_mdiobus_destroy(struct enetc_pf *pf);
int enetc_phylink_create(struct enetc_ndev_priv *priv, struct device_node *node,
const struct phylink_mac_ops *ops);
void enetc_phylink_destroy(struct enetc_ndev_priv *priv);
+int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid);
+int enetc_vlan_rx_del_vid(struct net_device *ndev, __be16 prot, u16 vid);
static inline u16 enetc_get_ip_revision(struct enetc_hw *hw)
{
--
2.34.1
next prev parent reply other threads:[~2025-01-03 6:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 6:05 [PATCH net-next 00/13] Add more feautues for ENETC v4 - round 2 Wei Fang
2025-01-03 6:05 ` [PATCH net-next 01/13] net: enetc: add initial netc-lib driver to support NTMP Wei Fang
2025-01-03 16:20 ` Andrew Lunn
2025-01-06 2:45 ` Wei Fang
2025-01-03 6:05 ` [PATCH net-next 02/13] net: enetc: add command BD ring support for i.MX95 ENETC Wei Fang
2025-01-03 6:05 ` [PATCH net-next 03/13] net: enetc: move generic MAC filterng interfaces to enetc-core Wei Fang
2025-01-03 6:06 ` [PATCH net-next 04/13] net: enetc: add MAC filter for i.MX95 ENETC PF Wei Fang
2025-01-05 1:45 ` Jakub Kicinski
2025-01-03 6:06 ` [PATCH net-next 05/13] net: enetc: add debugfs interface to dump MAC filter Wei Fang
2025-01-03 16:25 ` Andrew Lunn
2025-01-06 2:19 ` Wei Fang
2025-01-03 6:06 ` [PATCH net-next 06/13] net: enetc: make enetc_set_rxfh() and enetc_get_rxfh() reusable Wei Fang
2025-01-03 6:06 ` [PATCH net-next 07/13] net: enetc: add RSS support for i.MX95 ENETC PF Wei Fang
2025-01-03 6:06 ` [PATCH net-next 08/13] net: enetc: enable RSS feature by default Wei Fang
2025-01-03 6:06 ` [PATCH net-next 09/13] net: enetc: move generic VLAN filter interfaces to enetc-core Wei Fang
2025-01-03 6:06 ` Wei Fang [this message]
2025-01-03 6:06 ` [PATCH net-next 11/13] net: enetc: add VLAN filtering support for i.MX95 ENETC PF Wei Fang
2025-01-03 6:06 ` [PATCH net-next 12/13] net: enetc: add loopback " Wei Fang
2025-01-03 6:06 ` [PATCH net-next 13/13] MAINTAINERS: add new file ntmp.h to ENETC driver Wei Fang
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=20250103060610.2233908-11-wei.fang@nxp.com \
--to=wei.fang@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoning.wang@nxp.com \
/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).