Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PCNET BCNT computation #122

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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