Skip to content

Commit ae4686d

Browse files
mennovfMenno Vanfrachem
authored andcommitted
net/tcp/udp: Modify calls of net_iob*alloc calls to be unthrottled for sends,
throttle for receives. The Kconfig option CONFIG_IOB_THROTTLE is used to limit the amount allocated by TCP (and UDP) receives as to not starve sends. This distinction is made via a 'throttle' argument passed to the iob_*alloc functions, which are wrapped by net_iob*alloc. Previously the udp/tcp_wrbuffer_write functions incorrectly allocate with throttle=true, effectively making the IOB_THROTTLE option useless. This patch modifies the calls in udp/tcp_wrbuffer_write to allocate unthrottled, and fixes an unthrottled allocation in the TCP receive path. There were also several locations in the receive path that incorrectly allocated unthrottled. Signed-off-by: Menno Vanfrachem <[email protected]> Modify receives to allocate throttled
1 parent b2b0452 commit ae4686d

File tree

22 files changed

+37
-33
lines changed

22 files changed

+37
-33
lines changed

Documentation/components/net/netdriver.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ Here is a guide to do so:
229229
*/
230230
231231
len = receive_data_into(devbuf);
232-
netpkt_copyin(dev, pkt, devbuf + sizeof(struct <chip>_rxhead_s), len, 0);
232+
netpkt_copyin(dev, pkt, devbuf + sizeof(struct <chip>_rxhead_s), len, 0,
233+
NETPKT_RX);
233234
#endif
234235
}
235236

arch/risc-v/src/common/espressif/esp_wlan_netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
10181018
goto out;
10191019
}
10201020

1021-
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0);
1021+
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0, NETPKT_RX);
10221022
if (ret < 0)
10231023
{
10241024
wlerr("ERROR: Failed to copy packet\n");

arch/risc-v/src/mpfs/mpfs_can.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ static netpkt_t *mpfs_receive(struct netdev_lowerhalf_s *dev)
678678
if (pkt != NULL)
679679
{
680680
netpkt_copyin(dev, pkt, (uint8_t *)&cf,
681-
sizeof(struct can_frame), 0);
681+
sizeof(struct can_frame), 0
682+
NETPKT_RX);
682683
}
683684

684685
ninfo("Received CAN message (ID: 0x%X, DLC: %d) "

arch/sim/src/sim/sim_netdriver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static netpkt_t *netdriver_recv(struct netdev_lowerhalf_s *dev)
181181
#ifdef SIM_NETDEV_RECV_OFFLOAD
182182
netpkt_setdatalen(dev, pkt, len);
183183
#else
184-
netpkt_copyin(dev, pkt, DEVBUF(dev), len, 0);
184+
netpkt_copyin(dev, pkt, DEVBUF(dev), len, 0, NETPKT_RX);
185185
#endif
186186
}
187187

arch/xtensa/src/common/espressif/esp_openeth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static netpkt_t *openeth_receive(struct netdev_lowerhalf_s *dev)
286286
goto err;
287287
}
288288

289-
netpkt_copyin(dev, pkt, desc_val.rxpnt, desc_val.len, 0);
289+
netpkt_copyin(dev, pkt, desc_val.rxpnt, desc_val.len, 0, NETPKT_RX);
290290

291291
/* Free up the descriptor */
292292

arch/xtensa/src/common/espressif/esp_wlan_netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
10181018
goto out;
10191019
}
10201020

1021-
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0);
1021+
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0, NETPKT_RX);
10221022
if (ret < 0)
10231023
{
10241024
wlerr("ERROR: Failed to copy packet\n");

drivers/net/netdev_upperhalf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ FAR netpkt_t *netpkt_alloc(FAR struct netdev_lowerhalf_s *dev,
13951395
return NULL;
13961396
}
13971397

1398-
pkt = iob_tryalloc(false);
1398+
pkt = iob_tryalloc(type == NETPKT_RX);
13991399
if (pkt == NULL)
14001400
{
14011401
atomic_fetch_add(&dev->quota[type], 1);
@@ -1446,10 +1446,12 @@ void netpkt_free(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
14461446
****************************************************************************/
14471447

14481448
int netpkt_copyin(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
1449-
FAR const uint8_t *src, unsigned int len, int offset)
1449+
FAR const uint8_t *src, unsigned int len, int offset,
1450+
enum netpkt_type_e type)
14501451
{
14511452
return iob_trycopyin(pkt, src, len,
1452-
offset - NET_LL_HDRLEN(&dev->netdev), false);
1453+
offset - NET_LL_HDRLEN(&dev->netdev),
1454+
type == NETPKT_RX);
14531455
}
14541456

14551457
/****************************************************************************

drivers/net/oa_tc6/oa_tc6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ static void oa_tc6_handle_rx_chunk(FAR struct oa_tc6_driver_s *priv,
867867
}
868868

869869
netpkt_copyin(&priv->dev, priv->rx_pkt, rxbuf,
870-
rxlen, priv->rx_pkt_idx);
870+
rxlen, priv->rx_pkt_idx,
871+
NETPKT_RX);
871872
priv->rx_pkt_idx = newlen;
872873

873874
if (oa_tc6_end_valid(footer))

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
998998
{
999999
net_lock();
10001000
netdev_iob_release(&priv->dev);
1001-
ret = netdev_iob_prepare(&priv->dev, false, 0);
1001+
ret = netdev_iob_prepare(&priv->dev, true, 0);
10021002
priv->dev.d_buf = NULL;
10031003
if (ret < 0)
10041004
{

drivers/usbdev/cdcncm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ static int cdcncm_packet_handler(FAR struct cdcncm_driver_s *self,
977977
return ret;
978978
}
979979

980-
ret = netpkt_copyin(&self->dev, pkt, dgram, dglen, 0);
980+
ret = netpkt_copyin(&self->dev, pkt, dgram, dglen, 0, NETPKT_RX);
981981
if (ret < 0)
982982
{
983983
netpkt_free(&self->dev, pkt, NETPKT_RX);

0 commit comments

Comments
 (0)