Skip to content

Commit f4cfd04

Browse files
Final cleanup
1 parent 9640f77 commit f4cfd04

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/NuvotonM480EthMAC.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ bool NuvotonM480EthMAC::TxDMA::descOwnedByDMA(size_t descIdx) {
208208
}
209209

210210
bool NuvotonM480EthMAC::TxDMA::isDMAReadableBuffer(uint8_t const *start, size_t size) const {
211-
return false;
211+
// No restrictions on what DMA can read
212+
return true;
212213
}
213214

214215
void NuvotonM480EthMAC::TxDMA::giveToDMA(size_t descIdx, uint8_t const *buffer, size_t len, bool firstDesc,

connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M480/NuvotonM480EthMAC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class NuvotonM480EthMAC : public CompositeEMAC
8686
void giveToDMA(size_t descIdx, uint8_t const * buffer, size_t len, bool firstDesc, bool lastDesc) override;
8787
public:
8888
explicit TxDMA(EMAC_T * const base):
89+
GenericTxDMARing(0, false), // we do NOT support multiple descriptors in the hardware
8990
base(base)
9091
{}
9192
};

connectivity/drivers/emac/include/GenericEthDMA.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ namespace mbed {
4343
/// This is used to support Eth MACs that don't allow enqueuing every single descriptor at a time.
4444
const size_t extraTxDescsToLeave;
4545

46+
/// Whether the hardware supports chaining multiple descriptors together to send one
47+
/// packet that's split across multiple buffers.
48+
const bool supportsDescChaining;
49+
4650
/// Pointer to first memory buffer in the chain associated with descriptor n.
4751
/// The buffer address shall only be set for the *last* descriptor, so that the entire chain is freed
4852
/// when the last descriptor is returned.
@@ -60,8 +64,9 @@ namespace mbed {
6064
size_t txReclaimIndex; ///< Index of the next Tx descriptor that will be reclaimed by the mac thread calling reclaimTxDescs().
6165

6266
/// Construct, passing a value for extraTxDescsToLeave
63-
GenericTxDMARing(size_t extraTxDescsToLeave = 0):
64-
extraTxDescsToLeave(extraTxDescsToLeave)
67+
GenericTxDMARing(size_t extraTxDescsToLeave = 0, bool supportsDescChaining = true):
68+
extraTxDescsToLeave(extraTxDescsToLeave),
69+
supportsDescChaining(supportsDescChaining)
6570
{}
6671

6772
/// Configure DMA registers to point to the DMA ring,
@@ -193,6 +198,14 @@ namespace mbed {
193198
size_t packetDescsUsed = memory_manager->count_buffers(buf);
194199
size_t neededFreeDescs = packetDescsUsed + extraTxDescsToLeave;
195200
bool needToCopy = false;
201+
202+
if(packetDescsUsed > 1 && !supportsDescChaining)
203+
{
204+
/// Packet uses more than 1 descriptor and the hardware doesn't support that so
205+
/// we have to copy it into one single descriptor.
206+
needToCopy = true;
207+
}
208+
196209
if(neededFreeDescs >= TX_NUM_DESCS)
197210
{
198211
// Packet uses too many buffers, we have to copy it into a continuous buffer.

0 commit comments

Comments
 (0)