Rename BCD -> BDC. That's what Broadcom calls it. Still no idea what it means.

This commit is contained in:
Dario Nieuwenhuis 2023-05-08 22:01:44 +02:00
parent 881e9d07d2
commit 6b5d9642d5
2 changed files with 22 additions and 22 deletions

View File

@ -249,7 +249,7 @@ where
let mut buf = [0; 512]; let mut buf = [0; 512];
let buf8 = slice8_mut(&mut buf); let buf8 = slice8_mut(&mut buf);
// There MUST be 2 bytes of padding between the SDPCM and BCD headers. // There MUST be 2 bytes of padding between the SDPCM and BDC headers.
// And ONLY for data packets! // And ONLY for data packets!
// No idea why, but the firmware will append two zero bytes to the tx'd packets // No idea why, but the firmware will append two zero bytes to the tx'd packets
// otherwise. If the packet is exactly 1514 bytes (the max MTU), this makes it // otherwise. If the packet is exactly 1514 bytes (the max MTU), this makes it
@ -258,7 +258,7 @@ where
// 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 // 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
// ¯\_(ツ)_/¯ // ¯\_(ツ)_/¯
const PADDING_SIZE: usize = 2; const PADDING_SIZE: usize = 2;
let total_len = SdpcmHeader::SIZE + PADDING_SIZE + BcdHeader::SIZE + packet.len(); let total_len = SdpcmHeader::SIZE + PADDING_SIZE + BdcHeader::SIZE + packet.len();
let seq = self.sdpcm_seq; let seq = self.sdpcm_seq;
self.sdpcm_seq = self.sdpcm_seq.wrapping_add(1); self.sdpcm_seq = self.sdpcm_seq.wrapping_add(1);
@ -275,19 +275,19 @@ where
reserved: [0, 0], reserved: [0, 0],
}; };
let bcd_header = BcdHeader { let bdc_header = BdcHeader {
flags: BDC_VERSION << BDC_VERSION_SHIFT, flags: BDC_VERSION << BDC_VERSION_SHIFT,
priority: 0, priority: 0,
flags2: 0, flags2: 0,
data_offset: 0, data_offset: 0,
}; };
trace!("tx {:?}", sdpcm_header); trace!("tx {:?}", sdpcm_header);
trace!(" {:?}", bcd_header); trace!(" {:?}", bdc_header);
buf8[0..SdpcmHeader::SIZE].copy_from_slice(&sdpcm_header.to_bytes()); buf8[0..SdpcmHeader::SIZE].copy_from_slice(&sdpcm_header.to_bytes());
buf8[SdpcmHeader::SIZE + PADDING_SIZE..][..BcdHeader::SIZE] buf8[SdpcmHeader::SIZE + PADDING_SIZE..][..BdcHeader::SIZE]
.copy_from_slice(&bcd_header.to_bytes()); .copy_from_slice(&bdc_header.to_bytes());
buf8[SdpcmHeader::SIZE + PADDING_SIZE + BcdHeader::SIZE..][..packet.len()] buf8[SdpcmHeader::SIZE + PADDING_SIZE + BdcHeader::SIZE..][..packet.len()]
.copy_from_slice(packet); .copy_from_slice(packet);
let total_len = (total_len + 3) & !3; // round up to 4byte let total_len = (total_len + 3) & !3; // round up to 4byte
@ -366,13 +366,13 @@ where
} }
} }
CHANNEL_TYPE_EVENT => { CHANNEL_TYPE_EVENT => {
let Some((_, bcd_packet)) = BcdHeader::parse(payload) else { let Some((_, bdc_packet)) = BdcHeader::parse(payload) else {
warn!("BCD event, incomplete header"); warn!("BDC event, incomplete header");
return; return;
}; };
let Some((event_packet, evt_data)) = EventPacket::parse(bcd_packet) else { let Some((event_packet, evt_data)) = EventPacket::parse(bdc_packet) else {
warn!("BCD event, incomplete data"); warn!("BDC event, incomplete data");
return; return;
}; };
@ -439,7 +439,7 @@ where
} }
} }
CHANNEL_TYPE_DATA => { CHANNEL_TYPE_DATA => {
let Some((_, packet)) = BcdHeader::parse(payload) else { return }; let Some((_, packet)) = BdcHeader::parse(payload) else { return };
trace!("rx pkt {:02x}", Bytes(&packet[..packet.len().min(48)])); trace!("rx pkt {:02x}", Bytes(&packet[..packet.len().min(48)]));
match self.ch.try_rx_buf() { match self.ch.try_rx_buf() {

View File

@ -165,7 +165,7 @@ pub const BDC_VERSION_SHIFT: u8 = 4;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[repr(C)] #[repr(C)]
pub struct BcdHeader { pub struct BdcHeader {
pub flags: u8, pub flags: u8,
/// 802.1d Priority (low 3 bits) /// 802.1d Priority (low 3 bits)
pub priority: u8, pub priority: u8,
@ -173,24 +173,24 @@ pub struct BcdHeader {
/// Offset from end of BDC header to packet data, in 4-uint8_t words. Leaves room for optional headers. /// Offset from end of BDC header to packet data, in 4-uint8_t words. Leaves room for optional headers.
pub data_offset: u8, pub data_offset: u8,
} }
impl_bytes!(BcdHeader); impl_bytes!(BdcHeader);
impl BcdHeader { impl BdcHeader {
pub fn parse(packet: &mut [u8]) -> Option<(&mut Self, &mut [u8])> { pub fn parse(packet: &mut [u8]) -> Option<(&mut Self, &mut [u8])> {
if packet.len() < Self::SIZE { if packet.len() < Self::SIZE {
return None; return None;
} }
let (bcd_header, bcd_packet) = packet.split_at_mut(Self::SIZE); let (bdc_header, bdc_packet) = packet.split_at_mut(Self::SIZE);
let bcd_header = Self::from_bytes_mut(bcd_header.try_into().unwrap()); let bdc_header = Self::from_bytes_mut(bdc_header.try_into().unwrap());
trace!(" {:?}", bcd_header); trace!(" {:?}", bdc_header);
let packet_start = 4 * bcd_header.data_offset as usize; let packet_start = 4 * bdc_header.data_offset as usize;
let bcd_packet = bcd_packet.get_mut(packet_start..)?; let bdc_packet = bdc_packet.get_mut(packet_start..)?;
trace!(" {:02x}", Bytes(&bcd_packet[..bcd_packet.len().min(36)])); trace!(" {:02x}", Bytes(&bdc_packet[..bdc_packet.len().min(36)]));
Some((bcd_header, bcd_packet)) Some((bdc_header, bdc_packet))
} }
} }