Skip to content

Commit

Permalink
Fix PCNET BCNT computation (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc authored Nov 16, 2020
1 parent 60ab58c commit 9f46e0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/kernel/net/pcnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 9f46e0d

Please sign in to comment.