From a00d4c9b600ce4a173d413f6dafeb9e8c8839a4b Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Mon, 16 Nov 2020 10:21:32 +0100 Subject: [PATCH] Fix PCNET BCNT computation --- src/kernel/net/pcnet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/net/pcnet.rs b/src/kernel/net/pcnet.rs index c8dbdbdf7..fff237606 100644 --- a/src/kernel/net/pcnet.rs +++ b/src/kernel/net/pcnet.rs @@ -179,7 +179,7 @@ impl PCNET { des[DE_LEN * i + 3] = addr[3]; // Set buffer byte count (0..12 BCNT + 12..16 ONES) - let bcnt = ((((MTU as u16).reverse_bits() + 1) & 0x0FFF) | 0xF000).to_le_bytes(); + let bcnt = (0xF000 | (0x0FFF & (1 + !(MTU as u16)))).to_le_bytes(); des[DE_LEN * i + 4] = bcnt[0]; des[DE_LEN * i + 5] = bcnt[1]; @@ -413,7 +413,7 @@ impl phy::TxToken for TxToken { self.device.tx_des[tx_id * DE_LEN + 7].set_bit(DE_ENP, true); // Set end of packet // Set buffer byte count (0..12 BCNT + 12..16 ONES) - let bcnt = ((((len as u16).reverse_bits() + 1) & 0x0FFF) | 0xF000).to_le_bytes(); + let bcnt = (0xF000 | (0x0FFF & (1 + !(len as u16)))).to_le_bytes(); self.device.tx_des[tx_id * DE_LEN + 4] = bcnt[0]; self.device.tx_des[tx_id * DE_LEN + 5] = bcnt[1];