* [PATCH 2/3] [v4, net-next] net: ethernet: ti-cpsw: fix linking built-in code to modules
From: Arnd Bergmann @ 2026-04-02 18:46 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Grygorii Strashko
Cc: Siddharth Vadapalli, Roger Quadros, Vladimir Oltean,
Alexander Sverdlin, Ioana Ciornei, linux-omap, Arnd Bergmann,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, Stanislav Fomichev, Andrew F. Davis,
Basharath Hussain Khaja, Parvathi Pudi, linux-kernel, bpf
In-Reply-To: <20260402184726.3746487-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
There are six variants of the cpsw driver, sharing various parts of
the code: davinci-emac, cpsw, cpsw-switchdev, netcp, netcp_ethss and
am65-cpsw-nuss.
I noticed that this means some files can be linked into more than
one loadable module, or even part of vmlinux but also linked into
a loadable module, both of which mess up assumptions of the build
system, and causes warnings:
scripts/Makefile.build:279: cpsw_ale.o is added to multiple modules: ti-am65-cpsw-nuss ti_cpsw ti_cpsw_new
scripts/Makefile.build:279: cpsw_priv.o is added to multiple modules: ti_cpsw ti_cpsw_new
scripts/Makefile.build:279: cpsw_sl.o is added to multiple modules: ti-am65-cpsw-nuss ti_cpsw ti_cpsw_new
scripts/Makefile.build:279: cpsw_ethtool.o is added to multiple modules: ti_cpsw ti_cpsw_new
scripts/Makefile.build:279: davinci_cpdma.o is added to multiple modules: ti_cpsw ti_cpsw_new ti_davinci_emac
Change this back to having separate modules for each portion that
can be linked standalone, exporting symbols as needed:
- ti-cpsw-common.ko now contains both cpsw-common.o and
davinci_cpdma.o as they are always used together
- ti-cpsw-priv.ko contains cpsw_priv.o, cpsw_sl.o and cpsw_ethtool.o,
which are the core of the cpsw and cpsw-new drivers.
- ti-cpsw-sl.ko contains the cpsw-sl.o object and is used on
ti-am65-cpsw-nuss.ko in addition to the two other cpsw variants.
- ti-cpsw-ale.o is the one standalone module that is used by all
except davinci_emac.
Each of these will be built-in if any of its users are built-in, otherwise
it's a loadable module if there is at least one module using it. I did
not bring back the separate Kconfig symbols for this, but just handle
it using Makefile logic.
Note: ideally this is something that Kbuild complains about, but usually
we just notice when something using THIS_MODULE misbehaves in a way that
a user notices.
Fixes: 99f6297182729 ("net: ethernet: ti: cpsw: drop TI_DAVINCI_CPDMA config option")
Link: https://lore.kernel.org/lkml/20240417084400.3034104-1-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: rebase on top of v6.9-rc
v3: rebase on top of v7.0-rc
v4: resend together with soft_reset() change, which is a dependency
---
drivers/net/ethernet/ti/Makefile | 30 ++++++++++----------
drivers/net/ethernet/ti/cpsw_ale.c | 25 +++++++++++++++++
drivers/net/ethernet/ti/cpsw_ethtool.c | 24 ++++++++++++++++
drivers/net/ethernet/ti/cpsw_priv.c | 37 +++++++++++++++++++++++++
drivers/net/ethernet/ti/cpsw_sl.c | 11 ++++++++
drivers/net/ethernet/ti/davinci_cpdma.c | 27 ++++++++++++++++++
6 files changed, 139 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index 6da50f4b7c2e..f4276c9a7762 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -6,30 +6,30 @@
obj-$(CONFIG_TI_PRUETH) += icssm-prueth.o
icssm-prueth-y := icssm/icssm_prueth.o icssm/icssm_prueth_switch.o icssm/icssm_switchdev.o
-obj-$(CONFIG_TI_CPSW) += cpsw-common.o
-obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o
-obj-$(CONFIG_TI_CPSW_SWITCHDEV) += cpsw-common.o
+ti-cpsw-common-y += cpsw-common.o davinci_cpdma.o
+ti-cpsw-priv-y += cpsw_priv.o cpsw_ethtool.o
+ti-cpsw-ale-y += cpsw_ale.o
+ti-cpsw-sl-y += cpsw_sl.o
obj-$(CONFIG_TLAN) += tlan.o
-obj-$(CONFIG_TI_DAVINCI_EMAC) += ti_davinci_emac.o
-ti_davinci_emac-y := davinci_emac.o davinci_cpdma.o
+obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o ti-cpsw-common.o
obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o
obj-$(CONFIG_TI_CPTS) += cpts.o
-obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
-ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o cpsw_sl.o cpsw_ethtool.o
-obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o
-ti_cpsw_new-y := cpsw_switchdev.o cpsw_new.o davinci_cpdma.o cpsw_ale.o cpsw_sl.o cpsw_priv.o cpsw_ethtool.o
+obj-$(CONFIG_TI_CPSW) += ti_cpsw.o ti-cpsw-common.o ti-cpsw-priv.o ti-cpsw-ale.o ti-cpsw-sl.o
+ti_cpsw-y := cpsw.o
+obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o ti-cpsw-common.o ti-cpsw-priv.o ti-cpsw-ale.o ti-cpsw-sl.o
+ti_cpsw_new-y := cpsw_switchdev.o cpsw_new.o
-obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
-keystone_netcp-y := netcp_core.o cpsw_ale.o
-obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
-keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.o
+obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o ti-cpsw-ale.o
+keystone_netcp-y := netcp_core.o
+obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o ti-cpsw-ale.o
+keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o
obj-$(CONFIG_TI_K3_CPPI_DESC_POOL) += k3-cppi-desc-pool.o
-obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
-ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o
+obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o ti-cpsw-sl.o ti-cpsw-ale.o
+ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o am65-cpsw-ethtool.o
ti-am65-cpsw-nuss-$(CONFIG_TI_AM65_CPSW_QOS) += am65-cpsw-qos.o
ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index be7b69319221..e202bba49480 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -493,6 +493,7 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
}
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_flush_multicast);
static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry,
int flags, u16 vid)
@@ -530,6 +531,7 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
cpsw_ale_write(ale, idx, ale_entry);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_add_ucast);
int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
int flags, u16 vid)
@@ -545,6 +547,7 @@ int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
cpsw_ale_write(ale, idx, ale_entry);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_del_ucast);
int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
int flags, u16 vid, int mcast_state)
@@ -578,6 +581,7 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
cpsw_ale_write(ale, idx, ale_entry);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_add_mcast);
int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
int flags, u16 vid)
@@ -607,6 +611,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
cpsw_ale_write(ale, idx, ale_entry);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_del_mcast);
/* ALE NetCP NU switch specific vlan functions */
static void cpsw_ale_set_vlan_mcast(struct cpsw_ale *ale, u32 *ale_entry,
@@ -676,6 +681,7 @@ int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
cpsw_ale_write(ale, idx, ale_entry);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_add_vlan);
static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale, u32 *ale_entry,
u16 vid, int port_mask)
@@ -733,6 +739,7 @@ int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_vlan_del_modify);
int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
{
@@ -767,6 +774,7 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_del_vlan);
int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
int untag_mask, int reg_mask, int unreg_mask)
@@ -806,6 +814,7 @@ int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_vlan_add_modify);
void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
bool add)
@@ -833,6 +842,7 @@ void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
cpsw_ale_write(ale, idx, ale_entry);
}
}
+EXPORT_SYMBOL_GPL(cpsw_ale_set_unreg_mcast);
static void cpsw_ale_vlan_set_unreg_mcast(struct cpsw_ale *ale, u32 *ale_entry,
int allmulti)
@@ -898,6 +908,7 @@ void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port)
cpsw_ale_write(ale, idx, ale_entry);
}
}
+EXPORT_SYMBOL_GPL(cpsw_ale_set_allmulti);
struct ale_control_info {
const char *name;
@@ -1155,6 +1166,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_control_set);
int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
{
@@ -1178,6 +1190,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
tmp = readl_relaxed(ale->params.ale_regs + offset) >> shift;
return tmp & BITMASK(info->bits);
}
+EXPORT_SYMBOL_GPL(cpsw_ale_control_get);
int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)
@@ -1200,6 +1213,7 @@ int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int rateli
port, val * ALE_RATE_LIMIT_MIN_PPS);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_rx_ratelimit_mc);
int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)
@@ -1222,6 +1236,7 @@ int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int rateli
port, val * ALE_RATE_LIMIT_MIN_PPS);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_rx_ratelimit_bc);
static void cpsw_ale_timer(struct timer_list *t)
{
@@ -1311,6 +1326,7 @@ void cpsw_ale_start(struct cpsw_ale *ale)
cpsw_ale_aging_start(ale);
}
+EXPORT_SYMBOL_GPL(cpsw_ale_start);
void cpsw_ale_stop(struct cpsw_ale *ale)
{
@@ -1318,6 +1334,7 @@ void cpsw_ale_stop(struct cpsw_ale *ale)
cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
}
+EXPORT_SYMBOL_GPL(cpsw_ale_stop);
static const struct reg_field ale_fields_cpsw[] = {
/* CPSW_ALE_IDVER_REG */
@@ -1618,6 +1635,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
return ale;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_create);
void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
{
@@ -1628,6 +1646,7 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
data += ALE_ENTRY_WORDS;
}
}
+EXPORT_SYMBOL_GPL(cpsw_ale_dump);
void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
{
@@ -1638,11 +1657,13 @@ void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
data += ALE_ENTRY_WORDS;
}
}
+EXPORT_SYMBOL_GPL(cpsw_ale_restore);
u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale)
{
return ale ? ale->params.ale_entries : 0;
}
+EXPORT_SYMBOL_GPL(cpsw_ale_get_num_entries);
/* Reads the specified policer index into ALE POLICER registers */
static void cpsw_ale_policer_read_idx(struct cpsw_ale *ale, u32 idx)
@@ -1745,3 +1766,7 @@ void cpsw_ale_classifier_setup_default(struct cpsw_ale *ale, int num_rx_ch)
1);
}
}
+EXPORT_SYMBOL_GPL(cpsw_ale_classifier_setup_default);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TI N-Port Ethernet Switch Address Lookup Engine");
diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c
index a43f75ee269e..3f2682c461f9 100644
--- a/drivers/net/ethernet/ti/cpsw_ethtool.c
+++ b/drivers/net/ethernet/ti/cpsw_ethtool.c
@@ -144,6 +144,7 @@ u32 cpsw_get_msglevel(struct net_device *ndev)
return priv->msg_enable;
}
+EXPORT_SYMBOL_GPL(cpsw_get_msglevel);
void cpsw_set_msglevel(struct net_device *ndev, u32 value)
{
@@ -151,6 +152,7 @@ void cpsw_set_msglevel(struct net_device *ndev, u32 value)
priv->msg_enable = value;
}
+EXPORT_SYMBOL_GPL(cpsw_set_msglevel);
int cpsw_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
struct kernel_ethtool_coalesce *kernel_coal,
@@ -161,6 +163,7 @@ int cpsw_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
coal->rx_coalesce_usecs = cpsw->coal_intvl;
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_get_coalesce);
int cpsw_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
struct kernel_ethtool_coalesce *kernel_coal,
@@ -220,6 +223,7 @@ int cpsw_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_set_coalesce);
int cpsw_get_sset_count(struct net_device *ndev, int sset)
{
@@ -234,6 +238,7 @@ int cpsw_get_sset_count(struct net_device *ndev, int sset)
return -EOPNOTSUPP;
}
}
+EXPORT_SYMBOL_GPL(cpsw_get_sset_count);
static void cpsw_add_ch_strings(u8 **p, int ch_num, int rx_dir)
{
@@ -271,6 +276,7 @@ void cpsw_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
break;
}
}
+EXPORT_SYMBOL_GPL(cpsw_get_strings);
void cpsw_get_ethtool_stats(struct net_device *ndev,
struct ethtool_stats *stats, u64 *data)
@@ -303,6 +309,7 @@ void cpsw_get_ethtool_stats(struct net_device *ndev,
}
}
}
+EXPORT_SYMBOL_GPL(cpsw_get_ethtool_stats);
void cpsw_get_pauseparam(struct net_device *ndev,
struct ethtool_pauseparam *pause)
@@ -313,6 +320,7 @@ void cpsw_get_pauseparam(struct net_device *ndev,
pause->rx_pause = priv->rx_pause ? true : false;
pause->tx_pause = priv->tx_pause ? true : false;
}
+EXPORT_SYMBOL_GPL(cpsw_get_pauseparam);
void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{
@@ -326,6 +334,7 @@ void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
if (cpsw->slaves[slave_no].phy)
phy_ethtool_get_wol(cpsw->slaves[slave_no].phy, wol);
}
+EXPORT_SYMBOL_GPL(cpsw_get_wol);
int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{
@@ -338,6 +347,7 @@ int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
else
return -EOPNOTSUPP;
}
+EXPORT_SYMBOL_GPL(cpsw_set_wol);
int cpsw_get_regs_len(struct net_device *ndev)
{
@@ -346,6 +356,7 @@ int cpsw_get_regs_len(struct net_device *ndev)
return cpsw_ale_get_num_entries(cpsw->ale) *
ALE_ENTRY_WORDS * sizeof(u32);
}
+EXPORT_SYMBOL_GPL(cpsw_get_regs_len);
void cpsw_get_regs(struct net_device *ndev, struct ethtool_regs *regs, void *p)
{
@@ -357,6 +368,7 @@ void cpsw_get_regs(struct net_device *ndev, struct ethtool_regs *regs, void *p)
cpsw_ale_dump(cpsw->ale, reg);
}
+EXPORT_SYMBOL_GPL(cpsw_get_regs);
int cpsw_ethtool_op_begin(struct net_device *ndev)
{
@@ -370,6 +382,7 @@ int cpsw_ethtool_op_begin(struct net_device *ndev)
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_ethtool_op_begin);
void cpsw_ethtool_op_complete(struct net_device *ndev)
{
@@ -377,6 +390,7 @@ void cpsw_ethtool_op_complete(struct net_device *ndev)
pm_runtime_put(priv->cpsw->dev);
}
+EXPORT_SYMBOL_GPL(cpsw_ethtool_op_complete);
void cpsw_get_channels(struct net_device *ndev, struct ethtool_channels *ch)
{
@@ -391,6 +405,7 @@ void cpsw_get_channels(struct net_device *ndev, struct ethtool_channels *ch)
ch->tx_count = cpsw->tx_ch_num;
ch->combined_count = 0;
}
+EXPORT_SYMBOL_GPL(cpsw_get_channels);
int cpsw_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *ecmd)
@@ -405,6 +420,7 @@ int cpsw_get_link_ksettings(struct net_device *ndev,
phy_ethtool_ksettings_get(cpsw->slaves[slave_no].phy, ecmd);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_get_link_ksettings);
int cpsw_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *ecmd)
@@ -418,6 +434,7 @@ int cpsw_set_link_ksettings(struct net_device *ndev,
return phy_ethtool_ksettings_set(cpsw->slaves[slave_no].phy, ecmd);
}
+EXPORT_SYMBOL_GPL(cpsw_set_link_ksettings);
int cpsw_get_eee(struct net_device *ndev, struct ethtool_keee *edata)
{
@@ -430,6 +447,7 @@ int cpsw_get_eee(struct net_device *ndev, struct ethtool_keee *edata)
else
return -EOPNOTSUPP;
}
+EXPORT_SYMBOL_GPL(cpsw_get_eee);
int cpsw_nway_reset(struct net_device *ndev)
{
@@ -442,6 +460,7 @@ int cpsw_nway_reset(struct net_device *ndev)
else
return -EOPNOTSUPP;
}
+EXPORT_SYMBOL_GPL(cpsw_nway_reset);
static void cpsw_suspend_data_pass(struct net_device *ndev)
{
@@ -639,6 +658,7 @@ int cpsw_set_channels_common(struct net_device *ndev,
cpsw_fail(cpsw);
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_set_channels_common);
void cpsw_get_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ering,
@@ -654,6 +674,7 @@ void cpsw_get_ringparam(struct net_device *ndev,
ering->rx_max_pending = cpsw->descs_pool_size - CPSW_MAX_QUEUES;
ering->rx_pending = cpdma_get_num_rx_descs(cpsw->dma);
}
+EXPORT_SYMBOL_GPL(cpsw_get_ringparam);
int cpsw_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ering,
@@ -700,6 +721,7 @@ int cpsw_set_ringparam(struct net_device *ndev,
cpsw_fail(cpsw);
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_set_ringparam);
#if IS_ENABLED(CONFIG_TI_CPTS)
int cpsw_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *info)
@@ -720,6 +742,7 @@ int cpsw_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *inf
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_get_ts_info);
#else
int cpsw_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *info)
{
@@ -729,4 +752,5 @@ int cpsw_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *inf
info->rx_filters = 0;
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_get_ts_info);
#endif
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index c6eb6b785b0b..1f6f374551cb 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -32,6 +32,7 @@
#define CPTS_N_ETX_TS 4
int (*cpsw_slave_index)(struct cpsw_common *cpsw, struct cpsw_priv *priv);
+EXPORT_SYMBOL_GPL(cpsw_slave_index);
void cpsw_intr_enable(struct cpsw_common *cpsw)
{
@@ -40,6 +41,7 @@ void cpsw_intr_enable(struct cpsw_common *cpsw)
cpdma_ctlr_int_ctrl(cpsw->dma, true);
}
+EXPORT_SYMBOL_GPL(cpsw_intr_enable);
void cpsw_intr_disable(struct cpsw_common *cpsw)
{
@@ -48,6 +50,7 @@ void cpsw_intr_disable(struct cpsw_common *cpsw)
cpdma_ctlr_int_ctrl(cpsw->dma, false);
}
+EXPORT_SYMBOL_GPL(cpsw_intr_disable);
void cpsw_tx_handler(void *token, int len, int status)
{
@@ -82,6 +85,7 @@ void cpsw_tx_handler(void *token, int len, int status)
ndev->stats.tx_packets++;
ndev->stats.tx_bytes += len;
}
+EXPORT_SYMBOL_GPL(cpsw_tx_handler);
irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
{
@@ -98,6 +102,7 @@ irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
napi_schedule(&cpsw->napi_tx);
return IRQ_HANDLED;
}
+EXPORT_SYMBOL_GPL(cpsw_tx_interrupt);
irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
{
@@ -114,6 +119,7 @@ irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
napi_schedule(&cpsw->napi_rx);
return IRQ_HANDLED;
}
+EXPORT_SYMBOL_GPL(cpsw_rx_interrupt);
irqreturn_t cpsw_misc_interrupt(int irq, void *dev_id)
{
@@ -126,6 +132,7 @@ irqreturn_t cpsw_misc_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+EXPORT_SYMBOL_GPL(cpsw_misc_interrupt);
int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget)
{
@@ -158,6 +165,7 @@ int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget)
return num_tx;
}
+EXPORT_SYMBOL_GPL(cpsw_tx_mq_poll);
int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
{
@@ -176,6 +184,7 @@ int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
return num_tx;
}
+EXPORT_SYMBOL_GPL(cpsw_tx_poll);
int cpsw_rx_mq_poll(struct napi_struct *napi_rx, int budget)
{
@@ -208,6 +217,7 @@ int cpsw_rx_mq_poll(struct napi_struct *napi_rx, int budget)
return num_rx;
}
+EXPORT_SYMBOL_GPL(cpsw_rx_mq_poll);
int cpsw_rx_poll(struct napi_struct *napi_rx, int budget)
{
@@ -226,6 +236,7 @@ int cpsw_rx_poll(struct napi_struct *napi_rx, int budget)
return num_rx;
}
+EXPORT_SYMBOL_GPL(cpsw_rx_poll);
void cpsw_rx_vlan_encap(struct sk_buff *skb)
{
@@ -268,12 +279,14 @@ void cpsw_rx_vlan_encap(struct sk_buff *skb)
skb_pull(skb, VLAN_HLEN);
}
}
+EXPORT_SYMBOL_GPL(cpsw_rx_vlan_encap);
void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
slave_write(slave, mac_hi(priv->mac_addr), SA_HI);
slave_write(slave, mac_lo(priv->mac_addr), SA_LO);
}
+EXPORT_SYMBOL_GPL(cpsw_set_slave_mac);
void cpsw_soft_reset(const char *module, void __iomem *reg)
{
@@ -286,6 +299,7 @@ void cpsw_soft_reset(const char *module, void __iomem *reg)
WARN(readl_relaxed(reg) & 1, "failed to soft-reset %s\n", module);
}
+EXPORT_SYMBOL_GPL(cpsw_soft_reset);
void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue)
{
@@ -305,6 +319,7 @@ void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue)
netif_trans_update(ndev);
netif_tx_wake_all_queues(ndev);
}
+EXPORT_SYMBOL_GPL(cpsw_ndo_tx_timeout);
static int cpsw_get_common_speed(struct cpsw_common *cpsw)
{
@@ -343,6 +358,7 @@ int cpsw_need_resplit(struct cpsw_common *cpsw)
return 1;
}
+EXPORT_SYMBOL_GPL(cpsw_need_resplit);
void cpsw_split_res(struct cpsw_common *cpsw)
{
@@ -428,6 +444,7 @@ void cpsw_split_res(struct cpsw_common *cpsw)
if (budget)
cpsw->rxv[0].budget += budget;
}
+EXPORT_SYMBOL_GPL(cpsw_split_res);
int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
int ale_ageout, phys_addr_t desc_mem_phys,
@@ -548,6 +565,7 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_init_common);
#if IS_ENABLED(CONFIG_TI_CPTS)
@@ -678,6 +696,7 @@ int cpsw_hwtstamp_set(struct net_device *dev,
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_hwtstamp_set);
int cpsw_hwtstamp_get(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
@@ -695,12 +714,14 @@ int cpsw_hwtstamp_get(struct net_device *dev,
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_hwtstamp_get);
#else
int cpsw_hwtstamp_get(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
{
return -EOPNOTSUPP;
}
+EXPORT_SYMBOL_GPL(cpsw_hwtstamp_set);
int cpsw_hwtstamp_set(struct net_device *dev,
struct kernel_hwtstamp_config *cfg,
@@ -708,6 +729,7 @@ int cpsw_hwtstamp_set(struct net_device *dev,
{
return -EOPNOTSUPP;
}
+EXPORT_SYMBOL_GPL(cpsw_hwtstamp_get);
#endif /*CONFIG_TI_CPTS*/
int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate)
@@ -758,6 +780,7 @@ int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate)
cpsw_split_res(cpsw);
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_ndo_set_tx_maxrate);
static int cpsw_tc_to_fifo(int tc, int num_tc)
{
@@ -782,6 +805,7 @@ bool cpsw_shp_is_off(struct cpsw_priv *priv)
return !val;
}
+EXPORT_SYMBOL_GPL(cpsw_shp_is_off);
static void cpsw_fifo_shp_on(struct cpsw_priv *priv, int fifo, int on)
{
@@ -1043,6 +1067,7 @@ int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
return -EOPNOTSUPP;
}
}
+EXPORT_SYMBOL_GPL(cpsw_ndo_setup_tc);
void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
@@ -1056,6 +1081,7 @@ void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
cpsw_set_fifo_rlimit(priv, fifo, bw);
}
}
+EXPORT_SYMBOL_GPL(cpsw_cbs_resume);
void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
@@ -1078,6 +1104,7 @@ void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
slave_write(slave, tx_prio_map, tx_prio_rg);
}
+EXPORT_SYMBOL_GPL(cpsw_mqprio_resume);
int cpsw_fill_rx_channels(struct cpsw_priv *priv)
{
@@ -1123,6 +1150,7 @@ int cpsw_fill_rx_channels(struct cpsw_priv *priv)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_fill_rx_channels);
static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw,
int size)
@@ -1208,6 +1236,7 @@ void cpsw_destroy_xdp_rxqs(struct cpsw_common *cpsw)
cpsw->page_pool[ch] = NULL;
}
}
+EXPORT_SYMBOL_GPL(cpsw_destroy_xdp_rxqs);
int cpsw_create_xdp_rxqs(struct cpsw_common *cpsw)
{
@@ -1240,6 +1269,7 @@ int cpsw_create_xdp_rxqs(struct cpsw_common *cpsw)
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_create_xdp_rxqs);
static int cpsw_xdp_prog_setup(struct cpsw_priv *priv, struct netdev_bpf *bpf)
{
@@ -1267,6 +1297,7 @@ int cpsw_ndo_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
return -EINVAL;
}
}
+EXPORT_SYMBOL_GPL(cpsw_ndo_bpf);
int cpsw_xdp_tx_frame(struct cpsw_priv *priv, struct xdp_frame *xdpf,
struct page *page, int port)
@@ -1300,6 +1331,7 @@ int cpsw_xdp_tx_frame(struct cpsw_priv *priv, struct xdp_frame *xdpf,
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_xdp_tx_frame);
int cpsw_run_xdp(struct cpsw_priv *priv, int ch, struct xdp_buff *xdp,
struct page *page, int port, int *len)
@@ -1362,6 +1394,7 @@ int cpsw_run_xdp(struct cpsw_priv *priv, int ch, struct xdp_buff *xdp,
page_pool_recycle_direct(cpsw->page_pool[ch], page);
return ret;
}
+EXPORT_SYMBOL_GPL(cpsw_run_xdp);
static int cpsw_qos_clsflower_add_policer(struct cpsw_priv *priv,
struct netlink_ext_ack *extack,
@@ -1564,3 +1597,7 @@ void cpsw_qos_clsflower_resume(struct cpsw_priv *priv)
cpsw_ale_rx_ratelimit_mc(priv->cpsw->ale, port_id,
priv->ale_mc_ratelimit.rate_packet_ps);
}
+EXPORT_SYMBOL_GPL(cpsw_qos_clsflower_resume);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TI CPSW Ethernet Switch Driver");
diff --git a/drivers/net/ethernet/ti/cpsw_sl.c b/drivers/net/ethernet/ti/cpsw_sl.c
index 0c7531cb0f39..761719a348fa 100644
--- a/drivers/net/ethernet/ti/cpsw_sl.c
+++ b/drivers/net/ethernet/ti/cpsw_sl.c
@@ -200,6 +200,7 @@ u32 cpsw_sl_reg_read(struct cpsw_sl *sl, enum cpsw_sl_regs reg)
dev_dbg(sl->dev, "cpsw_sl: reg: %04X r 0x%08X\n", sl->regs[reg], val);
return val;
}
+EXPORT_SYMBOL_GPL(cpsw_sl_reg_read);
void cpsw_sl_reg_write(struct cpsw_sl *sl, enum cpsw_sl_regs reg, u32 val)
{
@@ -212,6 +213,7 @@ void cpsw_sl_reg_write(struct cpsw_sl *sl, enum cpsw_sl_regs reg, u32 val)
dev_dbg(sl->dev, "cpsw_sl: reg: %04X w 0x%08X\n", sl->regs[reg], val);
writel(val, sl->sl_base + sl->regs[reg]);
}
+EXPORT_SYMBOL_GPL(cpsw_sl_reg_write);
static const struct cpsw_sl_dev_id *cpsw_sl_match_id(
const struct cpsw_sl_dev_id *id,
@@ -252,6 +254,7 @@ struct cpsw_sl *cpsw_sl_get(const char *device_id, struct device *dev,
return sl;
}
+EXPORT_SYMBOL_GPL(cpsw_sl_get);
void cpsw_sl_reset(struct cpsw_sl *sl, unsigned long tmo)
{
@@ -270,6 +273,7 @@ void cpsw_sl_reset(struct cpsw_sl *sl, unsigned long tmo)
if (cpsw_sl_reg_read(sl, CPSW_SL_SOFT_RESET) & CPSW_SL_SOFT_RESET_BIT)
dev_err(sl->dev, "cpsw_sl failed to soft-reset.\n");
}
+EXPORT_SYMBOL_GPL(cpsw_sl_reset);
u32 cpsw_sl_ctl_set(struct cpsw_sl *sl, u32 ctl_funcs)
{
@@ -287,6 +291,7 @@ u32 cpsw_sl_ctl_set(struct cpsw_sl *sl, u32 ctl_funcs)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_sl_ctl_set);
u32 cpsw_sl_ctl_clr(struct cpsw_sl *sl, u32 ctl_funcs)
{
@@ -304,11 +309,13 @@ u32 cpsw_sl_ctl_clr(struct cpsw_sl *sl, u32 ctl_funcs)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_sl_ctl_clr);
void cpsw_sl_ctl_reset(struct cpsw_sl *sl)
{
cpsw_sl_reg_write(sl, CPSW_SL_MACCONTROL, 0);
}
+EXPORT_SYMBOL_GPL(cpsw_sl_ctl_reset);
int cpsw_sl_wait_for_idle(struct cpsw_sl *sl, unsigned long tmo)
{
@@ -326,3 +333,7 @@ int cpsw_sl_wait_for_idle(struct cpsw_sl *sl, unsigned long tmo)
return 0;
}
+EXPORT_SYMBOL_GPL(cpsw_sl_wait_for_idle);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TI Ethernet Switch media-access-controller (MAC) submodule");
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index d2eab5cd1e0c..41e89a19be53 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -531,6 +531,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
ctlr->num_chan = CPDMA_MAX_CHANNELS;
return ctlr;
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_create);
int cpdma_ctlr_start(struct cpdma_ctlr *ctlr)
{
@@ -591,6 +592,7 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr)
spin_unlock_irqrestore(&ctlr->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_start);
int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr)
{
@@ -623,6 +625,7 @@ int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr)
spin_unlock_irqrestore(&ctlr->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_stop);
int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
{
@@ -640,6 +643,7 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_desc_pool_destroy(ctlr);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy);
int cpdma_ctlr_int_ctrl(struct cpdma_ctlr *ctlr, bool enable)
{
@@ -660,21 +664,25 @@ int cpdma_ctlr_int_ctrl(struct cpdma_ctlr *ctlr, bool enable)
spin_unlock_irqrestore(&ctlr->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_int_ctrl);
void cpdma_ctlr_eoi(struct cpdma_ctlr *ctlr, u32 value)
{
dma_reg_write(ctlr, CPDMA_MACEOIVECTOR, value);
}
+EXPORT_SYMBOL_GPL(cpdma_ctlr_eoi);
u32 cpdma_ctrl_rxchs_state(struct cpdma_ctlr *ctlr)
{
return dma_reg_read(ctlr, CPDMA_RXINTSTATMASKED);
}
+EXPORT_SYMBOL_GPL(cpdma_ctrl_rxchs_state);
u32 cpdma_ctrl_txchs_state(struct cpdma_ctlr *ctlr)
{
return dma_reg_read(ctlr, CPDMA_TXINTSTATMASKED);
}
+EXPORT_SYMBOL_GPL(cpdma_ctrl_txchs_state);
static void cpdma_chan_set_descs(struct cpdma_ctlr *ctlr,
int rx, int desc_num,
@@ -802,6 +810,7 @@ int cpdma_chan_set_weight(struct cpdma_chan *ch, int weight)
spin_unlock_irqrestore(&ctlr->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_set_weight);
/* cpdma_chan_get_min_rate - get minimum allowed rate for channel
* Should be called before cpdma_chan_set_rate.
@@ -816,6 +825,7 @@ u32 cpdma_chan_get_min_rate(struct cpdma_ctlr *ctlr)
return DIV_ROUND_UP(divident, divisor);
}
+EXPORT_SYMBOL_GPL(cpdma_chan_get_min_rate);
/* cpdma_chan_set_rate - limits bandwidth for transmit channel.
* The bandwidth * limited channels have to be in order beginning from lowest.
@@ -860,6 +870,7 @@ int cpdma_chan_set_rate(struct cpdma_chan *ch, u32 rate)
spin_unlock_irqrestore(&ctlr->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_set_rate);
u32 cpdma_chan_get_rate(struct cpdma_chan *ch)
{
@@ -872,6 +883,7 @@ u32 cpdma_chan_get_rate(struct cpdma_chan *ch)
return rate;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_get_rate);
struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
cpdma_handler_fn handler, int rx_type)
@@ -931,6 +943,7 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
spin_unlock_irqrestore(&ctlr->lock, flags);
return chan;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_create);
int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan)
{
@@ -943,6 +956,7 @@ int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan)
return desc_num;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_get_rx_buf_num);
int cpdma_chan_destroy(struct cpdma_chan *chan)
{
@@ -964,6 +978,7 @@ int cpdma_chan_destroy(struct cpdma_chan *chan)
spin_unlock_irqrestore(&ctlr->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_destroy);
int cpdma_chan_get_stats(struct cpdma_chan *chan,
struct cpdma_chan_stats *stats)
@@ -976,6 +991,7 @@ int cpdma_chan_get_stats(struct cpdma_chan *chan,
spin_unlock_irqrestore(&chan->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_get_stats);
static void __cpdma_chan_submit(struct cpdma_chan *chan,
struct cpdma_desc __iomem *desc)
@@ -1100,6 +1116,7 @@ int cpdma_chan_idle_submit(struct cpdma_chan *chan, void *token, void *data,
spin_unlock_irqrestore(&chan->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_idle_submit);
int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token,
dma_addr_t data, int len, int directed)
@@ -1125,6 +1142,7 @@ int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token,
spin_unlock_irqrestore(&chan->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_idle_submit_mapped);
int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data,
int len, int directed)
@@ -1150,6 +1168,7 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data,
spin_unlock_irqrestore(&chan->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_submit);
int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token,
dma_addr_t data, int len, int directed)
@@ -1175,6 +1194,7 @@ int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token,
spin_unlock_irqrestore(&chan->lock, flags);
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_submit_mapped);
bool cpdma_check_free_tx_desc(struct cpdma_chan *chan)
{
@@ -1189,6 +1209,7 @@ bool cpdma_check_free_tx_desc(struct cpdma_chan *chan)
spin_unlock_irqrestore(&chan->lock, flags);
return free_tx_desc;
}
+EXPORT_SYMBOL_GPL(cpdma_check_free_tx_desc);
static void __cpdma_chan_free(struct cpdma_chan *chan,
struct cpdma_desc __iomem *desc,
@@ -1289,6 +1310,7 @@ int cpdma_chan_process(struct cpdma_chan *chan, int quota)
}
return used;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_process);
int cpdma_chan_start(struct cpdma_chan *chan)
{
@@ -1308,6 +1330,7 @@ int cpdma_chan_start(struct cpdma_chan *chan)
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_start);
int cpdma_chan_stop(struct cpdma_chan *chan)
{
@@ -1370,6 +1393,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
spin_unlock_irqrestore(&chan->lock, flags);
return 0;
}
+EXPORT_SYMBOL_GPL(cpdma_chan_stop);
int cpdma_chan_int_ctrl(struct cpdma_chan *chan, bool enable)
{
@@ -1416,11 +1440,13 @@ int cpdma_get_num_rx_descs(struct cpdma_ctlr *ctlr)
{
return ctlr->num_rx_desc;
}
+EXPORT_SYMBOL_GPL(cpdma_get_num_rx_descs);
int cpdma_get_num_tx_descs(struct cpdma_ctlr *ctlr)
{
return ctlr->num_tx_desc;
}
+EXPORT_SYMBOL_GPL(cpdma_get_num_tx_descs);
int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc)
{
@@ -1442,3 +1468,4 @@ int cpdma_set_num_rx_descs(struct cpdma_ctlr *ctlr, int num_rx_desc)
return ret;
}
+EXPORT_SYMBOL_GPL(cpdma_set_num_rx_descs);
--
2.39.5
^ permalink raw reply related
* [PATCH 1/3] [v4, net-next] net: ethernet: ti-cpsw:: rename soft_reset() function
From: Arnd Bergmann @ 2026-04-02 18:46 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Grygorii Strashko, Ilias Apalodimas,
Murali Karicheri
Cc: Siddharth Vadapalli, Roger Quadros, Vladimir Oltean,
Alexander Sverdlin, Ioana Ciornei, linux-omap, Arnd Bergmann,
Kevin Hao, Daniel Zahka, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
While looking at the glob symbols shared between the cpsw drivers,
I noticed that soft_reset() is the only one that is missing a proper
namespace prefix, and will pollute the kernel namespace, so rename
it to be consistent with the other symbols.
Fixes: c5013ac1dd0e1 ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/ti/cpsw.c | 2 +-
drivers/net/ethernet/ti/cpsw_new.c | 2 +-
drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
drivers/net/ethernet/ti/cpsw_priv.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index b0e18bdc2c85..aa3531e844e8 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -706,7 +706,7 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
struct cpsw_common *cpsw = priv->cpsw;
/* soft reset the controller and initialize ale */
- soft_reset("cpsw", &cpsw->regs->soft_reset);
+ cpsw_soft_reset("cpsw", &cpsw->regs->soft_reset);
cpsw_ale_start(cpsw->ale);
/* switch to vlan aware mode */
diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
index 7f42f58a4b03..c5be359f3c66 100644
--- a/drivers/net/ethernet/ti/cpsw_new.c
+++ b/drivers/net/ethernet/ti/cpsw_new.c
@@ -573,7 +573,7 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
u32 control_reg;
/* soft reset the controller and initialize ale */
- soft_reset("cpsw", &cpsw->regs->soft_reset);
+ cpsw_soft_reset("cpsw", &cpsw->regs->soft_reset);
cpsw_ale_start(cpsw->ale);
/* switch to vlan aware mode */
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index bc4fdf17a99e..c6eb6b785b0b 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -275,7 +275,7 @@ void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv)
slave_write(slave, mac_lo(priv->mac_addr), SA_LO);
}
-void soft_reset(const char *module, void __iomem *reg)
+void cpsw_soft_reset(const char *module, void __iomem *reg)
{
unsigned long timeout = jiffies + HZ;
diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h
index acb6181c5c9e..fddd7a79f4b0 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.h
+++ b/drivers/net/ethernet/ti/cpsw_priv.h
@@ -458,7 +458,7 @@ int cpsw_tx_poll(struct napi_struct *napi_tx, int budget);
int cpsw_rx_mq_poll(struct napi_struct *napi_rx, int budget);
int cpsw_rx_poll(struct napi_struct *napi_rx, int budget);
void cpsw_rx_vlan_encap(struct sk_buff *skb);
-void soft_reset(const char *module, void __iomem *reg);
+void cpsw_soft_reset(const char *module, void __iomem *reg);
void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv);
void cpsw_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue);
int cpsw_need_resplit(struct cpsw_common *cpsw);
--
2.39.5
^ permalink raw reply related
* [PATCH v4 3/3] dpll: zl3073x: implement frequency monitoring
From: Ivan Vecera @ 2026-04-02 18:40 UTC (permalink / raw)
To: netdev
Cc: Petr Oros, Arkadiusz Kubalewski, David S. Miller, Donald Hunter,
Eric Dumazet, Jakub Kicinski, Jiri Pirko, Jonathan Corbet,
Michal Schmidt, Paolo Abeni, Prathosh Satish, Shuah Khan,
Simon Horman, Vadim Fedorenko, linux-doc, linux-kernel
In-Reply-To: <20260402184057.1890514-1-ivecera@redhat.com>
Extract common measurement latch logic from zl3073x_ref_ffo_update()
into a new zl3073x_ref_freq_meas_latch() helper and add
zl3073x_ref_freq_meas_update() that uses it to latch and read absolute
input reference frequencies in Hz.
Add meas_freq field to struct zl3073x_ref and the corresponding
zl3073x_ref_meas_freq_get() accessor. The measured frequencies are
updated periodically alongside the existing FFO measurements.
Add freq_monitor boolean to struct zl3073x_dpll and implement the
freq_monitor_set/get device callbacks to enable/disable frequency
monitoring via the DPLL netlink interface.
Implement measured_freq_get pin callback for input pins that returns the
measured input frequency in mHz.
Reviewed-by: Petr Oros <poros@redhat.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
drivers/dpll/zl3073x/core.c | 88 ++++++++++++++++++++++++++-----
drivers/dpll/zl3073x/dpll.c | 100 ++++++++++++++++++++++++++++++++++--
drivers/dpll/zl3073x/dpll.h | 2 +
drivers/dpll/zl3073x/ref.h | 14 +++++
4 files changed, 187 insertions(+), 17 deletions(-)
diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c
index 6363002d48d46..cb47a5db061aa 100644
--- a/drivers/dpll/zl3073x/core.c
+++ b/drivers/dpll/zl3073x/core.c
@@ -632,22 +632,21 @@ int zl3073x_ref_phase_offsets_update(struct zl3073x_dev *zldev, int channel)
}
/**
- * zl3073x_ref_ffo_update - update reference fractional frequency offsets
+ * zl3073x_ref_freq_meas_latch - latch reference frequency measurements
* @zldev: pointer to zl3073x_dev structure
+ * @type: measurement type (ZL_REF_FREQ_MEAS_CTRL_*)
*
- * The function asks device to update fractional frequency offsets latch
- * registers the latest measured values, reads and stores them into
+ * The function waits for the previous measurement to finish, selects all
+ * references and requests a new measurement of the given type.
*
* Return: 0 on success, <0 on error
*/
static int
-zl3073x_ref_ffo_update(struct zl3073x_dev *zldev)
+zl3073x_ref_freq_meas_latch(struct zl3073x_dev *zldev, u8 type)
{
- int i, rc;
+ int rc;
- /* Per datasheet we have to wait for 'ref_freq_meas_ctrl' to be zero
- * to ensure that the measured data are coherent.
- */
+ /* Wait for previous measurement to finish */
rc = zl3073x_poll_zero_u8(zldev, ZL_REG_REF_FREQ_MEAS_CTRL,
ZL_REF_FREQ_MEAS_CTRL);
if (rc)
@@ -663,15 +662,64 @@ zl3073x_ref_ffo_update(struct zl3073x_dev *zldev)
if (rc)
return rc;
- /* Request frequency offset measurement */
- rc = zl3073x_write_u8(zldev, ZL_REG_REF_FREQ_MEAS_CTRL,
- ZL_REF_FREQ_MEAS_CTRL_REF_FREQ_OFF);
+ /* Request measurement */
+ rc = zl3073x_write_u8(zldev, ZL_REG_REF_FREQ_MEAS_CTRL, type);
if (rc)
return rc;
/* Wait for finish */
- rc = zl3073x_poll_zero_u8(zldev, ZL_REG_REF_FREQ_MEAS_CTRL,
- ZL_REF_FREQ_MEAS_CTRL);
+ return zl3073x_poll_zero_u8(zldev, ZL_REG_REF_FREQ_MEAS_CTRL,
+ ZL_REF_FREQ_MEAS_CTRL);
+}
+
+/**
+ * zl3073x_ref_freq_meas_update - update measured input reference frequencies
+ * @zldev: pointer to zl3073x_dev structure
+ *
+ * The function asks device to latch measured input reference frequencies
+ * and stores the results in the ref state.
+ *
+ * Return: 0 on success, <0 on error
+ */
+static int
+zl3073x_ref_freq_meas_update(struct zl3073x_dev *zldev)
+{
+ int i, rc;
+
+ rc = zl3073x_ref_freq_meas_latch(zldev, ZL_REF_FREQ_MEAS_CTRL_REF_FREQ);
+ if (rc)
+ return rc;
+
+ /* Read measured frequencies in Hz (unsigned 32-bit, LSB = 1 Hz) */
+ for (i = 0; i < ZL3073X_NUM_REFS; i++) {
+ u32 value;
+
+ rc = zl3073x_read_u32(zldev, ZL_REG_REF_FREQ(i), &value);
+ if (rc)
+ return rc;
+
+ zldev->ref[i].meas_freq = value;
+ }
+
+ return 0;
+}
+
+/**
+ * zl3073x_ref_ffo_update - update reference fractional frequency offsets
+ * @zldev: pointer to zl3073x_dev structure
+ *
+ * The function asks device to latch the latest measured fractional
+ * frequency offset values, reads and stores them into the ref state.
+ *
+ * Return: 0 on success, <0 on error
+ */
+static int
+zl3073x_ref_ffo_update(struct zl3073x_dev *zldev)
+{
+ int i, rc;
+
+ rc = zl3073x_ref_freq_meas_latch(zldev,
+ ZL_REF_FREQ_MEAS_CTRL_REF_FREQ_OFF);
if (rc)
return rc;
@@ -714,6 +762,20 @@ zl3073x_dev_periodic_work(struct kthread_work *work)
dev_warn(zldev->dev, "Failed to update phase offsets: %pe\n",
ERR_PTR(rc));
+ /* Update measured input reference frequencies if any DPLL has
+ * frequency monitoring enabled.
+ */
+ list_for_each_entry(zldpll, &zldev->dplls, list) {
+ if (zldpll->freq_monitor) {
+ rc = zl3073x_ref_freq_meas_update(zldev);
+ if (rc)
+ dev_warn(zldev->dev,
+ "Failed to update measured frequencies: %pe\n",
+ ERR_PTR(rc));
+ break;
+ }
+ }
+
/* Update references' fractional frequency offsets */
rc = zl3073x_ref_ffo_update(zldev);
if (rc)
diff --git a/drivers/dpll/zl3073x/dpll.c b/drivers/dpll/zl3073x/dpll.c
index a29f606318f6d..d788ca45a17e5 100644
--- a/drivers/dpll/zl3073x/dpll.c
+++ b/drivers/dpll/zl3073x/dpll.c
@@ -39,6 +39,7 @@
* @pin_state: last saved pin state
* @phase_offset: last saved pin phase offset
* @freq_offset: last saved fractional frequency offset
+ * @measured_freq: last saved measured frequency
*/
struct zl3073x_dpll_pin {
struct list_head list;
@@ -54,6 +55,7 @@ struct zl3073x_dpll_pin {
enum dpll_pin_state pin_state;
s64 phase_offset;
s64 freq_offset;
+ u32 measured_freq;
};
/*
@@ -202,6 +204,21 @@ zl3073x_dpll_input_pin_ffo_get(const struct dpll_pin *dpll_pin, void *pin_priv,
return 0;
}
+static int
+zl3073x_dpll_input_pin_measured_freq_get(const struct dpll_pin *dpll_pin,
+ void *pin_priv,
+ const struct dpll_device *dpll,
+ void *dpll_priv, u64 *measured_freq,
+ struct netlink_ext_ack *extack)
+{
+ struct zl3073x_dpll_pin *pin = pin_priv;
+
+ *measured_freq = pin->measured_freq;
+ *measured_freq *= DPLL_PIN_MEASURED_FREQUENCY_DIVIDER;
+
+ return 0;
+}
+
static int
zl3073x_dpll_input_pin_frequency_get(const struct dpll_pin *dpll_pin,
void *pin_priv,
@@ -1116,6 +1133,35 @@ zl3073x_dpll_phase_offset_monitor_set(const struct dpll_device *dpll,
return 0;
}
+static int
+zl3073x_dpll_freq_monitor_get(const struct dpll_device *dpll,
+ void *dpll_priv,
+ enum dpll_feature_state *state,
+ struct netlink_ext_ack *extack)
+{
+ struct zl3073x_dpll *zldpll = dpll_priv;
+
+ if (zldpll->freq_monitor)
+ *state = DPLL_FEATURE_STATE_ENABLE;
+ else
+ *state = DPLL_FEATURE_STATE_DISABLE;
+
+ return 0;
+}
+
+static int
+zl3073x_dpll_freq_monitor_set(const struct dpll_device *dpll,
+ void *dpll_priv,
+ enum dpll_feature_state state,
+ struct netlink_ext_ack *extack)
+{
+ struct zl3073x_dpll *zldpll = dpll_priv;
+
+ zldpll->freq_monitor = (state == DPLL_FEATURE_STATE_ENABLE);
+
+ return 0;
+}
+
static const struct dpll_pin_ops zl3073x_dpll_input_pin_ops = {
.direction_get = zl3073x_dpll_pin_direction_get,
.esync_get = zl3073x_dpll_input_pin_esync_get,
@@ -1123,6 +1169,7 @@ static const struct dpll_pin_ops zl3073x_dpll_input_pin_ops = {
.ffo_get = zl3073x_dpll_input_pin_ffo_get,
.frequency_get = zl3073x_dpll_input_pin_frequency_get,
.frequency_set = zl3073x_dpll_input_pin_frequency_set,
+ .measured_freq_get = zl3073x_dpll_input_pin_measured_freq_get,
.phase_offset_get = zl3073x_dpll_input_pin_phase_offset_get,
.phase_adjust_get = zl3073x_dpll_input_pin_phase_adjust_get,
.phase_adjust_set = zl3073x_dpll_input_pin_phase_adjust_set,
@@ -1151,6 +1198,8 @@ static const struct dpll_device_ops zl3073x_dpll_device_ops = {
.phase_offset_avg_factor_set = zl3073x_dpll_phase_offset_avg_factor_set,
.phase_offset_monitor_get = zl3073x_dpll_phase_offset_monitor_get,
.phase_offset_monitor_set = zl3073x_dpll_phase_offset_monitor_set,
+ .freq_monitor_get = zl3073x_dpll_freq_monitor_get,
+ .freq_monitor_set = zl3073x_dpll_freq_monitor_set,
.supported_modes_get = zl3073x_dpll_supported_modes_get,
};
@@ -1572,6 +1621,7 @@ zl3073x_dpll_pin_ffo_check(struct zl3073x_dpll_pin *pin)
struct zl3073x_dev *zldev = zldpll->dev;
const struct zl3073x_ref *ref;
u8 ref_id;
+ s64 ffo;
/* Get reference monitor status */
ref_id = zl3073x_input_pin_ref_get(pin->id);
@@ -1582,10 +1632,47 @@ zl3073x_dpll_pin_ffo_check(struct zl3073x_dpll_pin *pin)
return false;
/* Compare with previous value */
- if (pin->freq_offset != ref->ffo) {
+ ffo = zl3073x_ref_ffo_get(ref);
+ if (pin->freq_offset != ffo) {
dev_dbg(zldev->dev, "%s freq offset changed: %lld -> %lld\n",
- pin->label, pin->freq_offset, ref->ffo);
- pin->freq_offset = ref->ffo;
+ pin->label, pin->freq_offset, ffo);
+ pin->freq_offset = ffo;
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * zl3073x_dpll_pin_measured_freq_check - check for pin measured frequency
+ * change
+ * @pin: pin to check
+ *
+ * Check for the given pin's measured frequency change.
+ *
+ * Return: true on measured frequency change, false otherwise
+ */
+static bool
+zl3073x_dpll_pin_measured_freq_check(struct zl3073x_dpll_pin *pin)
+{
+ struct zl3073x_dpll *zldpll = pin->dpll;
+ struct zl3073x_dev *zldev = zldpll->dev;
+ const struct zl3073x_ref *ref;
+ u8 ref_id;
+ u32 freq;
+
+ if (!zldpll->freq_monitor)
+ return false;
+
+ ref_id = zl3073x_input_pin_ref_get(pin->id);
+ ref = zl3073x_ref_state_get(zldev, ref_id);
+
+ freq = zl3073x_ref_meas_freq_get(ref);
+ if (pin->measured_freq != freq) {
+ dev_dbg(zldev->dev, "%s measured freq changed: %u -> %u\n",
+ pin->label, pin->measured_freq, freq);
+ pin->measured_freq = freq;
return true;
}
@@ -1677,13 +1764,18 @@ zl3073x_dpll_changes_check(struct zl3073x_dpll *zldpll)
pin_changed = true;
}
- /* Check for phase offset and ffo change once per second */
+ /* Check for phase offset, ffo, and measured freq change
+ * once per second.
+ */
if (zldpll->check_count % 2 == 0) {
if (zl3073x_dpll_pin_phase_offset_check(pin))
pin_changed = true;
if (zl3073x_dpll_pin_ffo_check(pin))
pin_changed = true;
+
+ if (zl3073x_dpll_pin_measured_freq_check(pin))
+ pin_changed = true;
}
if (pin_changed)
diff --git a/drivers/dpll/zl3073x/dpll.h b/drivers/dpll/zl3073x/dpll.h
index 115ee4f67e7ab..434c32a7db123 100644
--- a/drivers/dpll/zl3073x/dpll.h
+++ b/drivers/dpll/zl3073x/dpll.h
@@ -15,6 +15,7 @@
* @id: DPLL index
* @check_count: periodic check counter
* @phase_monitor: is phase offset monitor enabled
+ * @freq_monitor: is frequency monitor enabled
* @ops: DPLL device operations for this instance
* @dpll_dev: pointer to registered DPLL device
* @tracker: tracking object for the acquired reference
@@ -28,6 +29,7 @@ struct zl3073x_dpll {
u8 id;
u8 check_count;
bool phase_monitor;
+ bool freq_monitor;
struct dpll_device_ops ops;
struct dpll_device *dpll_dev;
dpll_tracker tracker;
diff --git a/drivers/dpll/zl3073x/ref.h b/drivers/dpll/zl3073x/ref.h
index 06d8d4d97ea26..be16be20dbc7e 100644
--- a/drivers/dpll/zl3073x/ref.h
+++ b/drivers/dpll/zl3073x/ref.h
@@ -23,6 +23,7 @@ struct zl3073x_dev;
* @sync_ctrl: reference sync control
* @config: reference config
* @ffo: current fractional frequency offset
+ * @meas_freq: measured input frequency in Hz
* @mon_status: reference monitor status
*/
struct zl3073x_ref {
@@ -40,6 +41,7 @@ struct zl3073x_ref {
);
struct_group(stat, /* Status */
s64 ffo;
+ u32 meas_freq;
u8 mon_status;
);
};
@@ -68,6 +70,18 @@ zl3073x_ref_ffo_get(const struct zl3073x_ref *ref)
return ref->ffo;
}
+/**
+ * zl3073x_ref_meas_freq_get - get measured input frequency
+ * @ref: pointer to ref state
+ *
+ * Return: measured input frequency in Hz
+ */
+static inline u32
+zl3073x_ref_meas_freq_get(const struct zl3073x_ref *ref)
+{
+ return ref->meas_freq;
+}
+
/**
* zl3073x_ref_freq_get - get given input reference frequency
* @ref: pointer to ref state
--
2.52.0
^ permalink raw reply related
* [PATCH v4 2/3] dpll: add frequency monitoring callback ops
From: Ivan Vecera @ 2026-04-02 18:40 UTC (permalink / raw)
To: netdev
Cc: Vadim Fedorenko, Arkadiusz Kubalewski, David S. Miller,
Donald Hunter, Eric Dumazet, Jakub Kicinski, Jiri Pirko,
Jonathan Corbet, Michal Schmidt, Paolo Abeni, Petr Oros,
Prathosh Satish, Shuah Khan, Simon Horman, linux-doc,
linux-kernel
In-Reply-To: <20260402184057.1890514-1-ivecera@redhat.com>
Add new callback operations for a dpll device:
- freq_monitor_get(..) - to obtain current state of frequency monitor
feature from dpll device,
- freq_monitor_set(..) - to allow feature configuration.
Add new callback operation for a dpll pin:
- measured_freq_get(..) - to obtain the measured frequency in mHz.
Obtain the feature state value using the get callback and provide it to
the user if the device driver implements callbacks. The measured_freq_get
pin callback is only invoked when the frequency monitor is enabled.
The freq_monitor_get device callback is required when measured_freq_get
is provided by the driver.
Execute the set callback upon user requests.
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
Changes v3 -> v4:
- Moved freq_monitor_{g,s}et validation from netlink to pin
registration with WARN_ON (Vadim)
Changes v2 -> v3:
- Made freq_monitor_get required when measured_freq_get is present (Jakub)
Changes v1 -> v2:
- Renamed actual-frequency to measured-frequency (Vadim)
---
drivers/dpll/dpll_core.c | 5 ++-
drivers/dpll/dpll_netlink.c | 90 +++++++++++++++++++++++++++++++++++++
include/linux/dpll.h | 10 +++++
3 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 3f54754cdec4b..cbb635db43210 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -876,7 +876,10 @@ dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
if (WARN_ON(!ops) ||
WARN_ON(!ops->state_on_dpll_get) ||
- WARN_ON(!ops->direction_get))
+ WARN_ON(!ops->direction_get) ||
+ WARN_ON(ops->measured_freq_get &&
+ (!dpll_device_ops(dpll)->freq_monitor_get ||
+ !dpll_device_ops(dpll)->freq_monitor_set)))
return -EINVAL;
mutex_lock(&dpll_lock);
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 83cbd64abf5a4..af7ce62ec55ca 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -175,6 +175,26 @@ dpll_msg_add_phase_offset_monitor(struct sk_buff *msg, struct dpll_device *dpll,
return 0;
}
+static int
+dpll_msg_add_freq_monitor(struct sk_buff *msg, struct dpll_device *dpll,
+ struct netlink_ext_ack *extack)
+{
+ const struct dpll_device_ops *ops = dpll_device_ops(dpll);
+ enum dpll_feature_state state;
+ int ret;
+
+ if (ops->freq_monitor_set && ops->freq_monitor_get) {
+ ret = ops->freq_monitor_get(dpll, dpll_priv(dpll),
+ &state, extack);
+ if (ret)
+ return ret;
+ if (nla_put_u32(msg, DPLL_A_FREQUENCY_MONITOR, state))
+ return -EMSGSIZE;
+ }
+
+ return 0;
+}
+
static int
dpll_msg_add_phase_offset_avg_factor(struct sk_buff *msg,
struct dpll_device *dpll,
@@ -400,6 +420,38 @@ static int dpll_msg_add_ffo(struct sk_buff *msg, struct dpll_pin *pin,
ffo);
}
+static int dpll_msg_add_measured_freq(struct sk_buff *msg, struct dpll_pin *pin,
+ struct dpll_pin_ref *ref,
+ struct netlink_ext_ack *extack)
+{
+ const struct dpll_device_ops *dev_ops = dpll_device_ops(ref->dpll);
+ const struct dpll_pin_ops *ops = dpll_pin_ops(ref);
+ struct dpll_device *dpll = ref->dpll;
+ enum dpll_feature_state state;
+ u64 measured_freq;
+ int ret;
+
+ if (!ops->measured_freq_get)
+ return 0;
+ ret = dev_ops->freq_monitor_get(dpll, dpll_priv(dpll),
+ &state, extack);
+ if (ret)
+ return ret;
+ if (state == DPLL_FEATURE_STATE_DISABLE)
+ return 0;
+ ret = ops->measured_freq_get(pin, dpll_pin_on_dpll_priv(dpll, pin),
+ dpll, dpll_priv(dpll), &measured_freq,
+ extack);
+ if (ret)
+ return ret;
+ if (nla_put_64bit(msg, DPLL_A_PIN_MEASURED_FREQUENCY,
+ sizeof(measured_freq), &measured_freq,
+ DPLL_A_PIN_PAD))
+ return -EMSGSIZE;
+
+ return 0;
+}
+
static int
dpll_msg_add_pin_freq(struct sk_buff *msg, struct dpll_pin *pin,
struct dpll_pin_ref *ref, struct netlink_ext_ack *extack)
@@ -670,6 +722,9 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
if (ret)
return ret;
ret = dpll_msg_add_ffo(msg, pin, ref, extack);
+ if (ret)
+ return ret;
+ ret = dpll_msg_add_measured_freq(msg, pin, ref, extack);
if (ret)
return ret;
ret = dpll_msg_add_pin_esync(msg, pin, ref, extack);
@@ -722,6 +777,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
if (ret)
return ret;
ret = dpll_msg_add_phase_offset_avg_factor(msg, dpll, extack);
+ if (ret)
+ return ret;
+ ret = dpll_msg_add_freq_monitor(msg, dpll, extack);
if (ret)
return ret;
@@ -948,6 +1006,32 @@ dpll_phase_offset_avg_factor_set(struct dpll_device *dpll, struct nlattr *a,
extack);
}
+static int
+dpll_freq_monitor_set(struct dpll_device *dpll, struct nlattr *a,
+ struct netlink_ext_ack *extack)
+{
+ const struct dpll_device_ops *ops = dpll_device_ops(dpll);
+ enum dpll_feature_state state = nla_get_u32(a), old_state;
+ int ret;
+
+ if (!(ops->freq_monitor_set && ops->freq_monitor_get)) {
+ NL_SET_ERR_MSG_ATTR(extack, a,
+ "dpll device not capable of frequency monitor");
+ return -EOPNOTSUPP;
+ }
+ ret = ops->freq_monitor_get(dpll, dpll_priv(dpll), &old_state,
+ extack);
+ if (ret) {
+ NL_SET_ERR_MSG(extack,
+ "unable to get current state of frequency monitor");
+ return ret;
+ }
+ if (state == old_state)
+ return 0;
+
+ return ops->freq_monitor_set(dpll, dpll_priv(dpll), state, extack);
+}
+
static int
dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
struct netlink_ext_ack *extack)
@@ -1878,6 +1962,12 @@ dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info)
if (ret)
return ret;
break;
+ case DPLL_A_FREQUENCY_MONITOR:
+ ret = dpll_freq_monitor_set(dpll, a,
+ info->extack);
+ if (ret)
+ return ret;
+ break;
}
}
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 2ce295b46b8cd..b7277a8b484d2 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -52,6 +52,12 @@ struct dpll_device_ops {
int (*phase_offset_avg_factor_get)(const struct dpll_device *dpll,
void *dpll_priv, u32 *factor,
struct netlink_ext_ack *extack);
+ int (*freq_monitor_set)(const struct dpll_device *dpll, void *dpll_priv,
+ enum dpll_feature_state state,
+ struct netlink_ext_ack *extack);
+ int (*freq_monitor_get)(const struct dpll_device *dpll, void *dpll_priv,
+ enum dpll_feature_state *state,
+ struct netlink_ext_ack *extack);
};
struct dpll_pin_ops {
@@ -110,6 +116,10 @@ struct dpll_pin_ops {
int (*ffo_get)(const struct dpll_pin *pin, void *pin_priv,
const struct dpll_device *dpll, void *dpll_priv,
s64 *ffo, struct netlink_ext_ack *extack);
+ int (*measured_freq_get)(const struct dpll_pin *pin, void *pin_priv,
+ const struct dpll_device *dpll,
+ void *dpll_priv, u64 *measured_freq,
+ struct netlink_ext_ack *extack);
int (*esync_set)(const struct dpll_pin *pin, void *pin_priv,
const struct dpll_device *dpll, void *dpll_priv,
u64 freq, struct netlink_ext_ack *extack);
--
2.52.0
^ permalink raw reply related
* [PATCH v4 1/3] dpll: add frequency monitoring to netlink spec
From: Ivan Vecera @ 2026-04-02 18:40 UTC (permalink / raw)
To: netdev
Cc: Vadim Fedorenko, Arkadiusz Kubalewski, David S. Miller,
Donald Hunter, Eric Dumazet, Jakub Kicinski, Jiri Pirko,
Jonathan Corbet, Michal Schmidt, Paolo Abeni, Petr Oros,
Prathosh Satish, Shuah Khan, Simon Horman, linux-doc,
linux-kernel
In-Reply-To: <20260402184057.1890514-1-ivecera@redhat.com>
Add DPLL_A_FREQUENCY_MONITOR device attribute to allow control over
the frequency monitor feature. The attribute uses the existing
dpll_feature_state enum (enable/disable) and is present in both
device-get reply and device-set request.
Add DPLL_A_PIN_MEASURED_FREQUENCY pin attribute to expose the measured
input frequency in millihertz (mHz). The attribute is present in the
pin-get reply. Add DPLL_PIN_MEASURED_FREQUENCY_DIVIDER constant to
allow userspace to extract integer and fractional parts.
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
Changes v2 -> v3:
- Improved frequency-monitor doc wording (Jakub)
- Changed measured-frequency to mHz with divider constant (Jakub)
Changes v1 -> v2:
- Renamed actual-frequency to measured-frequency (Vadim)
---
Documentation/driver-api/dpll.rst | 20 +++++++++++++++
Documentation/netlink/specs/dpll.yaml | 35 +++++++++++++++++++++++++++
drivers/dpll/dpll_nl.c | 5 ++--
include/uapi/linux/dpll.h | 5 +++-
4 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 83118c728ed90..93c191b2d0898 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -250,6 +250,24 @@ in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute.
``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature
=============================== ========================
+Frequency monitor
+=================
+
+Some DPLL devices may offer the capability to measure the actual
+frequency of all available input pins. The attribute and current feature state
+shall be included in the response message of the ``DPLL_CMD_DEVICE_GET``
+command for supported DPLL devices. In such cases, users can also control
+the feature using the ``DPLL_CMD_DEVICE_SET`` command by setting the
+``enum dpll_feature_state`` values for the attribute.
+Once enabled the measured input frequency for each input pin shall be
+returned in the ``DPLL_A_PIN_MEASURED_FREQUENCY`` attribute. The value
+is in millihertz (mHz), using ``DPLL_PIN_MEASURED_FREQUENCY_DIVIDER``
+as the divider.
+
+ =============================== ========================
+ ``DPLL_A_FREQUENCY_MONITOR`` attr state of a feature
+ =============================== ========================
+
Embedded SYNC
=============
@@ -411,6 +429,8 @@ according to attribute purpose.
``DPLL_A_PIN_STATE`` attr state of pin on the parent
pin
``DPLL_A_PIN_CAPABILITIES`` attr bitmask of pin capabilities
+ ``DPLL_A_PIN_MEASURED_FREQUENCY`` attr measured frequency of
+ an input pin in mHz
==================================== ==================================
==================================== =================================
diff --git a/Documentation/netlink/specs/dpll.yaml b/Documentation/netlink/specs/dpll.yaml
index 3dd48a32f7837..40465a3d7fc20 100644
--- a/Documentation/netlink/specs/dpll.yaml
+++ b/Documentation/netlink/specs/dpll.yaml
@@ -240,6 +240,20 @@ definitions:
integer part of a measured phase offset value.
Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER) is a
fractional part of a measured phase offset value.
+ -
+ type: const
+ name: pin-measured-frequency-divider
+ value: 1000
+ doc: |
+ pin measured frequency divider allows userspace to calculate
+ a value of measured input frequency as a fractional value with
+ three digit decimal precision (millihertz).
+ Value of (DPLL_A_PIN_MEASURED_FREQUENCY /
+ DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is an integer part of
+ a measured frequency value.
+ Value of (DPLL_A_PIN_MEASURED_FREQUENCY %
+ DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is a fractional part of
+ a measured frequency value.
-
type: enum
name: feature-state
@@ -319,6 +333,13 @@ attribute-sets:
name: phase-offset-avg-factor
type: u32
doc: Averaging factor applied to calculation of reported phase offset.
+ -
+ name: frequency-monitor
+ type: u32
+ enum: feature-state
+ doc: Current or desired state of the frequency monitor feature.
+ If enabled, dpll device shall measure all currently available
+ inputs for their actual input frequency.
-
name: pin
enum-name: dpll_a_pin
@@ -456,6 +477,17 @@ attribute-sets:
Value is in PPT (parts per trillion, 10^-12).
Note: This attribute provides higher resolution than the standard
fractional-frequency-offset (which is in PPM).
+ -
+ name: measured-frequency
+ type: u64
+ doc: |
+ The measured frequency of the input pin in millihertz (mHz).
+ Value of (DPLL_A_PIN_MEASURED_FREQUENCY /
+ DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is an integer part (Hz)
+ of a measured frequency value.
+ Value of (DPLL_A_PIN_MEASURED_FREQUENCY %
+ DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is a fractional part
+ of a measured frequency value.
-
name: pin-parent-device
@@ -544,6 +576,7 @@ operations:
- type
- phase-offset-monitor
- phase-offset-avg-factor
+ - frequency-monitor
dump:
reply: *dev-attrs
@@ -563,6 +596,7 @@ operations:
- mode
- phase-offset-monitor
- phase-offset-avg-factor
+ - frequency-monitor
-
name: device-create-ntf
doc: Notification about device appearing
@@ -643,6 +677,7 @@ operations:
- esync-frequency-supported
- esync-pulse
- reference-sync
+ - measured-frequency
dump:
request:
diff --git a/drivers/dpll/dpll_nl.c b/drivers/dpll/dpll_nl.c
index a2b22d4921142..1e652340a5d73 100644
--- a/drivers/dpll/dpll_nl.c
+++ b/drivers/dpll/dpll_nl.c
@@ -43,11 +43,12 @@ static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = {
};
/* DPLL_CMD_DEVICE_SET - do */
-static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_PHASE_OFFSET_AVG_FACTOR + 1] = {
+static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_FREQUENCY_MONITOR + 1] = {
[DPLL_A_ID] = { .type = NLA_U32, },
[DPLL_A_MODE] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
[DPLL_A_PHASE_OFFSET_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
[DPLL_A_PHASE_OFFSET_AVG_FACTOR] = { .type = NLA_U32, },
+ [DPLL_A_FREQUENCY_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
};
/* DPLL_CMD_PIN_ID_GET - do */
@@ -115,7 +116,7 @@ static const struct genl_split_ops dpll_nl_ops[] = {
.doit = dpll_nl_device_set_doit,
.post_doit = dpll_post_doit,
.policy = dpll_device_set_nl_policy,
- .maxattr = DPLL_A_PHASE_OFFSET_AVG_FACTOR,
+ .maxattr = DPLL_A_FREQUENCY_MONITOR,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
diff --git a/include/uapi/linux/dpll.h b/include/uapi/linux/dpll.h
index de0005f28e5c5..871685f7c353b 100644
--- a/include/uapi/linux/dpll.h
+++ b/include/uapi/linux/dpll.h
@@ -191,7 +191,8 @@ enum dpll_pin_capabilities {
DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE = 4,
};
-#define DPLL_PHASE_OFFSET_DIVIDER 1000
+#define DPLL_PHASE_OFFSET_DIVIDER 1000
+#define DPLL_PIN_MEASURED_FREQUENCY_DIVIDER 1000
/**
* enum dpll_feature_state - Allow control (enable/disable) and status checking
@@ -218,6 +219,7 @@ enum dpll_a {
DPLL_A_CLOCK_QUALITY_LEVEL,
DPLL_A_PHASE_OFFSET_MONITOR,
DPLL_A_PHASE_OFFSET_AVG_FACTOR,
+ DPLL_A_FREQUENCY_MONITOR,
__DPLL_A_MAX,
DPLL_A_MAX = (__DPLL_A_MAX - 1)
@@ -254,6 +256,7 @@ enum dpll_a_pin {
DPLL_A_PIN_REFERENCE_SYNC,
DPLL_A_PIN_PHASE_ADJUST_GRAN,
DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT,
+ DPLL_A_PIN_MEASURED_FREQUENCY,
__DPLL_A_PIN_MAX,
DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)
--
2.52.0
^ permalink raw reply related
* [PATCH v4 0/3] dpll: add frequency monitoring feature
From: Ivan Vecera @ 2026-04-02 18:40 UTC (permalink / raw)
To: netdev
Cc: Arkadiusz Kubalewski, David S. Miller, Donald Hunter,
Eric Dumazet, Jakub Kicinski, Jiri Pirko, Jonathan Corbet,
Michal Schmidt, Paolo Abeni, Petr Oros, Prathosh Satish,
Shuah Khan, Simon Horman, Vadim Fedorenko, linux-doc,
linux-kernel
This series adds support for monitoring the measured input frequency
of DPLL input pins via the DPLL netlink interface.
Some DPLL devices can measure the actual frequency being received on
input pins. The approach mirrors the existing phase-offset-monitor
feature: a device-level attribute (DPLL_A_FREQUENCY_MONITOR) enables
or disables monitoring, and a per-pin attribute
(DPLL_A_PIN_MEASURED_FREQUENCY) exposes the measured frequency in
millihertz (mHz) when monitoring is enabled.
Patch 1 adds the new attributes to the DPLL netlink spec (dpll.yaml),
the DPLL_PIN_MEASURED_FREQUENCY_DIVIDER constant, regenerates the
auto-generated UAPI header and netlink policy, and updates
Documentation/driver-api/dpll.rst.
Patch 2 adds the callback operations (freq_monitor_get/set for
devices, measured_freq_get for pins) and the corresponding netlink
GET/SET handlers in the DPLL core. The core only invokes
measured_freq_get when the frequency monitor is enabled on the parent
device. The freq_monitor_get callback is required when measured_freq_get
is provided.
Patch 3 implements the feature in the ZL3073x driver by extracting
a common measurement latch helper from the existing FFO update path,
adding a frequency measurement function, and wiring up the new
callbacks.
Changes v3 -> v4:
- Moved freq_monitor_{g,s}et validation from netlink to pin
registration with WARN_ON (Vadim)
Changes v2 -> v3:
- Improved frequency-monitor doc wording (Jakub)
- Changed measured-frequency to mHz with divider constant (Jakub)
- Made freq_monitor_get required when measured_freq_get is present (Jakub)
Changes v1 -> v2:
- Renamed actual-frequency to measured-frequency (Vadim)
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Ivan Vecera (3):
dpll: add frequency monitoring to netlink spec
dpll: add frequency monitoring callback ops
dpll: zl3073x: implement frequency monitoring
Documentation/driver-api/dpll.rst | 20 ++++++
Documentation/netlink/specs/dpll.yaml | 35 +++++++++
drivers/dpll/dpll_core.c | 5 +-
drivers/dpll/dpll_netlink.c | 90 +++++++++++++++++++++++
drivers/dpll/dpll_nl.c | 5 +-
drivers/dpll/zl3073x/core.c | 88 +++++++++++++++++++----
drivers/dpll/zl3073x/dpll.c | 100 ++++++++++++++++++++++++--
drivers/dpll/zl3073x/dpll.h | 2 +
drivers/dpll/zl3073x/ref.h | 14 ++++
include/linux/dpll.h | 10 +++
include/uapi/linux/dpll.h | 5 +-
11 files changed, 353 insertions(+), 21 deletions(-)
--
2.52.0
^ permalink raw reply
* Re: [PATCH net-next v2 00/14] net: stmmac: TSO fixes/cleanups
From: patchwork-bot+netdevbpf @ 2026-04-02 18:40 UTC (permalink / raw)
To: Russell King
Cc: andrew, alexandre.torgue, andrew+netdev, davem, edumazet, kuba,
linux-arm-kernel, linux-stm32, netdev, boon.leong.ong, pabeni
In-Reply-To: <aczHVF04LIGq_lYO@shell.armlinux.org.uk>
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 1 Apr 2026 08:20:52 +0100 you wrote:
> This is a more refined version of the previous patch series fixing
> and cleaning up the TSO code.
>
> I'm not sure whether "TSO" or "GSO" should be used to describe this
> feature - although it primarily handles TCP, dwmac4 appears to also
> be able to handle UDP.
>
> [...]
Here is the summary with links:
- [net-next,v2,01/14] net: stmmac: fix channel TSO enable on resume
https://git.kernel.org/netdev/net-next/c/989a9c20f63e
- [net-next,v2,02/14] net: stmmac: fix .ndo_fix_features()
https://git.kernel.org/netdev/net-next/c/afe840ddf15c
- [net-next,v2,03/14] net: stmmac: fix TSO support when some channels have TBS available
https://git.kernel.org/netdev/net-next/c/e32820264c29
- [net-next,v2,04/14] net: stmmac: add stmmac_tso_header_size()
https://git.kernel.org/netdev/net-next/c/f799b5dab9c9
- [net-next,v2,05/14] net: stmmac: add TSO check for header length
https://git.kernel.org/netdev/net-next/c/6732e474f880
- [net-next,v2,06/14] net: stmmac: add GSO MSS checks
https://git.kernel.org/netdev/net-next/c/c05a81cbee87
- [net-next,v2,07/14] net: stmmac: move TSO VLAN tag insertion to core code
https://git.kernel.org/netdev/net-next/c/3f6a6eb9ef21
- [net-next,v2,08/14] net: stmmac: move check for hardware checksum supported
https://git.kernel.org/netdev/net-next/c/b55dfb173ce8
- [net-next,v2,09/14] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
https://git.kernel.org/netdev/net-next/c/2e4082e4b739
- [net-next,v2,10/14] net: stmmac: split out gso features setup
https://git.kernel.org/netdev/net-next/c/c04939cb9851
- [net-next,v2,11/14] net: stmmac: make stmmac_set_gso_features() more readable
https://git.kernel.org/netdev/net-next/c/6ad004442897
- [net-next,v2,12/14] net: stmmac: add warning when TSO is requested but unsupported
https://git.kernel.org/netdev/net-next/c/f8c70ab540c1
- [net-next,v2,13/14] net: stmmac: check txpbl for TSO
https://git.kernel.org/netdev/net-next/c/33f5cc83bbbd
- [net-next,v2,14/14] net: stmmac: move "TSO supported" message to stmmac_set_gso_features()
https://git.kernel.org/netdev/net-next/c/0f96212a5142
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply
* Re: [PATCH net v2 2/2] selftests: seg6: add test for dst_cache isolation in seg6 lwtunnel
From: Justin Iurman @ 2026-04-02 18:35 UTC (permalink / raw)
To: Andrea Mayer, netdev
Cc: davem, edumazet, kuba, pabeni, horms, dsahern, david.lebrun,
stefano.salsano, paolo.lungaroni, nicolas.dichtel, linux-kernel,
Shuah Khan, linux-kselftest
In-Reply-To: <20260401185755.29813-3-andrea.mayer@uniroma2.it>
On 4/1/26 20:57, Andrea Mayer wrote:
> Add a selftest that verifies the dst_cache in seg6 lwtunnel is not
> shared between the input (forwarding) and output (locally generated)
> paths.
>
> The test creates three namespaces (ns_src, ns_router, ns_dst)
> connected in a line. An SRv6 encap route on ns_router encapsulates
> traffic destined to cafe::1 with SID fc00::100. The SID is
> reachable only for forwarded traffic (from ns_src) via an ip rule
> matching the ingress interface (iif veth-r0 lookup 100), and
> blackholed in the main table.
>
> The test verifies that:
>
> 1. A packet generated locally on ns_router does not reach
> ns_dst with an empty cache, since the SID is blackholed;
> 2. A forwarded packet from ns_src populates the input cache
> from table 100 and reaches ns_dst;
> 3. A packet generated locally on ns_router still does not
> reach ns_dst after the input cache is populated,
> confirming the output path does not reuse the input
> cache entry.
>
> Both the forwarded and local packets are pinned to the same CPU
> with taskset, since dst_cache is per-cpu.
>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
> Changes v1 -> v2:
> - fix SKIP message wording (Nicolas)
> ---
> tools/testing/selftests/net/Makefile | 1 +
> .../selftests/net/srv6_iptunnel_cache.sh | 177 ++++++++++++++++++
> 2 files changed, 178 insertions(+)
> create mode 100755 tools/testing/selftests/net/srv6_iptunnel_cache.sh
>
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index 605c54c0e8a3..c709523c99c6 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -89,6 +89,7 @@ TEST_PROGS := \
> srv6_end_x_next_csid_l3vpn_test.sh \
> srv6_hencap_red_l3vpn_test.sh \
> srv6_hl2encap_red_l2vpn_test.sh \
> + srv6_iptunnel_cache.sh \
> stress_reuseport_listen.sh \
> tcp_fastopen_backup_key.sh \
> test_bpf.sh \
> diff --git a/tools/testing/selftests/net/srv6_iptunnel_cache.sh b/tools/testing/selftests/net/srv6_iptunnel_cache.sh
> new file mode 100755
> index 000000000000..1f3ebb930eb2
> --- /dev/null
> +++ b/tools/testing/selftests/net/srv6_iptunnel_cache.sh
> @@ -0,0 +1,177 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# author: Andrea Mayer <andrea.mayer@uniroma2.it>
> +
> +# This test verifies that the seg6 lwtunnel does not share the dst_cache
> +# between the input (forwarding) and output (locally generated) paths.
> +#
> +# A shared dst_cache allows a forwarded packet to populate the cache and a
> +# subsequent locally generated packet to silently reuse that entry, bypassing
> +# its own route lookup. To expose this, the SID is made reachable only for
> +# forwarded traffic (via an ip rule matching iif) and blackholed for everything
> +# else. A local ping on ns_router must always hit the blackhole;
> +# if it succeeds after a forwarded packet has populated the
> +# cache, the bug is confirmed.
> +#
> +# Both forwarded and local packets are pinned to the same CPU with taskset,
> +# since dst_cache is per-cpu.
> +#
> +#
> +# +--------------------+ +--------------------+
> +# | ns_src | | ns_dst |
> +# | | | |
> +# | veth-s0 | | veth-d0 |
> +# | fd00::1/64 | | fd01::2/64 |
> +# +-------|------------+ +----------|---------+
> +# | |
> +# | +--------------------+ |
> +# | | ns_router | |
> +# | | | |
> +# +----------->+ veth-r0 veth-r1 +<-------------+
> +# | fd00::2 fd01::1 |
> +# +--------------------+
> +#
> +#
> +# ns_router: encap (main table)
> +# +---------+---------------------------------------+
> +# | dst | action |
> +# +---------+---------------------------------------+
> +# | cafe::1 | encap seg6 mode encap segs fc00::100 |
> +# +---------+---------------------------------------+
> +#
> +# ns_router: post-encap SID resolution
> +# +-------+------------+----------------------------+
> +# | table | dst | action |
> +# +-------+------------+----------------------------+
> +# | 100 | fc00::100 | via fd01::2 dev veth-r1 |
> +# +-------+------------+----------------------------+
> +# | main | fc00::100 | blackhole |
> +# +-------+------------+----------------------------+
> +#
> +# ns_router: ip rule
> +# +------------------+------------------------------+
> +# | match | action |
> +# +------------------+------------------------------+
> +# | iif veth-r0 | lookup 100 |
> +# +------------------+------------------------------+
> +#
> +# ns_dst: SRv6 decap (main table)
> +# +--------------+----------------------------------+
> +# | SID | action |
> +# +--------------+----------------------------------+
> +# | fc00::100 | End.DT6 table 255 (local) |
> +# +--------------+----------------------------------+
> +
> +source lib.sh
> +
> +readonly SID="fc00::100"
> +readonly DEST="cafe::1"
> +
> +readonly SRC_MAC="02:00:00:00:00:01"
> +readonly RTR_R0_MAC="02:00:00:00:00:02"
> +readonly RTR_R1_MAC="02:00:00:00:00:03"
> +readonly DST_MAC="02:00:00:00:00:04"
> +
> +cleanup()
> +{
> + cleanup_ns "${NS_SRC}" "${NS_RTR}" "${NS_DST}"
> +}
> +
> +check_prerequisites()
> +{
> + if ! command -v taskset &>/dev/null; then
> + echo "SKIP: taskset not found"
> + exit "${ksft_skip}"
> + fi
> +}
> +
> +setup()
> +{
> + setup_ns NS_SRC NS_RTR NS_DST
> +
> + ip link add veth-s0 netns "${NS_SRC}" type veth \
> + peer name veth-r0 netns "${NS_RTR}"
> + ip link add veth-r1 netns "${NS_RTR}" type veth \
> + peer name veth-d0 netns "${NS_DST}"
> +
> + ip -n "${NS_SRC}" link set veth-s0 address "${SRC_MAC}"
> + ip -n "${NS_RTR}" link set veth-r0 address "${RTR_R0_MAC}"
> + ip -n "${NS_RTR}" link set veth-r1 address "${RTR_R1_MAC}"
> + ip -n "${NS_DST}" link set veth-d0 address "${DST_MAC}"
> +
> + # ns_src
> + ip -n "${NS_SRC}" link set veth-s0 up
> + ip -n "${NS_SRC}" addr add fd00::1/64 dev veth-s0 nodad
> + ip -n "${NS_SRC}" -6 route add "${DEST}"/128 via fd00::2
> +
> + # ns_router
> + ip -n "${NS_RTR}" link set veth-r0 up
> + ip -n "${NS_RTR}" addr add fd00::2/64 dev veth-r0 nodad
> + ip -n "${NS_RTR}" link set veth-r1 up
> + ip -n "${NS_RTR}" addr add fd01::1/64 dev veth-r1 nodad
> + ip netns exec "${NS_RTR}" sysctl -qw net.ipv6.conf.all.forwarding=1
> +
> + ip -n "${NS_RTR}" -6 route add "${DEST}"/128 \
> + encap seg6 mode encap segs "${SID}" dev veth-r0
> + ip -n "${NS_RTR}" -6 route add "${SID}"/128 table 100 \
> + via fd01::2 dev veth-r1
> + ip -n "${NS_RTR}" -6 route add blackhole "${SID}"/128
> + ip -n "${NS_RTR}" -6 rule add iif veth-r0 lookup 100
> +
> + # ns_dst
> + ip -n "${NS_DST}" link set veth-d0 up
> + ip -n "${NS_DST}" addr add fd01::2/64 dev veth-d0 nodad
> + ip -n "${NS_DST}" addr add "${DEST}"/128 dev lo nodad
> + ip -n "${NS_DST}" -6 route add "${SID}"/128 \
> + encap seg6local action End.DT6 table 255 dev veth-d0
> + ip -n "${NS_DST}" -6 route add fd00::/64 via fd01::1
> +
> + # static neighbors
> + ip -n "${NS_SRC}" -6 neigh add fd00::2 dev veth-s0 \
> + lladdr "${RTR_R0_MAC}" nud permanent
> + ip -n "${NS_RTR}" -6 neigh add fd00::1 dev veth-r0 \
> + lladdr "${SRC_MAC}" nud permanent
> + ip -n "${NS_RTR}" -6 neigh add fd01::2 dev veth-r1 \
> + lladdr "${DST_MAC}" nud permanent
> + ip -n "${NS_DST}" -6 neigh add fd01::1 dev veth-d0 \
> + lladdr "${RTR_R1_MAC}" nud permanent
> +}
> +
> +test_cache_isolation()
> +{
> + RET=0
> +
> + # local ping with empty cache: must fail (SID is blackholed)
> + if ip netns exec "${NS_RTR}" taskset -c 0 \
> + ping6 -c 1 -W 2 "${DEST}" &>/dev/null; then
> + echo "SKIP: local ping succeeded, topology broken"
> + exit "${ksft_skip}"
> + fi
> +
> + # forward from ns_src to populate the input cache
> + if ! ip netns exec "${NS_SRC}" taskset -c 0 \
> + ping6 -c 1 -W 2 "${DEST}" &>/dev/null; then
> + echo "SKIP: forwarded ping failed, topology broken"
> + exit "${ksft_skip}"
> + fi
> +
> + # local ping again: must still fail; if the output path reuses
> + # the input cache, it bypasses the blackhole and the ping succeeds
> + if ip netns exec "${NS_RTR}" taskset -c 0 \
> + ping6 -c 1 -W 2 "${DEST}" &>/dev/null; then
> + echo "FAIL: output path used dst cached by input path"
> + RET="${ksft_fail}"
> + else
> + echo "PASS: output path dst_cache is independent"
> + fi
> +
> + return "${RET}"
> +}
> +
We should check it runs as root here (e.g, required for netns creation).
if [ "$(id -u)" -ne 0 ]; then
echo "SKIP: Need root privileges"
exit "${ksft_skip}"
fi
Otherwise, LGTM:
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
> +trap cleanup EXIT
> +
> +check_prerequisites
> +setup
> +test_cache_isolation
> +exit "${RET}"
^ permalink raw reply
* Re: [PATCH v25 05/11] sfc: create type2 cxl memdev
From: Dan Williams @ 2026-04-02 18:32 UTC (permalink / raw)
To: Alejandro Lucero Palau, Dan Williams, alejandro.lucero-palau,
linux-cxl, netdev, dave.jiang, edward.cree, davem, kuba, pabeni,
edumazet
Cc: Martin Habets, Fan Ni, Edward Cree, Jonathan Cameron
In-Reply-To: <1d9abc6a-9032-4e0f-b7d8-1bdbdfa0d615@amd.com>
Alejandro Lucero Palau wrote:
[..]
> > ...but it *is* possible to remove cxl_acpi, it *is* possible to invoke
> > 'cxl disable-port'. The fact that it is possible contributes to
> > complexity, but it also supports flexibility and is a building block for
> > error handling / recovery.
>
>
> It is possible but, should it? When should it be allowed with drivers
> relying on its functionality?
That is a good question, but not for this set. The immediate goal is
acquire a region safely, and that means complying with current locking
and lifetime rules. We can always evolve the core over time, but for the
present "just give me a region and call me back if something invalidates
it" is the status quo.
^ permalink raw reply
* [PATCH net-next] eth: remove the driver for acenic / tigon1&2
From: Jakub Kicinski @ 2026-04-02 18:30 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
jes, chenhuacai, kernel, tsbogend, James.Bottomley, deller, maddy,
mpe, npiggin, chleroy, hca, gor, agordeev, borntraeger, svens,
bhelgaas, dakr, kwilczynski, ojeda, boqun, gary, bjorn3_gh,
lossin, a.hindborg, aliceryhl, tmgross, ebiggers, ardb, tiwai,
tytso, enelsonmoore, martin.petersen, jirislaby, gregkh, geert,
herbert, vineethr, lirongqing, kshk, vadim.fedorenko, dong100,
wangruikang, hkallweit1, kees, loongarch, linux-mips,
linux-parisc, linuxppc-dev, linux-s390, linux-pci, rust-for-linux
The entire git history for this driver looks like tree-wide
and automated cleanups. There's even more coming now with
AI, so let's try to delete it instead.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jes@trained-monkey.org
CC: chenhuacai@kernel.org
CC: kernel@xen0n.name
CC: tsbogend@alpha.franken.de
CC: James.Bottomley@HansenPartnership.com
CC: deller@gmx.de
CC: maddy@linux.ibm.com
CC: mpe@ellerman.id.au
CC: npiggin@gmail.com
CC: chleroy@kernel.org
CC: hca@linux.ibm.com
CC: gor@linux.ibm.com
CC: agordeev@linux.ibm.com
CC: borntraeger@linux.ibm.com
CC: svens@linux.ibm.com
CC: bhelgaas@google.com
CC: dakr@kernel.org
CC: kwilczynski@kernel.org
CC: ojeda@kernel.org
CC: boqun@kernel.org
CC: gary@garyguo.net
CC: bjorn3_gh@protonmail.com
CC: lossin@kernel.org
CC: a.hindborg@kernel.org
CC: aliceryhl@google.com
CC: tmgross@umich.edu
CC: ebiggers@google.com
CC: ardb@kernel.org
CC: tiwai@suse.de
CC: tytso@mit.edu
CC: enelsonmoore@gmail.com
CC: martin.petersen@oracle.com
CC: jirislaby@kernel.org
CC: gregkh@linuxfoundation.org
CC: geert@linux-m68k.org
CC: herbert@gondor.apana.org.au
CC: vineethr@linux.ibm.com
CC: lirongqing@baidu.com
CC: kshk@linux.ibm.com
CC: vadim.fedorenko@linux.dev
CC: dong100@mucse.com
CC: wangruikang@iscas.ac.cn
CC: hkallweit1@gmail.com
CC: kees@kernel.org
CC: loongarch@lists.linux.dev
CC: linux-mips@vger.kernel.org
CC: linux-parisc@vger.kernel.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s390@vger.kernel.org
CC: linux-pci@vger.kernel.org
CC: rust-for-linux@vger.kernel.org
---
MAINTAINERS | 6 -
drivers/net/ethernet/Kconfig | 1 -
drivers/net/ethernet/alteon/Kconfig | 47 -
drivers/net/ethernet/Makefile | 1 -
drivers/net/ethernet/alteon/Makefile | 6 -
drivers/net/ethernet/alteon/acenic.h | 791 -----
include/linux/pci_ids.h | 2 -
drivers/net/ethernet/alteon/acenic.c | 3178 -------------------
arch/loongarch/configs/loongson32_defconfig | 1 -
arch/loongarch/configs/loongson64_defconfig | 1 -
arch/mips/configs/cavium_octeon_defconfig | 1 -
arch/mips/configs/loongson2k_defconfig | 1 -
arch/mips/configs/loongson3_defconfig | 1 -
arch/mips/configs/malta_qemu_32r6_defconfig | 1 -
arch/mips/configs/maltaaprp_defconfig | 1 -
arch/mips/configs/maltasmvp_defconfig | 1 -
arch/mips/configs/maltasmvp_eva_defconfig | 1 -
arch/mips/configs/maltaup_defconfig | 1 -
arch/mips/configs/mtx1_defconfig | 1 -
arch/parisc/configs/generic-32bit_defconfig | 1 -
arch/parisc/configs/generic-64bit_defconfig | 1 -
arch/powerpc/configs/44x/akebono_defconfig | 1 -
arch/powerpc/configs/g5_defconfig | 2 -
arch/powerpc/configs/powernv_defconfig | 2 -
arch/powerpc/configs/ppc64_defconfig | 2 -
arch/powerpc/configs/ppc64e_defconfig | 2 -
arch/powerpc/configs/ppc6xx_defconfig | 1 -
arch/powerpc/configs/skiroot_defconfig | 2 -
arch/s390/configs/debug_defconfig | 1 -
arch/s390/configs/defconfig | 1 -
rust/kernel/pci/id.rs | 1 -
31 files changed, 4060 deletions(-)
delete mode 100644 drivers/net/ethernet/alteon/Kconfig
delete mode 100644 drivers/net/ethernet/alteon/Makefile
delete mode 100644 drivers/net/ethernet/alteon/acenic.h
delete mode 100644 drivers/net/ethernet/alteon/acenic.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 7a2ffd9d37d5..8158e4471bb7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -261,12 +261,6 @@ L: linux-gpio@vger.kernel.org
S: Maintained
F: drivers/gpio/gpio-pcie-idio-24.c
-ACENIC DRIVER
-M: Jes Sorensen <jes@trained-monkey.org>
-L: linux-acenic@sunsite.dk
-S: Maintained
-F: drivers/net/ethernet/alteon/acenic*
-
ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER
M: Peter Kaestle <peter@piie.net>
L: platform-driver-x86@vger.kernel.org
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index aa7103e7f47f..bdc29d143160 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -23,7 +23,6 @@ source "drivers/net/ethernet/agere/Kconfig"
source "drivers/net/ethernet/airoha/Kconfig"
source "drivers/net/ethernet/alacritech/Kconfig"
source "drivers/net/ethernet/allwinner/Kconfig"
-source "drivers/net/ethernet/alteon/Kconfig"
source "drivers/net/ethernet/altera/Kconfig"
source "drivers/net/ethernet/amazon/Kconfig"
source "drivers/net/ethernet/amd/Kconfig"
diff --git a/drivers/net/ethernet/alteon/Kconfig b/drivers/net/ethernet/alteon/Kconfig
deleted file mode 100644
index cfe1f3159d61..000000000000
--- a/drivers/net/ethernet/alteon/Kconfig
+++ /dev/null
@@ -1,47 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Alteon network device configuration
-#
-
-config NET_VENDOR_ALTEON
- bool "Alteon devices"
- default y
- depends on PCI
- help
- If you have a network (Ethernet) card belonging to this class, say Y.
-
- Note that the answer to this question doesn't directly affect the
- kernel: saying N will just cause the configurator to skip all
- the questions about Alteon cards. If you say Y, you will be asked for
- your specific card in the following questions.
-
-if NET_VENDOR_ALTEON
-
-config ACENIC
- tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
- depends on PCI
- help
- Say Y here if you have an Alteon AceNIC, 3Com 3C985(B), NetGear
- GA620, SGI Gigabit or Farallon PN9000-SX PCI Gigabit Ethernet
- adapter. The driver allows for using the Jumbo Frame option (9000
- bytes/frame) however it requires that your switches can handle this
- as well. To enable Jumbo Frames, add `mtu 9000' to your ifconfig
- line.
-
- To compile this driver as a module, choose M here: the
- module will be called acenic.
-
-config ACENIC_OMIT_TIGON_I
- bool "Omit support for old Tigon I based AceNICs"
- depends on ACENIC
- help
- Say Y here if you only have Tigon II based AceNICs and want to leave
- out support for the older Tigon I based cards which are no longer
- being sold (ie. the original Alteon AceNIC and 3Com 3C985 (non B
- version)). This will reduce the size of the driver object by
- app. 100KB. If you are not sure whether your card is a Tigon I or a
- Tigon II, say N here.
-
- The safe and default value for this is N.
-
-endif # NET_VENDOR_ALTEON
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index 6615a67a63d5..6bffb60ba644 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_NET_VENDOR_AGERE) += agere/
obj-$(CONFIG_NET_VENDOR_AIROHA) += airoha/
obj-$(CONFIG_NET_VENDOR_ALACRITECH) += alacritech/
obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/
-obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/
obj-$(CONFIG_ALTERA_TSE) += altera/
obj-$(CONFIG_NET_VENDOR_AMAZON) += amazon/
obj-$(CONFIG_NET_VENDOR_AMD) += amd/
diff --git a/drivers/net/ethernet/alteon/Makefile b/drivers/net/ethernet/alteon/Makefile
deleted file mode 100644
index be5225559b6d..000000000000
--- a/drivers/net/ethernet/alteon/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Makefile for the Alteon network device drivers.
-#
-
-obj-$(CONFIG_ACENIC) += acenic.o
diff --git a/drivers/net/ethernet/alteon/acenic.h b/drivers/net/ethernet/alteon/acenic.h
deleted file mode 100644
index 0e45a97b9c9b..000000000000
--- a/drivers/net/ethernet/alteon/acenic.h
+++ /dev/null
@@ -1,791 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ACENIC_H_
-#define _ACENIC_H_
-#include <linux/interrupt.h>
-#include <linux/workqueue.h>
-
-/*
- * Generate TX index update each time, when TX ring is closed.
- * Normally, this is not useful, because results in more dma (and irqs
- * without TX_COAL_INTS_ONLY).
- */
-#define USE_TX_COAL_NOW 0
-
-/*
- * Addressing:
- *
- * The Tigon uses 64-bit host addresses, regardless of their actual
- * length, and it expects a big-endian format. For 32 bit systems the
- * upper 32 bits of the address are simply ignored (zero), however for
- * little endian 64 bit systems (Alpha) this looks strange with the
- * two parts of the address word being swapped.
- *
- * The addresses are split in two 32 bit words for all architectures
- * as some of them are in PCI shared memory and it is necessary to use
- * readl/writel to access them.
- *
- * The addressing code is derived from Pete Wyckoff's work, but
- * modified to deal properly with readl/writel usage.
- */
-
-struct ace_regs {
- u32 pad0[16]; /* PCI control registers */
-
- u32 HostCtrl; /* 0x40 */
- u32 LocalCtrl;
-
- u32 pad1[2];
-
- u32 MiscCfg; /* 0x50 */
-
- u32 pad2[2];
-
- u32 PciState;
-
- u32 pad3[2]; /* 0x60 */
-
- u32 WinBase;
- u32 WinData;
-
- u32 pad4[12]; /* 0x70 */
-
- u32 DmaWriteState; /* 0xa0 */
- u32 pad5[3];
- u32 DmaReadState; /* 0xb0 */
-
- u32 pad6[26];
-
- u32 AssistState;
-
- u32 pad7[8]; /* 0x120 */
-
- u32 CpuCtrl; /* 0x140 */
- u32 Pc;
-
- u32 pad8[3];
-
- u32 SramAddr; /* 0x154 */
- u32 SramData;
-
- u32 pad9[49];
-
- u32 MacRxState; /* 0x220 */
-
- u32 pad10[7];
-
- u32 CpuBCtrl; /* 0x240 */
- u32 PcB;
-
- u32 pad11[3];
-
- u32 SramBAddr; /* 0x254 */
- u32 SramBData;
-
- u32 pad12[105];
-
- u32 pad13[32]; /* 0x400 */
- u32 Stats[32];
-
- u32 Mb0Hi; /* 0x500 */
- u32 Mb0Lo;
- u32 Mb1Hi;
- u32 CmdPrd;
- u32 Mb2Hi;
- u32 TxPrd;
- u32 Mb3Hi;
- u32 RxStdPrd;
- u32 Mb4Hi;
- u32 RxJumboPrd;
- u32 Mb5Hi;
- u32 RxMiniPrd;
- u32 Mb6Hi;
- u32 Mb6Lo;
- u32 Mb7Hi;
- u32 Mb7Lo;
- u32 Mb8Hi;
- u32 Mb8Lo;
- u32 Mb9Hi;
- u32 Mb9Lo;
- u32 MbAHi;
- u32 MbALo;
- u32 MbBHi;
- u32 MbBLo;
- u32 MbCHi;
- u32 MbCLo;
- u32 MbDHi;
- u32 MbDLo;
- u32 MbEHi;
- u32 MbELo;
- u32 MbFHi;
- u32 MbFLo;
-
- u32 pad14[32];
-
- u32 MacAddrHi; /* 0x600 */
- u32 MacAddrLo;
- u32 InfoPtrHi;
- u32 InfoPtrLo;
- u32 MultiCastHi; /* 0x610 */
- u32 MultiCastLo;
- u32 ModeStat;
- u32 DmaReadCfg;
- u32 DmaWriteCfg; /* 0x620 */
- u32 TxBufRat;
- u32 EvtCsm;
- u32 CmdCsm;
- u32 TuneRxCoalTicks;/* 0x630 */
- u32 TuneTxCoalTicks;
- u32 TuneStatTicks;
- u32 TuneMaxTxDesc;
- u32 TuneMaxRxDesc; /* 0x640 */
- u32 TuneTrace;
- u32 TuneLink;
- u32 TuneFastLink;
- u32 TracePtr; /* 0x650 */
- u32 TraceStrt;
- u32 TraceLen;
- u32 IfIdx;
- u32 IfMtu; /* 0x660 */
- u32 MaskInt;
- u32 GigLnkState;
- u32 FastLnkState;
- u32 pad16[4]; /* 0x670 */
- u32 RxRetCsm; /* 0x680 */
-
- u32 pad17[31];
-
- u32 CmdRng[64]; /* 0x700 */
- u32 Window[0x200];
-};
-
-
-typedef struct {
- u32 addrhi;
- u32 addrlo;
-} aceaddr;
-
-
-#define ACE_WINDOW_SIZE 0x800
-
-#define ACE_JUMBO_MTU 9000
-#define ACE_STD_MTU 1500
-
-#define ACE_TRACE_SIZE 0x8000
-
-/*
- * Host control register bits.
- */
-
-#define IN_INT 0x01
-#define CLR_INT 0x02
-#define HW_RESET 0x08
-#define BYTE_SWAP 0x10
-#define WORD_SWAP 0x20
-#define MASK_INTS 0x40
-
-/*
- * Local control register bits.
- */
-
-#define EEPROM_DATA_IN 0x800000
-#define EEPROM_DATA_OUT 0x400000
-#define EEPROM_WRITE_ENABLE 0x200000
-#define EEPROM_CLK_OUT 0x100000
-
-#define EEPROM_BASE 0xa0000000
-
-#define EEPROM_WRITE_SELECT 0xa0
-#define EEPROM_READ_SELECT 0xa1
-
-#define SRAM_BANK_512K 0x200
-
-
-/*
- * udelay() values for when clocking the eeprom
- */
-#define ACE_SHORT_DELAY 2
-#define ACE_LONG_DELAY 4
-
-
-/*
- * Misc Config bits
- */
-
-#define SYNC_SRAM_TIMING 0x100000
-
-
-/*
- * CPU state bits.
- */
-
-#define CPU_RESET 0x01
-#define CPU_TRACE 0x02
-#define CPU_PROM_FAILED 0x10
-#define CPU_HALT 0x00010000
-#define CPU_HALTED 0xffff0000
-
-
-/*
- * PCI State bits.
- */
-
-#define DMA_READ_MAX_4 0x04
-#define DMA_READ_MAX_16 0x08
-#define DMA_READ_MAX_32 0x0c
-#define DMA_READ_MAX_64 0x10
-#define DMA_READ_MAX_128 0x14
-#define DMA_READ_MAX_256 0x18
-#define DMA_READ_MAX_1K 0x1c
-#define DMA_WRITE_MAX_4 0x20
-#define DMA_WRITE_MAX_16 0x40
-#define DMA_WRITE_MAX_32 0x60
-#define DMA_WRITE_MAX_64 0x80
-#define DMA_WRITE_MAX_128 0xa0
-#define DMA_WRITE_MAX_256 0xc0
-#define DMA_WRITE_MAX_1K 0xe0
-#define DMA_READ_WRITE_MASK 0xfc
-#define MEM_READ_MULTIPLE 0x00020000
-#define PCI_66MHZ 0x00080000
-#define PCI_32BIT 0x00100000
-#define DMA_WRITE_ALL_ALIGN 0x00800000
-#define READ_CMD_MEM 0x06000000
-#define WRITE_CMD_MEM 0x70000000
-
-
-/*
- * Mode status
- */
-
-#define ACE_BYTE_SWAP_BD 0x02
-#define ACE_WORD_SWAP_BD 0x04 /* not actually used */
-#define ACE_WARN 0x08
-#define ACE_BYTE_SWAP_DMA 0x10
-#define ACE_NO_JUMBO_FRAG 0x200
-#define ACE_FATAL 0x40000000
-
-
-/*
- * DMA config
- */
-
-#define DMA_THRESH_1W 0x10
-#define DMA_THRESH_2W 0x20
-#define DMA_THRESH_4W 0x40
-#define DMA_THRESH_8W 0x80
-#define DMA_THRESH_16W 0x100
-#define DMA_THRESH_32W 0x0 /* not described in doc, but exists. */
-
-
-/*
- * Tuning parameters
- */
-
-#define TICKS_PER_SEC 1000000
-
-
-/*
- * Link bits
- */
-
-#define LNK_PREF 0x00008000
-#define LNK_10MB 0x00010000
-#define LNK_100MB 0x00020000
-#define LNK_1000MB 0x00040000
-#define LNK_FULL_DUPLEX 0x00080000
-#define LNK_HALF_DUPLEX 0x00100000
-#define LNK_TX_FLOW_CTL_Y 0x00200000
-#define LNK_NEG_ADVANCED 0x00400000
-#define LNK_RX_FLOW_CTL_Y 0x00800000
-#define LNK_NIC 0x01000000
-#define LNK_JAM 0x02000000
-#define LNK_JUMBO 0x04000000
-#define LNK_ALTEON 0x08000000
-#define LNK_NEG_FCTL 0x10000000
-#define LNK_NEGOTIATE 0x20000000
-#define LNK_ENABLE 0x40000000
-#define LNK_UP 0x80000000
-
-
-/*
- * Event definitions
- */
-
-#define EVT_RING_ENTRIES 256
-#define EVT_RING_SIZE (EVT_RING_ENTRIES * sizeof(struct event))
-
-struct event {
-#ifdef __LITTLE_ENDIAN_BITFIELD
- u32 idx:12;
- u32 code:12;
- u32 evt:8;
-#else
- u32 evt:8;
- u32 code:12;
- u32 idx:12;
-#endif
- u32 pad;
-};
-
-
-/*
- * Events
- */
-
-#define E_FW_RUNNING 0x01
-#define E_STATS_UPDATED 0x04
-
-#define E_STATS_UPDATE 0x04
-
-#define E_LNK_STATE 0x06
-#define E_C_LINK_UP 0x01
-#define E_C_LINK_DOWN 0x02
-#define E_C_LINK_10_100 0x03
-
-#define E_ERROR 0x07
-#define E_C_ERR_INVAL_CMD 0x01
-#define E_C_ERR_UNIMP_CMD 0x02
-#define E_C_ERR_BAD_CFG 0x03
-
-#define E_MCAST_LIST 0x08
-#define E_C_MCAST_ADDR_ADD 0x01
-#define E_C_MCAST_ADDR_DEL 0x02
-
-#define E_RESET_JUMBO_RNG 0x09
-
-
-/*
- * Commands
- */
-
-#define CMD_RING_ENTRIES 64
-
-struct cmd {
-#ifdef __LITTLE_ENDIAN_BITFIELD
- u32 idx:12;
- u32 code:12;
- u32 evt:8;
-#else
- u32 evt:8;
- u32 code:12;
- u32 idx:12;
-#endif
-};
-
-
-#define C_HOST_STATE 0x01
-#define C_C_STACK_UP 0x01
-#define C_C_STACK_DOWN 0x02
-
-#define C_FDR_FILTERING 0x02
-#define C_C_FDR_FILT_ENABLE 0x01
-#define C_C_FDR_FILT_DISABLE 0x02
-
-#define C_SET_RX_PRD_IDX 0x03
-#define C_UPDATE_STATS 0x04
-#define C_RESET_JUMBO_RNG 0x05
-#define C_ADD_MULTICAST_ADDR 0x08
-#define C_DEL_MULTICAST_ADDR 0x09
-
-#define C_SET_PROMISC_MODE 0x0a
-#define C_C_PROMISC_ENABLE 0x01
-#define C_C_PROMISC_DISABLE 0x02
-
-#define C_LNK_NEGOTIATION 0x0b
-#define C_C_NEGOTIATE_BOTH 0x00
-#define C_C_NEGOTIATE_GIG 0x01
-#define C_C_NEGOTIATE_10_100 0x02
-
-#define C_SET_MAC_ADDR 0x0c
-#define C_CLEAR_PROFILE 0x0d
-
-#define C_SET_MULTICAST_MODE 0x0e
-#define C_C_MCAST_ENABLE 0x01
-#define C_C_MCAST_DISABLE 0x02
-
-#define C_CLEAR_STATS 0x0f
-#define C_SET_RX_JUMBO_PRD_IDX 0x10
-#define C_REFRESH_STATS 0x11
-
-
-/*
- * Descriptor flags
- */
-#define BD_FLG_TCP_UDP_SUM 0x01
-#define BD_FLG_IP_SUM 0x02
-#define BD_FLG_END 0x04
-#define BD_FLG_MORE 0x08
-#define BD_FLG_JUMBO 0x10
-#define BD_FLG_UCAST 0x20
-#define BD_FLG_MCAST 0x40
-#define BD_FLG_BCAST 0x60
-#define BD_FLG_TYP_MASK 0x60
-#define BD_FLG_IP_FRAG 0x80
-#define BD_FLG_IP_FRAG_END 0x100
-#define BD_FLG_VLAN_TAG 0x200
-#define BD_FLG_FRAME_ERROR 0x400
-#define BD_FLG_COAL_NOW 0x800
-#define BD_FLG_MINI 0x1000
-
-
-/*
- * Ring Control block flags
- */
-#define RCB_FLG_TCP_UDP_SUM 0x01
-#define RCB_FLG_IP_SUM 0x02
-#define RCB_FLG_NO_PSEUDO_HDR 0x08
-#define RCB_FLG_VLAN_ASSIST 0x10
-#define RCB_FLG_COAL_INT_ONLY 0x20
-#define RCB_FLG_TX_HOST_RING 0x40
-#define RCB_FLG_IEEE_SNAP_SUM 0x80
-#define RCB_FLG_EXT_RX_BD 0x100
-#define RCB_FLG_RNG_DISABLE 0x200
-
-
-/*
- * TX ring - maximum TX ring entries for Tigon I's is 128
- */
-#define MAX_TX_RING_ENTRIES 256
-#define TIGON_I_TX_RING_ENTRIES 128
-#define TX_RING_SIZE (MAX_TX_RING_ENTRIES * sizeof(struct tx_desc))
-#define TX_RING_BASE 0x3800
-
-struct tx_desc{
- aceaddr addr;
- u32 flagsize;
-#if 0
-/*
- * This is in PCI shared mem and must be accessed with readl/writel
- * real layout is:
- */
-#if __LITTLE_ENDIAN
- u16 flags;
- u16 size;
- u16 vlan;
- u16 reserved;
-#else
- u16 size;
- u16 flags;
- u16 reserved;
- u16 vlan;
-#endif
-#endif
- u32 vlanres;
-};
-
-
-#define RX_STD_RING_ENTRIES 512
-#define RX_STD_RING_SIZE (RX_STD_RING_ENTRIES * sizeof(struct rx_desc))
-
-#define RX_JUMBO_RING_ENTRIES 256
-#define RX_JUMBO_RING_SIZE (RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))
-
-#define RX_MINI_RING_ENTRIES 1024
-#define RX_MINI_RING_SIZE (RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))
-
-#define RX_RETURN_RING_ENTRIES 2048
-#define RX_RETURN_RING_SIZE (RX_MAX_RETURN_RING_ENTRIES * \
- sizeof(struct rx_desc))
-
-struct rx_desc{
- aceaddr addr;
-#ifdef __LITTLE_ENDIAN
- u16 size;
- u16 idx;
-#else
- u16 idx;
- u16 size;
-#endif
-#ifdef __LITTLE_ENDIAN
- u16 flags;
- u16 type;
-#else
- u16 type;
- u16 flags;
-#endif
-#ifdef __LITTLE_ENDIAN
- u16 tcp_udp_csum;
- u16 ip_csum;
-#else
- u16 ip_csum;
- u16 tcp_udp_csum;
-#endif
-#ifdef __LITTLE_ENDIAN
- u16 vlan;
- u16 err_flags;
-#else
- u16 err_flags;
- u16 vlan;
-#endif
- u32 reserved;
- u32 opague;
-};
-
-
-/*
- * This struct is shared with the NIC firmware.
- */
-struct ring_ctrl {
- aceaddr rngptr;
-#ifdef __LITTLE_ENDIAN
- u16 flags;
- u16 max_len;
-#else
- u16 max_len;
- u16 flags;
-#endif
- u32 pad;
-};
-
-
-struct ace_mac_stats {
- u32 excess_colls;
- u32 coll_1;
- u32 coll_2;
- u32 coll_3;
- u32 coll_4;
- u32 coll_5;
- u32 coll_6;
- u32 coll_7;
- u32 coll_8;
- u32 coll_9;
- u32 coll_10;
- u32 coll_11;
- u32 coll_12;
- u32 coll_13;
- u32 coll_14;
- u32 coll_15;
- u32 late_coll;
- u32 defers;
- u32 crc_err;
- u32 underrun;
- u32 crs_err;
- u32 pad[3];
- u32 drop_ula;
- u32 drop_mc;
- u32 drop_fc;
- u32 drop_space;
- u32 coll;
- u32 kept_bc;
- u32 kept_mc;
- u32 kept_uc;
-};
-
-
-struct ace_info {
- union {
- u32 stats[256];
- } s;
- struct ring_ctrl evt_ctrl;
- struct ring_ctrl cmd_ctrl;
- struct ring_ctrl tx_ctrl;
- struct ring_ctrl rx_std_ctrl;
- struct ring_ctrl rx_jumbo_ctrl;
- struct ring_ctrl rx_mini_ctrl;
- struct ring_ctrl rx_return_ctrl;
- aceaddr evt_prd_ptr;
- aceaddr rx_ret_prd_ptr;
- aceaddr tx_csm_ptr;
- aceaddr stats2_ptr;
-};
-
-
-struct ring_info {
- struct sk_buff *skb;
- DEFINE_DMA_UNMAP_ADDR(mapping);
-};
-
-
-/*
- * Funny... As soon as we add maplen on alpha, it starts to work
- * much slower. Hmm... is it because struct does not fit to one cacheline?
- * So, split tx_ring_info.
- */
-struct tx_ring_info {
- struct sk_buff *skb;
- DEFINE_DMA_UNMAP_ADDR(mapping);
- DEFINE_DMA_UNMAP_LEN(maplen);
-};
-
-
-/*
- * struct ace_skb holding the rings of skb's. This is an awful lot of
- * pointers, but I don't see any other smart mode to do this in an
- * efficient manner ;-(
- */
-struct ace_skb
-{
- struct tx_ring_info tx_skbuff[MAX_TX_RING_ENTRIES];
- struct ring_info rx_std_skbuff[RX_STD_RING_ENTRIES];
- struct ring_info rx_mini_skbuff[RX_MINI_RING_ENTRIES];
- struct ring_info rx_jumbo_skbuff[RX_JUMBO_RING_ENTRIES];
-};
-
-
-/*
- * Struct private for the AceNIC.
- *
- * Elements are grouped so variables used by the tx handling goes
- * together, and will go into the same cache lines etc. in order to
- * avoid cache line contention between the rx and tx handling on SMP.
- *
- * Frequently accessed variables are put at the beginning of the
- * struct to help the compiler generate better/shorter code.
- */
-struct ace_private
-{
- struct net_device *ndev; /* backpointer */
- struct ace_info *info;
- struct ace_regs __iomem *regs; /* register base */
- struct ace_skb *skb;
- dma_addr_t info_dma; /* 32/64 bit */
-
- int version, link;
- int promisc, mcast_all;
-
- /*
- * TX elements
- */
- struct tx_desc *tx_ring;
- u32 tx_prd;
- volatile u32 tx_ret_csm;
- int tx_ring_entries;
-
- /*
- * RX elements
- */
- unsigned long std_refill_busy
- __attribute__ ((aligned (SMP_CACHE_BYTES)));
- unsigned long mini_refill_busy, jumbo_refill_busy;
- atomic_t cur_rx_bufs;
- atomic_t cur_mini_bufs;
- atomic_t cur_jumbo_bufs;
- u32 rx_std_skbprd, rx_mini_skbprd, rx_jumbo_skbprd;
- u32 cur_rx;
-
- struct rx_desc *rx_std_ring;
- struct rx_desc *rx_jumbo_ring;
- struct rx_desc *rx_mini_ring;
- struct rx_desc *rx_return_ring;
-
- int bh_work_pending, jumbo;
- struct work_struct ace_bh_work;
-
- struct event *evt_ring;
-
- volatile u32 *evt_prd, *rx_ret_prd, *tx_csm;
-
- dma_addr_t tx_ring_dma; /* 32/64 bit */
- dma_addr_t rx_ring_base_dma;
- dma_addr_t evt_ring_dma;
- dma_addr_t evt_prd_dma, rx_ret_prd_dma, tx_csm_dma;
-
- unsigned char *trace_buf;
- struct pci_dev *pdev;
- struct net_device *next;
- volatile int fw_running;
- int board_idx;
- u16 pci_command;
- u8 pci_latency;
- const char *name;
-#ifdef INDEX_DEBUG
- spinlock_t debug_lock
- __attribute__ ((aligned (SMP_CACHE_BYTES)));
- u32 last_tx, last_std_rx, last_mini_rx;
-#endif
- u8 firmware_major;
- u8 firmware_minor;
- u8 firmware_fix;
- u32 firmware_start;
-};
-
-
-#define TX_RESERVED MAX_SKB_FRAGS
-
-static inline int tx_space (struct ace_private *ap, u32 csm, u32 prd)
-{
- return (csm - prd - 1) & (ACE_TX_RING_ENTRIES(ap) - 1);
-}
-
-#define tx_free(ap) tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)
-#define tx_ring_full(ap, csm, prd) (tx_space(ap, csm, prd) <= TX_RESERVED)
-
-static inline void set_aceaddr(aceaddr *aa, dma_addr_t addr)
-{
- u64 baddr = (u64) addr;
- aa->addrlo = baddr & 0xffffffff;
- aa->addrhi = baddr >> 32;
- wmb();
-}
-
-
-static inline void ace_set_txprd(struct ace_regs __iomem *regs,
- struct ace_private *ap, u32 value)
-{
-#ifdef INDEX_DEBUG
- unsigned long flags;
- spin_lock_irqsave(&ap->debug_lock, flags);
- writel(value, ®s->TxPrd);
- if (value == ap->last_tx)
- printk(KERN_ERR "AceNIC RACE ALERT! writing identical value "
- "to tx producer (%i)\n", value);
- ap->last_tx = value;
- spin_unlock_irqrestore(&ap->debug_lock, flags);
-#else
- writel(value, ®s->TxPrd);
-#endif
- wmb();
-}
-
-
-static inline void ace_mask_irq(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
-
- if (ACE_IS_TIGON_I(ap))
- writel(1, ®s->MaskInt);
- else
- writel(readl(®s->HostCtrl) | MASK_INTS, ®s->HostCtrl);
-
- ace_sync_irq(dev->irq);
-}
-
-
-static inline void ace_unmask_irq(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
-
- if (ACE_IS_TIGON_I(ap))
- writel(0, ®s->MaskInt);
- else
- writel(readl(®s->HostCtrl) & ~MASK_INTS, ®s->HostCtrl);
-}
-
-
-/*
- * Prototypes
- */
-static int ace_init(struct net_device *dev);
-static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs);
-static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs);
-static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs);
-static irqreturn_t ace_interrupt(int irq, void *dev_id);
-static int ace_load_firmware(struct net_device *dev);
-static int ace_open(struct net_device *dev);
-static netdev_tx_t ace_start_xmit(struct sk_buff *skb,
- struct net_device *dev);
-static int ace_close(struct net_device *dev);
-static void ace_bh_work(struct work_struct *work);
-static void ace_dump_trace(struct ace_private *ap);
-static void ace_set_multicast_list(struct net_device *dev);
-static int ace_change_mtu(struct net_device *dev, int new_mtu);
-static int ace_set_mac_addr(struct net_device *dev, void *p);
-static void ace_set_rxtx_parms(struct net_device *dev, int jumbo);
-static int ace_allocate_descriptors(struct net_device *dev);
-static void ace_free_descriptors(struct net_device *dev);
-static void ace_init_cleanup(struct net_device *dev);
-static struct net_device_stats *ace_get_stats(struct net_device *dev);
-static int read_eeprom_byte(struct net_device *dev, unsigned long offset);
-
-#endif /* _ACENIC_H_ */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 406abf629be2..8608361fac95 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1809,8 +1809,6 @@
/* formerly Platform Tech */
#define PCI_DEVICE_ID_ESS_ESS0100 0x0100
-#define PCI_VENDOR_ID_ALTEON 0x12ae
-
#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4
#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001
#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002
diff --git a/drivers/net/ethernet/alteon/acenic.c b/drivers/net/ethernet/alteon/acenic.c
deleted file mode 100644
index 455ee8930824..000000000000
--- a/drivers/net/ethernet/alteon/acenic.c
+++ /dev/null
@@ -1,3178 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * acenic.c: Linux driver for the Alteon AceNIC Gigabit Ethernet card
- * and other Tigon based cards.
- *
- * Copyright 1998-2002 by Jes Sorensen, <jes@trained-monkey.org>.
- *
- * Thanks to Alteon and 3Com for providing hardware and documentation
- * enabling me to write this driver.
- *
- * A mailing list for discussing the use of this driver has been
- * setup, please subscribe to the lists if you have any questions
- * about the driver. Send mail to linux-acenic-help@sunsite.auc.dk to
- * see how to subscribe.
- *
- * Additional credits:
- * Pete Wyckoff <wyckoff@ca.sandia.gov>: Initial Linux/Alpha and trace
- * dump support. The trace dump support has not been
- * integrated yet however.
- * Troy Benjegerdes: Big Endian (PPC) patches.
- * Nate Stahl: Better out of memory handling and stats support.
- * Aman Singla: Nasty race between interrupt handler and tx code dealing
- * with 'testing the tx_ret_csm and setting tx_full'
- * David S. Miller <davem@redhat.com>: conversion to new PCI dma mapping
- * infrastructure and Sparc support
- * Pierrick Pinasseau (CERN): For lending me an Ultra 5 to test the
- * driver under Linux/Sparc64
- * Matt Domsch <Matt_Domsch@dell.com>: Detect Alteon 1000baseT cards
- * ETHTOOL_GDRVINFO support
- * Chip Salzenberg <chip@valinux.com>: Fix race condition between tx
- * handler and close() cleanup.
- * Ken Aaker <kdaaker@rchland.vnet.ibm.com>: Correct check for whether
- * memory mapped IO is enabled to
- * make the driver work on RS/6000.
- * Takayoshi Kouchi <kouchi@hpc.bs1.fc.nec.co.jp>: Identifying problem
- * where the driver would disable
- * bus master mode if it had to disable
- * write and invalidate.
- * Stephen Hack <stephen_hack@hp.com>: Fixed ace_set_mac_addr for little
- * endian systems.
- * Val Henson <vhenson@esscom.com>: Reset Jumbo skb producer and
- * rx producer index when
- * flushing the Jumbo ring.
- * Hans Grobler <grobh@sun.ac.za>: Memory leak fixes in the
- * driver init path.
- * Grant Grundler <grundler@cup.hp.com>: PCI write posting fixes.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/delay.h>
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/sockios.h>
-#include <linux/firmware.h>
-#include <linux/slab.h>
-#include <linux/prefetch.h>
-#include <linux/if_vlan.h>
-
-#ifdef SIOCETHTOOL
-#include <linux/ethtool.h>
-#endif
-
-#include <net/sock.h>
-#include <net/ip.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/byteorder.h>
-#include <linux/uaccess.h>
-
-
-#define DRV_NAME "acenic"
-
-#undef INDEX_DEBUG
-
-#ifdef CONFIG_ACENIC_OMIT_TIGON_I
-#define ACE_IS_TIGON_I(ap) 0
-#define ACE_TX_RING_ENTRIES(ap) MAX_TX_RING_ENTRIES
-#else
-#define ACE_IS_TIGON_I(ap) (ap->version == 1)
-#define ACE_TX_RING_ENTRIES(ap) ap->tx_ring_entries
-#endif
-
-#ifndef PCI_VENDOR_ID_ALTEON
-#define PCI_VENDOR_ID_ALTEON 0x12ae
-#endif
-#ifndef PCI_DEVICE_ID_ALTEON_ACENIC_FIBRE
-#define PCI_DEVICE_ID_ALTEON_ACENIC_FIBRE 0x0001
-#define PCI_DEVICE_ID_ALTEON_ACENIC_COPPER 0x0002
-#endif
-#ifndef PCI_DEVICE_ID_3COM_3C985
-#define PCI_DEVICE_ID_3COM_3C985 0x0001
-#endif
-#ifndef PCI_VENDOR_ID_NETGEAR
-#define PCI_VENDOR_ID_NETGEAR 0x1385
-#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
-#endif
-#ifndef PCI_DEVICE_ID_NETGEAR_GA620T
-#define PCI_DEVICE_ID_NETGEAR_GA620T 0x630a
-#endif
-
-
-/*
- * Farallon used the DEC vendor ID by mistake and they seem not
- * to care - stinky!
- */
-#ifndef PCI_DEVICE_ID_FARALLON_PN9000SX
-#define PCI_DEVICE_ID_FARALLON_PN9000SX 0x1a
-#endif
-#ifndef PCI_DEVICE_ID_FARALLON_PN9100T
-#define PCI_DEVICE_ID_FARALLON_PN9100T 0xfa
-#endif
-#ifndef PCI_VENDOR_ID_SGI
-#define PCI_VENDOR_ID_SGI 0x10a9
-#endif
-#ifndef PCI_DEVICE_ID_SGI_ACENIC
-#define PCI_DEVICE_ID_SGI_ACENIC 0x0009
-#endif
-
-static const struct pci_device_id acenic_pci_tbl[] = {
- { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_FIBRE,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_COPPER,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C985,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_NETGEAR, PCI_DEVICE_ID_NETGEAR_GA620,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_NETGEAR, PCI_DEVICE_ID_NETGEAR_GA620T,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- /*
- * Farallon used the DEC vendor ID on their cards incorrectly,
- * then later Alteon's ID.
- */
- { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_FARALLON_PN9000SX,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_FARALLON_PN9100T,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_ACENIC,
- PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
- { }
-};
-MODULE_DEVICE_TABLE(pci, acenic_pci_tbl);
-
-#define ace_sync_irq(irq) synchronize_irq(irq)
-
-#ifndef offset_in_page
-#define offset_in_page(ptr) ((unsigned long)(ptr) & ~PAGE_MASK)
-#endif
-
-#define ACE_MAX_MOD_PARMS 8
-#define BOARD_IDX_STATIC 0
-#define BOARD_IDX_OVERFLOW -1
-
-#include "acenic.h"
-
-/*
- * These must be defined before the firmware is included.
- */
-#define MAX_TEXT_LEN 96*1024
-#define MAX_RODATA_LEN 8*1024
-#define MAX_DATA_LEN 2*1024
-
-#ifndef tigon2FwReleaseLocal
-#define tigon2FwReleaseLocal 0
-#endif
-
-/*
- * This driver currently supports Tigon I and Tigon II based cards
- * including the Alteon AceNIC, the 3Com 3C985[B] and NetGear
- * GA620. The driver should also work on the SGI, DEC and Farallon
- * versions of the card, however I have not been able to test that
- * myself.
- *
- * This card is really neat, it supports receive hardware checksumming
- * and jumbo frames (up to 9000 bytes) and does a lot of work in the
- * firmware. Also the programming interface is quite neat, except for
- * the parts dealing with the i2c eeprom on the card ;-)
- *
- * Using jumbo frames:
- *
- * To enable jumbo frames, simply specify an mtu between 1500 and 9000
- * bytes to ifconfig. Jumbo frames can be enabled or disabled at any time
- * by running `ifconfig eth<X> mtu <MTU>' with <X> being the Ethernet
- * interface number and <MTU> being the MTU value.
- *
- * Module parameters:
- *
- * When compiled as a loadable module, the driver allows for a number
- * of module parameters to be specified. The driver supports the
- * following module parameters:
- *
- * trace=<val> - Firmware trace level. This requires special traced
- * firmware to replace the firmware supplied with
- * the driver - for debugging purposes only.
- *
- * link=<val> - Link state. Normally you want to use the default link
- * parameters set by the driver. This can be used to
- * override these in case your switch doesn't negotiate
- * the link properly. Valid values are:
- * 0x0001 - Force half duplex link.
- * 0x0002 - Do not negotiate line speed with the other end.
- * 0x0010 - 10Mbit/sec link.
- * 0x0020 - 100Mbit/sec link.
- * 0x0040 - 1000Mbit/sec link.
- * 0x0100 - Do not negotiate flow control.
- * 0x0200 - Enable RX flow control Y
- * 0x0400 - Enable TX flow control Y (Tigon II NICs only).
- * Default value is 0x0270, ie. enable link+flow
- * control negotiation. Negotiating the highest
- * possible link speed with RX flow control enabled.
- *
- * When disabling link speed negotiation, only one link
- * speed is allowed to be specified!
- *
- * tx_coal_tick=<val> - number of coalescing clock ticks (us) allowed
- * to wait for more packets to arive before
- * interrupting the host, from the time the first
- * packet arrives.
- *
- * rx_coal_tick=<val> - number of coalescing clock ticks (us) allowed
- * to wait for more packets to arive in the transmit ring,
- * before interrupting the host, after transmitting the
- * first packet in the ring.
- *
- * max_tx_desc=<val> - maximum number of transmit descriptors
- * (packets) transmitted before interrupting the host.
- *
- * max_rx_desc=<val> - maximum number of receive descriptors
- * (packets) received before interrupting the host.
- *
- * tx_ratio=<val> - 7 bit value (0 - 63) specifying the split in 64th
- * increments of the NIC's on board memory to be used for
- * transmit and receive buffers. For the 1MB NIC app. 800KB
- * is available, on the 1/2MB NIC app. 300KB is available.
- * 68KB will always be available as a minimum for both
- * directions. The default value is a 50/50 split.
- * dis_pci_mem_inval=<val> - disable PCI memory write and invalidate
- * operations, default (1) is to always disable this as
- * that is what Alteon does on NT. I have not been able
- * to measure any real performance differences with
- * this on my systems. Set <val>=0 if you want to
- * enable these operations.
- *
- * If you use more than one NIC, specify the parameters for the
- * individual NICs with a comma, ie. trace=0,0x00001fff,0 you want to
- * run tracing on NIC #2 but not on NIC #1 and #3.
- *
- * TODO:
- *
- * - Proper multicast support.
- * - NIC dump support.
- * - More tuning parameters.
- *
- * The mini ring is not used under Linux and I am not sure it makes sense
- * to actually use it.
- *
- * New interrupt handler strategy:
- *
- * The old interrupt handler worked using the traditional method of
- * replacing an skbuff with a new one when a packet arrives. However
- * the rx rings do not need to contain a static number of buffer
- * descriptors, thus it makes sense to move the memory allocation out
- * of the main interrupt handler and do it in a bottom half handler
- * and only allocate new buffers when the number of buffers in the
- * ring is below a certain threshold. In order to avoid starving the
- * NIC under heavy load it is however necessary to force allocation
- * when hitting a minimum threshold. The strategy for alloction is as
- * follows:
- *
- * RX_LOW_BUF_THRES - allocate buffers in the bottom half
- * RX_PANIC_LOW_THRES - we are very low on buffers, allocate
- * the buffers in the interrupt handler
- * RX_RING_THRES - maximum number of buffers in the rx ring
- * RX_MINI_THRES - maximum number of buffers in the mini ring
- * RX_JUMBO_THRES - maximum number of buffers in the jumbo ring
- *
- * One advantagous side effect of this allocation approach is that the
- * entire rx processing can be done without holding any spin lock
- * since the rx rings and registers are totally independent of the tx
- * ring and its registers. This of course includes the kmalloc's of
- * new skb's. Thus start_xmit can run in parallel with rx processing
- * and the memory allocation on SMP systems.
- *
- * Note that running the skb reallocation in a bottom half opens up
- * another can of races which needs to be handled properly. In
- * particular it can happen that the interrupt handler tries to run
- * the reallocation while the bottom half is either running on another
- * CPU or was interrupted on the same CPU. To get around this the
- * driver uses bitops to prevent the reallocation routines from being
- * reentered.
- *
- * TX handling can also be done without holding any spin lock, wheee
- * this is fun! since tx_ret_csm is only written to by the interrupt
- * handler. The case to be aware of is when shutting down the device
- * and cleaning up where it is necessary to make sure that
- * start_xmit() is not running while this is happening. Well DaveM
- * informs me that this case is already protected against ... bye bye
- * Mr. Spin Lock, it was nice to know you.
- *
- * TX interrupts are now partly disabled so the NIC will only generate
- * TX interrupts for the number of coal ticks, not for the number of
- * TX packets in the queue. This should reduce the number of TX only,
- * ie. when no RX processing is done, interrupts seen.
- */
-
-/*
- * Threshold values for RX buffer allocation - the low water marks for
- * when to start refilling the rings are set to 75% of the ring
- * sizes. It seems to make sense to refill the rings entirely from the
- * intrrupt handler once it gets below the panic threshold, that way
- * we don't risk that the refilling is moved to another CPU when the
- * one running the interrupt handler just got the slab code hot in its
- * cache.
- */
-#define RX_RING_SIZE 72
-#define RX_MINI_SIZE 64
-#define RX_JUMBO_SIZE 48
-
-#define RX_PANIC_STD_THRES 16
-#define RX_PANIC_STD_REFILL (3*RX_PANIC_STD_THRES)/2
-#define RX_LOW_STD_THRES (3*RX_RING_SIZE)/4
-#define RX_PANIC_MINI_THRES 12
-#define RX_PANIC_MINI_REFILL (3*RX_PANIC_MINI_THRES)/2
-#define RX_LOW_MINI_THRES (3*RX_MINI_SIZE)/4
-#define RX_PANIC_JUMBO_THRES 6
-#define RX_PANIC_JUMBO_REFILL (3*RX_PANIC_JUMBO_THRES)/2
-#define RX_LOW_JUMBO_THRES (3*RX_JUMBO_SIZE)/4
-
-
-/*
- * Size of the mini ring entries, basically these just should be big
- * enough to take TCP ACKs
- */
-#define ACE_MINI_SIZE 100
-
-#define ACE_MINI_BUFSIZE ACE_MINI_SIZE
-#define ACE_STD_BUFSIZE (ACE_STD_MTU + ETH_HLEN + 4)
-#define ACE_JUMBO_BUFSIZE (ACE_JUMBO_MTU + ETH_HLEN + 4)
-
-/*
- * There seems to be a magic difference in the effect between 995 and 996
- * but little difference between 900 and 995 ... no idea why.
- *
- * There is now a default set of tuning parameters which is set, depending
- * on whether or not the user enables Jumbo frames. It's assumed that if
- * Jumbo frames are enabled, the user wants optimal tuning for that case.
- */
-#define DEF_TX_COAL 400 /* 996 */
-#define DEF_TX_MAX_DESC 60 /* was 40 */
-#define DEF_RX_COAL 120 /* 1000 */
-#define DEF_RX_MAX_DESC 25
-#define DEF_TX_RATIO 21 /* 24 */
-
-#define DEF_JUMBO_TX_COAL 20
-#define DEF_JUMBO_TX_MAX_DESC 60
-#define DEF_JUMBO_RX_COAL 30
-#define DEF_JUMBO_RX_MAX_DESC 6
-#define DEF_JUMBO_TX_RATIO 21
-
-#if tigon2FwReleaseLocal < 20001118
-/*
- * Standard firmware and early modifications duplicate
- * IRQ load without this flag (coal timer is never reset).
- * Note that with this flag tx_coal should be less than
- * time to xmit full tx ring.
- * 400usec is not so bad for tx ring size of 128.
- */
-#define TX_COAL_INTS_ONLY 1 /* worth it */
-#else
-/*
- * With modified firmware, this is not necessary, but still useful.
- */
-#define TX_COAL_INTS_ONLY 1
-#endif
-
-#define DEF_TRACE 0
-#define DEF_STAT (2 * TICKS_PER_SEC)
-
-
-static int link_state[ACE_MAX_MOD_PARMS];
-static int trace[ACE_MAX_MOD_PARMS];
-static int tx_coal_tick[ACE_MAX_MOD_PARMS];
-static int rx_coal_tick[ACE_MAX_MOD_PARMS];
-static int max_tx_desc[ACE_MAX_MOD_PARMS];
-static int max_rx_desc[ACE_MAX_MOD_PARMS];
-static int tx_ratio[ACE_MAX_MOD_PARMS];
-static int dis_pci_mem_inval[ACE_MAX_MOD_PARMS] = {1, 1, 1, 1, 1, 1, 1, 1};
-
-MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver");
-#ifndef CONFIG_ACENIC_OMIT_TIGON_I
-MODULE_FIRMWARE("acenic/tg1.bin");
-#endif
-MODULE_FIRMWARE("acenic/tg2.bin");
-
-module_param_array_named(link, link_state, int, NULL, 0);
-module_param_array(trace, int, NULL, 0);
-module_param_array(tx_coal_tick, int, NULL, 0);
-module_param_array(max_tx_desc, int, NULL, 0);
-module_param_array(rx_coal_tick, int, NULL, 0);
-module_param_array(max_rx_desc, int, NULL, 0);
-module_param_array(tx_ratio, int, NULL, 0);
-MODULE_PARM_DESC(link, "AceNIC/3C985/NetGear link state");
-MODULE_PARM_DESC(trace, "AceNIC/3C985/NetGear firmware trace level");
-MODULE_PARM_DESC(tx_coal_tick, "AceNIC/3C985/GA620 max clock ticks to wait from first tx descriptor arrives");
-MODULE_PARM_DESC(max_tx_desc, "AceNIC/3C985/GA620 max number of transmit descriptors to wait");
-MODULE_PARM_DESC(rx_coal_tick, "AceNIC/3C985/GA620 max clock ticks to wait from first rx descriptor arrives");
-MODULE_PARM_DESC(max_rx_desc, "AceNIC/3C985/GA620 max number of receive descriptors to wait");
-MODULE_PARM_DESC(tx_ratio, "AceNIC/3C985/GA620 ratio of NIC memory used for TX/RX descriptors (range 0-63)");
-
-
-static const char version[] =
- "acenic.c: v0.92 08/05/2002 Jes Sorensen, linux-acenic@SunSITE.dk\n"
- " http://home.cern.ch/~jes/gige/acenic.html\n";
-
-static int ace_get_link_ksettings(struct net_device *,
- struct ethtool_link_ksettings *);
-static int ace_set_link_ksettings(struct net_device *,
- const struct ethtool_link_ksettings *);
-static void ace_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
-
-static const struct ethtool_ops ace_ethtool_ops = {
- .get_drvinfo = ace_get_drvinfo,
- .get_link_ksettings = ace_get_link_ksettings,
- .set_link_ksettings = ace_set_link_ksettings,
-};
-
-static void ace_watchdog(struct net_device *dev, unsigned int txqueue);
-
-static const struct net_device_ops ace_netdev_ops = {
- .ndo_open = ace_open,
- .ndo_stop = ace_close,
- .ndo_tx_timeout = ace_watchdog,
- .ndo_get_stats = ace_get_stats,
- .ndo_start_xmit = ace_start_xmit,
- .ndo_set_rx_mode = ace_set_multicast_list,
- .ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = ace_set_mac_addr,
- .ndo_change_mtu = ace_change_mtu,
-};
-
-static int acenic_probe_one(struct pci_dev *pdev,
- const struct pci_device_id *id)
-{
- struct net_device *dev;
- struct ace_private *ap;
- static int boards_found;
-
- dev = alloc_etherdev(sizeof(struct ace_private));
- if (dev == NULL)
- return -ENOMEM;
-
- SET_NETDEV_DEV(dev, &pdev->dev);
-
- ap = netdev_priv(dev);
- ap->ndev = dev;
- ap->pdev = pdev;
- ap->name = pci_name(pdev);
-
- dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
- dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
-
- dev->watchdog_timeo = 5*HZ;
- dev->min_mtu = 0;
- dev->max_mtu = ACE_JUMBO_MTU;
-
- dev->netdev_ops = &ace_netdev_ops;
- dev->ethtool_ops = &ace_ethtool_ops;
-
- /* we only display this string ONCE */
- if (!boards_found)
- printk(version);
-
- if (pci_enable_device(pdev))
- goto fail_free_netdev;
-
- /*
- * Enable master mode before we start playing with the
- * pci_command word since pci_set_master() will modify
- * it.
- */
- pci_set_master(pdev);
-
- pci_read_config_word(pdev, PCI_COMMAND, &ap->pci_command);
-
- /* OpenFirmware on Mac's does not set this - DOH.. */
- if (!(ap->pci_command & PCI_COMMAND_MEMORY)) {
- printk(KERN_INFO "%s: Enabling PCI Memory Mapped "
- "access - was not enabled by BIOS/Firmware\n",
- ap->name);
- ap->pci_command = ap->pci_command | PCI_COMMAND_MEMORY;
- pci_write_config_word(ap->pdev, PCI_COMMAND,
- ap->pci_command);
- wmb();
- }
-
- pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &ap->pci_latency);
- if (ap->pci_latency <= 0x40) {
- ap->pci_latency = 0x40;
- pci_write_config_byte(pdev, PCI_LATENCY_TIMER, ap->pci_latency);
- }
-
- /*
- * Remap the regs into kernel space - this is abuse of
- * dev->base_addr since it was means for I/O port
- * addresses but who gives a damn.
- */
- dev->base_addr = pci_resource_start(pdev, 0);
- ap->regs = ioremap(dev->base_addr, 0x4000);
- if (!ap->regs) {
- printk(KERN_ERR "%s: Unable to map I/O register, "
- "AceNIC %i will be disabled.\n",
- ap->name, boards_found);
- goto fail_free_netdev;
- }
-
- switch(pdev->vendor) {
- case PCI_VENDOR_ID_ALTEON:
- if (pdev->device == PCI_DEVICE_ID_FARALLON_PN9100T) {
- printk(KERN_INFO "%s: Farallon PN9100-T ",
- ap->name);
- } else {
- printk(KERN_INFO "%s: Alteon AceNIC ",
- ap->name);
- }
- break;
- case PCI_VENDOR_ID_3COM:
- printk(KERN_INFO "%s: 3Com 3C985 ", ap->name);
- break;
- case PCI_VENDOR_ID_NETGEAR:
- printk(KERN_INFO "%s: NetGear GA620 ", ap->name);
- break;
- case PCI_VENDOR_ID_DEC:
- if (pdev->device == PCI_DEVICE_ID_FARALLON_PN9000SX) {
- printk(KERN_INFO "%s: Farallon PN9000-SX ",
- ap->name);
- break;
- }
- fallthrough;
- case PCI_VENDOR_ID_SGI:
- printk(KERN_INFO "%s: SGI AceNIC ", ap->name);
- break;
- default:
- printk(KERN_INFO "%s: Unknown AceNIC ", ap->name);
- break;
- }
-
- printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr);
- printk("irq %d\n", pdev->irq);
-
-#ifdef CONFIG_ACENIC_OMIT_TIGON_I
- if ((readl(&ap->regs->HostCtrl) >> 28) == 4) {
- printk(KERN_ERR "%s: Driver compiled without Tigon I"
- " support - NIC disabled\n", dev->name);
- goto fail_uninit;
- }
-#endif
-
- if (ace_allocate_descriptors(dev))
- goto fail_free_netdev;
-
-#ifdef MODULE
- if (boards_found >= ACE_MAX_MOD_PARMS)
- ap->board_idx = BOARD_IDX_OVERFLOW;
- else
- ap->board_idx = boards_found;
-#else
- ap->board_idx = BOARD_IDX_STATIC;
-#endif
-
- if (ace_init(dev))
- goto fail_free_netdev;
-
- if (register_netdev(dev)) {
- printk(KERN_ERR "acenic: device registration failed\n");
- goto fail_uninit;
- }
- ap->name = dev->name;
-
- dev->features |= NETIF_F_HIGHDMA;
-
- pci_set_drvdata(pdev, dev);
-
- boards_found++;
- return 0;
-
- fail_uninit:
- ace_init_cleanup(dev);
- fail_free_netdev:
- free_netdev(dev);
- return -ENODEV;
-}
-
-static void acenic_remove_one(struct pci_dev *pdev)
-{
- struct net_device *dev = pci_get_drvdata(pdev);
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- short i;
-
- unregister_netdev(dev);
-
- writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl);
- if (ap->version >= 2)
- writel(readl(®s->CpuBCtrl) | CPU_HALT, ®s->CpuBCtrl);
-
- /*
- * This clears any pending interrupts
- */
- writel(1, ®s->Mb0Lo);
- readl(®s->CpuCtrl); /* flush */
-
- /*
- * Make sure no other CPUs are processing interrupts
- * on the card before the buffers are being released.
- * Otherwise one might experience some `interesting'
- * effects.
- *
- * Then release the RX buffers - jumbo buffers were
- * already released in ace_close().
- */
- ace_sync_irq(dev->irq);
-
- for (i = 0; i < RX_STD_RING_ENTRIES; i++) {
- struct sk_buff *skb = ap->skb->rx_std_skbuff[i].skb;
-
- if (skb) {
- struct ring_info *ringp;
- dma_addr_t mapping;
-
- ringp = &ap->skb->rx_std_skbuff[i];
- mapping = dma_unmap_addr(ringp, mapping);
- dma_unmap_page(&ap->pdev->dev, mapping,
- ACE_STD_BUFSIZE, DMA_FROM_DEVICE);
-
- ap->rx_std_ring[i].size = 0;
- ap->skb->rx_std_skbuff[i].skb = NULL;
- dev_kfree_skb(skb);
- }
- }
-
- if (ap->version >= 2) {
- for (i = 0; i < RX_MINI_RING_ENTRIES; i++) {
- struct sk_buff *skb = ap->skb->rx_mini_skbuff[i].skb;
-
- if (skb) {
- struct ring_info *ringp;
- dma_addr_t mapping;
-
- ringp = &ap->skb->rx_mini_skbuff[i];
- mapping = dma_unmap_addr(ringp,mapping);
- dma_unmap_page(&ap->pdev->dev, mapping,
- ACE_MINI_BUFSIZE,
- DMA_FROM_DEVICE);
-
- ap->rx_mini_ring[i].size = 0;
- ap->skb->rx_mini_skbuff[i].skb = NULL;
- dev_kfree_skb(skb);
- }
- }
- }
-
- for (i = 0; i < RX_JUMBO_RING_ENTRIES; i++) {
- struct sk_buff *skb = ap->skb->rx_jumbo_skbuff[i].skb;
- if (skb) {
- struct ring_info *ringp;
- dma_addr_t mapping;
-
- ringp = &ap->skb->rx_jumbo_skbuff[i];
- mapping = dma_unmap_addr(ringp, mapping);
- dma_unmap_page(&ap->pdev->dev, mapping,
- ACE_JUMBO_BUFSIZE, DMA_FROM_DEVICE);
-
- ap->rx_jumbo_ring[i].size = 0;
- ap->skb->rx_jumbo_skbuff[i].skb = NULL;
- dev_kfree_skb(skb);
- }
- }
-
- ace_init_cleanup(dev);
- free_netdev(dev);
-}
-
-static struct pci_driver acenic_pci_driver = {
- .name = "acenic",
- .id_table = acenic_pci_tbl,
- .probe = acenic_probe_one,
- .remove = acenic_remove_one,
-};
-
-static void ace_free_descriptors(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- int size;
-
- if (ap->rx_std_ring != NULL) {
- size = (sizeof(struct rx_desc) *
- (RX_STD_RING_ENTRIES +
- RX_JUMBO_RING_ENTRIES +
- RX_MINI_RING_ENTRIES +
- RX_RETURN_RING_ENTRIES));
- dma_free_coherent(&ap->pdev->dev, size, ap->rx_std_ring,
- ap->rx_ring_base_dma);
- ap->rx_std_ring = NULL;
- ap->rx_jumbo_ring = NULL;
- ap->rx_mini_ring = NULL;
- ap->rx_return_ring = NULL;
- }
- if (ap->evt_ring != NULL) {
- size = (sizeof(struct event) * EVT_RING_ENTRIES);
- dma_free_coherent(&ap->pdev->dev, size, ap->evt_ring,
- ap->evt_ring_dma);
- ap->evt_ring = NULL;
- }
- if (ap->tx_ring != NULL && !ACE_IS_TIGON_I(ap)) {
- size = (sizeof(struct tx_desc) * MAX_TX_RING_ENTRIES);
- dma_free_coherent(&ap->pdev->dev, size, ap->tx_ring,
- ap->tx_ring_dma);
- }
- ap->tx_ring = NULL;
-
- if (ap->evt_prd != NULL) {
- dma_free_coherent(&ap->pdev->dev, sizeof(u32),
- (void *)ap->evt_prd, ap->evt_prd_dma);
- ap->evt_prd = NULL;
- }
- if (ap->rx_ret_prd != NULL) {
- dma_free_coherent(&ap->pdev->dev, sizeof(u32),
- (void *)ap->rx_ret_prd, ap->rx_ret_prd_dma);
- ap->rx_ret_prd = NULL;
- }
- if (ap->tx_csm != NULL) {
- dma_free_coherent(&ap->pdev->dev, sizeof(u32),
- (void *)ap->tx_csm, ap->tx_csm_dma);
- ap->tx_csm = NULL;
- }
-}
-
-
-static int ace_allocate_descriptors(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- int size;
-
- size = (sizeof(struct rx_desc) *
- (RX_STD_RING_ENTRIES +
- RX_JUMBO_RING_ENTRIES +
- RX_MINI_RING_ENTRIES +
- RX_RETURN_RING_ENTRIES));
-
- ap->rx_std_ring = dma_alloc_coherent(&ap->pdev->dev, size,
- &ap->rx_ring_base_dma, GFP_KERNEL);
- if (ap->rx_std_ring == NULL)
- goto fail;
-
- ap->rx_jumbo_ring = ap->rx_std_ring + RX_STD_RING_ENTRIES;
- ap->rx_mini_ring = ap->rx_jumbo_ring + RX_JUMBO_RING_ENTRIES;
- ap->rx_return_ring = ap->rx_mini_ring + RX_MINI_RING_ENTRIES;
-
- size = (sizeof(struct event) * EVT_RING_ENTRIES);
-
- ap->evt_ring = dma_alloc_coherent(&ap->pdev->dev, size,
- &ap->evt_ring_dma, GFP_KERNEL);
-
- if (ap->evt_ring == NULL)
- goto fail;
-
- /*
- * Only allocate a host TX ring for the Tigon II, the Tigon I
- * has to use PCI registers for this ;-(
- */
- if (!ACE_IS_TIGON_I(ap)) {
- size = (sizeof(struct tx_desc) * MAX_TX_RING_ENTRIES);
-
- ap->tx_ring = dma_alloc_coherent(&ap->pdev->dev, size,
- &ap->tx_ring_dma, GFP_KERNEL);
-
- if (ap->tx_ring == NULL)
- goto fail;
- }
-
- ap->evt_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32),
- &ap->evt_prd_dma, GFP_KERNEL);
- if (ap->evt_prd == NULL)
- goto fail;
-
- ap->rx_ret_prd = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32),
- &ap->rx_ret_prd_dma, GFP_KERNEL);
- if (ap->rx_ret_prd == NULL)
- goto fail;
-
- ap->tx_csm = dma_alloc_coherent(&ap->pdev->dev, sizeof(u32),
- &ap->tx_csm_dma, GFP_KERNEL);
- if (ap->tx_csm == NULL)
- goto fail;
-
- return 0;
-
-fail:
- /* Clean up. */
- ace_init_cleanup(dev);
- return 1;
-}
-
-
-/*
- * Generic cleanup handling data allocated during init. Used when the
- * module is unloaded or if an error occurs during initialization
- */
-static void ace_init_cleanup(struct net_device *dev)
-{
- struct ace_private *ap;
-
- ap = netdev_priv(dev);
-
- ace_free_descriptors(dev);
-
- if (ap->info)
- dma_free_coherent(&ap->pdev->dev, sizeof(struct ace_info),
- ap->info, ap->info_dma);
- kfree(ap->skb);
- kfree(ap->trace_buf);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- iounmap(ap->regs);
-}
-
-
-/*
- * Commands are considered to be slow.
- */
-static inline void ace_issue_cmd(struct ace_regs __iomem *regs, struct cmd *cmd)
-{
- u32 idx;
-
- idx = readl(®s->CmdPrd);
-
- writel(*(u32 *)(cmd), ®s->CmdRng[idx]);
- idx = (idx + 1) % CMD_RING_ENTRIES;
-
- writel(idx, ®s->CmdPrd);
-}
-
-
-static int ace_init(struct net_device *dev)
-{
- struct ace_private *ap;
- struct ace_regs __iomem *regs;
- struct ace_info *info = NULL;
- struct pci_dev *pdev;
- unsigned long myjif;
- u64 tmp_ptr;
- u32 tig_ver, mac1, mac2, tmp, pci_state;
- int board_idx, ecode = 0;
- short i;
- unsigned char cache_size;
- u8 addr[ETH_ALEN];
-
- ap = netdev_priv(dev);
- regs = ap->regs;
-
- board_idx = ap->board_idx;
-
- /*
- * aman@sgi.com - its useful to do a NIC reset here to
- * address the `Firmware not running' problem subsequent
- * to any crashes involving the NIC
- */
- writel(HW_RESET | (HW_RESET << 24), ®s->HostCtrl);
- readl(®s->HostCtrl); /* PCI write posting */
- udelay(5);
-
- /*
- * Don't access any other registers before this point!
- */
-#ifdef __BIG_ENDIAN
- /*
- * This will most likely need BYTE_SWAP once we switch
- * to using __raw_writel()
- */
- writel((WORD_SWAP | CLR_INT | ((WORD_SWAP | CLR_INT) << 24)),
- ®s->HostCtrl);
-#else
- writel((CLR_INT | WORD_SWAP | ((CLR_INT | WORD_SWAP) << 24)),
- ®s->HostCtrl);
-#endif
- readl(®s->HostCtrl); /* PCI write posting */
-
- /*
- * Stop the NIC CPU and clear pending interrupts
- */
- writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl);
- readl(®s->CpuCtrl); /* PCI write posting */
- writel(0, ®s->Mb0Lo);
-
- tig_ver = readl(®s->HostCtrl) >> 28;
-
- switch(tig_ver){
-#ifndef CONFIG_ACENIC_OMIT_TIGON_I
- case 4:
- case 5:
- printk(KERN_INFO " Tigon I (Rev. %i), Firmware: %i.%i.%i, ",
- tig_ver, ap->firmware_major, ap->firmware_minor,
- ap->firmware_fix);
- writel(0, ®s->LocalCtrl);
- ap->version = 1;
- ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES;
- break;
-#endif
- case 6:
- printk(KERN_INFO " Tigon II (Rev. %i), Firmware: %i.%i.%i, ",
- tig_ver, ap->firmware_major, ap->firmware_minor,
- ap->firmware_fix);
- writel(readl(®s->CpuBCtrl) | CPU_HALT, ®s->CpuBCtrl);
- readl(®s->CpuBCtrl); /* PCI write posting */
- /*
- * The SRAM bank size does _not_ indicate the amount
- * of memory on the card, it controls the _bank_ size!
- * Ie. a 1MB AceNIC will have two banks of 512KB.
- */
- writel(SRAM_BANK_512K, ®s->LocalCtrl);
- writel(SYNC_SRAM_TIMING, ®s->MiscCfg);
- ap->version = 2;
- ap->tx_ring_entries = MAX_TX_RING_ENTRIES;
- break;
- default:
- printk(KERN_WARNING " Unsupported Tigon version detected "
- "(%i)\n", tig_ver);
- ecode = -ENODEV;
- goto init_error;
- }
-
- /*
- * ModeStat _must_ be set after the SRAM settings as this change
- * seems to corrupt the ModeStat and possible other registers.
- * The SRAM settings survive resets and setting it to the same
- * value a second time works as well. This is what caused the
- * `Firmware not running' problem on the Tigon II.
- */
-#ifdef __BIG_ENDIAN
- writel(ACE_BYTE_SWAP_DMA | ACE_WARN | ACE_FATAL | ACE_BYTE_SWAP_BD |
- ACE_WORD_SWAP_BD | ACE_NO_JUMBO_FRAG, ®s->ModeStat);
-#else
- writel(ACE_BYTE_SWAP_DMA | ACE_WARN | ACE_FATAL |
- ACE_WORD_SWAP_BD | ACE_NO_JUMBO_FRAG, ®s->ModeStat);
-#endif
- readl(®s->ModeStat); /* PCI write posting */
-
- mac1 = 0;
- for(i = 0; i < 4; i++) {
- int t;
-
- mac1 = mac1 << 8;
- t = read_eeprom_byte(dev, 0x8c+i);
- if (t < 0) {
- ecode = -EIO;
- goto init_error;
- } else
- mac1 |= (t & 0xff);
- }
- mac2 = 0;
- for(i = 4; i < 8; i++) {
- int t;
-
- mac2 = mac2 << 8;
- t = read_eeprom_byte(dev, 0x8c+i);
- if (t < 0) {
- ecode = -EIO;
- goto init_error;
- } else
- mac2 |= (t & 0xff);
- }
-
- writel(mac1, ®s->MacAddrHi);
- writel(mac2, ®s->MacAddrLo);
-
- addr[0] = (mac1 >> 8) & 0xff;
- addr[1] = mac1 & 0xff;
- addr[2] = (mac2 >> 24) & 0xff;
- addr[3] = (mac2 >> 16) & 0xff;
- addr[4] = (mac2 >> 8) & 0xff;
- addr[5] = mac2 & 0xff;
- eth_hw_addr_set(dev, addr);
-
- printk("MAC: %pM\n", dev->dev_addr);
-
- /*
- * Looks like this is necessary to deal with on all architectures,
- * even this %$#%$# N440BX Intel based thing doesn't get it right.
- * Ie. having two NICs in the machine, one will have the cache
- * line set at boot time, the other will not.
- */
- pdev = ap->pdev;
- pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_size);
- cache_size <<= 2;
- if (cache_size != SMP_CACHE_BYTES) {
- printk(KERN_INFO " PCI cache line size set incorrectly "
- "(%i bytes) by BIOS/FW, ", cache_size);
- if (cache_size > SMP_CACHE_BYTES)
- printk("expecting %i\n", SMP_CACHE_BYTES);
- else {
- printk("correcting to %i\n", SMP_CACHE_BYTES);
- pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
- SMP_CACHE_BYTES >> 2);
- }
- }
-
- pci_state = readl(®s->PciState);
- printk(KERN_INFO " PCI bus width: %i bits, speed: %iMHz, "
- "latency: %i clks\n",
- (pci_state & PCI_32BIT) ? 32 : 64,
- (pci_state & PCI_66MHZ) ? 66 : 33,
- ap->pci_latency);
-
- /*
- * Set the max DMA transfer size. Seems that for most systems
- * the performance is better when no MAX parameter is
- * set. However for systems enabling PCI write and invalidate,
- * DMA writes must be set to the L1 cache line size to get
- * optimal performance.
- *
- * The default is now to turn the PCI write and invalidate off
- * - that is what Alteon does for NT.
- */
- tmp = READ_CMD_MEM | WRITE_CMD_MEM;
- if (ap->version >= 2) {
- tmp |= (MEM_READ_MULTIPLE | (pci_state & PCI_66MHZ));
- /*
- * Tuning parameters only supported for 8 cards
- */
- if (board_idx == BOARD_IDX_OVERFLOW ||
- dis_pci_mem_inval[board_idx]) {
- if (ap->pci_command & PCI_COMMAND_INVALIDATE) {
- ap->pci_command &= ~PCI_COMMAND_INVALIDATE;
- pci_write_config_word(pdev, PCI_COMMAND,
- ap->pci_command);
- printk(KERN_INFO " Disabling PCI memory "
- "write and invalidate\n");
- }
- } else if (ap->pci_command & PCI_COMMAND_INVALIDATE) {
- printk(KERN_INFO " PCI memory write & invalidate "
- "enabled by BIOS, enabling counter measures\n");
-
- switch(SMP_CACHE_BYTES) {
- case 16:
- tmp |= DMA_WRITE_MAX_16;
- break;
- case 32:
- tmp |= DMA_WRITE_MAX_32;
- break;
- case 64:
- tmp |= DMA_WRITE_MAX_64;
- break;
- case 128:
- tmp |= DMA_WRITE_MAX_128;
- break;
- default:
- printk(KERN_INFO " Cache line size %i not "
- "supported, PCI write and invalidate "
- "disabled\n", SMP_CACHE_BYTES);
- ap->pci_command &= ~PCI_COMMAND_INVALIDATE;
- pci_write_config_word(pdev, PCI_COMMAND,
- ap->pci_command);
- }
- }
- }
-
-#ifdef __sparc__
- /*
- * On this platform, we know what the best dma settings
- * are. We use 64-byte maximum bursts, because if we
- * burst larger than the cache line size (or even cross
- * a 64byte boundary in a single burst) the UltraSparc
- * PCI controller will disconnect at 64-byte multiples.
- *
- * Read-multiple will be properly enabled above, and when
- * set will give the PCI controller proper hints about
- * prefetching.
- */
- tmp &= ~DMA_READ_WRITE_MASK;
- tmp |= DMA_READ_MAX_64;
- tmp |= DMA_WRITE_MAX_64;
-#endif
-#ifdef __alpha__
- tmp &= ~DMA_READ_WRITE_MASK;
- tmp |= DMA_READ_MAX_128;
- /*
- * All the docs say MUST NOT. Well, I did.
- * Nothing terrible happens, if we load wrong size.
- * Bit w&i still works better!
- */
- tmp |= DMA_WRITE_MAX_128;
-#endif
- writel(tmp, ®s->PciState);
-
-#if 0
- /*
- * The Host PCI bus controller driver has to set FBB.
- * If all devices on that PCI bus support FBB, then the controller
- * can enable FBB support in the Host PCI Bus controller (or on
- * the PCI-PCI bridge if that applies).
- * -ggg
- */
- /*
- * I have received reports from people having problems when this
- * bit is enabled.
- */
- if (!(ap->pci_command & PCI_COMMAND_FAST_BACK)) {
- printk(KERN_INFO " Enabling PCI Fast Back to Back\n");
- ap->pci_command |= PCI_COMMAND_FAST_BACK;
- pci_write_config_word(pdev, PCI_COMMAND, ap->pci_command);
- }
-#endif
-
- /*
- * Configure DMA attributes.
- */
- if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
- ecode = -ENODEV;
- goto init_error;
- }
-
- /*
- * Initialize the generic info block and the command+event rings
- * and the control blocks for the transmit and receive rings
- * as they need to be setup once and for all.
- */
- if (!(info = dma_alloc_coherent(&ap->pdev->dev, sizeof(struct ace_info),
- &ap->info_dma, GFP_KERNEL))) {
- ecode = -EAGAIN;
- goto init_error;
- }
- ap->info = info;
-
- /*
- * Get the memory for the skb rings.
- */
- if (!(ap->skb = kzalloc_obj(struct ace_skb))) {
- ecode = -EAGAIN;
- goto init_error;
- }
-
- ecode = request_irq(pdev->irq, ace_interrupt, IRQF_SHARED,
- DRV_NAME, dev);
- if (ecode) {
- printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
- DRV_NAME, pdev->irq);
- goto init_error;
- } else
- dev->irq = pdev->irq;
-
-#ifdef INDEX_DEBUG
- spin_lock_init(&ap->debug_lock);
- ap->last_tx = ACE_TX_RING_ENTRIES(ap) - 1;
- ap->last_std_rx = 0;
- ap->last_mini_rx = 0;
-#endif
-
- ecode = ace_load_firmware(dev);
- if (ecode)
- goto init_error;
-
- ap->fw_running = 0;
-
- tmp_ptr = ap->info_dma;
- writel(tmp_ptr >> 32, ®s->InfoPtrHi);
- writel(tmp_ptr & 0xffffffff, ®s->InfoPtrLo);
-
- memset(ap->evt_ring, 0, EVT_RING_ENTRIES * sizeof(struct event));
-
- set_aceaddr(&info->evt_ctrl.rngptr, ap->evt_ring_dma);
- info->evt_ctrl.flags = 0;
-
- *(ap->evt_prd) = 0;
- wmb();
- set_aceaddr(&info->evt_prd_ptr, ap->evt_prd_dma);
- writel(0, ®s->EvtCsm);
-
- set_aceaddr(&info->cmd_ctrl.rngptr, 0x100);
- info->cmd_ctrl.flags = 0;
- info->cmd_ctrl.max_len = 0;
-
- for (i = 0; i < CMD_RING_ENTRIES; i++)
- writel(0, ®s->CmdRng[i]);
-
- writel(0, ®s->CmdPrd);
- writel(0, ®s->CmdCsm);
-
- tmp_ptr = ap->info_dma;
- tmp_ptr += (unsigned long) &(((struct ace_info *)0)->s.stats);
- set_aceaddr(&info->stats2_ptr, (dma_addr_t) tmp_ptr);
-
- set_aceaddr(&info->rx_std_ctrl.rngptr, ap->rx_ring_base_dma);
- info->rx_std_ctrl.max_len = ACE_STD_BUFSIZE;
- info->rx_std_ctrl.flags =
- RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | RCB_FLG_VLAN_ASSIST;
-
- memset(ap->rx_std_ring, 0,
- RX_STD_RING_ENTRIES * sizeof(struct rx_desc));
-
- for (i = 0; i < RX_STD_RING_ENTRIES; i++)
- ap->rx_std_ring[i].flags = BD_FLG_TCP_UDP_SUM;
-
- ap->rx_std_skbprd = 0;
- atomic_set(&ap->cur_rx_bufs, 0);
-
- set_aceaddr(&info->rx_jumbo_ctrl.rngptr,
- (ap->rx_ring_base_dma +
- (sizeof(struct rx_desc) * RX_STD_RING_ENTRIES)));
- info->rx_jumbo_ctrl.max_len = 0;
- info->rx_jumbo_ctrl.flags =
- RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | RCB_FLG_VLAN_ASSIST;
-
- memset(ap->rx_jumbo_ring, 0,
- RX_JUMBO_RING_ENTRIES * sizeof(struct rx_desc));
-
- for (i = 0; i < RX_JUMBO_RING_ENTRIES; i++)
- ap->rx_jumbo_ring[i].flags = BD_FLG_TCP_UDP_SUM | BD_FLG_JUMBO;
-
- ap->rx_jumbo_skbprd = 0;
- atomic_set(&ap->cur_jumbo_bufs, 0);
-
- memset(ap->rx_mini_ring, 0,
- RX_MINI_RING_ENTRIES * sizeof(struct rx_desc));
-
- if (ap->version >= 2) {
- set_aceaddr(&info->rx_mini_ctrl.rngptr,
- (ap->rx_ring_base_dma +
- (sizeof(struct rx_desc) *
- (RX_STD_RING_ENTRIES +
- RX_JUMBO_RING_ENTRIES))));
- info->rx_mini_ctrl.max_len = ACE_MINI_SIZE;
- info->rx_mini_ctrl.flags =
- RCB_FLG_TCP_UDP_SUM|RCB_FLG_NO_PSEUDO_HDR|RCB_FLG_VLAN_ASSIST;
-
- for (i = 0; i < RX_MINI_RING_ENTRIES; i++)
- ap->rx_mini_ring[i].flags =
- BD_FLG_TCP_UDP_SUM | BD_FLG_MINI;
- } else {
- set_aceaddr(&info->rx_mini_ctrl.rngptr, 0);
- info->rx_mini_ctrl.flags = RCB_FLG_RNG_DISABLE;
- info->rx_mini_ctrl.max_len = 0;
- }
-
- ap->rx_mini_skbprd = 0;
- atomic_set(&ap->cur_mini_bufs, 0);
-
- set_aceaddr(&info->rx_return_ctrl.rngptr,
- (ap->rx_ring_base_dma +
- (sizeof(struct rx_desc) *
- (RX_STD_RING_ENTRIES +
- RX_JUMBO_RING_ENTRIES +
- RX_MINI_RING_ENTRIES))));
- info->rx_return_ctrl.flags = 0;
- info->rx_return_ctrl.max_len = RX_RETURN_RING_ENTRIES;
-
- memset(ap->rx_return_ring, 0,
- RX_RETURN_RING_ENTRIES * sizeof(struct rx_desc));
-
- set_aceaddr(&info->rx_ret_prd_ptr, ap->rx_ret_prd_dma);
- *(ap->rx_ret_prd) = 0;
-
- writel(TX_RING_BASE, ®s->WinBase);
-
- if (ACE_IS_TIGON_I(ap)) {
- ap->tx_ring = (__force struct tx_desc *) regs->Window;
- for (i = 0; i < (TIGON_I_TX_RING_ENTRIES
- * sizeof(struct tx_desc)) / sizeof(u32); i++)
- writel(0, (__force void __iomem *)ap->tx_ring + i * 4);
-
- set_aceaddr(&info->tx_ctrl.rngptr, TX_RING_BASE);
- } else {
- memset(ap->tx_ring, 0,
- MAX_TX_RING_ENTRIES * sizeof(struct tx_desc));
-
- set_aceaddr(&info->tx_ctrl.rngptr, ap->tx_ring_dma);
- }
-
- info->tx_ctrl.max_len = ACE_TX_RING_ENTRIES(ap);
- tmp = RCB_FLG_TCP_UDP_SUM | RCB_FLG_NO_PSEUDO_HDR | RCB_FLG_VLAN_ASSIST;
-
- /*
- * The Tigon I does not like having the TX ring in host memory ;-(
- */
- if (!ACE_IS_TIGON_I(ap))
- tmp |= RCB_FLG_TX_HOST_RING;
-#if TX_COAL_INTS_ONLY
- tmp |= RCB_FLG_COAL_INT_ONLY;
-#endif
- info->tx_ctrl.flags = tmp;
-
- set_aceaddr(&info->tx_csm_ptr, ap->tx_csm_dma);
-
- /*
- * Potential item for tuning parameter
- */
-#if 0 /* NO */
- writel(DMA_THRESH_16W, ®s->DmaReadCfg);
- writel(DMA_THRESH_16W, ®s->DmaWriteCfg);
-#else
- writel(DMA_THRESH_8W, ®s->DmaReadCfg);
- writel(DMA_THRESH_8W, ®s->DmaWriteCfg);
-#endif
-
- writel(0, ®s->MaskInt);
- writel(1, ®s->IfIdx);
-#if 0
- /*
- * McKinley boxes do not like us fiddling with AssistState
- * this early
- */
- writel(1, ®s->AssistState);
-#endif
-
- writel(DEF_STAT, ®s->TuneStatTicks);
- writel(DEF_TRACE, ®s->TuneTrace);
-
- ace_set_rxtx_parms(dev, 0);
-
- if (board_idx == BOARD_IDX_OVERFLOW) {
- printk(KERN_WARNING "%s: more than %i NICs detected, "
- "ignoring module parameters!\n",
- ap->name, ACE_MAX_MOD_PARMS);
- } else if (board_idx >= 0) {
- if (tx_coal_tick[board_idx])
- writel(tx_coal_tick[board_idx],
- ®s->TuneTxCoalTicks);
- if (max_tx_desc[board_idx])
- writel(max_tx_desc[board_idx], ®s->TuneMaxTxDesc);
-
- if (rx_coal_tick[board_idx])
- writel(rx_coal_tick[board_idx],
- ®s->TuneRxCoalTicks);
- if (max_rx_desc[board_idx])
- writel(max_rx_desc[board_idx], ®s->TuneMaxRxDesc);
-
- if (trace[board_idx])
- writel(trace[board_idx], ®s->TuneTrace);
-
- if ((tx_ratio[board_idx] > 0) && (tx_ratio[board_idx] < 64))
- writel(tx_ratio[board_idx], ®s->TxBufRat);
- }
-
- /*
- * Default link parameters
- */
- tmp = LNK_ENABLE | LNK_FULL_DUPLEX | LNK_1000MB | LNK_100MB |
- LNK_10MB | LNK_RX_FLOW_CTL_Y | LNK_NEG_FCTL | LNK_NEGOTIATE;
- if(ap->version >= 2)
- tmp |= LNK_TX_FLOW_CTL_Y;
-
- /*
- * Override link default parameters
- */
- if ((board_idx >= 0) && link_state[board_idx]) {
- int option = link_state[board_idx];
-
- tmp = LNK_ENABLE;
-
- if (option & 0x01) {
- printk(KERN_INFO "%s: Setting half duplex link\n",
- ap->name);
- tmp &= ~LNK_FULL_DUPLEX;
- }
- if (option & 0x02)
- tmp &= ~LNK_NEGOTIATE;
- if (option & 0x10)
- tmp |= LNK_10MB;
- if (option & 0x20)
- tmp |= LNK_100MB;
- if (option & 0x40)
- tmp |= LNK_1000MB;
- if ((option & 0x70) == 0) {
- printk(KERN_WARNING "%s: No media speed specified, "
- "forcing auto negotiation\n", ap->name);
- tmp |= LNK_NEGOTIATE | LNK_1000MB |
- LNK_100MB | LNK_10MB;
- }
- if ((option & 0x100) == 0)
- tmp |= LNK_NEG_FCTL;
- else
- printk(KERN_INFO "%s: Disabling flow control "
- "negotiation\n", ap->name);
- if (option & 0x200)
- tmp |= LNK_RX_FLOW_CTL_Y;
- if ((option & 0x400) && (ap->version >= 2)) {
- printk(KERN_INFO "%s: Enabling TX flow control\n",
- ap->name);
- tmp |= LNK_TX_FLOW_CTL_Y;
- }
- }
-
- ap->link = tmp;
- writel(tmp, ®s->TuneLink);
- if (ap->version >= 2)
- writel(tmp, ®s->TuneFastLink);
-
- writel(ap->firmware_start, ®s->Pc);
-
- writel(0, ®s->Mb0Lo);
-
- /*
- * Set tx_csm before we start receiving interrupts, otherwise
- * the interrupt handler might think it is supposed to process
- * tx ints before we are up and running, which may cause a null
- * pointer access in the int handler.
- */
- ap->cur_rx = 0;
- ap->tx_prd = *(ap->tx_csm) = ap->tx_ret_csm = 0;
-
- wmb();
- ace_set_txprd(regs, ap, 0);
- writel(0, ®s->RxRetCsm);
-
- /*
- * Enable DMA engine now.
- * If we do this sooner, Mckinley box pukes.
- * I assume it's because Tigon II DMA engine wants to check
- * *something* even before the CPU is started.
- */
- writel(1, ®s->AssistState); /* enable DMA */
-
- /*
- * Start the NIC CPU
- */
- writel(readl(®s->CpuCtrl) & ~(CPU_HALT|CPU_TRACE), ®s->CpuCtrl);
- readl(®s->CpuCtrl);
-
- /*
- * Wait for the firmware to spin up - max 3 seconds.
- */
- myjif = jiffies + 3 * HZ;
- while (time_before(jiffies, myjif) && !ap->fw_running)
- cpu_relax();
-
- if (!ap->fw_running) {
- printk(KERN_ERR "%s: Firmware NOT running!\n", ap->name);
-
- ace_dump_trace(ap);
- writel(readl(®s->CpuCtrl) | CPU_HALT, ®s->CpuCtrl);
- readl(®s->CpuCtrl);
-
- /* aman@sgi.com - account for badly behaving firmware/NIC:
- * - have observed that the NIC may continue to generate
- * interrupts for some reason; attempt to stop it - halt
- * second CPU for Tigon II cards, and also clear Mb0
- * - if we're a module, we'll fail to load if this was
- * the only GbE card in the system => if the kernel does
- * see an interrupt from the NIC, code to handle it is
- * gone and OOps! - so free_irq also
- */
- if (ap->version >= 2)
- writel(readl(®s->CpuBCtrl) | CPU_HALT,
- ®s->CpuBCtrl);
- writel(0, ®s->Mb0Lo);
- readl(®s->Mb0Lo);
-
- ecode = -EBUSY;
- goto init_error;
- }
-
- /*
- * We load the ring here as there seem to be no way to tell the
- * firmware to wipe the ring without re-initializing it.
- */
- if (!test_and_set_bit(0, &ap->std_refill_busy))
- ace_load_std_rx_ring(dev, RX_RING_SIZE);
- else
- printk(KERN_ERR "%s: Someone is busy refilling the RX ring\n",
- ap->name);
- if (ap->version >= 2) {
- if (!test_and_set_bit(0, &ap->mini_refill_busy))
- ace_load_mini_rx_ring(dev, RX_MINI_SIZE);
- else
- printk(KERN_ERR "%s: Someone is busy refilling "
- "the RX mini ring\n", ap->name);
- }
- return 0;
-
- init_error:
- ace_init_cleanup(dev);
- return ecode;
-}
-
-
-static void ace_set_rxtx_parms(struct net_device *dev, int jumbo)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- int board_idx = ap->board_idx;
-
- if (board_idx >= 0) {
- if (!jumbo) {
- if (!tx_coal_tick[board_idx])
- writel(DEF_TX_COAL, ®s->TuneTxCoalTicks);
- if (!max_tx_desc[board_idx])
- writel(DEF_TX_MAX_DESC, ®s->TuneMaxTxDesc);
- if (!rx_coal_tick[board_idx])
- writel(DEF_RX_COAL, ®s->TuneRxCoalTicks);
- if (!max_rx_desc[board_idx])
- writel(DEF_RX_MAX_DESC, ®s->TuneMaxRxDesc);
- if (!tx_ratio[board_idx])
- writel(DEF_TX_RATIO, ®s->TxBufRat);
- } else {
- if (!tx_coal_tick[board_idx])
- writel(DEF_JUMBO_TX_COAL,
- ®s->TuneTxCoalTicks);
- if (!max_tx_desc[board_idx])
- writel(DEF_JUMBO_TX_MAX_DESC,
- ®s->TuneMaxTxDesc);
- if (!rx_coal_tick[board_idx])
- writel(DEF_JUMBO_RX_COAL,
- ®s->TuneRxCoalTicks);
- if (!max_rx_desc[board_idx])
- writel(DEF_JUMBO_RX_MAX_DESC,
- ®s->TuneMaxRxDesc);
- if (!tx_ratio[board_idx])
- writel(DEF_JUMBO_TX_RATIO, ®s->TxBufRat);
- }
- }
-}
-
-
-static void ace_watchdog(struct net_device *data, unsigned int txqueue)
-{
- struct net_device *dev = data;
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
-
- /*
- * We haven't received a stats update event for more than 2.5
- * seconds and there is data in the transmit queue, thus we
- * assume the card is stuck.
- */
- if (*ap->tx_csm != ap->tx_ret_csm) {
- printk(KERN_WARNING "%s: Transmitter is stuck, %08x\n",
- dev->name, (unsigned int)readl(®s->HostCtrl));
- /* This can happen due to ieee flow control. */
- } else {
- printk(KERN_DEBUG "%s: BUG... transmitter died. Kicking it.\n",
- dev->name);
-#if 0
- netif_wake_queue(dev);
-#endif
- }
-}
-
-
-static void ace_bh_work(struct work_struct *work)
-{
- struct ace_private *ap = from_work(ap, work, ace_bh_work);
- struct net_device *dev = ap->ndev;
- int cur_size;
-
- cur_size = atomic_read(&ap->cur_rx_bufs);
- if ((cur_size < RX_LOW_STD_THRES) &&
- !test_and_set_bit(0, &ap->std_refill_busy)) {
-#ifdef DEBUG
- printk("refilling buffers (current %i)\n", cur_size);
-#endif
- ace_load_std_rx_ring(dev, RX_RING_SIZE - cur_size);
- }
-
- if (ap->version >= 2) {
- cur_size = atomic_read(&ap->cur_mini_bufs);
- if ((cur_size < RX_LOW_MINI_THRES) &&
- !test_and_set_bit(0, &ap->mini_refill_busy)) {
-#ifdef DEBUG
- printk("refilling mini buffers (current %i)\n",
- cur_size);
-#endif
- ace_load_mini_rx_ring(dev, RX_MINI_SIZE - cur_size);
- }
- }
-
- cur_size = atomic_read(&ap->cur_jumbo_bufs);
- if (ap->jumbo && (cur_size < RX_LOW_JUMBO_THRES) &&
- !test_and_set_bit(0, &ap->jumbo_refill_busy)) {
-#ifdef DEBUG
- printk("refilling jumbo buffers (current %i)\n", cur_size);
-#endif
- ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE - cur_size);
- }
- ap->bh_work_pending = 0;
-}
-
-
-/*
- * Copy the contents of the NIC's trace buffer to kernel memory.
- */
-static void ace_dump_trace(struct ace_private *ap)
-{
-#if 0
- if (!ap->trace_buf)
- if (!(ap->trace_buf = kmalloc(ACE_TRACE_SIZE, GFP_KERNEL)))
- return;
-#endif
-}
-
-
-/*
- * Load the standard rx ring.
- *
- * Loading rings is safe without holding the spin lock since this is
- * done only before the device is enabled, thus no interrupts are
- * generated and by the interrupt handler/bh handler.
- */
-static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- short i, idx;
-
-
- prefetchw(&ap->cur_rx_bufs);
-
- idx = ap->rx_std_skbprd;
-
- for (i = 0; i < nr_bufs; i++) {
- struct sk_buff *skb;
- struct rx_desc *rd;
- dma_addr_t mapping;
-
- skb = netdev_alloc_skb_ip_align(dev, ACE_STD_BUFSIZE);
- if (!skb)
- break;
-
- mapping = dma_map_page(&ap->pdev->dev,
- virt_to_page(skb->data),
- offset_in_page(skb->data),
- ACE_STD_BUFSIZE, DMA_FROM_DEVICE);
- ap->skb->rx_std_skbuff[idx].skb = skb;
- dma_unmap_addr_set(&ap->skb->rx_std_skbuff[idx],
- mapping, mapping);
-
- rd = &ap->rx_std_ring[idx];
- set_aceaddr(&rd->addr, mapping);
- rd->size = ACE_STD_BUFSIZE;
- rd->idx = idx;
- idx = (idx + 1) % RX_STD_RING_ENTRIES;
- }
-
- if (!i)
- goto error_out;
-
- atomic_add(i, &ap->cur_rx_bufs);
- ap->rx_std_skbprd = idx;
-
- if (ACE_IS_TIGON_I(ap)) {
- struct cmd cmd;
- cmd.evt = C_SET_RX_PRD_IDX;
- cmd.code = 0;
- cmd.idx = ap->rx_std_skbprd;
- ace_issue_cmd(regs, &cmd);
- } else {
- writel(idx, ®s->RxStdPrd);
- wmb();
- }
-
- out:
- clear_bit(0, &ap->std_refill_busy);
- return;
-
- error_out:
- printk(KERN_INFO "Out of memory when allocating "
- "standard receive buffers\n");
- goto out;
-}
-
-
-static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- short i, idx;
-
- prefetchw(&ap->cur_mini_bufs);
-
- idx = ap->rx_mini_skbprd;
- for (i = 0; i < nr_bufs; i++) {
- struct sk_buff *skb;
- struct rx_desc *rd;
- dma_addr_t mapping;
-
- skb = netdev_alloc_skb_ip_align(dev, ACE_MINI_BUFSIZE);
- if (!skb)
- break;
-
- mapping = dma_map_page(&ap->pdev->dev,
- virt_to_page(skb->data),
- offset_in_page(skb->data),
- ACE_MINI_BUFSIZE, DMA_FROM_DEVICE);
- ap->skb->rx_mini_skbuff[idx].skb = skb;
- dma_unmap_addr_set(&ap->skb->rx_mini_skbuff[idx],
- mapping, mapping);
-
- rd = &ap->rx_mini_ring[idx];
- set_aceaddr(&rd->addr, mapping);
- rd->size = ACE_MINI_BUFSIZE;
- rd->idx = idx;
- idx = (idx + 1) % RX_MINI_RING_ENTRIES;
- }
-
- if (!i)
- goto error_out;
-
- atomic_add(i, &ap->cur_mini_bufs);
-
- ap->rx_mini_skbprd = idx;
-
- writel(idx, ®s->RxMiniPrd);
- wmb();
-
- out:
- clear_bit(0, &ap->mini_refill_busy);
- return;
- error_out:
- printk(KERN_INFO "Out of memory when allocating "
- "mini receive buffers\n");
- goto out;
-}
-
-
-/*
- * Load the jumbo rx ring, this may happen at any time if the MTU
- * is changed to a value > 1500.
- */
-static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- short i, idx;
-
- idx = ap->rx_jumbo_skbprd;
-
- for (i = 0; i < nr_bufs; i++) {
- struct sk_buff *skb;
- struct rx_desc *rd;
- dma_addr_t mapping;
-
- skb = netdev_alloc_skb_ip_align(dev, ACE_JUMBO_BUFSIZE);
- if (!skb)
- break;
-
- mapping = dma_map_page(&ap->pdev->dev,
- virt_to_page(skb->data),
- offset_in_page(skb->data),
- ACE_JUMBO_BUFSIZE, DMA_FROM_DEVICE);
- ap->skb->rx_jumbo_skbuff[idx].skb = skb;
- dma_unmap_addr_set(&ap->skb->rx_jumbo_skbuff[idx],
- mapping, mapping);
-
- rd = &ap->rx_jumbo_ring[idx];
- set_aceaddr(&rd->addr, mapping);
- rd->size = ACE_JUMBO_BUFSIZE;
- rd->idx = idx;
- idx = (idx + 1) % RX_JUMBO_RING_ENTRIES;
- }
-
- if (!i)
- goto error_out;
-
- atomic_add(i, &ap->cur_jumbo_bufs);
- ap->rx_jumbo_skbprd = idx;
-
- if (ACE_IS_TIGON_I(ap)) {
- struct cmd cmd;
- cmd.evt = C_SET_RX_JUMBO_PRD_IDX;
- cmd.code = 0;
- cmd.idx = ap->rx_jumbo_skbprd;
- ace_issue_cmd(regs, &cmd);
- } else {
- writel(idx, ®s->RxJumboPrd);
- wmb();
- }
-
- out:
- clear_bit(0, &ap->jumbo_refill_busy);
- return;
- error_out:
- if (net_ratelimit())
- printk(KERN_INFO "Out of memory when allocating "
- "jumbo receive buffers\n");
- goto out;
-}
-
-
-/*
- * All events are considered to be slow (RX/TX ints do not generate
- * events) and are handled here, outside the main interrupt handler,
- * to reduce the size of the handler.
- */
-static u32 ace_handle_event(struct net_device *dev, u32 evtcsm, u32 evtprd)
-{
- struct ace_private *ap;
-
- ap = netdev_priv(dev);
-
- while (evtcsm != evtprd) {
- switch (ap->evt_ring[evtcsm].evt) {
- case E_FW_RUNNING:
- printk(KERN_INFO "%s: Firmware up and running\n",
- ap->name);
- ap->fw_running = 1;
- wmb();
- break;
- case E_STATS_UPDATED:
- break;
- case E_LNK_STATE:
- {
- u16 code = ap->evt_ring[evtcsm].code;
- switch (code) {
- case E_C_LINK_UP:
- {
- u32 state = readl(&ap->regs->GigLnkState);
- printk(KERN_WARNING "%s: Optical link UP "
- "(%s Duplex, Flow Control: %s%s)\n",
- ap->name,
- state & LNK_FULL_DUPLEX ? "Full":"Half",
- state & LNK_TX_FLOW_CTL_Y ? "TX " : "",
- state & LNK_RX_FLOW_CTL_Y ? "RX" : "");
- break;
- }
- case E_C_LINK_DOWN:
- printk(KERN_WARNING "%s: Optical link DOWN\n",
- ap->name);
- break;
- case E_C_LINK_10_100:
- printk(KERN_WARNING "%s: 10/100BaseT link "
- "UP\n", ap->name);
- break;
- default:
- printk(KERN_ERR "%s: Unknown optical link "
- "state %02x\n", ap->name, code);
- }
- break;
- }
- case E_ERROR:
- switch(ap->evt_ring[evtcsm].code) {
- case E_C_ERR_INVAL_CMD:
- printk(KERN_ERR "%s: invalid command error\n",
- ap->name);
- break;
- case E_C_ERR_UNIMP_CMD:
- printk(KERN_ERR "%s: unimplemented command "
- "error\n", ap->name);
- break;
- case E_C_ERR_BAD_CFG:
- printk(KERN_ERR "%s: bad config error\n",
- ap->name);
- break;
- default:
- printk(KERN_ERR "%s: unknown error %02x\n",
- ap->name, ap->evt_ring[evtcsm].code);
- }
- break;
- case E_RESET_JUMBO_RNG:
- {
- int i;
- for (i = 0; i < RX_JUMBO_RING_ENTRIES; i++) {
- if (ap->skb->rx_jumbo_skbuff[i].skb) {
- ap->rx_jumbo_ring[i].size = 0;
- set_aceaddr(&ap->rx_jumbo_ring[i].addr, 0);
- dev_kfree_skb(ap->skb->rx_jumbo_skbuff[i].skb);
- ap->skb->rx_jumbo_skbuff[i].skb = NULL;
- }
- }
-
- if (ACE_IS_TIGON_I(ap)) {
- struct cmd cmd;
- cmd.evt = C_SET_RX_JUMBO_PRD_IDX;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(ap->regs, &cmd);
- } else {
- writel(0, &((ap->regs)->RxJumboPrd));
- wmb();
- }
-
- ap->jumbo = 0;
- ap->rx_jumbo_skbprd = 0;
- printk(KERN_INFO "%s: Jumbo ring flushed\n",
- ap->name);
- clear_bit(0, &ap->jumbo_refill_busy);
- break;
- }
- default:
- printk(KERN_ERR "%s: Unhandled event 0x%02x\n",
- ap->name, ap->evt_ring[evtcsm].evt);
- }
- evtcsm = (evtcsm + 1) % EVT_RING_ENTRIES;
- }
-
- return evtcsm;
-}
-
-
-static void ace_rx_int(struct net_device *dev, u32 rxretprd, u32 rxretcsm)
-{
- struct ace_private *ap = netdev_priv(dev);
- u32 idx;
- int mini_count = 0, std_count = 0;
-
- idx = rxretcsm;
-
- prefetchw(&ap->cur_rx_bufs);
- prefetchw(&ap->cur_mini_bufs);
-
- while (idx != rxretprd) {
- struct ring_info *rip;
- struct sk_buff *skb;
- struct rx_desc *retdesc;
- u32 skbidx;
- int bd_flags, desc_type, mapsize;
- u16 csum;
-
-
- /* make sure the rx descriptor isn't read before rxretprd */
- if (idx == rxretcsm)
- rmb();
-
- retdesc = &ap->rx_return_ring[idx];
- skbidx = retdesc->idx;
- bd_flags = retdesc->flags;
- desc_type = bd_flags & (BD_FLG_JUMBO | BD_FLG_MINI);
-
- switch(desc_type) {
- /*
- * Normal frames do not have any flags set
- *
- * Mini and normal frames arrive frequently,
- * so use a local counter to avoid doing
- * atomic operations for each packet arriving.
- */
- case 0:
- rip = &ap->skb->rx_std_skbuff[skbidx];
- mapsize = ACE_STD_BUFSIZE;
- std_count++;
- break;
- case BD_FLG_JUMBO:
- rip = &ap->skb->rx_jumbo_skbuff[skbidx];
- mapsize = ACE_JUMBO_BUFSIZE;
- atomic_dec(&ap->cur_jumbo_bufs);
- break;
- case BD_FLG_MINI:
- rip = &ap->skb->rx_mini_skbuff[skbidx];
- mapsize = ACE_MINI_BUFSIZE;
- mini_count++;
- break;
- default:
- printk(KERN_INFO "%s: unknown frame type (0x%02x) "
- "returned by NIC\n", dev->name,
- retdesc->flags);
- goto error;
- }
-
- skb = rip->skb;
- rip->skb = NULL;
- dma_unmap_page(&ap->pdev->dev, dma_unmap_addr(rip, mapping),
- mapsize, DMA_FROM_DEVICE);
- skb_put(skb, retdesc->size);
-
- /*
- * Fly baby, fly!
- */
- csum = retdesc->tcp_udp_csum;
-
- skb->protocol = eth_type_trans(skb, dev);
-
- /*
- * Instead of forcing the poor tigon mips cpu to calculate
- * pseudo hdr checksum, we do this ourselves.
- */
- if (bd_flags & BD_FLG_TCP_UDP_SUM) {
- skb->csum = htons(csum);
- skb->ip_summed = CHECKSUM_COMPLETE;
- } else {
- skb_checksum_none_assert(skb);
- }
-
- /* send it up */
- if ((bd_flags & BD_FLG_VLAN_TAG))
- __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), retdesc->vlan);
- netif_rx(skb);
-
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += retdesc->size;
-
- idx = (idx + 1) % RX_RETURN_RING_ENTRIES;
- }
-
- atomic_sub(std_count, &ap->cur_rx_bufs);
- if (!ACE_IS_TIGON_I(ap))
- atomic_sub(mini_count, &ap->cur_mini_bufs);
-
- out:
- /*
- * According to the documentation RxRetCsm is obsolete with
- * the 12.3.x Firmware - my Tigon I NICs seem to disagree!
- */
- if (ACE_IS_TIGON_I(ap)) {
- writel(idx, &ap->regs->RxRetCsm);
- }
- ap->cur_rx = idx;
-
- return;
- error:
- idx = rxretprd;
- goto out;
-}
-
-
-static inline void ace_tx_int(struct net_device *dev,
- u32 txcsm, u32 idx)
-{
- struct ace_private *ap = netdev_priv(dev);
-
- do {
- struct sk_buff *skb;
- struct tx_ring_info *info;
-
- info = ap->skb->tx_skbuff + idx;
- skb = info->skb;
-
- if (dma_unmap_len(info, maplen)) {
- dma_unmap_page(&ap->pdev->dev,
- dma_unmap_addr(info, mapping),
- dma_unmap_len(info, maplen),
- DMA_TO_DEVICE);
- dma_unmap_len_set(info, maplen, 0);
- }
-
- if (skb) {
- dev->stats.tx_packets++;
- dev->stats.tx_bytes += skb->len;
- dev_consume_skb_irq(skb);
- info->skb = NULL;
- }
-
- idx = (idx + 1) % ACE_TX_RING_ENTRIES(ap);
- } while (idx != txcsm);
-
- if (netif_queue_stopped(dev))
- netif_wake_queue(dev);
-
- wmb();
- ap->tx_ret_csm = txcsm;
-
- /* So... tx_ret_csm is advanced _after_ check for device wakeup.
- *
- * We could try to make it before. In this case we would get
- * the following race condition: hard_start_xmit on other cpu
- * enters after we advanced tx_ret_csm and fills space,
- * which we have just freed, so that we make illegal device wakeup.
- * There is no good way to workaround this (at entry
- * to ace_start_xmit detects this condition and prevents
- * ring corruption, but it is not a good workaround.)
- *
- * When tx_ret_csm is advanced after, we wake up device _only_
- * if we really have some space in ring (though the core doing
- * hard_start_xmit can see full ring for some period and has to
- * synchronize.) Superb.
- * BUT! We get another subtle race condition. hard_start_xmit
- * may think that ring is full between wakeup and advancing
- * tx_ret_csm and will stop device instantly! It is not so bad.
- * We are guaranteed that there is something in ring, so that
- * the next irq will resume transmission. To speedup this we could
- * mark descriptor, which closes ring with BD_FLG_COAL_NOW
- * (see ace_start_xmit).
- *
- * Well, this dilemma exists in all lock-free devices.
- * We, following scheme used in drivers by Donald Becker,
- * select the least dangerous.
- * --ANK
- */
-}
-
-
-static irqreturn_t ace_interrupt(int irq, void *dev_id)
-{
- struct net_device *dev = (struct net_device *)dev_id;
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- u32 idx;
- u32 txcsm, rxretcsm, rxretprd;
- u32 evtcsm, evtprd;
-
- /*
- * In case of PCI shared interrupts or spurious interrupts,
- * we want to make sure it is actually our interrupt before
- * spending any time in here.
- */
- if (!(readl(®s->HostCtrl) & IN_INT))
- return IRQ_NONE;
-
- /*
- * ACK intr now. Otherwise we will lose updates to rx_ret_prd,
- * which happened _after_ rxretprd = *ap->rx_ret_prd; but before
- * writel(0, ®s->Mb0Lo).
- *
- * "IRQ avoidance" recommended in docs applies to IRQs served
- * threads and it is wrong even for that case.
- */
- writel(0, ®s->Mb0Lo);
- readl(®s->Mb0Lo);
-
- /*
- * There is no conflict between transmit handling in
- * start_xmit and receive processing, thus there is no reason
- * to take a spin lock for RX handling. Wait until we start
- * working on the other stuff - hey we don't need a spin lock
- * anymore.
- */
- rxretprd = *ap->rx_ret_prd;
- rxretcsm = ap->cur_rx;
-
- if (rxretprd != rxretcsm)
- ace_rx_int(dev, rxretprd, rxretcsm);
-
- txcsm = *ap->tx_csm;
- idx = ap->tx_ret_csm;
-
- if (txcsm != idx) {
- /*
- * If each skb takes only one descriptor this check degenerates
- * to identity, because new space has just been opened.
- * But if skbs are fragmented we must check that this index
- * update releases enough of space, otherwise we just
- * wait for device to make more work.
- */
- if (!tx_ring_full(ap, txcsm, ap->tx_prd))
- ace_tx_int(dev, txcsm, idx);
- }
-
- evtcsm = readl(®s->EvtCsm);
- evtprd = *ap->evt_prd;
-
- if (evtcsm != evtprd) {
- evtcsm = ace_handle_event(dev, evtcsm, evtprd);
- writel(evtcsm, ®s->EvtCsm);
- }
-
- /*
- * This has to go last in the interrupt handler and run with
- * the spin lock released ... what lock?
- */
- if (netif_running(dev)) {
- int cur_size;
- int run_bh_work = 0;
-
- cur_size = atomic_read(&ap->cur_rx_bufs);
- if (cur_size < RX_LOW_STD_THRES) {
- if ((cur_size < RX_PANIC_STD_THRES) &&
- !test_and_set_bit(0, &ap->std_refill_busy)) {
-#ifdef DEBUG
- printk("low on std buffers %i\n", cur_size);
-#endif
- ace_load_std_rx_ring(dev,
- RX_RING_SIZE - cur_size);
- } else
- run_bh_work = 1;
- }
-
- if (!ACE_IS_TIGON_I(ap)) {
- cur_size = atomic_read(&ap->cur_mini_bufs);
- if (cur_size < RX_LOW_MINI_THRES) {
- if ((cur_size < RX_PANIC_MINI_THRES) &&
- !test_and_set_bit(0,
- &ap->mini_refill_busy)) {
-#ifdef DEBUG
- printk("low on mini buffers %i\n",
- cur_size);
-#endif
- ace_load_mini_rx_ring(dev,
- RX_MINI_SIZE - cur_size);
- } else
- run_bh_work = 1;
- }
- }
-
- if (ap->jumbo) {
- cur_size = atomic_read(&ap->cur_jumbo_bufs);
- if (cur_size < RX_LOW_JUMBO_THRES) {
- if ((cur_size < RX_PANIC_JUMBO_THRES) &&
- !test_and_set_bit(0,
- &ap->jumbo_refill_busy)){
-#ifdef DEBUG
- printk("low on jumbo buffers %i\n",
- cur_size);
-#endif
- ace_load_jumbo_rx_ring(dev,
- RX_JUMBO_SIZE - cur_size);
- } else
- run_bh_work = 1;
- }
- }
- if (run_bh_work && !ap->bh_work_pending) {
- ap->bh_work_pending = 1;
- queue_work(system_bh_wq, &ap->ace_bh_work);
- }
- }
-
- return IRQ_HANDLED;
-}
-
-static int ace_open(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- struct cmd cmd;
-
- if (!(ap->fw_running)) {
- printk(KERN_WARNING "%s: Firmware not running!\n", dev->name);
- return -EBUSY;
- }
-
- writel(dev->mtu + ETH_HLEN + 4, ®s->IfMtu);
-
- cmd.evt = C_CLEAR_STATS;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-
- cmd.evt = C_HOST_STATE;
- cmd.code = C_C_STACK_UP;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-
- if (ap->jumbo &&
- !test_and_set_bit(0, &ap->jumbo_refill_busy))
- ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE);
-
- if (dev->flags & IFF_PROMISC) {
- cmd.evt = C_SET_PROMISC_MODE;
- cmd.code = C_C_PROMISC_ENABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-
- ap->promisc = 1;
- }else
- ap->promisc = 0;
- ap->mcast_all = 0;
-
-#if 0
- cmd.evt = C_LNK_NEGOTIATION;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-#endif
-
- netif_start_queue(dev);
-
- /*
- * Setup the bottom half rx ring refill handler
- */
- INIT_WORK(&ap->ace_bh_work, ace_bh_work);
- return 0;
-}
-
-
-static int ace_close(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- struct cmd cmd;
- unsigned long flags;
- short i;
-
- /*
- * Without (or before) releasing irq and stopping hardware, this
- * is an absolute non-sense, by the way. It will be reset instantly
- * by the first irq.
- */
- netif_stop_queue(dev);
-
-
- if (ap->promisc) {
- cmd.evt = C_SET_PROMISC_MODE;
- cmd.code = C_C_PROMISC_DISABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- ap->promisc = 0;
- }
-
- cmd.evt = C_HOST_STATE;
- cmd.code = C_C_STACK_DOWN;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-
- cancel_work_sync(&ap->ace_bh_work);
-
- /*
- * Make sure one CPU is not processing packets while
- * buffers are being released by another.
- */
-
- local_irq_save(flags);
- ace_mask_irq(dev);
-
- for (i = 0; i < ACE_TX_RING_ENTRIES(ap); i++) {
- struct sk_buff *skb;
- struct tx_ring_info *info;
-
- info = ap->skb->tx_skbuff + i;
- skb = info->skb;
-
- if (dma_unmap_len(info, maplen)) {
- if (ACE_IS_TIGON_I(ap)) {
- /* NB: TIGON_1 is special, tx_ring is in io space */
- struct tx_desc __iomem *tx;
- tx = (__force struct tx_desc __iomem *) &ap->tx_ring[i];
- writel(0, &tx->addr.addrhi);
- writel(0, &tx->addr.addrlo);
- writel(0, &tx->flagsize);
- } else
- memset(ap->tx_ring + i, 0,
- sizeof(struct tx_desc));
- dma_unmap_page(&ap->pdev->dev,
- dma_unmap_addr(info, mapping),
- dma_unmap_len(info, maplen),
- DMA_TO_DEVICE);
- dma_unmap_len_set(info, maplen, 0);
- }
- if (skb) {
- dev_kfree_skb(skb);
- info->skb = NULL;
- }
- }
-
- if (ap->jumbo) {
- cmd.evt = C_RESET_JUMBO_RNG;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- }
-
- ace_unmask_irq(dev);
- local_irq_restore(flags);
-
- return 0;
-}
-
-
-static inline dma_addr_t
-ace_map_tx_skb(struct ace_private *ap, struct sk_buff *skb,
- struct sk_buff *tail, u32 idx)
-{
- dma_addr_t mapping;
- struct tx_ring_info *info;
-
- mapping = dma_map_page(&ap->pdev->dev, virt_to_page(skb->data),
- offset_in_page(skb->data), skb->len,
- DMA_TO_DEVICE);
-
- info = ap->skb->tx_skbuff + idx;
- info->skb = tail;
- dma_unmap_addr_set(info, mapping, mapping);
- dma_unmap_len_set(info, maplen, skb->len);
- return mapping;
-}
-
-
-static inline void
-ace_load_tx_bd(struct ace_private *ap, struct tx_desc *desc, u64 addr,
- u32 flagsize, u32 vlan_tag)
-{
-#if !USE_TX_COAL_NOW
- flagsize &= ~BD_FLG_COAL_NOW;
-#endif
-
- if (ACE_IS_TIGON_I(ap)) {
- struct tx_desc __iomem *io = (__force struct tx_desc __iomem *) desc;
- writel(addr >> 32, &io->addr.addrhi);
- writel(addr & 0xffffffff, &io->addr.addrlo);
- writel(flagsize, &io->flagsize);
- writel(vlan_tag, &io->vlanres);
- } else {
- desc->addr.addrhi = addr >> 32;
- desc->addr.addrlo = addr;
- desc->flagsize = flagsize;
- desc->vlanres = vlan_tag;
- }
-}
-
-
-static netdev_tx_t ace_start_xmit(struct sk_buff *skb,
- struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- struct tx_desc *desc;
- u32 idx, flagsize;
- unsigned long maxjiff = jiffies + 3*HZ;
-
-restart:
- idx = ap->tx_prd;
-
- if (tx_ring_full(ap, ap->tx_ret_csm, idx))
- goto overflow;
-
- if (!skb_shinfo(skb)->nr_frags) {
- dma_addr_t mapping;
- u32 vlan_tag = 0;
-
- mapping = ace_map_tx_skb(ap, skb, skb, idx);
- flagsize = (skb->len << 16) | (BD_FLG_END);
- if (skb->ip_summed == CHECKSUM_PARTIAL)
- flagsize |= BD_FLG_TCP_UDP_SUM;
- if (skb_vlan_tag_present(skb)) {
- flagsize |= BD_FLG_VLAN_TAG;
- vlan_tag = skb_vlan_tag_get(skb);
- }
- desc = ap->tx_ring + idx;
- idx = (idx + 1) % ACE_TX_RING_ENTRIES(ap);
-
- /* Look at ace_tx_int for explanations. */
- if (tx_ring_full(ap, ap->tx_ret_csm, idx))
- flagsize |= BD_FLG_COAL_NOW;
-
- ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
- } else {
- dma_addr_t mapping;
- u32 vlan_tag = 0;
- int i;
-
- mapping = ace_map_tx_skb(ap, skb, NULL, idx);
- flagsize = (skb_headlen(skb) << 16);
- if (skb->ip_summed == CHECKSUM_PARTIAL)
- flagsize |= BD_FLG_TCP_UDP_SUM;
- if (skb_vlan_tag_present(skb)) {
- flagsize |= BD_FLG_VLAN_TAG;
- vlan_tag = skb_vlan_tag_get(skb);
- }
-
- ace_load_tx_bd(ap, ap->tx_ring + idx, mapping, flagsize, vlan_tag);
-
- idx = (idx + 1) % ACE_TX_RING_ENTRIES(ap);
-
- for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
- const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
- struct tx_ring_info *info;
-
- info = ap->skb->tx_skbuff + idx;
- desc = ap->tx_ring + idx;
-
- mapping = skb_frag_dma_map(&ap->pdev->dev, frag, 0,
- skb_frag_size(frag),
- DMA_TO_DEVICE);
-
- flagsize = skb_frag_size(frag) << 16;
- if (skb->ip_summed == CHECKSUM_PARTIAL)
- flagsize |= BD_FLG_TCP_UDP_SUM;
- idx = (idx + 1) % ACE_TX_RING_ENTRIES(ap);
-
- if (i == skb_shinfo(skb)->nr_frags - 1) {
- flagsize |= BD_FLG_END;
- if (tx_ring_full(ap, ap->tx_ret_csm, idx))
- flagsize |= BD_FLG_COAL_NOW;
-
- /*
- * Only the last fragment frees
- * the skb!
- */
- info->skb = skb;
- } else {
- info->skb = NULL;
- }
- dma_unmap_addr_set(info, mapping, mapping);
- dma_unmap_len_set(info, maplen, skb_frag_size(frag));
- ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
- }
- }
-
- wmb();
- ap->tx_prd = idx;
- ace_set_txprd(regs, ap, idx);
-
- if (flagsize & BD_FLG_COAL_NOW) {
- netif_stop_queue(dev);
-
- /*
- * A TX-descriptor producer (an IRQ) might have gotten
- * between, making the ring free again. Since xmit is
- * serialized, this is the only situation we have to
- * re-test.
- */
- if (!tx_ring_full(ap, ap->tx_ret_csm, idx))
- netif_wake_queue(dev);
- }
-
- return NETDEV_TX_OK;
-
-overflow:
- /*
- * This race condition is unavoidable with lock-free drivers.
- * We wake up the queue _before_ tx_prd is advanced, so that we can
- * enter hard_start_xmit too early, while tx ring still looks closed.
- * This happens ~1-4 times per 100000 packets, so that we can allow
- * to loop syncing to other CPU. Probably, we need an additional
- * wmb() in ace_tx_intr as well.
- *
- * Note that this race is relieved by reserving one more entry
- * in tx ring than it is necessary (see original non-SG driver).
- * However, with SG we need to reserve 2*MAX_SKB_FRAGS+1, which
- * is already overkill.
- *
- * Alternative is to return with 1 not throttling queue. In this
- * case loop becomes longer, no more useful effects.
- */
- if (time_before(jiffies, maxjiff)) {
- barrier();
- cpu_relax();
- goto restart;
- }
-
- /* The ring is stuck full. */
- printk(KERN_WARNING "%s: Transmit ring stuck full\n", dev->name);
- return NETDEV_TX_BUSY;
-}
-
-
-static int ace_change_mtu(struct net_device *dev, int new_mtu)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
-
- writel(new_mtu + ETH_HLEN + 4, ®s->IfMtu);
- WRITE_ONCE(dev->mtu, new_mtu);
-
- if (new_mtu > ACE_STD_MTU) {
- if (!(ap->jumbo)) {
- printk(KERN_INFO "%s: Enabling Jumbo frame "
- "support\n", dev->name);
- ap->jumbo = 1;
- if (!test_and_set_bit(0, &ap->jumbo_refill_busy))
- ace_load_jumbo_rx_ring(dev, RX_JUMBO_SIZE);
- ace_set_rxtx_parms(dev, 1);
- }
- } else {
- while (test_and_set_bit(0, &ap->jumbo_refill_busy));
- ace_sync_irq(dev->irq);
- ace_set_rxtx_parms(dev, 0);
- if (ap->jumbo) {
- struct cmd cmd;
-
- cmd.evt = C_RESET_JUMBO_RNG;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- }
- }
-
- return 0;
-}
-
-static int ace_get_link_ksettings(struct net_device *dev,
- struct ethtool_link_ksettings *cmd)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- u32 link;
- u32 supported;
-
- memset(cmd, 0, sizeof(struct ethtool_link_ksettings));
-
- supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
- SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full |
- SUPPORTED_Autoneg | SUPPORTED_FIBRE);
-
- cmd->base.port = PORT_FIBRE;
-
- link = readl(®s->GigLnkState);
- if (link & LNK_1000MB) {
- cmd->base.speed = SPEED_1000;
- } else {
- link = readl(®s->FastLnkState);
- if (link & LNK_100MB)
- cmd->base.speed = SPEED_100;
- else if (link & LNK_10MB)
- cmd->base.speed = SPEED_10;
- else
- cmd->base.speed = 0;
- }
- if (link & LNK_FULL_DUPLEX)
- cmd->base.duplex = DUPLEX_FULL;
- else
- cmd->base.duplex = DUPLEX_HALF;
-
- if (link & LNK_NEGOTIATE)
- cmd->base.autoneg = AUTONEG_ENABLE;
- else
- cmd->base.autoneg = AUTONEG_DISABLE;
-
-#if 0
- /*
- * Current struct ethtool_cmd is insufficient
- */
- ecmd->trace = readl(®s->TuneTrace);
-
- ecmd->txcoal = readl(®s->TuneTxCoalTicks);
- ecmd->rxcoal = readl(®s->TuneRxCoalTicks);
-#endif
-
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
- supported);
-
- return 0;
-}
-
-static int ace_set_link_ksettings(struct net_device *dev,
- const struct ethtool_link_ksettings *cmd)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- u32 link, speed;
-
- link = readl(®s->GigLnkState);
- if (link & LNK_1000MB)
- speed = SPEED_1000;
- else {
- link = readl(®s->FastLnkState);
- if (link & LNK_100MB)
- speed = SPEED_100;
- else if (link & LNK_10MB)
- speed = SPEED_10;
- else
- speed = SPEED_100;
- }
-
- link = LNK_ENABLE | LNK_1000MB | LNK_100MB | LNK_10MB |
- LNK_RX_FLOW_CTL_Y | LNK_NEG_FCTL;
- if (!ACE_IS_TIGON_I(ap))
- link |= LNK_TX_FLOW_CTL_Y;
- if (cmd->base.autoneg == AUTONEG_ENABLE)
- link |= LNK_NEGOTIATE;
- if (cmd->base.speed != speed) {
- link &= ~(LNK_1000MB | LNK_100MB | LNK_10MB);
- switch (cmd->base.speed) {
- case SPEED_1000:
- link |= LNK_1000MB;
- break;
- case SPEED_100:
- link |= LNK_100MB;
- break;
- case SPEED_10:
- link |= LNK_10MB;
- break;
- }
- }
-
- if (cmd->base.duplex == DUPLEX_FULL)
- link |= LNK_FULL_DUPLEX;
-
- if (link != ap->link) {
- struct cmd cmd;
- printk(KERN_INFO "%s: Renegotiating link state\n",
- dev->name);
-
- ap->link = link;
- writel(link, ®s->TuneLink);
- if (!ACE_IS_TIGON_I(ap))
- writel(link, ®s->TuneFastLink);
- wmb();
-
- cmd.evt = C_LNK_NEGOTIATION;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- }
- return 0;
-}
-
-static void ace_get_drvinfo(struct net_device *dev,
- struct ethtool_drvinfo *info)
-{
- struct ace_private *ap = netdev_priv(dev);
-
- strscpy(info->driver, "acenic", sizeof(info->driver));
- snprintf(info->fw_version, sizeof(info->version), "%i.%i.%i",
- ap->firmware_major, ap->firmware_minor, ap->firmware_fix);
-
- if (ap->pdev)
- strscpy(info->bus_info, pci_name(ap->pdev),
- sizeof(info->bus_info));
-
-}
-
-/*
- * Set the hardware MAC address.
- */
-static int ace_set_mac_addr(struct net_device *dev, void *p)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- struct sockaddr *addr=p;
- const u8 *da;
- struct cmd cmd;
-
- if(netif_running(dev))
- return -EBUSY;
-
- eth_hw_addr_set(dev, addr->sa_data);
-
- da = (const u8 *)dev->dev_addr;
-
- writel(da[0] << 8 | da[1], ®s->MacAddrHi);
- writel((da[2] << 24) | (da[3] << 16) | (da[4] << 8) | da[5],
- ®s->MacAddrLo);
-
- cmd.evt = C_SET_MAC_ADDR;
- cmd.code = 0;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
-
- return 0;
-}
-
-
-static void ace_set_multicast_list(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- struct cmd cmd;
-
- if ((dev->flags & IFF_ALLMULTI) && !(ap->mcast_all)) {
- cmd.evt = C_SET_MULTICAST_MODE;
- cmd.code = C_C_MCAST_ENABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- ap->mcast_all = 1;
- } else if (ap->mcast_all) {
- cmd.evt = C_SET_MULTICAST_MODE;
- cmd.code = C_C_MCAST_DISABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- ap->mcast_all = 0;
- }
-
- if ((dev->flags & IFF_PROMISC) && !(ap->promisc)) {
- cmd.evt = C_SET_PROMISC_MODE;
- cmd.code = C_C_PROMISC_ENABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- ap->promisc = 1;
- }else if (!(dev->flags & IFF_PROMISC) && (ap->promisc)) {
- cmd.evt = C_SET_PROMISC_MODE;
- cmd.code = C_C_PROMISC_DISABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- ap->promisc = 0;
- }
-
- /*
- * For the time being multicast relies on the upper layers
- * filtering it properly. The Firmware does not allow one to
- * set the entire multicast list at a time and keeping track of
- * it here is going to be messy.
- */
- if (!netdev_mc_empty(dev) && !ap->mcast_all) {
- cmd.evt = C_SET_MULTICAST_MODE;
- cmd.code = C_C_MCAST_ENABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- }else if (!ap->mcast_all) {
- cmd.evt = C_SET_MULTICAST_MODE;
- cmd.code = C_C_MCAST_DISABLE;
- cmd.idx = 0;
- ace_issue_cmd(regs, &cmd);
- }
-}
-
-
-static struct net_device_stats *ace_get_stats(struct net_device *dev)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_mac_stats __iomem *mac_stats =
- (struct ace_mac_stats __iomem *)ap->regs->Stats;
-
- dev->stats.rx_missed_errors = readl(&mac_stats->drop_space);
- dev->stats.multicast = readl(&mac_stats->kept_mc);
- dev->stats.collisions = readl(&mac_stats->coll);
-
- return &dev->stats;
-}
-
-
-static void ace_copy(struct ace_regs __iomem *regs, const __be32 *src,
- u32 dest, int size)
-{
- void __iomem *tdest;
- short tsize, i;
-
- if (size <= 0)
- return;
-
- while (size > 0) {
- tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
- min_t(u32, size, ACE_WINDOW_SIZE));
- tdest = (void __iomem *) ®s->Window +
- (dest & (ACE_WINDOW_SIZE - 1));
- writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase);
- for (i = 0; i < (tsize / 4); i++) {
- /* Firmware is big-endian */
- writel(be32_to_cpup(src), tdest);
- src++;
- tdest += 4;
- dest += 4;
- size -= 4;
- }
- }
-}
-
-
-static void ace_clear(struct ace_regs __iomem *regs, u32 dest, int size)
-{
- void __iomem *tdest;
- short tsize = 0, i;
-
- if (size <= 0)
- return;
-
- while (size > 0) {
- tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
- min_t(u32, size, ACE_WINDOW_SIZE));
- tdest = (void __iomem *) ®s->Window +
- (dest & (ACE_WINDOW_SIZE - 1));
- writel(dest & ~(ACE_WINDOW_SIZE - 1), ®s->WinBase);
-
- for (i = 0; i < (tsize / 4); i++) {
- writel(0, tdest + i*4);
- }
-
- dest += tsize;
- size -= tsize;
- }
-}
-
-
-/*
- * Download the firmware into the SRAM on the NIC
- *
- * This operation requires the NIC to be halted and is performed with
- * interrupts disabled and with the spinlock hold.
- */
-static int ace_load_firmware(struct net_device *dev)
-{
- const struct firmware *fw;
- const char *fw_name = "acenic/tg2.bin";
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- const __be32 *fw_data;
- u32 load_addr;
- int ret;
-
- if (!(readl(®s->CpuCtrl) & CPU_HALTED)) {
- printk(KERN_ERR "%s: trying to download firmware while the "
- "CPU is running!\n", ap->name);
- return -EFAULT;
- }
-
- if (ACE_IS_TIGON_I(ap))
- fw_name = "acenic/tg1.bin";
-
- ret = request_firmware(&fw, fw_name, &ap->pdev->dev);
- if (ret) {
- printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n",
- ap->name, fw_name);
- return ret;
- }
-
- fw_data = (void *)fw->data;
-
- /* Firmware blob starts with version numbers, followed by
- load and start address. Remainder is the blob to be loaded
- contiguously from load address. We don't bother to represent
- the BSS/SBSS sections any more, since we were clearing the
- whole thing anyway. */
- ap->firmware_major = fw->data[0];
- ap->firmware_minor = fw->data[1];
- ap->firmware_fix = fw->data[2];
-
- ap->firmware_start = be32_to_cpu(fw_data[1]);
- if (ap->firmware_start < 0x4000 || ap->firmware_start >= 0x80000) {
- printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
- ap->name, ap->firmware_start, fw_name);
- ret = -EINVAL;
- goto out;
- }
-
- load_addr = be32_to_cpu(fw_data[2]);
- if (load_addr < 0x4000 || load_addr >= 0x80000) {
- printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
- ap->name, load_addr, fw_name);
- ret = -EINVAL;
- goto out;
- }
-
- /*
- * Do not try to clear more than 512KiB or we end up seeing
- * funny things on NICs with only 512KiB SRAM
- */
- ace_clear(regs, 0x2000, 0x80000-0x2000);
- ace_copy(regs, &fw_data[3], load_addr, fw->size-12);
- out:
- release_firmware(fw);
- return ret;
-}
-
-
-/*
- * The eeprom on the AceNIC is an Atmel i2c EEPROM.
- *
- * Accessing the EEPROM is `interesting' to say the least - don't read
- * this code right after dinner.
- *
- * This is all about black magic and bit-banging the device .... I
- * wonder in what hospital they have put the guy who designed the i2c
- * specs.
- *
- * Oh yes, this is only the beginning!
- *
- * Thanks to Stevarino Webinski for helping tracking down the bugs in the
- * code i2c readout code by beta testing all my hacks.
- */
-static void eeprom_start(struct ace_regs __iomem *regs)
-{
- u32 local;
-
- readl(®s->LocalCtrl);
- udelay(ACE_SHORT_DELAY);
- local = readl(®s->LocalCtrl);
- local |= EEPROM_DATA_OUT | EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local |= EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local &= ~EEPROM_DATA_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local &= ~EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
-}
-
-
-static void eeprom_prep(struct ace_regs __iomem *regs, u8 magic)
-{
- short i;
- u32 local;
-
- udelay(ACE_SHORT_DELAY);
- local = readl(®s->LocalCtrl);
- local &= ~EEPROM_DATA_OUT;
- local |= EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
-
- for (i = 0; i < 8; i++, magic <<= 1) {
- udelay(ACE_SHORT_DELAY);
- if (magic & 0x80)
- local |= EEPROM_DATA_OUT;
- else
- local &= ~EEPROM_DATA_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
-
- udelay(ACE_SHORT_DELAY);
- local |= EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local &= ~(EEPROM_CLK_OUT | EEPROM_DATA_OUT);
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- }
-}
-
-
-static int eeprom_check_ack(struct ace_regs __iomem *regs)
-{
- int state;
- u32 local;
-
- local = readl(®s->LocalCtrl);
- local &= ~EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_LONG_DELAY);
- local |= EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- /* sample data in middle of high clk */
- state = (readl(®s->LocalCtrl) & EEPROM_DATA_IN) != 0;
- udelay(ACE_SHORT_DELAY);
- mb();
- writel(readl(®s->LocalCtrl) & ~EEPROM_CLK_OUT, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
-
- return state;
-}
-
-
-static void eeprom_stop(struct ace_regs __iomem *regs)
-{
- u32 local;
-
- udelay(ACE_SHORT_DELAY);
- local = readl(®s->LocalCtrl);
- local |= EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local &= ~EEPROM_DATA_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local |= EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- local |= EEPROM_DATA_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_LONG_DELAY);
- local &= ~EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- mb();
-}
-
-
-/*
- * Read a whole byte from the EEPROM.
- */
-static int read_eeprom_byte(struct net_device *dev, unsigned long offset)
-{
- struct ace_private *ap = netdev_priv(dev);
- struct ace_regs __iomem *regs = ap->regs;
- unsigned long flags;
- u32 local;
- int result = 0;
- short i;
-
- /*
- * Don't take interrupts on this CPU will bit banging
- * the %#%#@$ I2C device
- */
- local_irq_save(flags);
-
- eeprom_start(regs);
-
- eeprom_prep(regs, EEPROM_WRITE_SELECT);
- if (eeprom_check_ack(regs)) {
- local_irq_restore(flags);
- printk(KERN_ERR "%s: Unable to sync eeprom\n", ap->name);
- result = -EIO;
- goto eeprom_read_error;
- }
-
- eeprom_prep(regs, (offset >> 8) & 0xff);
- if (eeprom_check_ack(regs)) {
- local_irq_restore(flags);
- printk(KERN_ERR "%s: Unable to set address byte 0\n",
- ap->name);
- result = -EIO;
- goto eeprom_read_error;
- }
-
- eeprom_prep(regs, offset & 0xff);
- if (eeprom_check_ack(regs)) {
- local_irq_restore(flags);
- printk(KERN_ERR "%s: Unable to set address byte 1\n",
- ap->name);
- result = -EIO;
- goto eeprom_read_error;
- }
-
- eeprom_start(regs);
- eeprom_prep(regs, EEPROM_READ_SELECT);
- if (eeprom_check_ack(regs)) {
- local_irq_restore(flags);
- printk(KERN_ERR "%s: Unable to set READ_SELECT\n",
- ap->name);
- result = -EIO;
- goto eeprom_read_error;
- }
-
- for (i = 0; i < 8; i++) {
- local = readl(®s->LocalCtrl);
- local &= ~EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- udelay(ACE_LONG_DELAY);
- mb();
- local |= EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- /* sample data mid high clk */
- result = (result << 1) |
- ((readl(®s->LocalCtrl) & EEPROM_DATA_IN) != 0);
- udelay(ACE_SHORT_DELAY);
- mb();
- local = readl(®s->LocalCtrl);
- local &= ~EEPROM_CLK_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- udelay(ACE_SHORT_DELAY);
- mb();
- if (i == 7) {
- local |= EEPROM_WRITE_ENABLE;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- }
- }
-
- local |= EEPROM_DATA_OUT;
- writel(local, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- writel(readl(®s->LocalCtrl) | EEPROM_CLK_OUT, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- udelay(ACE_LONG_DELAY);
- writel(readl(®s->LocalCtrl) & ~EEPROM_CLK_OUT, ®s->LocalCtrl);
- readl(®s->LocalCtrl);
- mb();
- udelay(ACE_SHORT_DELAY);
- eeprom_stop(regs);
-
- local_irq_restore(flags);
- out:
- return result;
-
- eeprom_read_error:
- printk(KERN_ERR "%s: Unable to read eeprom byte 0x%02lx\n",
- ap->name, offset);
- goto out;
-}
-
-module_pci_driver(acenic_pci_driver);
diff --git a/arch/loongarch/configs/loongson32_defconfig b/arch/loongarch/configs/loongson32_defconfig
index 276b1577e0be..37e5eada5a67 100644
--- a/arch/loongarch/configs/loongson32_defconfig
+++ b/arch/loongarch/configs/loongson32_defconfig
@@ -571,7 +571,6 @@ CONFIG_VIRTIO_NET=m
# CONFIG_NET_VENDOR_ADAPTEC is not set
# CONFIG_NET_VENDOR_AGERE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_AQUANTIA is not set
diff --git a/arch/loongarch/configs/loongson64_defconfig b/arch/loongarch/configs/loongson64_defconfig
index a14db1a95e7e..7648f6c73929 100644
--- a/arch/loongarch/configs/loongson64_defconfig
+++ b/arch/loongarch/configs/loongson64_defconfig
@@ -587,7 +587,6 @@ CONFIG_VIRTIO_NET=m
# CONFIG_NET_VENDOR_ADAPTEC is not set
# CONFIG_NET_VENDOR_AGERE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_AQUANTIA is not set
diff --git a/arch/mips/configs/cavium_octeon_defconfig b/arch/mips/configs/cavium_octeon_defconfig
index 68c363366bce..64da32b570aa 100644
--- a/arch/mips/configs/cavium_octeon_defconfig
+++ b/arch/mips/configs/cavium_octeon_defconfig
@@ -60,7 +60,6 @@ CONFIG_PATA_OCTEON_CF=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/loongson2k_defconfig b/arch/mips/configs/loongson2k_defconfig
index a5c50b63d478..ca534a6b66de 100644
--- a/arch/mips/configs/loongson2k_defconfig
+++ b/arch/mips/configs/loongson2k_defconfig
@@ -137,7 +137,6 @@ CONFIG_NETDEVICES=y
CONFIG_TUN=m
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ARC is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 575aaf242361..12cb1a6a1360 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -184,7 +184,6 @@ CONFIG_VETH=m
CONFIG_VIRTIO_NET=m
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ARC is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
diff --git a/arch/mips/configs/malta_qemu_32r6_defconfig b/arch/mips/configs/malta_qemu_32r6_defconfig
index accb471a1d93..dafc9a716e85 100644
--- a/arch/mips/configs/malta_qemu_32r6_defconfig
+++ b/arch/mips/configs/malta_qemu_32r6_defconfig
@@ -85,7 +85,6 @@ CONFIG_ATA_GENERIC=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
CONFIG_PCNET32=y
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/maltaaprp_defconfig b/arch/mips/configs/maltaaprp_defconfig
index 6bda67c5f68f..7361bca6a405 100644
--- a/arch/mips/configs/maltaaprp_defconfig
+++ b/arch/mips/configs/maltaaprp_defconfig
@@ -87,7 +87,6 @@ CONFIG_ATA_GENERIC=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
CONFIG_PCNET32=y
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/maltasmvp_defconfig b/arch/mips/configs/maltasmvp_defconfig
index e4082537f80f..c848a1bfca5c 100644
--- a/arch/mips/configs/maltasmvp_defconfig
+++ b/arch/mips/configs/maltasmvp_defconfig
@@ -86,7 +86,6 @@ CONFIG_ATA_PIIX=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
CONFIG_PCNET32=y
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/maltasmvp_eva_defconfig b/arch/mips/configs/maltasmvp_eva_defconfig
index 58f5af45fa98..905248e01b95 100644
--- a/arch/mips/configs/maltasmvp_eva_defconfig
+++ b/arch/mips/configs/maltasmvp_eva_defconfig
@@ -89,7 +89,6 @@ CONFIG_ATA_GENERIC=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
CONFIG_PCNET32=y
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/maltaup_defconfig b/arch/mips/configs/maltaup_defconfig
index 9bfef7de0d1c..b9bbe02f3595 100644
--- a/arch/mips/configs/maltaup_defconfig
+++ b/arch/mips/configs/maltaup_defconfig
@@ -86,7 +86,6 @@ CONFIG_ATA_GENERIC=y
CONFIG_NETDEVICES=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
CONFIG_PCNET32=y
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
index 77050ae3945f..2428a6a72747 100644
--- a/arch/mips/configs/mtx1_defconfig
+++ b/arch/mips/configs/mtx1_defconfig
@@ -257,7 +257,6 @@ CONFIG_PCMCIA_3C589=m
CONFIG_VORTEX=m
CONFIG_TYPHOON=m
CONFIG_ADAPTEC_STARFIRE=m
-CONFIG_ACENIC=m
CONFIG_AMD8111_ETH=m
CONFIG_PCNET32=m
CONFIG_PCMCIA_NMCLAN=m
diff --git a/arch/parisc/configs/generic-32bit_defconfig b/arch/parisc/configs/generic-32bit_defconfig
index 5444ce6405f3..ad2fb69184f3 100644
--- a/arch/parisc/configs/generic-32bit_defconfig
+++ b/arch/parisc/configs/generic-32bit_defconfig
@@ -78,7 +78,6 @@ CONFIG_DUMMY=m
CONFIG_TUN=m
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/parisc/configs/generic-64bit_defconfig b/arch/parisc/configs/generic-64bit_defconfig
index ce91f9d1fdbf..b21287a9250c 100644
--- a/arch/parisc/configs/generic-64bit_defconfig
+++ b/arch/parisc/configs/generic-64bit_defconfig
@@ -97,7 +97,6 @@ CONFIG_NETCONSOLE_DYNAMIC=y
CONFIG_TUN=y
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/powerpc/configs/44x/akebono_defconfig b/arch/powerpc/configs/44x/akebono_defconfig
index 02e88648a2e6..11ad5ed3cc90 100644
--- a/arch/powerpc/configs/44x/akebono_defconfig
+++ b/arch/powerpc/configs/44x/akebono_defconfig
@@ -47,7 +47,6 @@ CONFIG_SATA_AHCI_PLATFORM=y
# CONFIG_ATA_SFF is not set
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_ARC is not set
# CONFIG_NET_VENDOR_ATHEROS is not set
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index 428f17b45513..4247d9a30eba 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -92,8 +92,6 @@ CONFIG_NETDEVICES=y
CONFIG_BONDING=m
CONFIG_DUMMY=m
CONFIG_TUN=m
-CONFIG_ACENIC=m
-CONFIG_ACENIC_OMIT_TIGON_I=y
CONFIG_TIGON3=y
CONFIG_E1000=y
CONFIG_SUNGEM=y
diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
index 9ac746cfb4be..ce72c6d22ca2 100644
--- a/arch/powerpc/configs/powernv_defconfig
+++ b/arch/powerpc/configs/powernv_defconfig
@@ -158,8 +158,6 @@ CONFIG_NETCONSOLE=m
CONFIG_TUN=m
CONFIG_VETH=m
CONFIG_VORTEX=m
-CONFIG_ACENIC=m
-CONFIG_ACENIC_OMIT_TIGON_I=y
CONFIG_PCNET32=m
CONFIG_TIGON3=y
CONFIG_BNX2X=m
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 2b0720f2753b..7603af319385 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -204,8 +204,6 @@ CONFIG_NETCONSOLE=y
CONFIG_TUN=m
CONFIG_VIRTIO_NET=m
CONFIG_VORTEX=m
-CONFIG_ACENIC=m
-CONFIG_ACENIC_OMIT_TIGON_I=y
CONFIG_PCNET32=m
CONFIG_TIGON3=y
CONFIG_BNX2X=m
diff --git a/arch/powerpc/configs/ppc64e_defconfig b/arch/powerpc/configs/ppc64e_defconfig
index 90247b2a0ab0..e44c65693b51 100644
--- a/arch/powerpc/configs/ppc64e_defconfig
+++ b/arch/powerpc/configs/ppc64e_defconfig
@@ -96,8 +96,6 @@ CONFIG_DUMMY=m
CONFIG_NETCONSOLE=y
CONFIG_TUN=m
CONFIG_VORTEX=y
-CONFIG_ACENIC=y
-CONFIG_ACENIC_OMIT_TIGON_I=y
CONFIG_PCNET32=y
CONFIG_TIGON3=y
CONFIG_E100=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index 3c08f46f3d41..b70307b70af0 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -410,7 +410,6 @@ CONFIG_PCMCIA_3C589=m
CONFIG_VORTEX=m
CONFIG_TYPHOON=m
CONFIG_ADAPTEC_STARFIRE=m
-CONFIG_ACENIC=m
CONFIG_AMD8111_ETH=m
CONFIG_PCNET32=m
CONFIG_PCMCIA_NMCLAN=m
diff --git a/arch/powerpc/configs/skiroot_defconfig b/arch/powerpc/configs/skiroot_defconfig
index 86c74146824a..ff1bed4b6d2c 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -125,8 +125,6 @@ CONFIG_DM_MULTIPATH=m
# CONFIG_NET_VENDOR_ADAPTEC is not set
# CONFIG_NET_VENDOR_AGERE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
-CONFIG_ACENIC=m
-CONFIG_ACENIC_OMIT_TIGON_I=y
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_AQUANTIA is not set
diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
index 98fd0a2f51c6..2a94abcabd72 100644
--- a/arch/s390/configs/debug_defconfig
+++ b/arch/s390/configs/debug_defconfig
@@ -524,7 +524,6 @@ CONFIG_NLMON=m
# CONFIG_NET_VENDOR_ADAPTEC is not set
# CONFIG_NET_VENDOR_AGERE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_AQUANTIA is not set
diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
index 0f4cedcab3ce..763fc7db101f 100644
--- a/arch/s390/configs/defconfig
+++ b/arch/s390/configs/defconfig
@@ -514,7 +514,6 @@ CONFIG_NLMON=m
# CONFIG_NET_VENDOR_ADAPTEC is not set
# CONFIG_NET_VENDOR_AGERE is not set
# CONFIG_NET_VENDOR_ALACRITECH is not set
-# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_AMD is not set
# CONFIG_NET_VENDOR_AQUANTIA is not set
diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs
index 50005d176561..dc2035a4c175 100644
--- a/rust/kernel/pci/id.rs
+++ b/rust/kernel/pci/id.rs
@@ -428,7 +428,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
TRANSMETA = bindings::PCI_VENDOR_ID_TRANSMETA, // 0x1279
ROCKWELL = bindings::PCI_VENDOR_ID_ROCKWELL, // 0x127A
ITE = bindings::PCI_VENDOR_ID_ITE, // 0x1283
- ALTEON = bindings::PCI_VENDOR_ID_ALTEON, // 0x12ae
NVIDIA_SGS = bindings::PCI_VENDOR_ID_NVIDIA_SGS, // 0x12d2
PERICOM = bindings::PCI_VENDOR_ID_PERICOM, // 0x12D8
AUREAL = bindings::PCI_VENDOR_ID_AUREAL, // 0x12eb
--
2.53.0
^ permalink raw reply related
* Re: [PATCH net v2 1/2] seg6: separate dst_cache for input and output paths in seg6 lwtunnel
From: Justin Iurman @ 2026-04-02 18:30 UTC (permalink / raw)
To: Andrea Mayer, netdev
Cc: davem, edumazet, kuba, pabeni, horms, dsahern, david.lebrun,
stefano.salsano, paolo.lungaroni, nicolas.dichtel, linux-kernel,
stable
In-Reply-To: <20260401185755.29813-2-andrea.mayer@uniroma2.it>
On 4/1/26 20:57, Andrea Mayer wrote:
> The seg6 lwtunnel uses a single dst_cache per encap route, shared
> between seg6_input_core() and seg6_output_core(). These two paths
> can perform the post-encap SID lookup in different routing contexts
> (e.g., ip rules matching on the ingress interface, or VRF table
> separation). Whichever path runs first populates the cache, and the
> other reuses it blindly, bypassing its own lookup.
>
> Fix this by splitting the cache into cache_input and cache_output,
> so each path maintains its own cached dst independently.
>
> Fixes: 6c8702c60b88 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels")
> Cc: stable@vger.kernel.org
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
> net/ipv6/seg6_iptunnel.c | 34 +++++++++++++++++++++++-----------
> 1 file changed, 23 insertions(+), 11 deletions(-)
>
> diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
> index 3e1b9991131a..d6a0f7df9080 100644
> --- a/net/ipv6/seg6_iptunnel.c
> +++ b/net/ipv6/seg6_iptunnel.c
> @@ -48,7 +48,8 @@ static size_t seg6_lwt_headroom(struct seg6_iptunnel_encap *tuninfo)
> }
>
> struct seg6_lwt {
> - struct dst_cache cache;
> + struct dst_cache cache_input;
> + struct dst_cache cache_output;
> struct seg6_iptunnel_encap tuninfo[];
> };
>
> @@ -488,7 +489,7 @@ static int seg6_input_core(struct net *net, struct sock *sk,
> slwt = seg6_lwt_lwtunnel(lwtst);
>
> local_bh_disable();
> - dst = dst_cache_get(&slwt->cache);
> + dst = dst_cache_get(&slwt->cache_input);
> local_bh_enable();
>
> err = seg6_do_srh(skb, dst);
> @@ -504,7 +505,7 @@ static int seg6_input_core(struct net *net, struct sock *sk,
> /* cache only if we don't create a dst reference loop */
> if (!dst->error && lwtst != dst->lwtstate) {
> local_bh_disable();
> - dst_cache_set_ip6(&slwt->cache, dst,
> + dst_cache_set_ip6(&slwt->cache_input, dst,
> &ipv6_hdr(skb)->saddr);
> local_bh_enable();
> }
> @@ -564,7 +565,7 @@ static int seg6_output_core(struct net *net, struct sock *sk,
> slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate);
>
> local_bh_disable();
> - dst = dst_cache_get(&slwt->cache);
> + dst = dst_cache_get(&slwt->cache_output);
> local_bh_enable();
>
> err = seg6_do_srh(skb, dst);
> @@ -591,7 +592,7 @@ static int seg6_output_core(struct net *net, struct sock *sk,
> /* cache only if we don't create a dst reference loop */
> if (orig_dst->lwtstate != dst->lwtstate) {
> local_bh_disable();
> - dst_cache_set_ip6(&slwt->cache, dst, &fl6.saddr);
> + dst_cache_set_ip6(&slwt->cache_output, dst, &fl6.saddr);
> local_bh_enable();
> }
>
> @@ -701,11 +702,13 @@ static int seg6_build_state(struct net *net, struct nlattr *nla,
>
> slwt = seg6_lwt_lwtunnel(newts);
>
> - err = dst_cache_init(&slwt->cache, GFP_ATOMIC);
> - if (err) {
> - kfree(newts);
> - return err;
> - }
> + err = dst_cache_init(&slwt->cache_input, GFP_ATOMIC);
> + if (err)
> + goto err_free_newts;
> +
> + err = dst_cache_init(&slwt->cache_output, GFP_ATOMIC);
> + if (err)
> + goto err_destroy_input;
>
> memcpy(&slwt->tuninfo, tuninfo, tuninfo_len);
>
> @@ -720,11 +723,20 @@ static int seg6_build_state(struct net *net, struct nlattr *nla,
> *ts = newts;
>
> return 0;
> +
> +err_destroy_input:
> + dst_cache_destroy(&slwt->cache_input);
> +err_free_newts:
> + kfree(newts);
> + return err;
> }
>
> static void seg6_destroy_state(struct lwtunnel_state *lwt)
> {
> - dst_cache_destroy(&seg6_lwt_lwtunnel(lwt)->cache);
> + struct seg6_lwt *slwt = seg6_lwt_lwtunnel(lwt);
> +
> + dst_cache_destroy(&slwt->cache_input);
> + dst_cache_destroy(&slwt->cache_output);
> }
>
> static int seg6_fill_encap_info(struct sk_buff *skb,
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
^ permalink raw reply
* [PATCH net-next v5 3/3] net: mana: Expose hardware diagnostic info via debugfs
From: Erni Sri Satya Vennela @ 2026-04-02 18:26 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
edumazet, kuba, pabeni, kotaranov, horms, shradhagupta,
shirazsaleem, yury.norov, kees, ssengar, ernis, dipayanroy,
gargaditya, linux-hyperv, netdev, linux-kernel, linux-rdma
In-Reply-To: <20260402182704.2474739-1-ernis@linux.microsoft.com>
Add debugfs entries to expose hardware configuration and diagnostic
information that aids in debugging driver initialization and runtime
operations without adding noise to dmesg.
The debugfs directory creation and removal for each PCI device is
integrated into mana_gd_setup() and mana_gd_cleanup_device()
respectively, so that all callers (probe, remove, suspend, resume,
shutdown) share a single code path.
Device-level entries (under /sys/kernel/debug/mana/<BDF>/):
- num_msix_usable, max_num_queues: Max resources from hardware
- gdma_protocol_ver, pf_cap_flags1: VF version negotiation results
- num_vports, bm_hostmode: Device configuration
Per-vPort entries (under /sys/kernel/debug/mana/<BDF>/vportN/):
- port_handle: Hardware vPort handle
- max_sq, max_rq: Max queues from vPort config
- indir_table_sz: Indirection table size
- steer_rx, steer_rss, steer_update_tab, steer_cqe_coalescing:
Last applied steering configuration parameters
Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
---
Changes in v5:
* Update commit message.
* Fix conflicts to align with the new patches.
* Make it part of patchset.
Changes in v4:
* Rebase and fix conflicts.
Changes in v3:
* Rename mana_gd_cleanup to mana_gd_cleanup_device.
* Add creation of debugfs entries in mana_gd_setup.
* Add removal of debugfs entries in mana_gd_cleanup_device.
* Remove bm_hostmode and num_vports from debugfs in mana_remove itself,
because "ac" gets freed before debugfs_remove_recursive, to avoid
Use-After-Free error.
* Add "goto out:" in mana_cfg_vport_steering to avoid populating apc
values when resp.hdr.status is not NULL.
Changes in v2:
* Add debugfs_remove_recursice for gc>mana_pci_debugfs in
mana_gd_suspend to handle multiple duplicates creation in
mana_gd_setup and mana_gd_resume path.
* Move debugfs creation for num_vports and bm_hostmode out of
if(!resuming) condition since we have to create it again even for
resume.
* Recreate mana_pci_debugfs in mana_gd_resume.
---
.../net/ethernet/microsoft/mana/gdma_main.c | 59 ++++++++++---------
drivers/net/ethernet/microsoft/mana/mana_en.c | 33 +++++++++++
include/net/mana/gdma.h | 1 +
include/net/mana/mana.h | 8 +++
4 files changed, 74 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index 098fbda0d128..7a99db9afa03 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -194,6 +194,11 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
if (gc->max_num_queues > gc->num_msix_usable - 1)
gc->max_num_queues = gc->num_msix_usable - 1;
+ debugfs_create_u32("num_msix_usable", 0400, gc->mana_pci_debugfs,
+ &gc->num_msix_usable);
+ debugfs_create_u32("max_num_queues", 0400, gc->mana_pci_debugfs,
+ &gc->max_num_queues);
+
return 0;
}
@@ -1264,6 +1269,13 @@ int mana_gd_verify_vf_version(struct pci_dev *pdev)
return err ? err : -EPROTO;
}
gc->pf_cap_flags1 = resp.pf_cap_flags1;
+ gc->gdma_protocol_ver = resp.gdma_protocol_ver;
+
+ debugfs_create_x64("gdma_protocol_ver", 0400, gc->mana_pci_debugfs,
+ &gc->gdma_protocol_ver);
+ debugfs_create_x64("pf_cap_flags1", 0400, gc->mana_pci_debugfs,
+ &gc->pf_cap_flags1);
+
if (resp.pf_cap_flags1 & GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG) {
err = mana_gd_query_hwc_timeout(pdev, &hwc->hwc_timeout);
if (err) {
@@ -1943,15 +1955,20 @@ static int mana_gd_setup(struct pci_dev *pdev)
struct gdma_context *gc = pci_get_drvdata(pdev);
int err;
+ gc->mana_pci_debugfs = debugfs_create_dir(pci_name(pdev),
+ mana_debugfs_root);
+
err = mana_gd_init_registers(pdev);
if (err)
- return err;
+ goto remove_debugfs;
mana_smc_init(&gc->shm_channel, gc->dev, gc->shm_base);
gc->service_wq = alloc_ordered_workqueue("gdma_service_wq", 0);
- if (!gc->service_wq)
- return -ENOMEM;
+ if (!gc->service_wq) {
+ err = -ENOMEM;
+ goto remove_debugfs;
+ }
err = mana_gd_setup_hwc_irqs(pdev);
if (err) {
@@ -1992,11 +2009,14 @@ static int mana_gd_setup(struct pci_dev *pdev)
free_workqueue:
destroy_workqueue(gc->service_wq);
gc->service_wq = NULL;
+remove_debugfs:
+ debugfs_remove_recursive(gc->mana_pci_debugfs);
+ gc->mana_pci_debugfs = NULL;
dev_err(&pdev->dev, "%s failed (error %d)\n", __func__, err);
return err;
}
-static void mana_gd_cleanup(struct pci_dev *pdev)
+static void mana_gd_cleanup_device(struct pci_dev *pdev)
{
struct gdma_context *gc = pci_get_drvdata(pdev);
@@ -2008,6 +2028,10 @@ static void mana_gd_cleanup(struct pci_dev *pdev)
destroy_workqueue(gc->service_wq);
gc->service_wq = NULL;
}
+
+ debugfs_remove_recursive(gc->mana_pci_debugfs);
+ gc->mana_pci_debugfs = NULL;
+
dev_dbg(&pdev->dev, "mana gdma cleanup successful\n");
}
@@ -2065,9 +2089,6 @@ static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
gc->dev = &pdev->dev;
xa_init(&gc->irq_contexts);
- gc->mana_pci_debugfs = debugfs_create_dir(pci_name(pdev),
- mana_debugfs_root);
-
err = mana_gd_setup(pdev);
if (err)
goto unmap_bar;
@@ -2096,16 +2117,8 @@ static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
cleanup_mana:
mana_remove(&gc->mana, false);
cleanup_gd:
- mana_gd_cleanup(pdev);
+ mana_gd_cleanup_device(pdev);
unmap_bar:
- /*
- * at this point we know that the other debugfs child dir/files
- * are either not yet created or are already cleaned up.
- * The pci debugfs folder clean-up now, will only be cleaning up
- * adapter-MTU file and apc->mana_pci_debugfs folder.
- */
- debugfs_remove_recursive(gc->mana_pci_debugfs);
- gc->mana_pci_debugfs = NULL;
xa_destroy(&gc->irq_contexts);
pci_iounmap(pdev, bar0_va);
free_gc:
@@ -2155,11 +2168,7 @@ static void mana_gd_remove(struct pci_dev *pdev)
mana_rdma_remove(&gc->mana_ib);
mana_remove(&gc->mana, false);
- mana_gd_cleanup(pdev);
-
- debugfs_remove_recursive(gc->mana_pci_debugfs);
-
- gc->mana_pci_debugfs = NULL;
+ mana_gd_cleanup_device(pdev);
xa_destroy(&gc->irq_contexts);
@@ -2181,7 +2190,7 @@ int mana_gd_suspend(struct pci_dev *pdev, pm_message_t state)
mana_rdma_remove(&gc->mana_ib);
mana_remove(&gc->mana, true);
- mana_gd_cleanup(pdev);
+ mana_gd_cleanup_device(pdev);
return 0;
}
@@ -2220,11 +2229,7 @@ static void mana_gd_shutdown(struct pci_dev *pdev)
mana_rdma_remove(&gc->mana_ib);
mana_remove(&gc->mana, true);
- mana_gd_cleanup(pdev);
-
- debugfs_remove_recursive(gc->mana_pci_debugfs);
-
- gc->mana_pci_debugfs = NULL;
+ mana_gd_cleanup_device(pdev);
pci_disable_device(pdev);
}
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 78522205c5d0..33464a28e5d5 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -1269,6 +1269,9 @@ static int mana_query_vport_cfg(struct mana_port_context *apc, u32 vport_index,
apc->port_handle = resp.vport;
ether_addr_copy(apc->mac_addr, resp.mac_addr);
+ apc->vport_max_sq = *max_sq;
+ apc->vport_max_rq = *max_rq;
+
return 0;
}
@@ -1423,6 +1426,11 @@ static int mana_cfg_vport_steering(struct mana_port_context *apc,
netdev_info(ndev, "Configured steering vPort %llu entries %u\n",
apc->port_handle, apc->indir_table_sz);
+
+ apc->steer_rx = rx;
+ apc->steer_rss = apc->rss_state;
+ apc->steer_update_tab = update_tab;
+ apc->steer_cqe_coalescing = req->cqe_coalescing_enable;
out:
kfree(req);
return err;
@@ -3147,6 +3155,23 @@ static int mana_init_port(struct net_device *ndev)
eth_hw_addr_set(ndev, apc->mac_addr);
sprintf(vport, "vport%d", port_idx);
apc->mana_port_debugfs = debugfs_create_dir(vport, gc->mana_pci_debugfs);
+
+ debugfs_create_u64("port_handle", 0400, apc->mana_port_debugfs,
+ &apc->port_handle);
+ debugfs_create_u32("max_sq", 0400, apc->mana_port_debugfs,
+ &apc->vport_max_sq);
+ debugfs_create_u32("max_rq", 0400, apc->mana_port_debugfs,
+ &apc->vport_max_rq);
+ debugfs_create_u32("indir_table_sz", 0400, apc->mana_port_debugfs,
+ &apc->indir_table_sz);
+ debugfs_create_u32("steer_rx", 0400, apc->mana_port_debugfs,
+ &apc->steer_rx);
+ debugfs_create_u32("steer_rss", 0400, apc->mana_port_debugfs,
+ &apc->steer_rss);
+ debugfs_create_u32("steer_update_tab", 0400, apc->mana_port_debugfs,
+ &apc->steer_update_tab);
+ debugfs_create_u32("steer_cqe_coalescing", 0400, apc->mana_port_debugfs,
+ &apc->steer_cqe_coalescing);
debugfs_create_u32("current_speed", 0400, apc->mana_port_debugfs,
&apc->speed);
return 0;
@@ -3639,6 +3664,11 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
ac->bm_hostmode = bm_hostmode;
+ debugfs_create_u16("num_vports", 0400, gc->mana_pci_debugfs,
+ &ac->num_ports);
+ debugfs_create_u8("bm_hostmode", 0400, gc->mana_pci_debugfs,
+ &ac->bm_hostmode);
+
if (!resuming) {
ac->num_ports = num_ports;
@@ -3779,6 +3809,9 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
mana_gd_deregister_device(gd);
+ debugfs_lookup_and_remove("bm_hostmode", gc->mana_pci_debugfs);
+ debugfs_lookup_and_remove("num_vports", gc->mana_pci_debugfs);
+
if (suspending)
return;
diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h
index 7fe3a1b61b2d..c4e3ce5147f7 100644
--- a/include/net/mana/gdma.h
+++ b/include/net/mana/gdma.h
@@ -442,6 +442,7 @@ struct gdma_context {
struct gdma_dev mana_ib;
u64 pf_cap_flags1;
+ u64 gdma_protocol_ver;
struct workqueue_struct *service_wq;
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 96d21cbbdee2..6d2e05a7368c 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -568,6 +568,14 @@ struct mana_port_context {
/* Debugfs */
struct dentry *mana_port_debugfs;
+
+ /* Cached vport/steering config for debugfs */
+ u32 vport_max_sq;
+ u32 vport_max_rq;
+ u32 steer_rx;
+ u32 steer_rss;
+ u32 steer_update_tab;
+ u32 steer_cqe_coalescing;
};
netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev);
--
2.34.1
^ permalink raw reply related
* [PATCH net-next v5 2/3] net: mana: Move current_speed debugfs file to mana_init_port()
From: Erni Sri Satya Vennela @ 2026-04-02 18:26 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
edumazet, kuba, pabeni, kotaranov, horms, shradhagupta,
shirazsaleem, yury.norov, kees, ssengar, ernis, dipayanroy,
gargaditya, linux-hyperv, netdev, linux-kernel, linux-rdma
In-Reply-To: <20260402182704.2474739-1-ernis@linux.microsoft.com>
Move the current_speed debugfs file creation from mana_probe_port() to
mana_init_port(). The file was previously created only during initial
probe, but mana_cleanup_port_context() removes the entire vPort debugfs
directory during detach/attach cycles. Since mana_init_port() recreates
the directory on re-attach, moving current_speed here ensures it survives
these cycles.
Fixes: 75cabb46935b ("net: mana: Add support for net_shaper_ops")
Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
---
Changes in v5:
* New to the patchset.
Changes in v4, v3, v2:
* Not created.
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 565375cc20d3..78522205c5d0 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -3147,6 +3147,8 @@ static int mana_init_port(struct net_device *ndev)
eth_hw_addr_set(ndev, apc->mac_addr);
sprintf(vport, "vport%d", port_idx);
apc->mana_port_debugfs = debugfs_create_dir(vport, gc->mana_pci_debugfs);
+ debugfs_create_u32("current_speed", 0400, apc->mana_port_debugfs,
+ &apc->speed);
return 0;
reset_apc:
@@ -3425,8 +3427,6 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
netif_carrier_on(ndev);
- debugfs_create_u32("current_speed", 0400, apc->mana_port_debugfs, &apc->speed);
-
return 0;
free_indir:
--
2.34.1
^ permalink raw reply related
* [PATCH net-next v5 1/3] net: mana: Use pci_name() for debugfs directory naming
From: Erni Sri Satya Vennela @ 2026-04-02 18:26 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
edumazet, kuba, pabeni, kotaranov, horms, shradhagupta,
shirazsaleem, yury.norov, kees, ssengar, ernis, dipayanroy,
gargaditya, linux-hyperv, netdev, linux-kernel, linux-rdma
In-Reply-To: <20260402182704.2474739-1-ernis@linux.microsoft.com>
Use pci_name(pdev) for the per-device debugfs directory instead of
hardcoded "0" for PFs and pci_slot_name(pdev->slot) for VFs. The
previous approach had two issues:
1. pci_slot_name() dereferences pdev->slot, which can be NULL for VFs
in environments like generic VFIO passthrough or nested KVM,
causing a NULL pointer dereference.
2. Multiple PFs would all use "0", and VFs across different PCI
domains or buses could share the same slot name, leading to
-EEXIST errors from debugfs_create_dir().
pci_name(pdev) returns the unique BDF address, is always valid, and
is unique across the system.
Fixes: 6607c17c6c5e ("net: mana: Enable debugfs files for MANA device")
Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
---
Changes in v5:
* New to patchset.
Changes in v4, v3, v2:
* Not created
---
drivers/net/ethernet/microsoft/mana/gdma_main.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index 43741cd35af8..098fbda0d128 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -2065,11 +2065,8 @@ static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
gc->dev = &pdev->dev;
xa_init(&gc->irq_contexts);
- if (gc->is_pf)
- gc->mana_pci_debugfs = debugfs_create_dir("0", mana_debugfs_root);
- else
- gc->mana_pci_debugfs = debugfs_create_dir(pci_slot_name(pdev->slot),
- mana_debugfs_root);
+ gc->mana_pci_debugfs = debugfs_create_dir(pci_name(pdev),
+ mana_debugfs_root);
err = mana_gd_setup(pdev);
if (err)
--
2.34.1
^ permalink raw reply related
* [PATCH net-next v5 0/3] net: mana: debugfs fixes and diagnostic info
From: Erni Sri Satya Vennela @ 2026-04-02 18:26 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
edumazet, kuba, pabeni, kotaranov, horms, shradhagupta,
shirazsaleem, yury.norov, kees, ssengar, ernis, dipayanroy,
gargaditya, linux-hyperv, netdev, linux-kernel, linux-rdma
This series first fixes two pre-existing debugfs issues in the MANA
driver, then adds new debugfs entries for hardware diagnostic info.
Patch 1 fixes the per-device debugfs directory naming to use the unique
PCI BDF address via pci_name(), avoiding a potential NULL pointer
dereference when pdev->slot is NULL and preventing name collisions
across multiple PFs or VFs.
Patch 2 moves the current_speed debugfs file creation from
mana_probe_port() to mana_init_port() so it survives detach/attach
cycles triggered by MTU changes or XDP program changes.
Patch 3 adds new debugfs entries exposing hardware configuration and
diagnostic information (device capabilities, vPort config, steering
parameters) and consolidates debugfs directory lifecycle into
mana_gd_setup()/mana_gd_cleanup_device().
---
Changes in v5:
* Create new patchset including all the the patches.
Changes in v4:
* Rebase and fix conflicts.
Changes in v3:
* Rename mana_gd_cleanup to mana_gd_cleanup_device.
* Add creation of debugfs entries in mana_gd_setup.
* Add removal of debugfs entries in mana_gd_cleanup_device.
* Remove bm_hostmode and num_vports from debugfs in mana_remove itself,
because "ac" gets freed before debugfs_remove_recursive, to avoid
Use-After-Free error.
* Add "goto out:" in mana_cfg_vport_steering to avoid populating apc
values when resp.hdr.status is not NULL.
Changes in v2:
* Add debugfs_remove_recursice for gc>mana_pci_debugfs in
mana_gd_suspend to handle multiple duplicates creation in
mana_gd_setup and mana_gd_resume path.
* Move debugfs creation for num_vports and bm_hostmode out of
if(!resuming) condition since we have to create it again even for
resume.
* Recreate mana_pci_debugfs in mana_gd_resume.
---
Erni Sri Satya Vennela (3):
net: mana: Use pci_name() for debugfs directory naming
net: mana: Move current_speed debugfs file to mana_init_port()
net: mana: Expose hardware diagnostic info via debugfs
.../net/ethernet/microsoft/mana/gdma_main.c | 62 ++++++++++---------
drivers/net/ethernet/microsoft/mana/mana_en.c | 37 ++++++++++-
include/net/mana/gdma.h | 1 +
include/net/mana/mana.h | 8 +++
4 files changed, 76 insertions(+), 32 deletions(-)
--
2.34.1
^ permalink raw reply
* [PATCH v3] netfilter: xt_multiport: validate range encoding in checkentry
From: Ren Wei @ 2026-04-02 18:21 UTC (permalink / raw)
To: netfilter-devel, netdev
Cc: pablo, fw, phil, davem, edumazet, kuba, pabeni, horms,
yasuyuki.kozakai, kaber, yifanwucs, tomapufckgml, yuantan098,
bird, z1652074432, n05ec
In-Reply-To: <cover.1774624314.git.n05ec@lzu.edu.cn>
ports_match_v1() treats any non-zero pflags entry as the start of a
port range and unconditionally consumes the next ports[] element as
the range end.
The checkentry path currently validates protocol, flags and count, but
it does not validate the range encoding itself. As a result, malformed
rules can mark the last slot as a range start or place two range starts
back to back, leaving ports_match_v1() to step past the last valid
ports[] element while interpreting the rule.
Reject malformed multiport v1 rules in checkentry by validating that
each range start has a following element and that the following element
is not itself marked as another range start.
Fixes: a89ecb6a2ef7 ("[NETFILTER]: x_tables: unify IPv4/IPv6 multiport match")
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Co-developed-by: Yuan Tan <yuantan098@gmail.com>
Signed-off-by: Yuan Tan <yuantan098@gmail.com>
Suggested-by: Xin Liu <bird@lzu.edu.cn>
Tested-by: Yuhang Zheng <z1652074432@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
---
Changes in v2:
- drop the selftest patch
- send the fix publicly to netfilter-devel
Changes in v3:
- drop datatype cleanup from the fix
- keep the original check() interface unchanged
- validate malformed range encoding in checkentry
net/netfilter/xt_multiport.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/xt_multiport.c b/net/netfilter/xt_multiport.c
index 44a00f5acde8..07a0f2a3fc75 100644
--- a/net/netfilter/xt_multiport.c
+++ b/net/netfilter/xt_multiport.c
@@ -105,6 +105,24 @@ multiport_mt(const struct sk_buff *skb, struct xt_action_param *par)
return ports_match_v1(multiinfo, ntohs(pptr[0]), ntohs(pptr[1]));
}
+static inline bool
+multiport_valid_ranges(const struct xt_multiport_v1 *multiinfo)
+{
+ unsigned int i;
+
+ for (i = 0; i < multiinfo->count; i++) {
+ if (!multiinfo->pflags[i])
+ continue;
+
+ if (i + 1 >= multiinfo->count || multiinfo->pflags[i + 1])
+ return false;
+
+ i++;
+ }
+
+ return true;
+}
+
static inline bool
check(u_int16_t proto,
u_int8_t ip_invflags,
@@ -127,8 +145,10 @@ static int multiport_mt_check(const struct xt_mtchk_param *par)
const struct ipt_ip *ip = par->entryinfo;
const struct xt_multiport_v1 *multiinfo = par->matchinfo;
- return check(ip->proto, ip->invflags, multiinfo->flags,
- multiinfo->count) ? 0 : -EINVAL;
+ if (!check(ip->proto, ip->invflags, multiinfo->flags, multiinfo->count))
+ return -EINVAL;
+
+ return multiport_valid_ranges(multiinfo) ? 0 : -EINVAL;
}
static int multiport_mt6_check(const struct xt_mtchk_param *par)
@@ -136,8 +156,10 @@ static int multiport_mt6_check(const struct xt_mtchk_param *par)
const struct ip6t_ip6 *ip = par->entryinfo;
const struct xt_multiport_v1 *multiinfo = par->matchinfo;
- return check(ip->proto, ip->invflags, multiinfo->flags,
- multiinfo->count) ? 0 : -EINVAL;
+ if (!check(ip->proto, ip->invflags, multiinfo->flags, multiinfo->count))
+ return -EINVAL;
+
+ return multiport_valid_ranges(multiinfo) ? 0 : -EINVAL;
}
static struct xt_match multiport_mt_reg[] __read_mostly = {
--
2.51.0
^ permalink raw reply related
* Re: [PATCH net v4] rtnetlink: add missing netlink_ns_capable() check for peer netns
From: Nikolaos Gkarlis @ 2026-04-02 18:17 UTC (permalink / raw)
To: Kuniyuki Iwashima; +Cc: Jakub Kicinski, netdev
In-Reply-To: <CAAVpQUDPjpiC_rSx+ry5o0KLfEWPg4VEiN60ihkF9NwrOX_n1Q@mail.gmail.com>
> Let's focus on the fix in net.git.
> Also, I don't want to hide rtnl_nets_add() in a helper.
I've now submitted v5. Thanks for reviewing, and apologies
for the detour.
^ permalink raw reply
* [PATCH v5] rtnetlink: add missing netlink_ns_capable() check for peer netns
From: Nikolaos Gkarlis @ 2026-04-02 18:14 UTC (permalink / raw)
To: netdev; +Cc: kuba, nickgarlis, kuniyu
rtnl_newlink() lacks a CAP_NET_ADMIN capability check on the peer
network namespace when creating paired devices (veth, vxcan,
netkit). This allows an unprivileged user with a user namespace
to create interfaces in arbitrary network namespaces, including
init_net.
Add a netlink_ns_capable() check for CAP_NET_ADMIN in the peer
namespace before allowing device creation to proceed.
Fixes: 81adee47dfb6 ("net: Support specifying the network namespace upon device creation.")
Signed-off-by: Nikolaos Gkarlis <nickgarlis@gmail.com>
---
v5:
- Rework rtnl_get_peer_net() to explicitly handle early
exit for clarity (suggested by Jakub Kicinski)
v4:
- Use IS_ERR_OR_NULL instead of IS_ERR + null check.
v3:
- Move netlink_ns_capable() check from rtnl_newlink() into
rtnl_get_peer_net(), after the last rtnl_link_get_net_ifla(tb)
call. The tbp path is already covered by rtnl_link_get_net_capable()
in the caller. (suggested by Kuniyuki)
- Pass skb to rtnl_get_peer_net() for the capability check.
- Add IS_ERR() check on rtnl_link_get_net_ifla(tb) return value.
v2:
- Removed "Reported-by" tag
- Fixed "Fixes" tag with the help of Kuniyuki Iwashima (thanks !)
net/core/rtnetlink.c | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index fae8034efbf..69daba3ddaf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3894,28 +3894,42 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
goto out;
}
-static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
+static struct net *rtnl_get_peer_net(struct sk_buff *skb,
+ const struct rtnl_link_ops *ops,
struct nlattr *tbp[],
struct nlattr *data[],
struct netlink_ext_ack *extack)
{
- struct nlattr *tb[IFLA_MAX + 1];
+ struct nlattr *tb[IFLA_MAX + 1], **attrs;
+ struct net *net;
int err;
- if (!data || !data[ops->peer_type])
- return rtnl_link_get_net_ifla(tbp);
-
- err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
- if (err < 0)
- return ERR_PTR(err);
-
- if (ops->validate) {
- err = ops->validate(tb, NULL, extack);
+ if (!data || !data[ops->peer_type]) {
+ attrs = tbp;
+ } else {
+ err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
if (err < 0)
return ERR_PTR(err);
+
+ if (ops->validate) {
+ err = ops->validate(tb, NULL, extack);
+ if (err < 0)
+ return ERR_PTR(err);
+ }
+
+ attrs = tb;
}
- return rtnl_link_get_net_ifla(tb);
+ net = rtnl_link_get_net_ifla(attrs);
+ if (IS_ERR_OR_NULL(net))
+ return net;
+
+ if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+ put_net(net);
+ return ERR_PTR(-EPERM);
+ }
+
+ return net;
}
static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -4054,7 +4068,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
}
if (ops->peer_type) {
- peer_net = rtnl_get_peer_net(ops, tb, data, extack);
+ peer_net = rtnl_get_peer_net(skb, ops, tb, data, extack);
if (IS_ERR(peer_net)) {
ret = PTR_ERR(peer_net);
goto put_ops;
--
2.34.1
^ permalink raw reply related
* Re: [PATCH net] ipv6: ioam: fix potential NULL dereferences in __ioam6_fill_trace_data()
From: Justin Iurman @ 2026-04-02 18:10 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Yiming Qian
In-Reply-To: <20260402101732.1188059-1-edumazet@google.com>
On 4/2/26 12:17, Eric Dumazet wrote:
> We need to check __in6_dev_get() for possible NULL value, as
> suggested by Yiming Qian.
>
> Also add skb_dst_dev_rcu() instead of skb_dst_dev(),
> and two missing READ_ONCE().
>
> Note that @dev can't be NULL.
>
> Fixes: 9ee11f0fff20 ("ipv6: ioam: Data plane support for Pre-allocated Trace")
> Reported-by: Yiming Qian <yimingqian591@gmail.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Justin Iurman <justin.iurman@gmail.com>
> ---
> net/ipv6/ioam6.c | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/net/ipv6/ioam6.c b/net/ipv6/ioam6.c
> index 3978773bec424890cd18db78cf7cac9d3d652130..05a0b7d7e2aac35f634641fc4a791d1965dc85fd 100644
> --- a/net/ipv6/ioam6.c
> +++ b/net/ipv6/ioam6.c
> @@ -710,7 +710,9 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
> struct ioam6_schema *sc,
> unsigned int sclen, bool is_input)
> {
> - struct net_device *dev = skb_dst_dev(skb);
> + /* Note: skb_dst_dev_rcu() can't be NULL at this point. */
> + struct net_device *dev = skb_dst_dev_rcu(skb);
> + struct inet6_dev *i_skb_dev, *idev;
> struct timespec64 ts;
> ktime_t tstamp;
> u64 raw64;
> @@ -721,13 +723,16 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
>
> data = trace->data + trace->remlen * 4 - trace->nodelen * 4 - sclen * 4;
>
> + i_skb_dev = skb->dev ? __in6_dev_get(skb->dev) : NULL;
> + idev = __in6_dev_get(dev);
> +
> /* hop_lim and node_id */
> if (trace->type.bit0) {
> byte = ipv6_hdr(skb)->hop_limit;
> if (is_input)
> byte--;
>
> - raw32 = dev_net(dev)->ipv6.sysctl.ioam6_id;
> + raw32 = READ_ONCE(dev_net(dev)->ipv6.sysctl.ioam6_id);
>
> *(__be32 *)data = cpu_to_be32((byte << 24) | raw32);
> data += sizeof(__be32);
> @@ -735,18 +740,18 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
>
> /* ingress_if_id and egress_if_id */
> if (trace->type.bit1) {
> - if (!skb->dev)
> + if (!i_skb_dev)
> raw16 = IOAM6_U16_UNAVAILABLE;
> else
> - raw16 = (__force u16)READ_ONCE(__in6_dev_get(skb->dev)->cnf.ioam6_id);
> + raw16 = (__force u16)READ_ONCE(i_skb_dev->cnf.ioam6_id);
>
> *(__be16 *)data = cpu_to_be16(raw16);
> data += sizeof(__be16);
>
> - if (dev->flags & IFF_LOOPBACK)
> + if ((dev->flags & IFF_LOOPBACK) || !idev)
> raw16 = IOAM6_U16_UNAVAILABLE;
> else
> - raw16 = (__force u16)READ_ONCE(__in6_dev_get(dev)->cnf.ioam6_id);
> + raw16 = (__force u16)READ_ONCE(idev->cnf.ioam6_id);
>
> *(__be16 *)data = cpu_to_be16(raw16);
> data += sizeof(__be16);
> @@ -822,7 +827,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
> if (is_input)
> byte--;
>
> - raw64 = dev_net(dev)->ipv6.sysctl.ioam6_id_wide;
> + raw64 = READ_ONCE(dev_net(dev)->ipv6.sysctl.ioam6_id_wide);
>
> *(__be64 *)data = cpu_to_be64(((u64)byte << 56) | raw64);
> data += sizeof(__be64);
> @@ -830,18 +835,18 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
>
> /* ingress_if_id and egress_if_id (wide) */
> if (trace->type.bit9) {
> - if (!skb->dev)
> + if (!i_skb_dev)
> raw32 = IOAM6_U32_UNAVAILABLE;
> else
> - raw32 = READ_ONCE(__in6_dev_get(skb->dev)->cnf.ioam6_id_wide);
> + raw32 = READ_ONCE(i_skb_dev->cnf.ioam6_id_wide);
>
> *(__be32 *)data = cpu_to_be32(raw32);
> data += sizeof(__be32);
>
> - if (dev->flags & IFF_LOOPBACK)
> + if ((dev->flags & IFF_LOOPBACK) || !idev)
> raw32 = IOAM6_U32_UNAVAILABLE;
> else
> - raw32 = READ_ONCE(__in6_dev_get(dev)->cnf.ioam6_id_wide);
> + raw32 = READ_ONCE(idev->cnf.ioam6_id_wide);
>
> *(__be32 *)data = cpu_to_be32(raw32);
> data += sizeof(__be32);
LGTM, thanks Eric.
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
^ permalink raw reply
* Re: [PATCH net-next v4 3/3] net: phy: add a PHY write barrier when disabling interrupts
From: Andrew Lunn @ 2026-04-02 18:09 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Charles Perry, netdev, Heiner Kallweit, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
In-Reply-To: <ac6vfhsW2ThF8i2_@shell.armlinux.org.uk>
On Thu, Apr 02, 2026 at 07:03:42PM +0100, Russell King (Oracle) wrote:
> On Thu, Apr 02, 2026 at 03:31:52PM +0200, Andrew Lunn wrote:
> > > +static int phy_write_barrier(struct phy_device *phydev)
> > > +{
> > > + int err;
> > > +
> > > + err = phy_read(phydev, MII_PHYSID1);
> > > + if (err < 0)
> > > + return err;
> >
> > There are a small number of MDIO busses which don't implement C22,
> > only C45. You are likely to get -EIO or maybe ENODEV, -EOPNOTSUPP,
> > -EINVAL for such a read. Returning the error than makes
> > phy_disable_interrupts() fail, etc.
>
> If it returns -EOPNOTSUPP (meaning, at least, that bus->read is not
> implemented), do we want to issue a C45 read instead?
Maybe.
get_phy_c45_ids() first reads MDIO_MMD_PMAPMD : MII_PHYSID1. That
seems like a safe option.
Andrew
^ permalink raw reply
* Re: [PATCH net-next v4 3/3] net: phy: add a PHY write barrier when disabling interrupts
From: Russell King (Oracle) @ 2026-04-02 18:03 UTC (permalink / raw)
To: Andrew Lunn
Cc: Charles Perry, netdev, Heiner Kallweit, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
In-Reply-To: <6bb3aec4-1635-4287-b7ce-f15b693563ea@lunn.ch>
On Thu, Apr 02, 2026 at 03:31:52PM +0200, Andrew Lunn wrote:
> > +static int phy_write_barrier(struct phy_device *phydev)
> > +{
> > + int err;
> > +
> > + err = phy_read(phydev, MII_PHYSID1);
> > + if (err < 0)
> > + return err;
>
> There are a small number of MDIO busses which don't implement C22,
> only C45. You are likely to get -EIO or maybe ENODEV, -EOPNOTSUPP,
> -EINVAL for such a read. Returning the error than makes
> phy_disable_interrupts() fail, etc.
If it returns -EOPNOTSUPP (meaning, at least, that bus->read is not
implemented), do we want to issue a C45 read instead?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply
* Re: [PATCH net v4] rtnetlink: add missing netlink_ns_capable() check for peer netns
From: Kuniyuki Iwashima @ 2026-04-02 17:52 UTC (permalink / raw)
To: Nikolaos Gkarlis; +Cc: Jakub Kicinski, netdev
In-Reply-To: <CA+jwDR=9UgxAW828FF4geu8RukGyi7OLTS0ShVr4S8-36SWamw@mail.gmail.com>
On Thu, Apr 2, 2026 at 10:46 AM Nikolaos Gkarlis <nickgarlis@gmail.com> wrote:
>
> On Thu, Apr 2, 2026 at 4:45 AM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Sat, 28 Mar 2026 22:33:38 +0100 Nikolaos Gkarlis wrote:
> > > -static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
> > > +static struct net *rtnl_get_peer_net(struct sk_buff *skb,
> > > + const struct rtnl_link_ops *ops,
> > > struct nlattr *tbp[],
> > > struct nlattr *data[],
> > > struct netlink_ext_ack *extack)
> > > {
> > > struct nlattr *tb[IFLA_MAX + 1];
> > > + struct net *net;
> > > int err;
> > >
> > > if (!data || !data[ops->peer_type])
> >
> > There's an early return hiding outside of the context here.
> > the patch is technically correct, I think, because if we take this
> > shortcut we end up with the same netns as tgt_net so we'll validate
> > that it's capable later. But it's probably not obvious to a casual
> > reader of this code (or AI agents, sigh)
> >
> > So let's rewrite this along the lines of:
> >
> > struct nlattr *tb[IFLA_MAX + 1], **attrs;
> > struct net *net;
> > int err;
> >
> > if (!data || !data[ops->peer_type]) {
> > attrs = tbp;
> > } else {
> > err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
> > if (err < 0)
> > return ERR_PTR(err);
> >
> > if (ops->validate) {
> > err = ops->validate(tb, NULL, extack);
> > if (err < 0)
> > return ERR_PTR(err);
> > }
> >
> > attrs = tb;
> > }
> >
> > net = rtnl_link_get_net_ifla(attrs);
> > if (IS_ERR_OR_NULL(net))
> > return net;
> >
> > if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
> > ...
> >
> > ?
>
> I agree it’s a bit confusing with the early exit. I’ll apply the suggested
> changes and send a v5.
>
> That said, would it make sense to introduce a separate
> rtnl_nets_add_capable() helper that wraps rtnl_nets_add() instead?
Let's focus on the fix in net.git.
Also, I don't want to hide rtnl_nets_add() in a helper.
>
> Something along these lines:
>
> @@ -334,6 +334,19 @@ static void rtnl_nets_add(struct rtnl_nets
> *rtnl_nets, struct net *net)
> rtnl_nets->len++;
> }
>
> +static struct net *rtnl_nets_add_capable(struct sk_buff *skb,
> + struct rtnl_nets *rtnl_nets,
> + struct net *net)
> +{
> + if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
> + put_net(net);
> + return ERR_PTR(-EPERM);
> + }
> +
> + rtnl_nets_add(rtnl_nets, net);
> + return net;
> +}
> +
> static void rtnl_nets_lock(struct rtnl_nets *rtnl_nets)
> {
> int i;
> @@ -4059,18 +4072,29 @@ static int rtnl_newlink(struct sk_buff *skb,
> struct nlmsghdr *nlh,
> ret = PTR_ERR(peer_net);
> goto put_ops;
> }
> - if (peer_net)
> - rtnl_nets_add(&rtnl_nets, peer_net);
> + if (peer_net) {
> + peer_net = rtnl_nets_add_capable(skb,
> + &rtnl_nets,
> + peer_net);
> + if (IS_ERR(peer_net)) {
> + ret = PTR_ERR(peer_net);
> + goto put_ops;
> + }
> + }
> }
> }
>
> - tgt_net = rtnl_link_get_net_capable(skb, sock_net(skb->sk), tb,
> CAP_NET_ADMIN);
> + tgt_net = rtnl_link_get_net_by_nlattr(sock_net(skb->sk), tb);
> if (IS_ERR(tgt_net)) {
> ret = PTR_ERR(tgt_net);
> goto put_net;
> }
>
> - rtnl_nets_add(&rtnl_nets, tgt_net);
> + tgt_net = rtnl_nets_add_capable(skb, &rtnl_nets, tgt_net);
> + if (IS_ERR(tgt_net)) {
> + ret = PTR_ERR(tgt_net);
> + goto put_net;
> + }
>
> if (tb[IFLA_LINK_NETNSID]) {
> int id = nla_get_s32(tb[IFLA_LINK_NETNSID]);
> @@ -4082,10 +4106,10 @@ static int rtnl_newlink(struct sk_buff *skb,
> struct nlmsghdr *nlh,
> goto put_net;
> }
>
> - rtnl_nets_add(&rtnl_nets, link_net);
> -
> - if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) {
> - ret = -EPERM;
> + link_net = rtnl_nets_add_capable(skb, &rtnl_nets,
> + link_net);
> + if (IS_ERR(link_net)) {
> + ret = PTR_ERR(link_net);
> goto put_net;
> }
> }
>
> Note that this changes the order in link_net, checking capabilities
> before creating the object.
>
> Disclaimer: I’m not very familiar with this code, so this may be a bad idea.
^ permalink raw reply
* [RFC PATCH 1/6] rust: bindings: expose networking headers needed by nlmon
From: Wenzhao Liao @ 2026-04-02 16:36 UTC (permalink / raw)
To: rust-for-linux, netdev
Cc: linux-kernel, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross, dakr, andrew+netdev, davem, edumazet, kuba,
pabeni
In-Reply-To: <20260402163640.1079056-1-wenzhaoliao@ruc.edu.cn>
Expose the networking declarations consumed by the minimal Rust nlmon
reference driver before higher level wrappers are introduced.
This includes the core net_device, rtnl_link_ops, statistics, sk_buff,
and netlink tap declarations needed by the planned abstractions.
Signed-off-by: Wenzhao Liao <wenzhaoliao@ruc.edu.cn>
---
rust/bindings/bindings_helper.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 083cc44aa952..ee56505e03f9 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -57,6 +57,7 @@
#include <linux/file.h>
#include <linux/firmware.h>
#include <linux/fs.h>
+#include <linux/if_arp.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/io-pgtable.h>
@@ -66,6 +67,8 @@
#include <linux/mdio.h>
#include <linux/mm.h>
#include <linux/miscdevice.h>
+#include <linux/netdevice.h>
+#include <linux/netlink.h>
#include <linux/of_device.h>
#include <linux/pci.h>
#include <linux/phy.h>
@@ -88,6 +91,7 @@
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/xarray.h>
+#include <net/rtnetlink.h>
#include <trace/events/rust_sample.h>
/*
--
2.34.1
^ permalink raw reply related
* Re: [PATCH net-next v4 3/3] net: phy: add a PHY write barrier when disabling interrupts
From: Charles Perry @ 2026-04-02 17:51 UTC (permalink / raw)
To: Andrew Lunn
Cc: Charles Perry, netdev, Heiner Kallweit, Russell King,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
In-Reply-To: <6bb3aec4-1635-4287-b7ce-f15b693563ea@lunn.ch>
On Thu, Apr 02, 2026 at 03:31:52PM +0200, Andrew Lunn wrote:
> > +static int phy_write_barrier(struct phy_device *phydev)
> > +{
> > + int err;
> > +
> > + err = phy_read(phydev, MII_PHYSID1);
> > + if (err < 0)
> > + return err;
>
> There are a small number of MDIO busses which don't implement C22,
> only C45. You are likely to get -EIO or maybe ENODEV, -EOPNOTSUPP,
> -EINVAL for such a read. Returning the error than makes
> phy_disable_interrupts() fail, etc.
Ok, I didn't know about this. Do you think there's any merit in handling
the case where phydev->mdio.bus->read is NULL and doing a C45 access in
that case?
>
> This is why i suggested throwing away the return value.
Ok
Thanks,
Charles
>
> Maybe call phydev_info() if there is an error, but i suggest making
> this a void function.
>
> Andrew
>
> ---
> pw-bot: cr
^ permalink raw reply
* Re: [PATCH net v4] rtnetlink: add missing netlink_ns_capable() check for peer netns
From: Nikolaos Gkarlis @ 2026-04-02 17:45 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, kuniyu
In-Reply-To: <20260401194553.6e8a17f8@kernel.org>
On Thu, Apr 2, 2026 at 4:45 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Sat, 28 Mar 2026 22:33:38 +0100 Nikolaos Gkarlis wrote:
> > -static struct net *rtnl_get_peer_net(const struct rtnl_link_ops *ops,
> > +static struct net *rtnl_get_peer_net(struct sk_buff *skb,
> > + const struct rtnl_link_ops *ops,
> > struct nlattr *tbp[],
> > struct nlattr *data[],
> > struct netlink_ext_ack *extack)
> > {
> > struct nlattr *tb[IFLA_MAX + 1];
> > + struct net *net;
> > int err;
> >
> > if (!data || !data[ops->peer_type])
>
> There's an early return hiding outside of the context here.
> the patch is technically correct, I think, because if we take this
> shortcut we end up with the same netns as tgt_net so we'll validate
> that it's capable later. But it's probably not obvious to a casual
> reader of this code (or AI agents, sigh)
>
> So let's rewrite this along the lines of:
>
> struct nlattr *tb[IFLA_MAX + 1], **attrs;
> struct net *net;
> int err;
>
> if (!data || !data[ops->peer_type]) {
> attrs = tbp;
> } else {
> err = rtnl_nla_parse_ifinfomsg(tb, data[ops->peer_type], extack);
> if (err < 0)
> return ERR_PTR(err);
>
> if (ops->validate) {
> err = ops->validate(tb, NULL, extack);
> if (err < 0)
> return ERR_PTR(err);
> }
>
> attrs = tb;
> }
>
> net = rtnl_link_get_net_ifla(attrs);
> if (IS_ERR_OR_NULL(net))
> return net;
>
> if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
> ...
>
> ?
I agree it’s a bit confusing with the early exit. I’ll apply the suggested
changes and send a v5.
That said, would it make sense to introduce a separate
rtnl_nets_add_capable() helper that wraps rtnl_nets_add() instead?
Something along these lines:
@@ -334,6 +334,19 @@ static void rtnl_nets_add(struct rtnl_nets
*rtnl_nets, struct net *net)
rtnl_nets->len++;
}
+static struct net *rtnl_nets_add_capable(struct sk_buff *skb,
+ struct rtnl_nets *rtnl_nets,
+ struct net *net)
+{
+ if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+ put_net(net);
+ return ERR_PTR(-EPERM);
+ }
+
+ rtnl_nets_add(rtnl_nets, net);
+ return net;
+}
+
static void rtnl_nets_lock(struct rtnl_nets *rtnl_nets)
{
int i;
@@ -4059,18 +4072,29 @@ static int rtnl_newlink(struct sk_buff *skb,
struct nlmsghdr *nlh,
ret = PTR_ERR(peer_net);
goto put_ops;
}
- if (peer_net)
- rtnl_nets_add(&rtnl_nets, peer_net);
+ if (peer_net) {
+ peer_net = rtnl_nets_add_capable(skb,
+ &rtnl_nets,
+ peer_net);
+ if (IS_ERR(peer_net)) {
+ ret = PTR_ERR(peer_net);
+ goto put_ops;
+ }
+ }
}
}
- tgt_net = rtnl_link_get_net_capable(skb, sock_net(skb->sk), tb,
CAP_NET_ADMIN);
+ tgt_net = rtnl_link_get_net_by_nlattr(sock_net(skb->sk), tb);
if (IS_ERR(tgt_net)) {
ret = PTR_ERR(tgt_net);
goto put_net;
}
- rtnl_nets_add(&rtnl_nets, tgt_net);
+ tgt_net = rtnl_nets_add_capable(skb, &rtnl_nets, tgt_net);
+ if (IS_ERR(tgt_net)) {
+ ret = PTR_ERR(tgt_net);
+ goto put_net;
+ }
if (tb[IFLA_LINK_NETNSID]) {
int id = nla_get_s32(tb[IFLA_LINK_NETNSID]);
@@ -4082,10 +4106,10 @@ static int rtnl_newlink(struct sk_buff *skb,
struct nlmsghdr *nlh,
goto put_net;
}
- rtnl_nets_add(&rtnl_nets, link_net);
-
- if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) {
- ret = -EPERM;
+ link_net = rtnl_nets_add_capable(skb, &rtnl_nets,
+ link_net);
+ if (IS_ERR(link_net)) {
+ ret = PTR_ERR(link_net);
goto put_net;
}
}
Note that this changes the order in link_net, checking capabilities
before creating the object.
Disclaimer: I’m not very familiar with this code, so this may be a bad idea.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox