am243x_eth_driver.c File Reference

AM243x Ethernet MAC driver. More...

#include <hw_include/csl_cpswitch.h>
#include <kernel/dpl/AddrTranslateP.h>
#include <drivers/pinmux.h>
#include <drivers/udma/udma_priv.h>
#include <networking/enet/utils/include/enet_apputils.h>
#include <networking/enet/utils/include/enet_appmemutils.h>
#include <networking/enet/utils/include/enet_appmemutils_cfg.h>
#include "core/net.h"
#include "drivers/mac/am243x_eth_driver.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 
#define MDIO_INPUT_CLK   250000000
 
#define MDIO_OUTPUT_CLK   1000000
 

Functions

error_t am243xEthInitPort1 (NetInterface *interface)
 AM243x Ethernet MAC initialization (port 1) More...
 
error_t am243xEthInitPort2 (NetInterface *interface)
 AM243x Ethernet MAC initialization (port 2) More...
 
void am243xEthInitInstance (NetInterface *interface)
 Initialize CPSW instance. More...
 
__weak_func void am243xEthInitGpio (NetInterface *interface)
 GPIO configuration. More...
 
void am243xEthTick (NetInterface *interface)
 AM243x Ethernet MAC timer handler. More...
 
void am243xEthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void am243xEthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void am243xEthRxIrqHandler (void *arg)
 AM243x Ethernet MAC receive interrupt. More...
 
void am243xEthEventHandler (NetInterface *interface)
 AM243x Ethernet MAC event handler. More...
 
error_t am243xEthSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet. More...
 
error_t am243xEthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t am243xEthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void am243xEthWritePhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t am243xEthReadPhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
void am243xEthWriteEntry (uint_t index, const Am64xAleEntry *entry)
 Write an ALE table entry. More...
 
void am243xEthReadEntry (uint_t index, Am64xAleEntry *entry)
 Read an ALE table entry. More...
 
uint_t am243xEthFindFreeEntry (void)
 Find a free entry in the ALE table. More...
 
uint_t am243xEthFindVlanEntry (uint_t vlanId)
 Search the ALE table for the specified VLAN entry. More...
 
uint_t am243xEthFindVlanAddrEntry (uint_t vlanId, MacAddr *macAddr)
 Search the ALE table for the specified VLAN/address entry. More...
 
error_t am243xEthAddVlanEntry (uint_t port, uint_t vlanId)
 Add a VLAN entry in the ALE table. More...
 
error_t am243xEthAddVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Add a VLAN/address entry in the ALE table. More...
 
error_t am243xEthDeleteVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Remove a VLAN/address entry from the ALE table. More...
 

Variables

const NicDriver am243xEthPort1Driver
 AM243x Ethernet MAC driver (port1) More...
 
const NicDriver am243xEthPort2Driver
 AM243x Ethernet MAC driver (port2) More...
 

Detailed Description

AM243x 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 am243x_eth_driver.c.

Macro Definition Documentation

◆ MDIO_INPUT_CLK

#define MDIO_INPUT_CLK   250000000

Definition at line 47 of file am243x_eth_driver.c.

◆ MDIO_OUTPUT_CLK

#define MDIO_OUTPUT_CLK   1000000

Definition at line 49 of file am243x_eth_driver.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file am243x_eth_driver.c.

Function Documentation

◆ am243xEthAddVlanAddrEntry()

error_t am243xEthAddVlanAddrEntry ( 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 am243x_eth_driver.c.

◆ am243xEthAddVlanEntry()

error_t am243xEthAddVlanEntry ( 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 am243x_eth_driver.c.

◆ am243xEthDeleteVlanAddrEntry()

error_t am243xEthDeleteVlanAddrEntry ( 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 am243x_eth_driver.c.

◆ am243xEthDisableIrq()

void am243xEthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 712 of file am243x_eth_driver.c.

◆ am243xEthEnableIrq()

void am243xEthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 687 of file am243x_eth_driver.c.

◆ am243xEthEventHandler()

void am243xEthEventHandler ( NetInterface interface)

AM243x Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 759 of file am243x_eth_driver.c.

◆ am243xEthFindFreeEntry()

uint_t am243xEthFindFreeEntry ( void  )

Find a free entry in the ALE table.

Returns
Index of the first free entry

Definition at line 1218 of file am243x_eth_driver.c.

◆ am243xEthFindVlanAddrEntry()

uint_t am243xEthFindVlanAddrEntry ( 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 am243x_eth_driver.c.

◆ am243xEthFindVlanEntry()

uint_t am243xEthFindVlanEntry ( 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 am243x_eth_driver.c.

◆ am243xEthInitGpio()

__weak_func void am243xEthInitGpio ( NetInterface interface)

GPIO configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 581 of file am243x_eth_driver.c.

◆ am243xEthInitInstance()

void am243xEthInitInstance ( NetInterface interface)

Initialize CPSW instance.

Parameters
[in]interfaceUnderlying network interface

Definition at line 309 of file am243x_eth_driver.c.

◆ am243xEthInitPort1()

error_t am243xEthInitPort1 ( NetInterface interface)

AM243x Ethernet MAC initialization (port 1)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 123 of file am243x_eth_driver.c.

◆ am243xEthInitPort2()

error_t am243xEthInitPort2 ( NetInterface interface)

AM243x Ethernet MAC initialization (port 2)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 226 of file am243x_eth_driver.c.

◆ am243xEthReadEntry()

void am243xEthReadEntry ( 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 am243x_eth_driver.c.

◆ am243xEthReadPhyReg()

uint16_t am243xEthReadPhyReg ( 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 am243x_eth_driver.c.

◆ am243xEthRxIrqHandler()

void am243xEthRxIrqHandler ( void *  arg)

AM243x Ethernet MAC receive interrupt.

Parameters
[in]argUnused parameter

Definition at line 737 of file am243x_eth_driver.c.

◆ am243xEthSendPacket()

error_t am243xEthSendPacket ( 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 am243x_eth_driver.c.

◆ am243xEthTick()

void am243xEthTick ( NetInterface interface)

AM243x 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 am243x_eth_driver.c.

◆ am243xEthUpdateMacAddrFilter()

error_t am243xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 940 of file am243x_eth_driver.c.

◆ am243xEthUpdateMacConfig()

error_t am243xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 998 of file am243x_eth_driver.c.

◆ am243xEthWriteEntry()

void am243xEthWriteEntry ( 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 am243x_eth_driver.c.

◆ am243xEthWritePhyReg()

void am243xEthWritePhyReg ( 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 am243x_eth_driver.c.

Variable Documentation

◆ am243xEthPort1Driver

◆ am243xEthPort2Driver

#define TRUE
Definition: os_port.h:50
error_t am243xEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
error_t am243xEthInitPort1(NetInterface *interface)
AM243x Ethernet MAC initialization (port 1)
#define FALSE
Definition: os_port.h:46
void am243xEthEnableIrq(NetInterface *interface)
Enable interrupts.
uint16_t am243xEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void am243xEthDisableIrq(NetInterface *interface)
Disable interrupts.
void am243xEthTick(NetInterface *interface)
AM243x Ethernet MAC timer handler.
void am243xEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
#define ETH_MTU
Definition: ethernet.h:116
void am243xEthEventHandler(NetInterface *interface)
AM243x Ethernet MAC event handler.
error_t am243xEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t am243xEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
error_t am243xEthInitPort2(NetInterface *interface)
AM243x Ethernet MAC initialization (port 2)
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83