am335x_eth_driver.c File Reference

Sitara AM335x Ethernet MAC controller. More...

#include "soc_am335x.h"
#include "hw_types.h"
#include "hw_cm_per.h"
#include "hw_control_am335x.h"
#include "hw_cpsw_ale.h"
#include "hw_cpsw_cpdma.h"
#include "hw_cpsw_port.h"
#include "hw_cpsw_sl.h"
#include "hw_cpsw_ss.h"
#include "hw_cpsw_wr.h"
#include "hw_mdio.h"
#include "interrupt.h"
#include "core/net.h"
#include "drivers/mac/am335x_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   125000000
 
#define MDIO_OUTPUT_CLK   1000000
 

Functions

error_t am335xEthInitPort1 (NetInterface *interface)
 AM335x Ethernet MAC initialization (port 1) More...
 
error_t am335xEthInitPort2 (NetInterface *interface)
 AM335x Ethernet MAC initialization (port 2) More...
 
void am335xEthInitInstance (NetInterface *interface)
 Initialize CPSW instance. More...
 
void am335xEthInitBufferDesc (NetInterface *interface)
 Initialize buffer descriptor lists. More...
 
void am335xEthTick (NetInterface *interface)
 AM335x Ethernet MAC timer handler. More...
 
void am335xEthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void am335xEthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void am335xEthTxIrqHandler (void)
 Ethernet MAC transmit interrupt. More...
 
void am335xEthRxIrqHandler (void)
 Ethernet MAC receive interrupt. More...
 
void am335xEthEventHandler (NetInterface *interface)
 AM335x Ethernet MAC event handler. More...
 
error_t am335xEthSendPacketPort1 (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Send a packet (port 1) More...
 
error_t am335xEthSendPacketPort2 (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Send a packet (port 2) More...
 
error_t am335xEthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t am335xEthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void am335xEthWritePhyReg (uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t am335xEthReadPhyReg (uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
void am335xEthWriteEntry (uint_t index, const Am335xAleEntry *entry)
 Write an ALE table entry. More...
 
void am335xEthReadEntry (uint_t index, Am335xAleEntry *entry)
 Read an ALE table entry. More...
 
uint_t am335xEthFindFreeEntry (void)
 Find a free entry in the ALE table. More...
 
uint_t am335xEthFindVlanEntry (uint_t vlanId)
 Search the ALE table for the specified VLAN entry. More...
 
uint_t am335xEthFindVlanAddrEntry (uint_t vlanId, MacAddr *macAddr)
 Search the ALE table for the specified VLAN/address entry. More...
 
error_t am335xEthAddVlanEntry (uint_t port, uint_t vlanId)
 Add a VLAN entry in the ALE table. More...
 
error_t am335xEthAddVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Add a VLAN/address entry in the ALE table. More...
 
error_t am335xEthDeleteVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Remove a VLAN/address entry from the ALE table. More...
 

Variables

const NicDriver am335xEthPort1Driver
 AM335x Ethernet MAC driver (port1) More...
 
const NicDriver am335xEthPort2Driver
 AM335x Ethernet MAC driver (port2) More...
 

Detailed Description

Sitara AM335x Ethernet MAC controller.

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file am335x_eth_driver.c.

Macro Definition Documentation

◆ MDIO_INPUT_CLK

#define MDIO_INPUT_CLK   125000000

Definition at line 50 of file am335x_eth_driver.c.

◆ MDIO_OUTPUT_CLK

#define MDIO_OUTPUT_CLK   1000000

Definition at line 52 of file am335x_eth_driver.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 30 of file am335x_eth_driver.c.

Function Documentation

◆ am335xEthAddVlanAddrEntry()

error_t am335xEthAddVlanAddrEntry ( 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 1693 of file am335x_eth_driver.c.

◆ am335xEthAddVlanEntry()

error_t am335xEthAddVlanEntry ( 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 1633 of file am335x_eth_driver.c.

◆ am335xEthDeleteVlanAddrEntry()

error_t am335xEthDeleteVlanAddrEntry ( 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 1764 of file am335x_eth_driver.c.

◆ am335xEthDisableIrq()

void am335xEthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 857 of file am335x_eth_driver.c.

◆ am335xEthEnableIrq()

void am335xEthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 835 of file am335x_eth_driver.c.

◆ am335xEthEventHandler()

void am335xEthEventHandler ( NetInterface interface)

AM335x Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1017 of file am335x_eth_driver.c.

◆ am335xEthFindFreeEntry()

uint_t am335xEthFindFreeEntry ( void  )

Find a free entry in the ALE table.

Returns
Index of the first free entry

Definition at line 1506 of file am335x_eth_driver.c.

◆ am335xEthFindVlanAddrEntry()

uint_t am335xEthFindVlanAddrEntry ( 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 1582 of file am335x_eth_driver.c.

◆ am335xEthFindVlanEntry()

uint_t am335xEthFindVlanEntry ( 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 1540 of file am335x_eth_driver.c.

◆ am335xEthInitBufferDesc()

void am335xEthInitBufferDesc ( NetInterface interface)

Initialize buffer descriptor lists.

Parameters
[in]interfaceUnderlying network interface

Definition at line 705 of file am335x_eth_driver.c.

◆ am335xEthInitInstance()

void am335xEthInitInstance ( NetInterface interface)

Initialize CPSW instance.

Parameters
[in]interfaceUnderlying network interface

Definition at line 320 of file am335x_eth_driver.c.

◆ am335xEthInitPort1()

error_t am335xEthInitPort1 ( NetInterface interface)

AM335x Ethernet MAC initialization (port 1)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 175 of file am335x_eth_driver.c.

◆ am335xEthInitPort2()

error_t am335xEthInitPort2 ( NetInterface interface)

AM335x Ethernet MAC initialization (port 2)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 248 of file am335x_eth_driver.c.

◆ am335xEthReadEntry()

void am335xEthReadEntry ( uint_t  index,
Am335xAleEntry entry 
)

Read an ALE table entry.

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

Definition at line 1489 of file am335x_eth_driver.c.

◆ am335xEthReadPhyReg()

uint16_t am335xEthReadPhyReg ( uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]phyAddrPHY address
[in]regAddrRegister address
Returns
Register value

Definition at line 1444 of file am335x_eth_driver.c.

◆ am335xEthRxIrqHandler()

void am335xEthRxIrqHandler ( void  )

Ethernet MAC receive interrupt.

Definition at line 974 of file am335x_eth_driver.c.

◆ am335xEthSendPacketPort1()

error_t am335xEthSendPacketPort1 ( NetInterface interface,
const NetBuffer buffer,
size_t  offset 
)

Send a packet (port 1)

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
Returns
Error code

Definition at line 1144 of file am335x_eth_driver.c.

◆ am335xEthSendPacketPort2()

error_t am335xEthSendPacketPort2 ( NetInterface interface,
const NetBuffer buffer,
size_t  offset 
)

Send a packet (port 2)

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
Returns
Error code

Definition at line 1229 of file am335x_eth_driver.c.

◆ am335xEthTick()

void am335xEthTick ( NetInterface interface)

AM335x 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 811 of file am335x_eth_driver.c.

◆ am335xEthTxIrqHandler()

void am335xEthTxIrqHandler ( void  )

Ethernet MAC transmit interrupt.

Definition at line 878 of file am335x_eth_driver.c.

◆ am335xEthUpdateMacAddrFilter()

error_t am335xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 1312 of file am335x_eth_driver.c.

◆ am335xEthUpdateMacConfig()

error_t am335xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 1364 of file am335x_eth_driver.c.

◆ am335xEthWriteEntry()

void am335xEthWriteEntry ( uint_t  index,
const Am335xAleEntry entry 
)

Write an ALE table entry.

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

Definition at line 1471 of file am335x_eth_driver.c.

◆ am335xEthWritePhyReg()

void am335xEthWritePhyReg ( uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]phyAddrPHY address
[in]regAddrRegister address
[in]dataRegister value

Definition at line 1417 of file am335x_eth_driver.c.

Variable Documentation

◆ am335xEthPort1Driver

const NicDriver am335xEthPort1Driver
Initial value:
=
{
}
void am335xEthTick(NetInterface *interface)
AM335x Ethernet MAC timer handler.
error_t am335xEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t am335xEthInitPort1(NetInterface *interface)
AM335x Ethernet MAC initialization (port 1)
void am335xEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
error_t am335xEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define TRUE
Definition: os_port.h:48
uint16_t am335xEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void am335xEthEventHandler(NetInterface *interface)
AM335x Ethernet MAC event handler.
void am335xEthDisableIrq(NetInterface *interface)
Disable interrupts.
void am335xEthEnableIrq(NetInterface *interface)
Enable interrupts.
#define ETH_MTU
Definition: ethernet.h:82
Ethernet interface.
Definition: nic.h:69
#define FALSE
Definition: os_port.h:44
error_t am335xEthSendPacketPort1(NetInterface *interface, const NetBuffer *buffer, size_t offset)
Send a packet (port 1)

AM335x Ethernet MAC driver (port1)

Definition at line 123 of file am335x_eth_driver.c.

◆ am335xEthPort2Driver

const NicDriver am335xEthPort2Driver
Initial value:
=
{
}
void am335xEthTick(NetInterface *interface)
AM335x Ethernet MAC timer handler.
error_t am335xEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
void am335xEthWritePhyReg(uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
error_t am335xEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
error_t am335xEthSendPacketPort2(NetInterface *interface, const NetBuffer *buffer, size_t offset)
Send a packet (port 2)
#define TRUE
Definition: os_port.h:48
uint16_t am335xEthReadPhyReg(uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void am335xEthEventHandler(NetInterface *interface)
AM335x Ethernet MAC event handler.
void am335xEthDisableIrq(NetInterface *interface)
Disable interrupts.
void am335xEthEnableIrq(NetInterface *interface)
Enable interrupts.
#define ETH_MTU
Definition: ethernet.h:82
Ethernet interface.
Definition: nic.h:69
#define FALSE
Definition: os_port.h:44
error_t am335xEthInitPort2(NetInterface *interface)
AM335x Ethernet MAC initialization (port 2)

AM335x Ethernet MAC driver (port2)

Definition at line 148 of file am335x_eth_driver.c.