[PATCH iwl-next v2 8/8] igc: SW pad preemptible frames for correct mCRC calculation

Faizal Rahim posted 8 patches 9 months ago
There is a newer version of this series
[PATCH iwl-next v2 8/8] igc: SW pad preemptible frames for correct mCRC calculation
Posted by Faizal Rahim 9 months ago
From: Chwee-Lin Choong <chwee.lin.choong@intel.com>

A hardware-padded frame transmitted from the preemptible queue
results in an incorrect mCRC computation by hardware, as the
padding bytes are not included in the mCRC calculation.

To address this, manually pad frames in preemptible queues to a
minimum length of 60 bytes using skb_padto() before transmission.
This ensures that the hardware includes the padding bytes in the
mCRC computation, producing a correct mCRC value.

Signed-off-by: Chwee-Lin Choong <chwee.lin.choong@intel.com>
Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 4d748eca0c6c..509f95651f25 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -1685,6 +1685,15 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb,
 	first->tx_flags = tx_flags;
 	first->protocol = protocol;
 
+	/* For preemptible queue, manually pad the skb so that HW includes
+	 * padding bytes in mCRC calculation
+	 */
+	if (tx_ring->preemptible && skb->len < ETH_ZLEN) {
+		if (skb_padto(skb, ETH_ZLEN))
+			goto out_drop;
+		skb_put(skb, ETH_ZLEN - skb->len);
+	}
+
 	tso = igc_tso(tx_ring, first, launch_time, first_flag, &hdr_len);
 	if (tso < 0)
 		goto out_drop;
-- 
2.34.1
Re: [PATCH iwl-next v2 8/8] igc: SW pad preemptible frames for correct mCRC calculation
Posted by Simon Horman 8 months, 4 weeks ago
On Wed, May 14, 2025 at 12:29:45AM -0400, Faizal Rahim wrote:
> From: Chwee-Lin Choong <chwee.lin.choong@intel.com>
> 
> A hardware-padded frame transmitted from the preemptible queue
> results in an incorrect mCRC computation by hardware, as the
> padding bytes are not included in the mCRC calculation.
> 
> To address this, manually pad frames in preemptible queues to a
> minimum length of 60 bytes using skb_padto() before transmission.
> This ensures that the hardware includes the padding bytes in the
> mCRC computation, producing a correct mCRC value.
> 
> Signed-off-by: Chwee-Lin Choong <chwee.lin.choong@intel.com>
> Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>

Hi Faizal, all,

Perhaps it would be best to shuffle this patch within this series
so that it appears before the patches that add pre-emption support.
That way, when the are added the bug isn't present.
Re: [PATCH iwl-next v2 8/8] igc: SW pad preemptible frames for correct mCRC calculation
Posted by Abdul Rahim, Faizal 8 months, 3 weeks ago

On 16/5/2025 5:43 pm, Simon Horman wrote:
> On Wed, May 14, 2025 at 12:29:45AM -0400, Faizal Rahim wrote:
>> From: Chwee-Lin Choong <chwee.lin.choong@intel.com>
>>
>> A hardware-padded frame transmitted from the preemptible queue
>> results in an incorrect mCRC computation by hardware, as the
>> padding bytes are not included in the mCRC calculation.
>>
>> To address this, manually pad frames in preemptible queues to a
>> minimum length of 60 bytes using skb_padto() before transmission.
>> This ensures that the hardware includes the padding bytes in the
>> mCRC computation, producing a correct mCRC value.
>>
>> Signed-off-by: Chwee-Lin Choong <chwee.lin.choong@intel.com>
>> Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
> 
> Hi Faizal, all,
> 
> Perhaps it would be best to shuffle this patch within this series
> so that it appears before the patches that add pre-emption support.
> That way, when the are added the bug isn't present.
> 

Makes sense, will update. Thanks!