From c7e26db10bd4c8d2c97ff727274e9aa66bf925ac Mon Sep 17 00:00:00 2001 From: snokvist Date: Sat, 21 Nov 2026 12:00:00 +0100 Subject: [PATCH 1/2] rtl8733b: use the shared bulk-boundary helpers (follow-up to #592) send_packet and the agg limits carried their own copies of the speed-to-MPS expression and the PKT_OFFSET boundary test. Use usb_bulk_mps() and single_block_pkt_offset() from TxAggPlan.h instead. Same values on every speed; the RTL8733B is USB-only, so no PCIe guard. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011dReg158JQxkhEWGPBro5f --- src/rtl8733b/Rtl8733bDevice.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/rtl8733b/Rtl8733bDevice.cpp b/src/rtl8733b/Rtl8733bDevice.cpp index f264426e..08cc9441 100644 --- a/src/rtl8733b/Rtl8733bDevice.cpp +++ b/src/rtl8733b/Rtl8733bDevice.cpp @@ -617,13 +617,8 @@ bool Rtl8733bDevice::send_packet(const uint8_t *packet, size_t length) { if (radiotap_length == 0) return false; const size_t frame_len = length - radiotap_length; - const size_t bulk_packet = _device.speed() >= devourer::kUsbSpeedSuper - ? 1024u - : _device.speed() >= devourer::kUsbSpeedHigh - ? 512u - : 64u; - const uint8_t packet_offset = - (rtl8733b::kTxDescSize + frame_len) % bulk_packet == 0 ? 1 : 0; + const uint8_t packet_offset = devourer::single_block_pkt_offset( + rtl8733b::kTxDescSize, frame_len, devourer::usb_bulk_mps(_device.speed())); std::vector usb_frame(rtl8733b::kTxDescSize + static_cast(packet_offset) * 8u + frame_len, @@ -780,9 +775,7 @@ size_t Rtl8733bDevice::send_packets(const TxPacketView *pkts, size_t count) { devourer::TxAggLimits lim; lim.desc_size = rtl8733b::kTxDescSize; - lim.bulk_size = _device.speed() >= devourer::kUsbSpeedSuper ? 1024 - : _device.speed() >= devourer::kUsbSpeedHigh ? 512 - : 64; + lim.bulk_size = devourer::usb_bulk_mps(_device.speed()); /* BLK_DESC_NUM: MAC init already programs 3 into DWBCN0_CTRL[7:4] * (Halmac8733bMac.cpp) — the same field and value the HalMAC 88xx siblings * use — so 3 descriptors per bulk transfer is what this TXDMA parses. From 33a64b5ed2f6f4dea1c9087f59fcb08ce6eceaef Mon Sep 17 00:00:00 2001 From: snokvist Date: Sat, 21 Nov 2026 12:17:39 +0100 Subject: [PATCH 2/2] jaguar1: the agg limits use usb_bulk_mps() too The last hand-written copy of the speed-to-MPS expression. Same values on every speed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011dReg158JQxkhEWGPBro5f --- src/jaguar1/RtlJaguarDevice.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/jaguar1/RtlJaguarDevice.cpp b/src/jaguar1/RtlJaguarDevice.cpp index 135a1045..8b0ad226 100644 --- a/src/jaguar1/RtlJaguarDevice.cpp +++ b/src/jaguar1/RtlJaguarDevice.cpp @@ -1190,9 +1190,7 @@ size_t RtlJaguarDevice::send_packets(const TxPacketView *pkts, size_t count) { devourer::TxAggLimits lim; lim.desc_size = TXDESC_SIZE; - lim.bulk_size = _device.speed() >= devourer::kUsbSpeedSuper ? 1024 - : _device.speed() >= devourer::kUsbSpeedHigh ? 512 - : 64; + lim.bulk_size = devourer::usb_bulk_mps(_device.speed()); /* MAX_TX_AGG_PACKET_NUMBER_8812: the Jaguar1 TXDMA takes at most 64 blocks * per transfer (vendor hal_com_reg.h). */ lim.max_frames = std::min(agg, 64u);