Browse Source

drivers/ieee802154: Use net_pkt API for reading data on upipe driver

Some legacy left overs.
Just simplifying how to read data into a net_pkt.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pull/69733/head
Tomasz Bursztyka 2 years ago committed by Alberto Escolar
parent
commit
af85c8a11d
  1. 19
      drivers/ieee802154/ieee802154_uart_pipe.c
  2. 2
      drivers/ieee802154/ieee802154_uart_pipe.h

19
drivers/ieee802154/ieee802154_uart_pipe.c

@ -117,7 +117,7 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
} }
if (!upipe->rx_len) { if (!upipe->rx_len) {
if (*buf > 127) { if (*buf > IEEE802154_MAX_PHY_PACKET_SIZE) {
goto flush; goto flush;
} }
@ -128,27 +128,20 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
upipe->rx_buf[upipe->rx_off++] = *buf; upipe->rx_buf[upipe->rx_off++] = *buf;
if (upipe->rx_len == upipe->rx_off) { if (upipe->rx_len == upipe->rx_off) {
struct net_buf *frag; pkt = net_pkt_rx_alloc_with_buffer(upipe->iface, upipe->rx_len,
AF_UNSPEC, 0, K_NO_WAIT);
pkt = net_pkt_rx_alloc(K_NO_WAIT);
if (!pkt) { if (!pkt) {
LOG_DBG("No pkt available"); LOG_DBG("No pkt available");
goto flush; goto flush;
} }
frag = net_pkt_get_frag(pkt, upipe->rx_len, K_NO_WAIT); if (net_pkt_write(pkt, upipe->rx_buf, upipe->rx_len)) {
if (!frag) { LOG_DBG("No content read?");
LOG_DBG("No fragment available");
goto out; goto out;
} }
net_pkt_frag_insert(pkt, frag);
memcpy(frag->data, upipe->rx_buf, upipe->rx_len);
net_buf_add(frag, upipe->rx_len);
#if defined(CONFIG_IEEE802154_UPIPE_HW_FILTER) #if defined(CONFIG_IEEE802154_UPIPE_HW_FILTER)
if (received_dest_addr_matched(frag->data) == false) { if (received_dest_addr_matched(pkt->buffer->data) == false) {
LOG_DBG("Packet received is not addressed to me"); LOG_DBG("Packet received is not addressed to me");
goto out; goto out;
} }

2
drivers/ieee802154/ieee802154_uart_pipe.h

@ -20,7 +20,7 @@ struct upipe_context {
bool rx; bool rx;
uint8_t rx_len; uint8_t rx_len;
uint8_t rx_off; uint8_t rx_off;
uint8_t rx_buf[127]; uint8_t rx_buf[IEEE802154_MAX_PHY_PACKET_SIZE];
}; };
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_UART_PIPE_H_ */ #endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_UART_PIPE_H_ */

Loading…
Cancel
Save