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>
This commit is contained in:
Tomasz Bursztyka 2023-12-07 11:17:17 +01:00 committed by Alberto Escolar
parent f2a1a519b4
commit af85c8a11d
2 changed files with 7 additions and 14 deletions

View file

@ -117,7 +117,7 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
}
if (!upipe->rx_len) {
if (*buf > 127) {
if (*buf > IEEE802154_MAX_PHY_PACKET_SIZE) {
goto flush;
}
@ -128,27 +128,20 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
upipe->rx_buf[upipe->rx_off++] = *buf;
if (upipe->rx_len == upipe->rx_off) {
struct net_buf *frag;
pkt = net_pkt_rx_alloc(K_NO_WAIT);
pkt = net_pkt_rx_alloc_with_buffer(upipe->iface, upipe->rx_len,
AF_UNSPEC, 0, K_NO_WAIT);
if (!pkt) {
LOG_DBG("No pkt available");
goto flush;
}
frag = net_pkt_get_frag(pkt, upipe->rx_len, K_NO_WAIT);
if (!frag) {
LOG_DBG("No fragment available");
if (net_pkt_write(pkt, upipe->rx_buf, upipe->rx_len)) {
LOG_DBG("No content read?");
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 (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");
goto out;
}

View file

@ -20,7 +20,7 @@ struct upipe_context {
bool rx;
uint8_t rx_len;
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_ */