Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Documentation/components/net/netdriver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ Here is a guide to do so:
*/

len = receive_data_into(devbuf);
netpkt_copyin(dev, pkt, devbuf + sizeof(struct <chip>_rxhead_s), len, 0);
netpkt_copyin(dev, pkt, devbuf + sizeof(struct <chip>_rxhead_s), len, 0,
NETPKT_RX);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/espressif/esp_wlan_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
goto out;
}

ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0);
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0, NETPKT_RX);
if (ret < 0)
{
wlerr("ERROR: Failed to copy packet\n");
Expand Down
3 changes: 2 additions & 1 deletion arch/risc-v/src/mpfs/mpfs_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ static netpkt_t *mpfs_receive(struct netdev_lowerhalf_s *dev)
if (pkt != NULL)
{
netpkt_copyin(dev, pkt, (uint8_t *)&cf,
sizeof(struct can_frame), 0);
sizeof(struct can_frame), 0,
NETPKT_RX);
}

ninfo("Received CAN message (ID: 0x%X, DLC: %d) "
Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/sim/sim_netdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static netpkt_t *netdriver_recv(struct netdev_lowerhalf_s *dev)
#ifdef SIM_NETDEV_RECV_OFFLOAD
netpkt_setdatalen(dev, pkt, len);
#else
netpkt_copyin(dev, pkt, DEVBUF(dev), len, 0);
netpkt_copyin(dev, pkt, DEVBUF(dev), len, 0, NETPKT_RX);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/common/espressif/esp_openeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static netpkt_t *openeth_receive(struct netdev_lowerhalf_s *dev)
goto err;
}

netpkt_copyin(dev, pkt, desc_val.rxpnt, desc_val.len, 0);
netpkt_copyin(dev, pkt, desc_val.rxpnt, desc_val.len, 0, NETPKT_RX);

/* Free up the descriptor */

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/common/espressif/esp_wlan_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
goto out;
}

ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0);
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0, NETPKT_RX);
if (ret < 0)
{
wlerr("ERROR: Failed to copy packet\n");
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/netdev_upperhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ FAR netpkt_t *netpkt_alloc(FAR struct netdev_lowerhalf_s *dev,
return NULL;
}

pkt = iob_tryalloc(false);
pkt = iob_tryalloc(type == NETPKT_RX);
if (pkt == NULL)
{
atomic_fetch_add(&dev->quota[type], 1);
Expand Down Expand Up @@ -1446,10 +1446,12 @@ void netpkt_free(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
****************************************************************************/

int netpkt_copyin(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
FAR const uint8_t *src, unsigned int len, int offset)
FAR const uint8_t *src, unsigned int len, int offset,
enum netpkt_type_e type)
{
return iob_trycopyin(pkt, src, len,
offset - NET_LL_HDRLEN(&dev->netdev), false);
offset - NET_LL_HDRLEN(&dev->netdev),
type == NETPKT_RX);
}

/****************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/oa_tc6/oa_tc6.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,8 @@ static void oa_tc6_handle_rx_chunk(FAR struct oa_tc6_driver_s *priv,
}

netpkt_copyin(&priv->dev, priv->rx_pkt, rxbuf,
rxlen, priv->rx_pkt_idx);
rxlen, priv->rx_pkt_idx,
NETPKT_RX);
priv->rx_pkt_idx = newlen;

if (oa_tc6_end_valid(footer))
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
{
net_lock();
netdev_iob_release(&priv->dev);
ret = netdev_iob_prepare(&priv->dev, false, 0);
ret = netdev_iob_prepare(&priv->dev, true, 0);
priv->dev.d_buf = NULL;
if (ret < 0)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/usbdev/cdcncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ static int cdcncm_packet_handler(FAR struct cdcncm_driver_s *self,
return ret;
}

ret = netpkt_copyin(&self->dev, pkt, dgram, dglen, 0);
ret = netpkt_copyin(&self->dev, pkt, dgram, dglen, 0, NETPKT_RX);
if (ret < 0)
{
netpkt_free(&self->dev, pkt, NETPKT_RX);
Expand Down
6 changes: 3 additions & 3 deletions drivers/usbdev/rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static bool rndis_allocrxreq(FAR struct rndis_dev_s *priv)

/* Prepare buffer to receivce data from usb driver */

iob = iob_tryalloc(false);
iob = iob_tryalloc(true);
if (iob == NULL)
{
return false;
Expand Down Expand Up @@ -1291,7 +1291,7 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
iob_trycopyin(priv->rx_req->iob,
&reqbuf[priv->current_rx_datagram_offset],
reqlen - priv->current_rx_datagram_offset,
-NET_LL_HDRLEN(&priv->netdev), false);
-NET_LL_HDRLEN(&priv->netdev), true);
}
}
else
Expand All @@ -1316,7 +1316,7 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
if ((index + copysize) <= CONFIG_NET_ETH_PKTSIZE)
{
iob_trycopyin(priv->rx_req->iob, reqbuf, copysize,
priv->rx_req->iob->io_pktlen, false);
priv->rx_req->iob->io_pktlen, true);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion include/nuttx/net/netdev_lowerhalf.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,16 @@ void netpkt_free(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
* src - The source buffer
* len - How many bytes to copy
* offset - The offset of netpkt to put the data
* type - Whether used for TX or RX
*
* Returned Value:
* 0:Success; negated errno on failure
*
****************************************************************************/

int netpkt_copyin(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt,
FAR const uint8_t *src, unsigned int len, int offset);
FAR const uint8_t *src, unsigned int len, int offset,
enum netpkt_type_e type);

/****************************************************************************
* Name: netpkt_copyout
Expand Down
2 changes: 1 addition & 1 deletion net/devif/ipv4_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int ipv4_in(FAR struct net_driver_s *dev)
totlen = (ipv4->len[0] << 8) + ipv4->len[1];
if (totlen < dev->d_len)
{
iob_update_pktlen(dev->d_iob, totlen, false);
iob_update_pktlen(dev->d_iob, totlen, true);
dev->d_len = totlen;
}
else if (totlen > dev->d_len)
Expand Down
2 changes: 1 addition & 1 deletion net/devif/ipv6_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static int ipv6_in(FAR struct net_driver_s *dev)

if (paylen < dev->d_len)
{
iob_update_pktlen(dev->d_iob, paylen, false);
iob_update_pktlen(dev->d_iob, paylen, true);
dev->d_len = paylen;
}
else if (paylen > dev->d_len)
Expand Down
2 changes: 1 addition & 1 deletion net/ipfrag/ipv4_frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ int32_t ipv4_fragin(FAR struct net_driver_s *dev)
* 0 if success or a negative value if fail.
*
* Assumptions:
* Data length(dev->d_iob->io_pktlen) is grater than the MTU of
* Data length(dev->d_iob->io_pktlen) is greater than the MTU of
* current NIC
*
****************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions net/netdev/netdev_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ int netdev_input(FAR struct net_driver_s *dev,

/* Prepare iob buffer */

ret = netdev_iob_prepare(dev, false, 0);
ret = netdev_iob_prepare(dev, true, 0);
if (ret != OK)
{
return ret;
}

/* Copy data to iob entry */

ret = iob_trycopyin(dev->d_iob, buf, dev->d_len, -llhdrlen, false);
ret = iob_trycopyin(dev->d_iob, buf, dev->d_len, -llhdrlen, true);
if (ret == dev->d_len)
{
/* Update device buffer to l2 start */
Expand Down
8 changes: 2 additions & 6 deletions net/netdev/netdev_iob.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled,

if (dev->d_iob == NULL)
{
dev->d_iob = net_iobtimedalloc(false, timeout);
if (dev->d_iob == NULL && throttled)
{
dev->d_iob = net_iobtimedalloc(true, timeout);
}
dev->d_iob = net_iobtimedalloc(throttled, timeout);
}

if (dev->d_iob == NULL)
Expand All @@ -75,7 +71,7 @@ int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled,
return -ENOMEM;
}

/* Update l2 gruard size */
/* Update l2 guard size */

iob_reserve(dev->d_iob, CONFIG_NET_LL_GUARDSIZE);

Expand Down
4 changes: 2 additions & 2 deletions net/tcp/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
# define TCP_WBIOB(wrb) ((wrb)->wb_iob)
# define TCP_WBCOPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0))
# define TCP_WBCOPYIN(wrb,src,n,off) \
(iob_copyin((wrb)->wb_iob,src,(n),(off),true))
(iob_copyin((wrb)->wb_iob,src,(n),(off),false))
# define TCP_WBTRYCOPYIN(wrb,src,n,off) \
(iob_trycopyin((wrb)->wb_iob,src,(n),(off),true))
(iob_trycopyin((wrb)->wb_iob,src,(n),(off),false))

# define TCP_WBTRIM(wrb,n) \
do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0)
Expand Down
2 changes: 1 addition & 1 deletion net/tcp/tcp_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static uint16_t tcp_recvhandler(FAR struct net_driver_s *dev,

iob_reserve(iob, CONFIG_NET_LL_GUARDSIZE);
int ret = iob_clone_partial(dev->d_iob, dev->d_iob->io_pktlen,
0, iob, 0, false, false);
0, iob, 0, true, false);
if (ret < 0)
{
iob_free_chain(iob);
Expand Down
3 changes: 2 additions & 1 deletion net/tcp/tcp_send_buffered.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
* we risk a deadlock with other threads competing on IOBs.
*/

iob = net_iobtimedalloc(true, tcp_send_gettimeout(start, timeout));
iob = net_iobtimedalloc(false,
tcp_send_gettimeout(start, timeout));
if (iob != NULL)
{
iob_free_chain(iob);
Expand Down
2 changes: 1 addition & 1 deletion net/tcp/tcp_wrbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ FAR struct tcp_wrbuffer_s *tcp_wrbuffer_timedalloc(unsigned int timeout)

/* Now get the first I/O buffer for the write buffer structure */

wrb->wb_iob = net_iobtimedalloc(true, timeout);
wrb->wb_iob = net_iobtimedalloc(false, timeout);

/* Did we get an IOB? We should always get one except under some really
* weird error conditions.
Expand Down
2 changes: 1 addition & 1 deletion net/udp/udp_wrbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ FAR struct udp_wrbuffer_s *udp_wrbuffer_timedalloc(unsigned int timeout)

/* Now get the first I/O buffer for the write buffer structure */

wrb->wb_iob = net_iobtimedalloc(true, timeout);
wrb->wb_iob = net_iobtimedalloc(false, timeout);

/* Did we get an IOB? We should always get one except under some really
* weird error conditions.
Expand Down
Loading