Skip to content

Commit

Permalink
Merge pull request RIOT-OS#18108 from benpicco/drivers/dose-rxbuf
Browse files Browse the repository at this point in the history
drivers/dose: make RX buffer size configurable
  • Loading branch information
benpicco authored Aug 2, 2022
2 parents 24ff493 + d0ca629 commit e1e99c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions drivers/dose/dose.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,15 @@ static int _get(netdev_t *dev, netopt_t opt, void *value, size_t max_len)
*((netopt_enable_t *)value) = NETOPT_DISABLE;
}
return sizeof(netopt_enable_t);
case NETOPT_MAX_PDU_SIZE:
if (CONFIG_DOSE_RX_BUF_LEN < (ETHERNET_FRAME_LEN + DOSE_FRAME_CRC_LEN)) {
if (max_len < sizeof(uint16_t)) {
return -EINVAL;
}
*((uint16_t *)value) = CONFIG_DOSE_RX_BUF_LEN - DOSE_FRAME_CRC_LEN;
return sizeof(uint16_t);
}
/* fall-through */
default:
return netdev_eth_get(dev, opt, value, max_len);
}
Expand Down
11 changes: 9 additions & 2 deletions drivers/include/dose.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,14 @@ typedef enum {
/** @} */

#define DOSE_FRAME_CRC_LEN (2) /**< CRC16 is used */
#define DOSE_FRAME_LEN (ETHERNET_FRAME_LEN + DOSE_FRAME_CRC_LEN) /**< dose frame length */

/**
* @brief DOSE RX buffer length
* Should be large enough to fit at least one Ethernet frame
*/
#ifndef CONFIG_DOSE_RX_BUF_LEN
#define CONFIG_DOSE_RX_BUF_LEN (ETHERNET_FRAME_LEN + DOSE_FRAME_CRC_LEN)
#endif

/**
* @brief Hardware timer to use with the `dose_watchdog` module.
Expand All @@ -182,7 +189,7 @@ typedef struct {
uint8_t opts; /**< Driver options */
dose_state_t state; /**< Current state of the driver's state machine */
mutex_t state_mtx; /**< Is unlocked every time a state is (re)entered */
uint8_t recv_buf[DOSE_FRAME_LEN]; /**< Receive buffer for incoming frames */
uint8_t recv_buf[CONFIG_DOSE_RX_BUF_LEN]; /**< Receive buffer for incoming frames */
chunk_ringbuf_t rb; /**< Ringbuffer to store received frames. */
/* Written to from interrupts (with irq_disable */
/* to prevent any simultaneous writes), */
Expand Down

0 comments on commit e1e99c3

Please sign in to comment.