am64x_eth_driver.h File Reference

AM64x Ethernet MAC driver. More...

#include "core/nic.h"

Go to the source code of this file.

Data Structures

struct  Am64xAleEntry
 ALE table entry. More...
 
struct  Am64xTxDmaDesc
 Enhanced TX DMA descriptor. More...
 
struct  Am64xRxDmaDesc
 Enhanced RX DMA descriptor. More...
 

Macros

#define CPSW_PORT0   0
 
#define CPSW_PORT1   1
 
#define CPSW_PORT2   2
 
#define CPSW_CH0   0
 
#define CPSW_CH1   1
 
#define CPSW_CH2   2
 
#define CPSW_CH3   3
 
#define CPSW_CH4   4
 
#define CPSW_CH5   5
 
#define CPSW_CH6   6
 
#define CPSW_CH7   7
 
#define CPSW_ALE_MAX_ENTRIES   512
 
#define CPSW_ALE_WORD1_ENTRY_TYPE_MASK   (3 << 28)
 
#define CPSW_ALE_WORD1_ENTRY_TYPE_FREE   (0 << 28)
 
#define CPSW_ALE_WORD1_ENTRY_TYPE_ADDR   (1 << 28)
 
#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN   (2 << 28)
 
#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN_ADDR   (3 << 28)
 
#define CPSW_ALE_WORD1_MULTICAST   (1 << 8)
 
#define CPSW_ALE_WORD2_TRUNK   (1 << 4)
 
#define CPSW_ALE_WORD2_PORT_NUMBER_MASK   (3 << 2)
 
#define CPSW_ALE_WORD2_PORT_NUMBER(n)   ((n) << 2)
 
#define CPSW_ALE_WORD2_BLOCK   (1 << 1)
 
#define CPSW_ALE_WORD2_SECURE   (1 << 0)
 
#define CPSW_ALE_WORD1_UNICAST_TYPE_MASK   (3 << 30)
 
#define CPSW_ALE_WORD1_UNICAST_TYPE(n)   ((n) << 30)
 
#define CPSW_ALE_WORD2_PORT_MASK_MASK   (3 << 2)
 
#define CPSW_ALE_WORD2_PORT_MASK(n)   ((n) << 2)
 
#define CPSW_ALE_WORD2_SUPER   (1 << 1)
 
#define CPSW_ALE_WORD1_MCAST_FWD_STATE_MASK   (3 << 30)
 
#define CPSW_ALE_WORD1_MCAST_FWD_STATE(n)   ((n) << 30)
 
#define CPSW_ALE_WORD2_NO_LEARN_MASK_MASK   (7 << 2)
 
#define CPSW_ALE_WORD2_NO_LEARN_MASK(n)   ((n) << 2)
 
#define CPSW_ALE_WORD2_VLAN_FORCE_INGRESS_CHECK   (7 << 1)
 
#define CPSW_ALE_WORD1_VLAN_ID_MASK   (4095 << 16)
 
#define CPSW_ALE_WORD1_VLAN_ID(n)   ((n) << 16)
 
#define CPSW_ALE_WORD1_NOFRAG   (1 << 15)
 
#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX_MASK   (7 << 4)
 
#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX(n)   ((n) << 4)
 
#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS_MASK   (7 << 24)
 
#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS(n)   ((n) << 24)
 
#define CPSW_ALE_WORD0_LMTNXTHDR   (1 << 23)
 
#define CPSW_ALE_WORD0_UREGMSK_MASK   (7 << 12)
 
#define CPSW_ALE_WORD0_UREGMSK(n)   ((n) << 12)
 
#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST_MASK   (7 << 0)
 
#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST(n)   ((n) << 0)
 

Functions

error_t am64xEthInitPort1 (NetInterface *interface)
 AM64x Ethernet MAC initialization (port 1) More...
 
error_t am64xEthInitPort2 (NetInterface *interface)
 AM64x Ethernet MAC initialization (port 2) More...
 
void am64xEthInitInstance (NetInterface *interface)
 Initialize CPSW instance. More...
 
void am64xEthInitGpio (NetInterface *interface)
 GPIO configuration. More...
 
void am64xEthTick (NetInterface *interface)
 AM64x Ethernet MAC timer handler. More...
 
void am64xEthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void am64xEthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void am64xEthRxIrqHandler (void *arg)
 AM64x Ethernet MAC receive interrupt. More...
 
void am64xEthEventHandler (NetInterface *interface)
 AM64x Ethernet MAC event handler. More...
 
error_t am64xEthSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t am64xEthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t am64xEthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void am64xEthWritePhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t am64xEthReadPhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
void am64xEthWriteEntry (uint_t index, const Am64xAleEntry *entry)
 Write an ALE table entry. More...
 
void am64xEthReadEntry (uint_t index, Am64xAleEntry *entry)
 Read an ALE table entry. More...
 
uint_t am64xEthFindFreeEntry (void)
 Find a free entry in the ALE table. More...
 
uint_t am64xEthFindVlanEntry (uint_t vlanId)
 Search the ALE table for the specified VLAN entry. More...
 
uint_t am64xEthFindVlanAddrEntry (uint_t vlanId, MacAddr *macAddr)
 Search the ALE table for the specified VLAN/address entry. More...
 
error_t am64xEthAddVlanEntry (uint_t port, uint_t vlanId)
 Add a VLAN entry in the ALE table. More...
 
error_t am64xEthAddVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Add a VLAN/address entry in the ALE table. More...
 
error_t am64xEthDeleteVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Remove a VLAN/address entry from the ALE table. More...
 

Variables

const NicDriver am64xEthPort1Driver
 AM64x Ethernet MAC driver (port1) More...
 
const NicDriver am64xEthPort2Driver
 AM64x Ethernet MAC driver (port2) More...
 

Detailed Description

AM64x Ethernet MAC driver.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file am64x_eth_driver.h.

Macro Definition Documentation

◆ CPSW_ALE_MAX_ENTRIES

#define CPSW_ALE_MAX_ENTRIES   512

Definition at line 53 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS

#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS (   n)    ((n) << 24)

Definition at line 89 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS_MASK

#define CPSW_ALE_WORD0_FORCE_UNTAG_EGRESS_MASK   (7 << 24)

Definition at line 88 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_LMTNXTHDR

#define CPSW_ALE_WORD0_LMTNXTHDR   (1 << 23)

Definition at line 90 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_UREGMSK

#define CPSW_ALE_WORD0_UREGMSK (   n)    ((n) << 12)

Definition at line 92 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_UREGMSK_MASK

#define CPSW_ALE_WORD0_UREGMSK_MASK   (7 << 12)

Definition at line 91 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_VLAN_MEMBER_LIST

#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST (   n)    ((n) << 0)

Definition at line 94 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD0_VLAN_MEMBER_LIST_MASK

#define CPSW_ALE_WORD0_VLAN_MEMBER_LIST_MASK   (7 << 0)

Definition at line 93 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_ENTRY_TYPE_ADDR

#define CPSW_ALE_WORD1_ENTRY_TYPE_ADDR   (1 << 28)

Definition at line 58 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_ENTRY_TYPE_FREE

#define CPSW_ALE_WORD1_ENTRY_TYPE_FREE   (0 << 28)

Definition at line 57 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_ENTRY_TYPE_MASK

#define CPSW_ALE_WORD1_ENTRY_TYPE_MASK   (3 << 28)

Definition at line 56 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_ENTRY_TYPE_VLAN

#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN   (2 << 28)

Definition at line 59 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_ENTRY_TYPE_VLAN_ADDR

#define CPSW_ALE_WORD1_ENTRY_TYPE_VLAN_ADDR   (3 << 28)

Definition at line 60 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_MCAST_FWD_STATE

#define CPSW_ALE_WORD1_MCAST_FWD_STATE (   n)    ((n) << 30)

Definition at line 77 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_MCAST_FWD_STATE_MASK

#define CPSW_ALE_WORD1_MCAST_FWD_STATE_MASK   (3 << 30)

Definition at line 76 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_MULTICAST

#define CPSW_ALE_WORD1_MULTICAST   (1 << 8)

Definition at line 61 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_NOFRAG

#define CPSW_ALE_WORD1_NOFRAG   (1 << 15)

Definition at line 85 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX

#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX (   n)    ((n) << 4)

Definition at line 87 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX_MASK

#define CPSW_ALE_WORD1_REG_MCAST_FLOOD_INDEX_MASK   (7 << 4)

Definition at line 86 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_UNICAST_TYPE

#define CPSW_ALE_WORD1_UNICAST_TYPE (   n)    ((n) << 30)

Definition at line 70 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_UNICAST_TYPE_MASK

#define CPSW_ALE_WORD1_UNICAST_TYPE_MASK   (3 << 30)

Definition at line 69 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_VLAN_ID

#define CPSW_ALE_WORD1_VLAN_ID (   n)    ((n) << 16)

Definition at line 84 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD1_VLAN_ID_MASK

#define CPSW_ALE_WORD1_VLAN_ID_MASK   (4095 << 16)

Definition at line 83 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_BLOCK

#define CPSW_ALE_WORD2_BLOCK   (1 << 1)

Definition at line 67 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_NO_LEARN_MASK

#define CPSW_ALE_WORD2_NO_LEARN_MASK (   n)    ((n) << 2)

Definition at line 81 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_NO_LEARN_MASK_MASK

#define CPSW_ALE_WORD2_NO_LEARN_MASK_MASK   (7 << 2)

Definition at line 80 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_PORT_MASK

#define CPSW_ALE_WORD2_PORT_MASK (   n)    ((n) << 2)

Definition at line 74 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_PORT_MASK_MASK

#define CPSW_ALE_WORD2_PORT_MASK_MASK   (3 << 2)

Definition at line 73 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_PORT_NUMBER

#define CPSW_ALE_WORD2_PORT_NUMBER (   n)    ((n) << 2)

Definition at line 66 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_PORT_NUMBER_MASK

#define CPSW_ALE_WORD2_PORT_NUMBER_MASK   (3 << 2)

Definition at line 65 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_SECURE

#define CPSW_ALE_WORD2_SECURE   (1 << 0)

Definition at line 68 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_SUPER

#define CPSW_ALE_WORD2_SUPER   (1 << 1)

Definition at line 75 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_TRUNK

#define CPSW_ALE_WORD2_TRUNK   (1 << 4)

Definition at line 64 of file am64x_eth_driver.h.

◆ CPSW_ALE_WORD2_VLAN_FORCE_INGRESS_CHECK

#define CPSW_ALE_WORD2_VLAN_FORCE_INGRESS_CHECK   (7 << 1)

Definition at line 82 of file am64x_eth_driver.h.

◆ CPSW_CH0

#define CPSW_CH0   0

Definition at line 43 of file am64x_eth_driver.h.

◆ CPSW_CH1

#define CPSW_CH1   1

Definition at line 44 of file am64x_eth_driver.h.

◆ CPSW_CH2

#define CPSW_CH2   2

Definition at line 45 of file am64x_eth_driver.h.

◆ CPSW_CH3

#define CPSW_CH3   3

Definition at line 46 of file am64x_eth_driver.h.

◆ CPSW_CH4

#define CPSW_CH4   4

Definition at line 47 of file am64x_eth_driver.h.

◆ CPSW_CH5

#define CPSW_CH5   5

Definition at line 48 of file am64x_eth_driver.h.

◆ CPSW_CH6

#define CPSW_CH6   6

Definition at line 49 of file am64x_eth_driver.h.

◆ CPSW_CH7

#define CPSW_CH7   7

Definition at line 50 of file am64x_eth_driver.h.

◆ CPSW_PORT0

#define CPSW_PORT0   0

Definition at line 38 of file am64x_eth_driver.h.

◆ CPSW_PORT1

#define CPSW_PORT1   1

Definition at line 39 of file am64x_eth_driver.h.

◆ CPSW_PORT2

#define CPSW_PORT2   2

Definition at line 40 of file am64x_eth_driver.h.

Function Documentation

◆ am64xEthAddVlanAddrEntry()

error_t am64xEthAddVlanAddrEntry ( uint_t  port,
uint_t  vlanId,
MacAddr macAddr 
)

Add a VLAN/address entry in the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Error code

Definition at line 1405 of file am64x_eth_driver.c.

◆ am64xEthAddVlanEntry()

error_t am64xEthAddVlanEntry ( uint_t  port,
uint_t  vlanId 
)

Add a VLAN entry in the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
Returns
Error code

Definition at line 1345 of file am64x_eth_driver.c.

◆ am64xEthDeleteVlanAddrEntry()

error_t am64xEthDeleteVlanAddrEntry ( uint_t  port,
uint_t  vlanId,
MacAddr macAddr 
)

Remove a VLAN/address entry from the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Error code

Definition at line 1476 of file am64x_eth_driver.c.

◆ am64xEthDisableIrq()

void am64xEthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 712 of file am64x_eth_driver.c.

◆ am64xEthEnableIrq()

void am64xEthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 687 of file am64x_eth_driver.c.

◆ am64xEthEventHandler()

void am64xEthEventHandler ( NetInterface interface)

AM64x Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 759 of file am64x_eth_driver.c.

◆ am64xEthFindFreeEntry()

uint_t am64xEthFindFreeEntry ( void  )

Find a free entry in the ALE table.

Returns
Index of the first free entry

Definition at line 1218 of file am64x_eth_driver.c.

◆ am64xEthFindVlanAddrEntry()

uint_t am64xEthFindVlanAddrEntry ( uint_t  vlanId,
MacAddr macAddr 
)

Search the ALE table for the specified VLAN/address entry.

Parameters
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Index of the matching entry

Definition at line 1294 of file am64x_eth_driver.c.

◆ am64xEthFindVlanEntry()

uint_t am64xEthFindVlanEntry ( uint_t  vlanId)

Search the ALE table for the specified VLAN entry.

Parameters
[in]vlanIdVLAN identifier
Returns
Index of the matching entry

Definition at line 1252 of file am64x_eth_driver.c.

◆ am64xEthInitGpio()

void am64xEthInitGpio ( NetInterface interface)

GPIO configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 581 of file am64x_eth_driver.c.

◆ am64xEthInitInstance()

void am64xEthInitInstance ( NetInterface interface)

Initialize CPSW instance.

Parameters
[in]interfaceUnderlying network interface

Definition at line 309 of file am64x_eth_driver.c.

◆ am64xEthInitPort1()

error_t am64xEthInitPort1 ( NetInterface interface)

AM64x Ethernet MAC initialization (port 1)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 123 of file am64x_eth_driver.c.

◆ am64xEthInitPort2()

error_t am64xEthInitPort2 ( NetInterface interface)

AM64x Ethernet MAC initialization (port 2)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 226 of file am64x_eth_driver.c.

◆ am64xEthReadEntry()

void am64xEthReadEntry ( uint_t  index,
Am64xAleEntry entry 
)

Read an ALE table entry.

Parameters
[in]indexEntry index
[out]entryPointer to the ALE table entry

Definition at line 1196 of file am64x_eth_driver.c.

◆ am64xEthReadPhyReg()

uint16_t am64xEthReadPhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
Returns
Register value

Definition at line 1119 of file am64x_eth_driver.c.

◆ am64xEthRxIrqHandler()

void am64xEthRxIrqHandler ( void *  arg)

AM64x Ethernet MAC receive interrupt.

Parameters
[in]argUnused parameter

Definition at line 737 of file am64x_eth_driver.c.

◆ am64xEthSendPacket()

error_t am64xEthSendPacket ( NetInterface interface,
const NetBuffer buffer,
size_t  offset,
NetTxAncillary ancillary 
)

Send a packet.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 844 of file am64x_eth_driver.c.

◆ am64xEthTick()

void am64xEthTick ( NetInterface interface)

AM64x Ethernet MAC timer handler.

This routine is periodically called by the TCP/IP stack to handle periodic operations such as polling the link state

Parameters
[in]interfaceUnderlying network interface

Definition at line 662 of file am64x_eth_driver.c.

◆ am64xEthUpdateMacAddrFilter()

error_t am64xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 940 of file am64x_eth_driver.c.

◆ am64xEthUpdateMacConfig()

error_t am64xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 998 of file am64x_eth_driver.c.

◆ am64xEthWriteEntry()

void am64xEthWriteEntry ( uint_t  index,
const Am64xAleEntry entry 
)

Write an ALE table entry.

Parameters
[in]indexEntry index
[in]entryPointer to the ALE table entry

Definition at line 1173 of file am64x_eth_driver.c.

◆ am64xEthWritePhyReg()

void am64xEthWritePhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
[in]dataRegister value

Definition at line 1068 of file am64x_eth_driver.c.

Variable Documentation

◆ am64xEthPort1Driver

const NicDriver am64xEthPort1Driver
extern

AM64x Ethernet MAC driver (port1)

Definition at line 71 of file am64x_eth_driver.c.

◆ am64xEthPort2Driver

const NicDriver am64xEthPort2Driver
extern

AM64x Ethernet MAC driver (port2)

Definition at line 96 of file am64x_eth_driver.c.