Skip to content

Commit 3fec58f

Browse files
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== igc: Add support for Frame Preemption Faizal Rahim says: Introduce support for the FPE feature in the IGC driver. The patches aligns with the upstream FPE API: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/ https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/ It builds upon earlier work: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/ The patch series adds the following functionalities to the IGC driver: a) Configure FPE using `ethtool --set-mm`. b) Display FPE settings via `ethtool --show-mm`. c) View FPE statistics using `ethtool --include-statistics --show-mm'. e) Block setting preemptible tc in taprio since it is not supported yet. Existing code already blocks it in mqprio. Tested: Enabled CONFIG_PROVE_LOCKING, CONFIG_DEBUG_ATOMIC_SLEEP, CONFIG_DMA_API_DEBUG, and CONFIG_KASAN 1) selftests 2) netdev down/up cycles 3) suspend/resume cycles 4) fpe verification No bugs or unusual dmesg logs were observed. Ran 1), 2) and 3) with and without the patch series, compared dmesg and selftest logs - no differences found. * '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue: igc: add support to get frame preemption statistics via ethtool igc: add support to get MAC Merge data via ethtool igc: block setting preemptible traffic class in taprio igc: add support to set tx-min-frag-size igc: add support for frame preemption verification igc: set the RX packet buffer size for TSN mode igc: use FIELD_PREP and GENMASK for existing RX packet buffer size igc: optimize TX packet buffer utilization for TSN mode igc: use FIELD_PREP and GENMASK for existing TX packet buffer size igc: rename I225_RXPBSIZE_DEFAULT and I225_TXPBSIZE_DEFAULT igc: rename xdp_get_tx_ring() for non-xdp usage net: ethtool: mm: reset verification status when link is down net: ethtool: mm: extract stmmac verification logic into common library net: stmmac: move frag_size handling out of spin_lock ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a484fe8 + f05ce73 commit 3fec58f

File tree

17 files changed

+876
-221
lines changed

17 files changed

+876
-221
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ config IGC
369369
default n
370370
depends on PCI
371371
depends on PTP_1588_CLOCK_OPTIONAL
372+
depends on ETHTOOL_NETLINK
372373
help
373374
This driver supports Intel(R) Ethernet Controller I225-LM/I225-V
374375
family of adapters.

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ void igc_ethtool_set_ops(struct net_device *);
4040

4141
#define IGC_MAX_TX_TSTAMP_REGS 4
4242

43+
struct igc_fpe_t {
44+
struct ethtool_mmsv mmsv;
45+
u32 tx_min_frag_size;
46+
};
47+
4348
enum igc_mac_filter_type {
4449
IGC_MAC_FILTER_TYPE_DST = 0,
4550
IGC_MAC_FILTER_TYPE_SRC
@@ -333,6 +338,8 @@ struct igc_adapter {
333338
struct timespec64 period;
334339
} perout[IGC_N_PEROUT];
335340

341+
struct igc_fpe_t fpe;
342+
336343
/* LEDs */
337344
struct mutex led_mutex;
338345
struct igc_led_classdev *leds;
@@ -388,10 +395,11 @@ extern char igc_driver_name[];
388395
#define IGC_FLAG_TSN_QBV_ENABLED BIT(17)
389396
#define IGC_FLAG_TSN_QAV_ENABLED BIT(18)
390397
#define IGC_FLAG_TSN_LEGACY_ENABLED BIT(19)
398+
#define IGC_FLAG_TSN_PREEMPT_ENABLED BIT(20)
391399

392400
#define IGC_FLAG_TSN_ANY_ENABLED \
393401
(IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED | \
394-
IGC_FLAG_TSN_LEGACY_ENABLED)
402+
IGC_FLAG_TSN_LEGACY_ENABLED | IGC_FLAG_TSN_PREEMPT_ENABLED)
395403

396404
#define IGC_FLAG_RSS_FIELD_IPV4_UDP BIT(6)
397405
#define IGC_FLAG_RSS_FIELD_IPV6_UDP BIT(7)
@@ -736,7 +744,10 @@ struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter *adapter,
736744
u32 location);
737745
int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
738746
void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
739-
747+
void igc_disable_empty_addr_recv(struct igc_adapter *adapter);
748+
int igc_enable_empty_addr_recv(struct igc_adapter *adapter);
749+
struct igc_ring *igc_get_tx_ring(struct igc_adapter *adapter, int cpu);
750+
void igc_flush_tx_descriptors(struct igc_ring *ring);
740751
void igc_ptp_init(struct igc_adapter *adapter);
741752
void igc_ptp_reset(struct igc_adapter *adapter);
742753
void igc_ptp_suspend(struct igc_adapter *adapter);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct igc_adv_tx_context_desc {
4949
#define IGC_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */
5050
#define IGC_ADVTXD_DCMD_VLE 0x40000000 /* VLAN pkt enable */
5151
#define IGC_ADVTXD_DCMD_TSE 0x80000000 /* TCP Seg enable */
52+
#define IGC_ADVTXD_PAYLEN_MASK 0XFFFFC000 /* Adv desc PAYLEN mask */
5253
#define IGC_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */
5354

5455
#define IGC_RAR_ENTRIES 16

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

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@
308308
#define IGC_TXD_DTYP_C 0x00000000 /* Context Descriptor */
309309
#define IGC_TXD_POPTS_IXSM 0x01 /* Insert IP checksum */
310310
#define IGC_TXD_POPTS_TXSM 0x02 /* Insert TCP/UDP checksum */
311+
#define IGC_TXD_POPTS_SMD_MASK 0x3000 /* Indicates whether it's SMD-V or SMD-R */
312+
311313
#define IGC_TXD_CMD_EOP 0x01000000 /* End of Packet */
312314
#define IGC_TXD_CMD_IC 0x04000000 /* Insert Checksum */
313315
#define IGC_TXD_CMD_DEXT 0x20000000 /* Desc extension (0 = legacy) */
@@ -363,6 +365,8 @@
363365
#define IGC_SRRCTL_TIMER0SEL(timer) (((timer) & 0x3) << 17)
364366

365367
/* Receive Descriptor bit definitions */
368+
#define IGC_RXD_STAT_SMD_TYPE_V 0x01 /* SMD-V Packet */
369+
#define IGC_RXD_STAT_SMD_TYPE_R 0x02 /* SMD-R Packet */
366370
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
367371
#define IGC_RXD_STAT_IXSM 0x04 /* Ignore checksum */
368372
#define IGC_RXD_STAT_UDPCS 0x10 /* UDP xsum calculated */
@@ -372,7 +376,8 @@
372376
#define IGC_RXDEXT_STATERR_LB 0x00040000
373377

374378
/* Advanced Receive Descriptor bit definitions */
375-
#define IGC_RXDADV_STAT_TSIP 0x08000 /* timestamp in packet */
379+
#define IGC_RXDADV_STAT_SMD_TYPE_MASK 0x06000
380+
#define IGC_RXDADV_STAT_TSIP 0x08000 /* timestamp in packet */
376381

377382
#define IGC_RXDEXT_STATERR_L4E 0x20000000
378383
#define IGC_RXDEXT_STATERR_IPE 0x40000000
@@ -396,11 +401,47 @@
396401
#define IGC_RCTL_PMCF 0x00800000 /* pass MAC control frames */
397402
#define IGC_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */
398403

399-
#define I225_RXPBSIZE_DEFAULT 0x000000A2 /* RXPBSIZE default */
400-
#define I225_TXPBSIZE_DEFAULT 0x04000014 /* TXPBSIZE default */
401-
#define IGC_RXPBS_CFG_TS_EN 0x80000000 /* Timestamp in Rx buffer */
402-
403-
#define IGC_TXPBSIZE_TSN 0x04145145 /* 5k bytes buffer for each queue */
404+
/* Mask for RX packet buffer size */
405+
#define IGC_RXPBSIZE_EXP_MASK GENMASK(5, 0)
406+
#define IGC_BMC2OSPBSIZE_MASK GENMASK(11, 6)
407+
#define IGC_RXPBSIZE_BE_MASK GENMASK(17, 12)
408+
/* Mask for timestamp in RX buffer */
409+
#define IGC_RXPBS_CFG_TS_EN_MASK GENMASK(31, 31)
410+
/* High-priority RX packet buffer size (KB). Used for Express traffic when preemption is enabled */
411+
#define IGC_RXPBSIZE_EXP(x) FIELD_PREP(IGC_RXPBSIZE_EXP_MASK, (x))
412+
/* BMC to OS packet buffer size in KB */
413+
#define IGC_BMC2OSPBSIZE(x) FIELD_PREP(IGC_BMC2OSPBSIZE_MASK, (x))
414+
/* Low-priority RX packet buffer size (KB). Used for BE traffic when preemption is enabled */
415+
#define IGC_RXPBSIZE_BE(x) FIELD_PREP(IGC_RXPBSIZE_BE_MASK, (x))
416+
/* Enable RX packet buffer for timestamp descriptor, saving 16 bytes per packet if set */
417+
#define IGC_RXPBS_CFG_TS_EN FIELD_PREP(IGC_RXPBS_CFG_TS_EN_MASK, 1)
418+
/* Default value following I225/I226 SW User Manual Section 8.3.1 */
419+
#define IGC_RXPBSIZE_EXP_BMC_DEFAULT ( \
420+
IGC_RXPBSIZE_EXP(34) | IGC_BMC2OSPBSIZE(2))
421+
#define IGC_RXPBSIZE_EXP_BMC_BE_TSN ( \
422+
IGC_RXPBSIZE_EXP(15) | IGC_BMC2OSPBSIZE(2) | IGC_RXPBSIZE_BE(15))
423+
424+
/* Mask for TX packet buffer size */
425+
#define IGC_TXPB0SIZE_MASK GENMASK(5, 0)
426+
#define IGC_TXPB1SIZE_MASK GENMASK(11, 6)
427+
#define IGC_TXPB2SIZE_MASK GENMASK(17, 12)
428+
#define IGC_TXPB3SIZE_MASK GENMASK(23, 18)
429+
/* Mask for OS to BMC packet buffer size */
430+
#define IGC_OS2BMCPBSIZE_MASK GENMASK(29, 24)
431+
/* TX Packet buffer size in KB */
432+
#define IGC_TXPB0SIZE(x) FIELD_PREP(IGC_TXPB0SIZE_MASK, (x))
433+
#define IGC_TXPB1SIZE(x) FIELD_PREP(IGC_TXPB1SIZE_MASK, (x))
434+
#define IGC_TXPB2SIZE(x) FIELD_PREP(IGC_TXPB2SIZE_MASK, (x))
435+
#define IGC_TXPB3SIZE(x) FIELD_PREP(IGC_TXPB3SIZE_MASK, (x))
436+
/* OS to BMC packet buffer size in KB */
437+
#define IGC_OS2BMCPBSIZE(x) FIELD_PREP(IGC_OS2BMCPBSIZE_MASK, (x))
438+
/* Default value following I225/I226 SW User Manual Section 8.3.2 */
439+
#define IGC_TXPBSIZE_DEFAULT ( \
440+
IGC_TXPB0SIZE(20) | IGC_TXPB1SIZE(0) | IGC_TXPB2SIZE(0) | \
441+
IGC_TXPB3SIZE(0) | IGC_OS2BMCPBSIZE(4))
442+
#define IGC_TXPBSIZE_TSN ( \
443+
IGC_TXPB0SIZE(7) | IGC_TXPB1SIZE(7) | IGC_TXPB2SIZE(7) | \
444+
IGC_TXPB3SIZE(7) | IGC_OS2BMCPBSIZE(4))
404445

405446
#define IGC_DTXMXPKTSZ_TSN 0x19 /* 1600 bytes of max TX DMA packet size */
406447
#define IGC_DTXMXPKTSZ_DEFAULT 0x98 /* 9728-byte Jumbo frames */
@@ -539,8 +580,10 @@
539580

540581
/* Transmit Scheduling */
541582
#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
583+
#define IGC_TQAVCTRL_PREEMPT_ENA 0x00000002
542584
#define IGC_TQAVCTRL_ENHANCED_QAV 0x00000008
543585
#define IGC_TQAVCTRL_FUTSCDDIS 0x00000080
586+
#define IGC_TQAVCTRL_MIN_FRAG_MASK 0x0000C000
544587

545588
#define IGC_TXQCTL_QUEUE_MODE_LAUNCHT 0x00000001
546589
#define IGC_TXQCTL_STRICT_CYCLE 0x00000002

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "igc.h"
1010
#include "igc_diag.h"
11+
#include "igc_tsn.h"
1112

1213
/* forward declaration */
1314
struct igc_stats {
@@ -1781,6 +1782,83 @@ static int igc_ethtool_set_eee(struct net_device *netdev,
17811782
return 0;
17821783
}
17831784

1785+
static int igc_ethtool_get_mm(struct net_device *netdev,
1786+
struct ethtool_mm_state *cmd)
1787+
{
1788+
struct igc_adapter *adapter = netdev_priv(netdev);
1789+
struct igc_fpe_t *fpe = &adapter->fpe;
1790+
1791+
ethtool_mmsv_get_mm(&fpe->mmsv, cmd);
1792+
cmd->tx_min_frag_size = fpe->tx_min_frag_size;
1793+
cmd->rx_min_frag_size = IGC_RX_MIN_FRAG_SIZE;
1794+
1795+
return 0;
1796+
}
1797+
1798+
static int igc_ethtool_set_mm(struct net_device *netdev,
1799+
struct ethtool_mm_cfg *cmd,
1800+
struct netlink_ext_ack *extack)
1801+
{
1802+
struct igc_adapter *adapter = netdev_priv(netdev);
1803+
struct igc_fpe_t *fpe = &adapter->fpe;
1804+
1805+
fpe->tx_min_frag_size = igc_fpe_get_supported_frag_size(cmd->tx_min_frag_size);
1806+
if (fpe->tx_min_frag_size != cmd->tx_min_frag_size)
1807+
NL_SET_ERR_MSG_MOD(extack,
1808+
"tx-min-frag-size value set is unsupported. Rounded up to supported value (64, 128, 192, 256)");
1809+
1810+
if (fpe->mmsv.pmac_enabled != cmd->pmac_enabled) {
1811+
if (cmd->pmac_enabled)
1812+
static_branch_inc(&igc_fpe_enabled);
1813+
else
1814+
static_branch_dec(&igc_fpe_enabled);
1815+
}
1816+
1817+
ethtool_mmsv_set_mm(&fpe->mmsv, cmd);
1818+
1819+
return igc_tsn_offload_apply(adapter);
1820+
}
1821+
1822+
/**
1823+
* igc_ethtool_get_frame_ass_error - Get the frame assembly error count.
1824+
* @reg_value: Register value for IGC_PRMEXCPRCNT
1825+
* Return: The count of frame assembly errors.
1826+
*/
1827+
static u64 igc_ethtool_get_frame_ass_error(u32 reg_value)
1828+
{
1829+
/* Out of order statistics */
1830+
u32 ooo_frame_cnt, ooo_frag_cnt;
1831+
u32 miss_frame_frag_cnt;
1832+
1833+
ooo_frame_cnt = FIELD_GET(IGC_PRMEXCPRCNT_OOO_FRAME_CNT, reg_value);
1834+
ooo_frag_cnt = FIELD_GET(IGC_PRMEXCPRCNT_OOO_FRAG_CNT, reg_value);
1835+
miss_frame_frag_cnt = FIELD_GET(IGC_PRMEXCPRCNT_MISS_FRAME_FRAG_CNT,
1836+
reg_value);
1837+
1838+
return ooo_frame_cnt + ooo_frag_cnt + miss_frame_frag_cnt;
1839+
}
1840+
1841+
static u64 igc_ethtool_get_frame_smd_error(u32 reg_value)
1842+
{
1843+
return FIELD_GET(IGC_PRMEXCPRCNT_OOO_SMDC, reg_value);
1844+
}
1845+
1846+
static void igc_ethtool_get_mm_stats(struct net_device *dev,
1847+
struct ethtool_mm_stats *stats)
1848+
{
1849+
struct igc_adapter *adapter = netdev_priv(dev);
1850+
struct igc_hw *hw = &adapter->hw;
1851+
u32 reg_value;
1852+
1853+
reg_value = rd32(IGC_PRMEXCPRCNT);
1854+
1855+
stats->MACMergeFrameAssErrorCount = igc_ethtool_get_frame_ass_error(reg_value);
1856+
stats->MACMergeFrameSmdErrorCount = igc_ethtool_get_frame_smd_error(reg_value);
1857+
stats->MACMergeFrameAssOkCount = rd32(IGC_PRMPTDRCNT);
1858+
stats->MACMergeFragCountRx = rd32(IGC_PRMEVNTRCNT);
1859+
stats->MACMergeFragCountTx = rd32(IGC_PRMEVNTTCNT);
1860+
}
1861+
17841862
static int igc_ethtool_get_link_ksettings(struct net_device *netdev,
17851863
struct ethtool_link_ksettings *cmd)
17861864
{
@@ -2076,6 +2154,9 @@ static const struct ethtool_ops igc_ethtool_ops = {
20762154
.get_link_ksettings = igc_ethtool_get_link_ksettings,
20772155
.set_link_ksettings = igc_ethtool_set_link_ksettings,
20782156
.self_test = igc_ethtool_diag_test,
2157+
.get_mm = igc_ethtool_get_mm,
2158+
.get_mm_stats = igc_ethtool_get_mm_stats,
2159+
.set_mm = igc_ethtool_set_mm,
20792160
};
20802161

20812162
void igc_ethtool_set_ops(struct net_device *netdev)

0 commit comments

Comments
 (0)