Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-q ueue

Tony Nguyen says:

====================
Intel Wired LAN Driver Updates 2024-08-07 (igc)

This series contains updates to igc driver only.

Faizal adjusts the size of the MAC internal buffer on i226 devices to
resolve an errata for leaking packet transmits. He also corrects a
condition in which qbv_config_change_errors are incorrectly counted.
Lastly, he adjusts the conditions for resetting the adapter when
changing TSN Tx mode and corrects the conditions in which gtxoffset
register is set.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+75 -16
+6
drivers/net/ethernet/intel/igc/igc_defines.h
··· 404 404 #define IGC_DTXMXPKTSZ_TSN 0x19 /* 1600 bytes of max TX DMA packet size */ 405 405 #define IGC_DTXMXPKTSZ_DEFAULT 0x98 /* 9728-byte Jumbo frames */ 406 406 407 + /* Retry Buffer Control */ 408 + #define IGC_RETX_CTL 0x041C 409 + #define IGC_RETX_CTL_WATERMARK_MASK 0xF 410 + #define IGC_RETX_CTL_QBVFULLTH_SHIFT 8 /* QBV Retry Buffer Full Threshold */ 411 + #define IGC_RETX_CTL_QBVFULLEN 0x1000 /* Enable QBV Retry Buffer Full Threshold */ 412 + 407 413 /* Transmit Scheduling Latency */ 408 414 /* Latency between transmission scheduling (LaunchTime) and the time 409 415 * the packet is transmitted to the network in nanosecond.
+6 -2
drivers/net/ethernet/intel/igc/igc_main.c
··· 6315 6315 if (!validate_schedule(adapter, qopt)) 6316 6316 return -EINVAL; 6317 6317 6318 + igc_ptp_read(adapter, &now); 6319 + 6320 + if (igc_tsn_is_taprio_activated_by_user(adapter) && 6321 + is_base_time_past(qopt->base_time, &now)) 6322 + adapter->qbv_config_change_errors++; 6323 + 6318 6324 adapter->cycle_time = qopt->cycle_time; 6319 6325 adapter->base_time = qopt->base_time; 6320 6326 adapter->taprio_offload_enable = true; 6321 - 6322 - igc_ptp_read(adapter, &now); 6323 6327 6324 6328 for (n = 0; n < qopt->num_entries; n++) { 6325 6329 struct tc_taprio_sched_entry *e = &qopt->entries[n];
+62 -14
drivers/net/ethernet/intel/igc/igc_tsn.c
··· 49 49 return new_flags; 50 50 } 51 51 52 + static bool igc_tsn_is_tx_mode_in_tsn(struct igc_adapter *adapter) 53 + { 54 + struct igc_hw *hw = &adapter->hw; 55 + 56 + return !!(rd32(IGC_TQAVCTRL) & IGC_TQAVCTRL_TRANSMIT_MODE_TSN); 57 + } 58 + 52 59 void igc_tsn_adjust_txtime_offset(struct igc_adapter *adapter) 53 60 { 54 61 struct igc_hw *hw = &adapter->hw; 55 62 u16 txoffset; 56 63 57 - if (!is_any_launchtime(adapter)) 64 + if (!igc_tsn_is_tx_mode_in_tsn(adapter)) 58 65 return; 59 66 60 67 switch (adapter->link_speed) { ··· 85 78 wr32(IGC_GTXOFFSET, txoffset); 86 79 } 87 80 81 + static void igc_tsn_restore_retx_default(struct igc_adapter *adapter) 82 + { 83 + struct igc_hw *hw = &adapter->hw; 84 + u32 retxctl; 85 + 86 + retxctl = rd32(IGC_RETX_CTL) & IGC_RETX_CTL_WATERMARK_MASK; 87 + wr32(IGC_RETX_CTL, retxctl); 88 + } 89 + 90 + bool igc_tsn_is_taprio_activated_by_user(struct igc_adapter *adapter) 91 + { 92 + struct igc_hw *hw = &adapter->hw; 93 + 94 + return (rd32(IGC_BASET_H) || rd32(IGC_BASET_L)) && 95 + adapter->taprio_offload_enable; 96 + } 97 + 88 98 /* Returns the TSN specific registers to their default values after 89 99 * the adapter is reset. 90 100 */ ··· 114 90 wr32(IGC_GTXOFFSET, 0); 115 91 wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT); 116 92 wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT); 93 + 94 + if (igc_is_device_id_i226(hw)) 95 + igc_tsn_restore_retx_default(adapter); 117 96 118 97 tqavctrl = rd32(IGC_TQAVCTRL); 119 98 tqavctrl &= ~(IGC_TQAVCTRL_TRANSMIT_MODE_TSN | ··· 138 111 return 0; 139 112 } 140 113 114 + /* To partially fix i226 HW errata, reduce MAC internal buffering from 192 Bytes 115 + * to 88 Bytes by setting RETX_CTL register using the recommendation from: 116 + * a) Ethernet Controller I225/I226 Specification Update Rev 2.1 117 + * Item 9: TSN: Packet Transmission Might Cross the Qbv Window 118 + * b) I225/6 SW User Manual Rev 1.2.4: Section 8.11.5 Retry Buffer Control 119 + */ 120 + static void igc_tsn_set_retx_qbvfullthreshold(struct igc_adapter *adapter) 121 + { 122 + struct igc_hw *hw = &adapter->hw; 123 + u32 retxctl, watermark; 124 + 125 + retxctl = rd32(IGC_RETX_CTL); 126 + watermark = retxctl & IGC_RETX_CTL_WATERMARK_MASK; 127 + /* Set QBVFULLTH value using watermark and set QBVFULLEN */ 128 + retxctl |= (watermark << IGC_RETX_CTL_QBVFULLTH_SHIFT) | 129 + IGC_RETX_CTL_QBVFULLEN; 130 + wr32(IGC_RETX_CTL, retxctl); 131 + } 132 + 141 133 static int igc_tsn_enable_offload(struct igc_adapter *adapter) 142 134 { 143 135 struct igc_hw *hw = &adapter->hw; ··· 168 122 wr32(IGC_TSAUXC, 0); 169 123 wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_TSN); 170 124 wr32(IGC_TXPBS, IGC_TXPBSIZE_TSN); 125 + 126 + if (igc_is_device_id_i226(hw)) 127 + igc_tsn_set_retx_qbvfullthreshold(adapter); 171 128 172 129 for (i = 0; i < adapter->num_tx_queues; i++) { 173 130 struct igc_ring *ring = adapter->tx_ring[i]; ··· 311 262 s64 n = div64_s64(ktime_sub_ns(systim, base_time), cycle); 312 263 313 264 base_time = ktime_add_ns(base_time, (n + 1) * cycle); 314 - 315 - /* Increase the counter if scheduling into the past while 316 - * Gate Control List (GCL) is running. 317 - */ 318 - if ((rd32(IGC_BASET_H) || rd32(IGC_BASET_L)) && 319 - (adapter->tc_setup_type == TC_SETUP_QDISC_TAPRIO) && 320 - (adapter->qbv_count > 1)) 321 - adapter->qbv_config_change_errors++; 322 265 } else { 323 266 if (igc_is_device_id_i226(hw)) { 324 267 ktime_t adjust_time, expires_time; ··· 372 331 return err; 373 332 } 374 333 334 + static bool igc_tsn_will_tx_mode_change(struct igc_adapter *adapter) 335 + { 336 + bool any_tsn_enabled = !!(igc_tsn_new_flags(adapter) & 337 + IGC_FLAG_TSN_ANY_ENABLED); 338 + 339 + return (any_tsn_enabled && !igc_tsn_is_tx_mode_in_tsn(adapter)) || 340 + (!any_tsn_enabled && igc_tsn_is_tx_mode_in_tsn(adapter)); 341 + } 342 + 375 343 int igc_tsn_offload_apply(struct igc_adapter *adapter) 376 344 { 377 - struct igc_hw *hw = &adapter->hw; 378 - 379 - /* Per I225/6 HW Design Section 7.5.2.1, transmit mode 380 - * cannot be changed dynamically. Require reset the adapter. 345 + /* Per I225/6 HW Design Section 7.5.2.1 guideline, if tx mode change 346 + * from legacy->tsn or tsn->legacy, then reset adapter is needed. 381 347 */ 382 348 if (netif_running(adapter->netdev) && 383 - (igc_is_device_id_i225(hw) || !adapter->qbv_count)) { 349 + igc_tsn_will_tx_mode_change(adapter)) { 384 350 schedule_work(&adapter->reset_task); 385 351 return 0; 386 352 }
+1
drivers/net/ethernet/intel/igc/igc_tsn.h
··· 7 7 int igc_tsn_offload_apply(struct igc_adapter *adapter); 8 8 int igc_tsn_reset(struct igc_adapter *adapter); 9 9 void igc_tsn_adjust_txtime_offset(struct igc_adapter *adapter); 10 + bool igc_tsn_is_taprio_activated_by_user(struct igc_adapter *adapter); 10 11 11 12 #endif /* _IGC_BASE_H */