On Thu, Dec 03, 2026 at 09:40:53PM +0530, Vishnu Santhosh wrote:
> With QMAP, the multiplexing protocol handled by the rmnet driver, the > modem sets the length in the header of DATA packets to 0xffff. This > means that the payload fills the rest of the DMA transfer, which can > hold several QMAP packets. The driver treats 0xffff as a real length > and drops every such packet: > > Data larger than buffer? (65535 > 2040) > > Get the number of received bytes from the DMA result, and: > > - drop the buffer if the transfer failed or is shorter than a header > - take the payload length from the received size if the header says > 0xffff > - drop packets that claim more data than was received, replacing the > check against the buffer size, since a transfer cannot be larger > than the buffer > > Co-developed-by: Deepak Kumar Singh <deep…@oss.qualcomm.com> > Signed-off-by: Deepak Kumar Singh <deep…@oss.qualcomm.com> > Signed-off-by: Vishnu Santhosh <vish…@oss.qualcomm.com> > --- > drivers/net/wwan/qcom_bam_dmux.c | 38 ++++++++++++++++++++++++++++++-------- > 1 file changed, 30 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/wwan/qcom_bam_dmux.c b/drivers/net/wwan/qcom_bam_dmux.c > index e1cc3038a724ee2a3eba4a9d97715f1f5966452d..a7d05b1b8b1230d1d54e9a7abcbc16a16681797e 100644 > --- a/drivers/net/wwan/qcom_bam_dmux.c > +++ b/drivers/net/wwan/qcom_bam_dmux.c > [...] > @@ -593,9 +611,13 @@ static void bam_dmux_rx_callback(void *data) > goto out; > } > > + /* The remote side may leave it to us to use the DMA transfer size */ > + if (hdr->cmd == BAM_DMUX_CMD_DATA && hdr->len == BAM_DMUX_LEN_FROM_DMA) > + hdr->len = rx_len - sizeof(*hdr); > + > switch (hdr->cmd) { > case BAM_DMUX_CMD_DATA: > - bam_dmux_cmd_data(skb_dma); > + bam_dmux_cmd_data(skb_dma, rx_len); > break;
We already check for if (hdr->cmd == BAM_DMUX_CMD_DATA ...) in the switch statement here, so I think the code would be easier to read if you move the if statement above directly into bam_dmux_cmd_data(). I'm also not sure if we need to modify the hdr->len at all, since this is kind of a header/struct owned" by BAM-DMUX and not us. bam_dmux_cmd_data() could just read it into a variable and override it with your calculation from the BAM if it's BAM_DMUX_LEN_FROM_DMA. Thanks, Stephan