[PATCH 15/16] NTB: ntb_transport: Report the direct-DMA payload limit

From: Koichiro Den

Date: Mon Aug 10 2026 - 13:35:55 EST


ntb_transport_max_size() currently reports the copy-path limit, which
reserves space for struct ntb_payload_header. Direct DMA bypasses that
layout, so the same limit is unnecessarily restrictive.

For active direct-DMA TX, derive the limit from the DMA device's segment
and mapping limits. Keep it within INT_MAX because transport callbacks
report lengths as int. Continue reporting the copy-path limit until direct
TX is active.

This lets ntb_netdev use ETH_MAX_MTU over direct DMA. If the queue later
falls back to the copy path, larger frames are rejected.

Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
---
drivers/ntb/ntb_transport.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 9f5d6a407be7..2f69328d5201 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -3787,10 +3787,19 @@ unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp)
unsigned int max_size;
unsigned int copy_align;
struct dma_chan *rx_chan, *tx_chan;
+ struct device *dma_dev;

if (!qp)
return 0;

+ if (ntb_transport_link_query(qp) && ntb_direct_tx_enabled(qp)) {
+ dma_dev = dmaengine_get_dma_device(qp->direct_dma_chan);
+ max_size = min_t(size_t, dma_get_max_seg_size(dma_dev),
+ dma_max_mapping_size(dma_dev));
+
+ return min_t(unsigned int, max_size, INT_MAX);
+ }
+
rx_chan = qp->rx_dma_chan;
tx_chan = qp->tx_dma_chan;

--
2.51.0