From 39325a3bcec4b7a36535a67be9bbc655be6c7b75 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 26 Oct 2022 17:11:07 +0000 Subject: [PATCH] support ethtool ops Signed-off-by: Jim Ma --- Makefile | 2 +- backport.h | 22 ++++++++++++++++++++++ igc_ethtool.c | 6 +----- igc_main.c | 28 +++------------------------- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 82b1b8b..307e347 100644 --- a/Makefile +++ b/Makefile @@ -9,4 +9,4 @@ obj-m = igc.o # TODO enable ethtool api igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o \ -igc_diag.o igc_ptp.o igc_dump.o igc_tsn.o +igc_diag.o igc_ethtool.o igc_ptp.o igc_dump.o igc_tsn.o diff --git a/backport.h b/backport.h index 3b88f0e..a92ede2 100644 --- a/backport.h +++ b/backport.h @@ -178,4 +178,26 @@ pci_release_mem_regions(struct pci_dev *pdev) { return pci_release_selected_regions(pdev, pci_select_bars(pdev, IORESOURCE_MEM)); +} + +static inline bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, + const unsigned long *src) +{ + bool retval = true; + + /* TODO: following test will soon always be true */ + if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(ext); + + bitmap_zero(ext, __ETHTOOL_LINK_MODE_MASK_NBITS); + bitmap_fill(ext, 32); + bitmap_complement(ext, ext, __ETHTOOL_LINK_MODE_MASK_NBITS); + if (bitmap_intersects(ext, src, + __ETHTOOL_LINK_MODE_MASK_NBITS)) { + /* src mask goes beyond bit 31 */ + retval = false; + } + } + *legacy_u32 = src[0]; + return retval; } \ No newline at end of file diff --git a/igc_ethtool.c b/igc_ethtool.c index 6771259..a0fed0e 100644 --- a/igc_ethtool.c +++ b/igc_ethtool.c @@ -8,6 +8,7 @@ #include "igc.h" #include "igc_diag.h" +#include "backport.h" #include "backport_overflow.h" /* forward declaration */ @@ -1043,11 +1044,9 @@ static int igc_ethtool_get_rss_hash_opts(struct igc_adapter *adapter, switch (cmd->flow_type) { case TCP_V4_FLOW: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; - fallthrough; case UDP_V4_FLOW: if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV4_UDP) cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; - fallthrough; case SCTP_V4_FLOW: case AH_ESP_V4_FLOW: case AH_V4_FLOW: @@ -1057,11 +1056,9 @@ static int igc_ethtool_get_rss_hash_opts(struct igc_adapter *adapter, break; case TCP_V6_FLOW: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; - fallthrough; case UDP_V6_FLOW: if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV6_UDP) cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; - fallthrough; case SCTP_V6_FLOW: case AH_ESP_V6_FLOW: case AH_V6_FLOW: @@ -1924,7 +1921,6 @@ static void igc_ethtool_diag_test(struct net_device *netdev, } static const struct ethtool_ops igc_ethtool_ops = { - .supported_coalesce_params = ETHTOOL_COALESCE_USECS, .get_drvinfo = igc_ethtool_get_drvinfo, .get_regs_len = igc_ethtool_get_regs_len, .get_regs = igc_ethtool_get_regs, diff --git a/igc_main.c b/igc_main.c index 5a53bdf..4638f05 100644 --- a/igc_main.c +++ b/igc_main.c @@ -632,29 +632,6 @@ static void igc_configure_tx(struct igc_adapter *adapter) igc_configure_tx_ring(adapter, adapter->tx_ring[i]); } -// FIXME copy from igc_ethtool.c, remove this function after enable ethtool api -void igc_write_rss_indir_tbl(struct igc_adapter *adapter) -{ - struct igc_hw *hw = &adapter->hw; - u32 reg = IGC_RETA(0); - u32 shift = 0; - int i = 0; - - while (i < IGC_RETA_SIZE) { - u32 val = 0; - int j; - - for (j = 3; j >= 0; j--) { - val <<= 8; - val |= adapter->rss_indir_tbl[i + j]; - } - - wr32(reg, val << shift); - reg += 4; - i += 4; - } -} - /** * igc_setup_mrqc - configure the multiple receive queue control registers * @adapter: Board private structure @@ -3918,7 +3895,7 @@ static int igc_change_mtu(struct net_device *netdev, int new_mtu) * Returns the address of the device statistics structure. * The statistics are updated here and also from the timer callback. */ -static void igc_get_stats64(struct net_device *netdev, +static struct rtnl_link_stats64 *igc_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -3928,6 +3905,7 @@ static void igc_get_stats64(struct net_device *netdev, igc_update_stats(adapter); memcpy(stats, &adapter->stats64, sizeof(*stats)); spin_unlock(&adapter->stats64_lock); + return stats; } static netdev_features_t igc_fix_features(struct net_device *netdev, @@ -5061,7 +5039,7 @@ static int igc_probe(struct pci_dev *pdev, hw->hw_addr = adapter->io_addr; netdev->netdev_ops = &igc_netdev_ops; - // igc_ethtool_set_ops(netdev); + igc_ethtool_set_ops(netdev); netdev->watchdog_timeo = 5 * HZ; netdev->mem_start = pci_resource_start(pdev, 0);