Skip to content

Commit

Permalink
mpfs_ethernet.c: set GMAC_RX_UNITSIZE to max gmac frame len
Browse files Browse the repository at this point in the history
Verify that GMAC RX/TX buffers are 64 byte aligned
  • Loading branch information
jnippula committed May 29, 2024
1 parent c748289 commit e182aa4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions arch/risc-v/src/mpfs/mpfs_ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include "hardware/mpfs_ethernet.h"
#include "hardware/mpfs_mpucfg.h"

#define MEM_ALIGNED_64(m) (((m) + (0x3f)) & ~0x3f)

#if defined(CONFIG_MPFS_ETH0_PHY_KSZ9477) ||\
defined(CONFIG_MPFS_ETH1_PHY_KSZ9477)
# if !defined(CONFIG_MPFS_MAC_SGMII)
Expand Down Expand Up @@ -129,21 +131,18 @@
# define CONFIG_MPFS_ETHMAC_NTXBUFFERS (8)
#endif

/* GMAC buffer sizes
* REVISIT: do we want to make GMAC_RX_UNITSIZE configurable?
* issue when using the MTU size receive block
*/

#define GMAC_RX_UNITSIZE (512) /* Fixed size for RX buffer */
#define GMAC_TX_UNITSIZE CONFIG_NET_ETH_PKTSIZE /* MAX size for Ethernet packet */

/* The MAC can support frame lengths up to 1536 bytes */

#define GMAC_MAX_FRAMELEN (1536)
#if CONFIG_NET_ETH_PKTSIZE > GMAC_MAX_FRAMELEN
# error CONFIG_NET_ETH_PKTSIZE is too large
#endif

/* Max size of RX and TX buffers */

#define GMAC_RX_UNITSIZE MEM_ALIGNED_64(GMAC_MAX_FRAMELEN)
#define GMAC_TX_UNITSIZE MEM_ALIGNED_64(CONFIG_NET_ETH_PKTSIZE)

/* for DMA dma_rxbuf_size */

#define MPFS_MAC_RX_BUF_VALUE ((GMAC_RX_UNITSIZE + 63) / 64)
Expand Down

0 comments on commit e182aa4

Please sign in to comment.