Skip to content

Commit 095cf60

Browse files
committed
Merge: igc: Driver Update
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4559 JIRA: https://issues.redhat.com/browse/RHEL-17489 JIRA: https://issues.redhat.com/browse/RHEL-33266 CVE: CVE-2024-26853 Signed-off-by: Corinna Vinschen <vinschen@redhat.com> Andrew Lunn (2): net: intel: i40e/igc: Remove setting Autoneg in EEE capabilities net: intel: igc: Use linkmode helpers for EEE Arnd Bergmann (1): igc: fix LEDS_CLASS dependency Bjorn Helgaas (1): igc: Remove redundant runtime resume for ethtool ops Eric Dumazet (1): net: adopt skb_network_offset() and similar helpers Florian Kauer (1): igc: avoid returning frame twice in XDP_REDIRECT Jakub Kicinski (1): eth: igc: remove unused embedded struct net_device Jesse Brandeburg (4): intel: add bit macro includes where needed igc: field prep conversion igc: field get conversion net: intel: implement modern PM ops declarations Kurt Kanzenbach (8): igc: Report VLAN EtherType matching back to user igc: Check VLAN TCI mask igc: Check VLAN EtherType mask igc: Use reverse xmas tree igc: Use netdev printing functions for flex filters igc: Unify filtering rule fields igc: Add support for LEDs on i225/i226 igc: Remove stale comment about Tx timestamping Lukas Wunner (1): igc: Fix LED-related deadlock on driver unbind Rodrigo Cataldo (1): igc: Fix hicredit calculation Sasha Neftin (3): igc: Remove temporary workaround igc: Refactor runtime power management flow igc: Fix Energy Efficient Ethernet support declaration Vinicius Costa Gomes (3): igc: Simplify setting flags in the TX data descriptor igc: Add support for PTP .getcyclesx64() igc: Fix missing time sync events drivers/net/ethernet/intel/Kconfig | 9 + drivers/net/ethernet/intel/igc/Makefile | 1 + drivers/net/ethernet/intel/igc/igc.h | 32 +- drivers/net/ethernet/intel/igc/igc_base.c | 6 +- drivers/net/ethernet/intel/igc/igc_base.h | 4 + drivers/net/ethernet/intel/igc/igc_defines.h | 2 + drivers/net/ethernet/intel/igc/igc_ethtool.c | 83 +++-- drivers/net/ethernet/intel/igc/igc_i225.c | 6 +- drivers/net/ethernet/intel/igc/igc_leds.c | 302 +++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_main.c | 196 ++++++------ drivers/net/ethernet/intel/igc/igc_phy.c | 11 +- drivers/net/ethernet/intel/igc/igc_ptp.c | 50 +-- drivers/net/ethernet/intel/igc/igc_regs.h | 6 + drivers/net/ethernet/intel/igc/igc_tsn.c | 2 +- 14 files changed, 548 insertions(+), 162 deletions(-) create mode 100644 drivers/net/ethernet/intel/igc/igc_leds.c -- 2.43.0 Approved-by: Ken Cox <jkc@redhat.com> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents b624a43 + 0c7a89e commit 095cf60

File tree

14 files changed

+548
-162
lines changed

14 files changed

+548
-162
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ config IGC
372372

373373
To compile this driver as a module, choose M here. The module
374374
will be called igc.
375+
376+
config IGC_LEDS
377+
def_bool LEDS_TRIGGER_NETDEV
378+
depends on IGC && LEDS_CLASS
379+
depends on LEDS_CLASS=y || IGC=m
380+
help
381+
Optional support for controlling the NIC LED's with the netdev
382+
LED trigger.
383+
375384
config IDPF
376385
tristate "Intel(R) Infrastructure Data Path Function Support"
377386
depends on PCI_MSI

drivers/net/ethernet/intel/igc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77

88
obj-$(CONFIG_IGC) += igc.o
9+
igc-$(CONFIG_IGC_LEDS) += igc_leds.o
910

1011
igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o \
1112
igc_diag.o igc_ethtool.o igc_ptp.o igc_dump.o igc_tsn.o igc_xdp.o

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ struct igc_tx_timestamp_request {
8181
u32 flags; /* flags that should be added to the tx_buffer */
8282
};
8383

84+
struct igc_inline_rx_tstamps {
85+
/* Timestamps are saved in little endian at the beginning of the packet
86+
* buffer following the layout:
87+
*
88+
* DWORD: | 0 | 1 | 2 | 3 |
89+
* Field: | Timer1 SYSTIML | Timer1 SYSTIMH | Timer0 SYSTIML | Timer0 SYSTIMH |
90+
*
91+
* SYSTIML holds the nanoseconds part while SYSTIMH holds the seconds
92+
* part of the timestamp.
93+
*
94+
*/
95+
__le32 timer1[2];
96+
__le32 timer0[2];
97+
};
98+
8499
struct igc_ring_container {
85100
struct igc_ring *ring; /* pointer to linked list of rings */
86101
unsigned int total_bytes; /* total bytes processed this int */
@@ -261,6 +276,8 @@ struct igc_adapter {
261276
unsigned int ptp_flags;
262277
/* System time value lock */
263278
spinlock_t tmreg_lock;
279+
/* Free-running timer lock */
280+
spinlock_t free_timer_lock;
264281
struct cyclecounter cc;
265282
struct timecounter tc;
266283
struct timespec64 prev_ptp_time; /* Pre-reset PTP clock */
@@ -278,6 +295,10 @@ struct igc_adapter {
278295
struct timespec64 start;
279296
struct timespec64 period;
280297
} perout[IGC_N_PEROUT];
298+
299+
/* LEDs */
300+
struct mutex led_mutex;
301+
struct igc_led_classdev *leds;
281302
};
282303

283304
void igc_up(struct igc_adapter *adapter);
@@ -469,6 +490,8 @@ enum igc_tx_flags {
469490
IGC_TX_FLAGS_TSTAMP_1 = 0x100,
470491
IGC_TX_FLAGS_TSTAMP_2 = 0x200,
471492
IGC_TX_FLAGS_TSTAMP_3 = 0x400,
493+
494+
IGC_TX_FLAGS_TSTAMP_TIMER_1 = 0x800,
472495
};
473496

474497
enum igc_boards {
@@ -531,7 +554,7 @@ struct igc_rx_buffer {
531554
struct igc_xdp_buff {
532555
struct xdp_buff xdp;
533556
union igc_adv_rx_desc *rx_desc;
534-
ktime_t rx_ts; /* data indication bit IGC_RXDADV_STAT_TSIP */
557+
struct igc_inline_rx_tstamps *rx_ts; /* data indication bit IGC_RXDADV_STAT_TSIP */
535558
};
536559

537560
struct igc_q_vector {
@@ -548,7 +571,6 @@ struct igc_q_vector {
548571

549572
struct rcu_head rcu; /* to avoid race with update stats on free */
550573
char name[IFNAMSIZ + 9];
551-
struct net_device poll_dev;
552574

553575
/* for dynamic allocation of rings associated with this q_vector */
554576
struct igc_ring ring[] ____cacheline_internodealigned_in_smp;
@@ -566,8 +588,9 @@ enum igc_filter_match_flags {
566588
struct igc_nfc_filter {
567589
u8 match_flags;
568590
u16 etype;
569-
__be16 vlan_etype;
591+
u16 vlan_etype;
570592
u16 vlan_tci;
593+
u16 vlan_tci_mask;
571594
u8 src_addr[ETH_ALEN];
572595
u8 dst_addr[ETH_ALEN];
573596
u8 user_data[8];
@@ -700,6 +723,9 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter);
700723
void igc_ptp_read(struct igc_adapter *adapter, struct timespec64 *ts);
701724
void igc_ptp_tx_tstamp_event(struct igc_adapter *adapter);
702725

726+
int igc_led_setup(struct igc_adapter *adapter);
727+
void igc_led_free(struct igc_adapter *adapter);
728+
703729
#define igc_rx_pg_size(_ring) (PAGE_SIZE << igc_rx_pg_order(_ring))
704730

705731
#define IGC_TXD_DCMD (IGC_ADVTXD_DCMD_EOP | IGC_ADVTXD_DCMD_RS)

drivers/net/ethernet/intel/igc/igc_base.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ static s32 igc_init_nvm_params_base(struct igc_hw *hw)
6868
u32 eecd = rd32(IGC_EECD);
6969
u16 size;
7070

71-
size = (u16)((eecd & IGC_EECD_SIZE_EX_MASK) >>
72-
IGC_EECD_SIZE_EX_SHIFT);
71+
size = FIELD_GET(IGC_EECD_SIZE_EX_MASK, eecd);
7372

7473
/* Added to a constant, "size" becomes the left-shift value
7574
* for setting word_size.
@@ -162,8 +161,7 @@ static s32 igc_init_phy_params_base(struct igc_hw *hw)
162161
phy->reset_delay_us = 100;
163162

164163
/* set lan id */
165-
hw->bus.func = (rd32(IGC_STATUS) & IGC_STATUS_FUNC_MASK) >>
166-
IGC_STATUS_FUNC_SHIFT;
164+
hw->bus.func = FIELD_GET(IGC_STATUS_FUNC_MASK, rd32(IGC_STATUS));
167165

168166
/* Make sure the PHY is in a good state. Several people have reported
169167
* firmware leaving the PHY's page select register set to something

drivers/net/ethernet/intel/igc/igc_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ struct igc_adv_tx_context_desc {
3737
#define IGC_ADVTXD_TSTAMP_REG_1 0x00010000 /* Select register 1 for timestamp */
3838
#define IGC_ADVTXD_TSTAMP_REG_2 0x00020000 /* Select register 2 for timestamp */
3939
#define IGC_ADVTXD_TSTAMP_REG_3 0x00030000 /* Select register 3 for timestamp */
40+
#define IGC_ADVTXD_TSTAMP_TIMER_1 0x00010000 /* Select timer 1 for timestamp */
41+
#define IGC_ADVTXD_TSTAMP_TIMER_2 0x00020000 /* Select timer 2 for timestamp */
42+
#define IGC_ADVTXD_TSTAMP_TIMER_3 0x00030000 /* Select timer 3 for timestamp */
43+
4044
#define IGC_ADVTXD_DTYP_CTXT 0x00200000 /* Advanced Context Descriptor */
4145
#define IGC_ADVTXD_DTYP_DATA 0x00300000 /* Advanced Data Descriptor */
4246
#define IGC_ADVTXD_DCMD_EOP 0x01000000 /* End of Packet */

drivers/net/ethernet/intel/igc/igc_defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@
317317
#define IGC_TXD_CMD_TSE 0x04000000 /* TCP Seg enable */
318318
#define IGC_TXD_EXTCMD_TSTAMP 0x00000010 /* IEEE1588 Timestamp packet */
319319

320+
#define IGC_TXD_PTP2_TIMER_1 0x00000020
321+
320322
/* IPSec Encrypt Enable */
321323
#define IGC_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */
322324
#define IGC_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */

drivers/net/ethernet/intel/igc/igc_ethtool.c

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
956956
}
957957

958958
#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
959+
#define VLAN_TCI_FULL_MASK ((__force __be16)~0)
959960
static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
960961
struct ethtool_rxnfc *cmd)
961962
{
@@ -978,10 +979,16 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
978979
fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK;
979980
}
980981

982+
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) {
983+
fsp->flow_type |= FLOW_EXT;
984+
fsp->h_ext.vlan_etype = htons(rule->filter.vlan_etype);
985+
fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK;
986+
}
987+
981988
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
982989
fsp->flow_type |= FLOW_EXT;
983990
fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci);
984-
fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK);
991+
fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask);
985992
}
986993

987994
if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) {
@@ -1216,6 +1223,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
12161223

12171224
if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) {
12181225
rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci);
1226+
rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci);
12191227
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI;
12201228
}
12211229

@@ -1241,7 +1249,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
12411249

12421250
/* VLAN etype matching */
12431251
if ((fsp->flow_type & FLOW_EXT) && fsp->h_ext.vlan_etype) {
1244-
rule->filter.vlan_etype = fsp->h_ext.vlan_etype;
1252+
rule->filter.vlan_etype = ntohs(fsp->h_ext.vlan_etype);
12451253
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_ETYPE;
12461254
}
12471255

@@ -1253,11 +1261,19 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
12531261
memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data));
12541262
}
12551263

1256-
/* When multiple filter options or user data or vlan etype is set, use a
1257-
* flex filter.
1264+
/* The i225/i226 has various different filters. Flex filters provide a
1265+
* way to match up to the first 128 bytes of a packet. Use them for:
1266+
* a) For specific user data
1267+
* b) For VLAN EtherType
1268+
* c) For full TCI match
1269+
* d) Or in case multiple filter criteria are set
1270+
*
1271+
* Otherwise, use the simple MAC, VLAN PRIO or EtherType filters.
12581272
*/
12591273
if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) ||
12601274
(rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) ||
1275+
((rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) &&
1276+
rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) ||
12611277
(rule->filter.match_flags & (rule->filter.match_flags - 1)))
12621278
rule->flex = true;
12631279
else
@@ -1327,6 +1343,26 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,
13271343
return -EINVAL;
13281344
}
13291345

1346+
/* There are two ways to match the VLAN TCI:
1347+
* 1. Match on PCP field and use vlan prio filter for it
1348+
* 2. Match on complete TCI field and use flex filter for it
1349+
*/
1350+
if ((fsp->flow_type & FLOW_EXT) &&
1351+
fsp->m_ext.vlan_tci &&
1352+
fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) &&
1353+
fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) {
1354+
netdev_dbg(netdev, "VLAN mask not supported\n");
1355+
return -EOPNOTSUPP;
1356+
}
1357+
1358+
/* VLAN EtherType can only be matched by full mask. */
1359+
if ((fsp->flow_type & FLOW_EXT) &&
1360+
fsp->m_ext.vlan_etype &&
1361+
fsp->m_ext.vlan_etype != ETHER_TYPE_FULL_MASK) {
1362+
netdev_dbg(netdev, "VLAN EtherType mask not supported\n");
1363+
return -EOPNOTSUPP;
1364+
}
1365+
13301366
if (fsp->location >= IGC_MAX_RXNFC_RULES) {
13311367
netdev_dbg(netdev, "Invalid location\n");
13321368
return -EINVAL;
@@ -1593,12 +1629,16 @@ static int igc_ethtool_get_eee(struct net_device *netdev,
15931629
struct igc_hw *hw = &adapter->hw;
15941630
u32 eeer;
15951631

1596-
if (hw->dev_spec._base.eee_enable)
1597-
edata->advertised_u32 =
1598-
mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert);
1632+
linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
1633+
edata->supported);
1634+
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
1635+
edata->supported);
1636+
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
1637+
edata->supported);
15991638

1600-
*edata = adapter->eee;
1601-
edata->supported_u32 = SUPPORTED_Autoneg;
1639+
if (hw->dev_spec._base.eee_enable)
1640+
mii_eee_cap1_mod_linkmode_t(edata->advertised,
1641+
adapter->eee_advert);
16021642

16031643
eeer = rd32(IGC_EEER);
16041644

@@ -1611,17 +1651,14 @@ static int igc_ethtool_get_eee(struct net_device *netdev,
16111651

16121652
edata->eee_enabled = hw->dev_spec._base.eee_enable;
16131653

1614-
edata->advertised_u32 = SUPPORTED_Autoneg;
1615-
edata->lp_advertised_u32 = SUPPORTED_Autoneg;
1616-
16171654
/* Report correct negotiated EEE status for devices that
16181655
* wrongly report EEE at half-duplex
16191656
*/
16201657
if (adapter->link_duplex == HALF_DUPLEX) {
16211658
edata->eee_enabled = false;
16221659
edata->eee_active = false;
16231660
edata->tx_lpi_enabled = false;
1624-
edata->advertised_u32 &= ~edata->advertised_u32;
1661+
linkmode_zero(edata->advertised);
16251662
}
16261663

16271664
return 0;
@@ -1663,7 +1700,8 @@ static int igc_ethtool_set_eee(struct net_device *netdev,
16631700
return -EINVAL;
16641701
}
16651702

1666-
adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised_u32);
1703+
adapter->eee_advert = linkmode_to_mii_eee_cap1_t(edata->advertised);
1704+
16671705
if (hw->dev_spec._base.eee_enable != edata->eee_enabled) {
16681706
hw->dev_spec._base.eee_enable = edata->eee_enabled;
16691707
adapter->flags |= IGC_FLAG_EEE;
@@ -1678,21 +1716,6 @@ static int igc_ethtool_set_eee(struct net_device *netdev,
16781716
return 0;
16791717
}
16801718

1681-
static int igc_ethtool_begin(struct net_device *netdev)
1682-
{
1683-
struct igc_adapter *adapter = netdev_priv(netdev);
1684-
1685-
pm_runtime_get_sync(&adapter->pdev->dev);
1686-
return 0;
1687-
}
1688-
1689-
static void igc_ethtool_complete(struct net_device *netdev)
1690-
{
1691-
struct igc_adapter *adapter = netdev_priv(netdev);
1692-
1693-
pm_runtime_put(&adapter->pdev->dev);
1694-
}
1695-
16961719
static int igc_ethtool_get_link_ksettings(struct net_device *netdev,
16971720
struct ethtool_link_ksettings *cmd)
16981721
{
@@ -1992,8 +2015,6 @@ static const struct ethtool_ops igc_ethtool_ops = {
19922015
.set_priv_flags = igc_ethtool_set_priv_flags,
19932016
.get_eee = igc_ethtool_get_eee,
19942017
.set_eee = igc_ethtool_set_eee,
1995-
.begin = igc_ethtool_begin,
1996-
.complete = igc_ethtool_complete,
19972018
.get_link_ksettings = igc_ethtool_get_link_ksettings,
19982019
.set_link_ksettings = igc_ethtool_set_link_ksettings,
19992020
.self_test = igc_ethtool_diag_test,

drivers/net/ethernet/intel/igc/igc_i225.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (c) 2018 Intel Corporation */
33

4+
#include <linux/bitfield.h>
45
#include <linux/delay.h>
56

67
#include "igc_hw.h"
@@ -578,9 +579,8 @@ s32 igc_set_ltr_i225(struct igc_hw *hw, bool link)
578579

579580
/* Calculate tw_system (nsec). */
580581
if (speed == SPEED_100) {
581-
tw_system = ((rd32(IGC_EEE_SU) &
582-
IGC_TW_SYSTEM_100_MASK) >>
583-
IGC_TW_SYSTEM_100_SHIFT) * 500;
582+
tw_system = FIELD_GET(IGC_TW_SYSTEM_100_MASK,
583+
rd32(IGC_EEE_SU)) * 500;
584584
} else {
585585
tw_system = (rd32(IGC_EEE_SU) &
586586
IGC_TW_SYSTEM_1000_MASK) * 500;

0 commit comments

Comments
 (0)