aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-05-08 21:45:54 +0200
committerDario Nieuwenhuis <[email protected]>2023-05-08 21:53:03 +0200
commit881e9d07d2e1107b27952c8bfe1d5afeef172165 (patch)
treef3166ce24f2f86ee83e9a7748735d7e9aefc3778
parenta7dee5b65c602637f8209d46d4611ed846a17459 (diff)
Fix missing padding in tx. Makes max-sized packets not get dropped
-rw-r--r--src/runner.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/runner.rs b/src/runner.rs
index 98f8aff7f..1d8ec4359 100644
--- a/src/runner.rs
+++ b/src/runner.rs
@@ -249,7 +249,16 @@ where
249 let mut buf = [0; 512]; 249 let mut buf = [0; 512];
250 let buf8 = slice8_mut(&mut buf); 250 let buf8 = slice8_mut(&mut buf);
251 251
252 let total_len = SdpcmHeader::SIZE + BcdHeader::SIZE + packet.len(); 252 // There MUST be 2 bytes of padding between the SDPCM and BCD headers.
253 // And ONLY for data packets!
254 // No idea why, but the firmware will append two zero bytes to the tx'd packets
255 // otherwise. If the packet is exactly 1514 bytes (the max MTU), this makes it
256 // be oversized and get dropped.
257 // WHD adds it here https://github.com/Infineon/wifi-host-driver/blob/c04fcbb6b0d049304f376cf483fd7b1b570c8cd5/WiFi_Host_Driver/src/include/whd_sdpcm.h#L90
258 // and adds it to the header size her https://github.com/Infineon/wifi-host-driver/blob/c04fcbb6b0d049304f376cf483fd7b1b570c8cd5/WiFi_Host_Driver/src/whd_sdpcm.c#L597
259 // ¯\_(ツ)_/¯
260 const PADDING_SIZE: usize = 2;
261 let total_len = SdpcmHeader::SIZE + PADDING_SIZE + BcdHeader::SIZE + packet.len();
253 262
254 let seq = self.sdpcm_seq; 263 let seq = self.sdpcm_seq;
255 self.sdpcm_seq = self.sdpcm_seq.wrapping_add(1); 264 self.sdpcm_seq = self.sdpcm_seq.wrapping_add(1);
@@ -260,7 +269,7 @@ where
260 sequence: seq, 269 sequence: seq,
261 channel_and_flags: CHANNEL_TYPE_DATA, 270 channel_and_flags: CHANNEL_TYPE_DATA,
262 next_length: 0, 271 next_length: 0,
263 header_length: SdpcmHeader::SIZE as _, 272 header_length: (SdpcmHeader::SIZE + PADDING_SIZE) as _,
264 wireless_flow_control: 0, 273 wireless_flow_control: 0,
265 bus_data_credit: 0, 274 bus_data_credit: 0,
266 reserved: [0, 0], 275 reserved: [0, 0],
@@ -276,8 +285,10 @@ where
276 trace!(" {:?}", bcd_header); 285 trace!(" {:?}", bcd_header);
277 286
278 buf8[0..SdpcmHeader::SIZE].copy_from_slice(&sdpcm_header.to_bytes()); 287 buf8[0..SdpcmHeader::SIZE].copy_from_slice(&sdpcm_header.to_bytes());
279 buf8[SdpcmHeader::SIZE..][..BcdHeader::SIZE].copy_from_slice(&bcd_header.to_bytes()); 288 buf8[SdpcmHeader::SIZE + PADDING_SIZE..][..BcdHeader::SIZE]
280 buf8[SdpcmHeader::SIZE + BcdHeader::SIZE..][..packet.len()].copy_from_slice(packet); 289 .copy_from_slice(&bcd_header.to_bytes());
290 buf8[SdpcmHeader::SIZE + PADDING_SIZE + BcdHeader::SIZE..][..packet.len()]
291 .copy_from_slice(packet);
281 292
282 let total_len = (total_len + 3) & !3; // round up to 4byte 293 let total_len = (total_len + 3) & !3; // round up to 4byte
283 294