mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 02:36:11 +08:00
net/devif_poll: optimize device buffer alloc in txpoll
Allocate the device buffer only if the protocol really need to send data. not all protocols require the driver to prepare additional iob before sending, especially UDP, each iob reserves l2/l3 header in advance after prepare write buffer, net device could reuse this entry to send directly Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -78,12 +78,19 @@ void devif_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
||||
return;
|
||||
}
|
||||
|
||||
iob_update_pktlen(dev->d_iob, offset);
|
||||
|
||||
/* Copy in iob to target device buffer */
|
||||
|
||||
if (len <= iob_navail(false) * CONFIG_IOB_BUFSIZE)
|
||||
{
|
||||
/* Prepare device buffer before poll callback */
|
||||
|
||||
if (netdev_iob_prepare(dev, false, 0) != OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iob_update_pktlen(dev->d_iob, offset);
|
||||
|
||||
dev->d_sndlen = iob_trycopyin(dev->d_iob, buf, len, offset, false);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user