mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
soc: Added support for specify the maximum descriptor length when setting up the DMA descriptor link
This commit is contained in:
parent
2a28ec3522
commit
6e9d90d6e1
@ -377,7 +377,8 @@ static int esp_aes_process_dma(esp_aes_context *ctx, const unsigned char *input,
|
||||
block_out_desc = block_desc + lldesc_num;
|
||||
|
||||
lldesc_setup_link(block_in_desc, input, block_bytes, 0);
|
||||
lldesc_setup_link(block_out_desc, output, block_bytes, 0);
|
||||
//Limit max inlink descriptor length to be 16 byte aligned, require for EDMA
|
||||
lldesc_setup_link_constrained(block_out_desc, output, block_bytes, LLDESC_MAX_NUM_PER_DESC_16B_ALIGNED, 0);
|
||||
|
||||
out_desc_tail = &block_out_desc[lldesc_num - 1];
|
||||
}
|
||||
|
@ -31,6 +31,24 @@
|
||||
/** Maximum size of data in the buffer that a DMA descriptor can hold. */
|
||||
#define LLDESC_MAX_NUM_PER_DESC (4096-4)
|
||||
|
||||
// Some DMA operations might impose certain alignment restrictions on the length
|
||||
#define LLDESC_MAX_NUM_PER_DESC_16B_ALIGNED (4096 - 16)
|
||||
#define LLDESC_MAX_NUM_PER_DESC_32B_ALIGNED (4096 - 32)
|
||||
|
||||
/**
|
||||
* Generate a linked list pointing to a (huge) buffer in an descriptor array.
|
||||
*
|
||||
* The caller should ensure there is enough size to hold the array, by calling
|
||||
* ``lldesc_get_required_num_constrained`` with the same max_desc_size argument.
|
||||
*
|
||||
* @param[out] out_desc_array Output of a descriptor array, the head should be fed to the DMA.
|
||||
* @param buffer Buffer for the descriptors to point to.
|
||||
* @param size Size (or length for TX) of the buffer
|
||||
* @param max_desc_size Maximum length of each descriptor
|
||||
* @param isrx The RX DMA may require the buffer to be word-aligned, set to true for a RX link, otherwise false.
|
||||
*/
|
||||
void lldesc_setup_link_constrained(lldesc_t *out_desc_array, const void *buffer, int size, int max_desc_size, bool isrx);
|
||||
|
||||
/**
|
||||
* Generate a linked list pointing to a (huge) buffer in an descriptor array.
|
||||
*
|
||||
@ -42,7 +60,7 @@
|
||||
* @param size Size (or length for TX) of the buffer
|
||||
* @param isrx The RX DMA may require the buffer to be word-aligned, set to true for a RX link, otherwise false.
|
||||
*/
|
||||
void lldesc_setup_link(lldesc_t *out_desc_array, const void *buffer, int size, bool isrx);
|
||||
#define lldesc_setup_link(out_desc_array, buffer, size, isrx) lldesc_setup_link_constrained(out_desc_array, buffer, size, LLDESC_MAX_NUM_PER_DESC, isrx)
|
||||
|
||||
/**
|
||||
* @brief Get the received length of a linked list, until end of the link or eof.
|
||||
@ -54,6 +72,18 @@ void lldesc_setup_link(lldesc_t *out_desc_array, const void *buffer, int size, b
|
||||
*/
|
||||
int lldesc_get_received_len(lldesc_t* head, lldesc_t** out_next);
|
||||
|
||||
/**
|
||||
* Get the number of descriptors required for a given buffer size.
|
||||
*
|
||||
* @param data_size Size to check descriptor num.
|
||||
* @param max_desc_size Maximum length of each descriptor
|
||||
* @return Numbers required.
|
||||
*/
|
||||
static inline int lldesc_get_required_num_constrained(int data_size, int max_desc_size)
|
||||
{
|
||||
return (data_size + max_desc_size - 1) / max_desc_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of descriptors required for a given buffer size.
|
||||
*
|
||||
@ -61,7 +91,4 @@ int lldesc_get_received_len(lldesc_t* head, lldesc_t** out_next);
|
||||
*
|
||||
* @return Numbers required.
|
||||
*/
|
||||
static inline int lldesc_get_required_num(int data_size)
|
||||
{
|
||||
return (data_size + LLDESC_MAX_NUM_PER_DESC - 1) / LLDESC_MAX_NUM_PER_DESC;
|
||||
}
|
||||
#define lldesc_get_required_num(data_size) lldesc_get_required_num_constrained(data_size, LLDESC_MAX_NUM_PER_DESC)
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "soc/lldesc.h"
|
||||
|
||||
void lldesc_setup_link(lldesc_t *dmadesc, const void *data, int len, bool isrx)
|
||||
void lldesc_setup_link_constrained(lldesc_t *dmadesc, const void *data, int len, int max_desc_size, bool isrx)
|
||||
{
|
||||
int n = 0;
|
||||
while (len) {
|
||||
int dmachunklen = len;
|
||||
if (dmachunklen > LLDESC_MAX_NUM_PER_DESC) {
|
||||
dmachunklen = LLDESC_MAX_NUM_PER_DESC;
|
||||
if (dmachunklen > max_desc_size) {
|
||||
dmachunklen = max_desc_size;
|
||||
}
|
||||
if (isrx) {
|
||||
//Receive needs DMA length rounded to next 32-bit boundary
|
||||
|
Loading…
x
Reference in New Issue
Block a user