sja1105_driver.c File Reference

SJA1105 5-port Ethernet switch driver. More...

#include "core/net.h"
#include "core/ethernet_misc.h"
#include "drivers/switch/sja1105_driver.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t sja1105Init (NetInterface *interface)
 SJA1105 Ethernet switch initialization. More...
 
__weak_func error_t sja1105InitHook (NetInterface *interface)
 SJA1105 custom configuration. More...
 
error_t sja1105LoadStaticConfig (NetInterface *interface, const char_t *data, size_t length)
 Load static configuration into the device. More...
 
void sja1105ConfigurePll1 (NetInterface *interface)
 PLL1 setup for 50MHz. More...
 
error_t sja1105ConfigureCgu (NetInterface *interface, uint8_t port)
 Clock generation unit setup. More...
 
void sja1105Tick (NetInterface *interface)
 SJA1105 timer handler. More...
 
void sja1105EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void sja1105DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void sja1105EventHandler (NetInterface *interface)
 SJA1105 event handler. More...
 
error_t sja1105TagFrame (NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
 Add tail tag to Ethernet frame. More...
 
error_t sja1105UntagFrame (NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
 Decode tail tag from incoming Ethernet frame. More...
 
__weak_func bool_t sja1105GetLinkState (NetInterface *interface, uint8_t port)
 Get link state. More...
 
__weak_func uint32_t sja1105GetLinkSpeed (NetInterface *interface, uint8_t port)
 Get link speed. More...
 
NicDuplexMode sja1105GetDuplexMode (NetInterface *interface, uint8_t port)
 Get duplex mode. More...
 
void sja1105SetPortSpeed (NetInterface *interface, uint8_t port, uint32_t speed)
 Reconfigure port speed. More...
 
void sja1105SetPortState (NetInterface *interface, uint8_t port, SwitchPortState state)
 Set port state. More...
 
SwitchPortState sja1105GetPortState (NetInterface *interface, uint8_t port)
 Get port state. More...
 
void sja1105SetAgingTime (NetInterface *interface, uint32_t agingTime)
 Set aging time for dynamic filtering entries. More...
 
void sja1105EnableIgmpSnooping (NetInterface *interface, bool_t enable)
 Enable IGMP snooping. More...
 
void sja1105EnableMldSnooping (NetInterface *interface, bool_t enable)
 Enable MLD snooping. More...
 
void sja1105EnableRsvdMcastTable (NetInterface *interface, bool_t enable)
 Enable reserved multicast table. More...
 
error_t sja1105AddStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry)
 Add a new entry to the static MAC table. More...
 
error_t sja1105DeleteStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry)
 Remove an entry from the static MAC table. More...
 
error_t sja1105GetStaticFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
 Read an entry from the static MAC table. More...
 
void sja1105FlushStaticFdbTable (NetInterface *interface)
 Flush static MAC table. More...
 
void sja1105SetUnknownMcastFwdPorts (NetInterface *interface, bool_t enable, uint32_t forwardPorts)
 Set forward ports for unknown multicast packets. More...
 
error_t sja1105GetDynamicFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
 Read an entry from the dynamic MAC table. More...
 
void sja1105FlushDynamicFdbTable (NetInterface *interface, uint8_t port)
 Flush dynamic MAC table. More...
 
error_t sja1105WriteMacConfigEntry (NetInterface *interface, uint8_t port)
 Reconfigure an entry in the MAC configuration table. More...
 
error_t sja1105ReadMacConfigEntry (NetInterface *interface, uint8_t port)
 Read an entry from the MAC configuration table. More...
 
void sja1105WriteSingleReg (NetInterface *interface, uint32_t address, uint32_t data)
 Write a single register. More...
 
uint32_t sja1105ReadSingleReg (NetInterface *interface, uint32_t address)
 Read a single register. More...
 
void sja1105WriteMultipleRegs (NetInterface *interface, uint32_t address, const uint32_t *data, uint_t count)
 Write multiple registers. More...
 
void sja1105ReadMultipleRegs (NetInterface *interface, uint32_t address, uint32_t *data, uint_t count)
 Read multiple registers. More...
 
void sja1105DumpReg (NetInterface *interface)
 Dump registers for debugging purpose. More...
 
void sja1105WritePhyReg (NetInterface *interface, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t sja1105ReadPhyReg (NetInterface *interface, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
void sja1105DumpPhyReg (NetInterface *interface, uint8_t phyAddr)
 Dump PHY registers for debugging purpose. More...
 

Variables

const SwitchDriver sja1105SwitchDriver
 SJA1105 Ethernet switch driver. More...
 

Detailed Description

SJA1105 5-port Ethernet switch 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 sja1105_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file sja1105_driver.c.

Function Documentation

◆ sja1105AddStaticFdbEntry()

error_t sja1105AddStaticFdbEntry ( NetInterface interface,
const SwitchFdbEntry entry 
)

Add a new entry to the static MAC table.

Parameters
[in]interfaceUnderlying network interface
[in]entryPointer to the forwarding database entry
Returns
Error code

Definition at line 837 of file sja1105_driver.c.

◆ sja1105ConfigureCgu()

error_t sja1105ConfigureCgu ( NetInterface interface,
uint8_t  port 
)

Clock generation unit setup.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Error code

Definition at line 320 of file sja1105_driver.c.

◆ sja1105ConfigurePll1()

void sja1105ConfigurePll1 ( NetInterface interface)

PLL1 setup for 50MHz.

Parameters
[in]interfaceUnderlying network interface

Definition at line 292 of file sja1105_driver.c.

◆ sja1105DeleteStaticFdbEntry()

error_t sja1105DeleteStaticFdbEntry ( NetInterface interface,
const SwitchFdbEntry entry 
)

Remove an entry from the static MAC table.

Parameters
[in]interfaceUnderlying network interface
[in]entryForwarding database entry to remove from the table
Returns
Error code

Definition at line 852 of file sja1105_driver.c.

◆ sja1105DisableIrq()

void sja1105DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 568 of file sja1105_driver.c.

◆ sja1105DumpPhyReg()

void sja1105DumpPhyReg ( NetInterface interface,
uint8_t  phyAddr 
)

Dump PHY registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface
[in]phyAddrPHY address

Definition at line 1246 of file sja1105_driver.c.

◆ sja1105DumpReg()

void sja1105DumpReg ( NetInterface interface)

Dump registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1168 of file sja1105_driver.c.

◆ sja1105EnableIgmpSnooping()

void sja1105EnableIgmpSnooping ( NetInterface interface,
bool_t  enable 
)

Enable IGMP snooping.

Parameters
[in]interfaceUnderlying network interface
[in]enableEnable or disable IGMP snooping

Definition at line 800 of file sja1105_driver.c.

◆ sja1105EnableIrq()

void sja1105EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 558 of file sja1105_driver.c.

◆ sja1105EnableMldSnooping()

void sja1105EnableMldSnooping ( NetInterface interface,
bool_t  enable 
)

Enable MLD snooping.

Parameters
[in]interfaceUnderlying network interface
[in]enableEnable or disable MLD snooping

Definition at line 812 of file sja1105_driver.c.

◆ sja1105EnableRsvdMcastTable()

void sja1105EnableRsvdMcastTable ( NetInterface interface,
bool_t  enable 
)

Enable reserved multicast table.

Parameters
[in]interfaceUnderlying network interface
[in]enableEnable or disable reserved group addresses

Definition at line 824 of file sja1105_driver.c.

◆ sja1105EventHandler()

void sja1105EventHandler ( NetInterface interface)

SJA1105 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 578 of file sja1105_driver.c.

◆ sja1105FlushDynamicFdbTable()

void sja1105FlushDynamicFdbTable ( NetInterface interface,
uint8_t  port 
)

Flush dynamic MAC table.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number

Definition at line 923 of file sja1105_driver.c.

◆ sja1105FlushStaticFdbTable()

void sja1105FlushStaticFdbTable ( NetInterface interface)

Flush static MAC table.

Parameters
[in]interfaceUnderlying network interface

Definition at line 881 of file sja1105_driver.c.

◆ sja1105GetDuplexMode()

NicDuplexMode sja1105GetDuplexMode ( NetInterface interface,
uint8_t  port 
)

Get duplex mode.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Duplex mode

Definition at line 692 of file sja1105_driver.c.

◆ sja1105GetDynamicFdbEntry()

error_t sja1105GetDynamicFdbEntry ( NetInterface interface,
uint_t  index,
SwitchFdbEntry entry 
)

Read an entry from the dynamic MAC table.

Parameters
[in]interfaceUnderlying network interface
[in]indexZero-based index of the entry to read
[out]entryPointer to the forwarding database entry
Returns
Error code

Definition at line 909 of file sja1105_driver.c.

◆ sja1105GetLinkSpeed()

__weak_func uint32_t sja1105GetLinkSpeed ( NetInterface interface,
uint8_t  port 
)

Get link speed.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Link speed

Definition at line 678 of file sja1105_driver.c.

◆ sja1105GetLinkState()

__weak_func bool_t sja1105GetLinkState ( NetInterface interface,
uint8_t  port 
)

Get link state.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Link state

Definition at line 664 of file sja1105_driver.c.

◆ sja1105GetPortState()

SwitchPortState sja1105GetPortState ( NetInterface interface,
uint8_t  port 
)

Get port state.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Port state

Definition at line 775 of file sja1105_driver.c.

◆ sja1105GetStaticFdbEntry()

error_t sja1105GetStaticFdbEntry ( NetInterface interface,
uint_t  index,
SwitchFdbEntry entry 
)

Read an entry from the static MAC table.

Parameters
[in]interfaceUnderlying network interface
[in]indexZero-based index of the entry to read
[out]entryPointer to the forwarding database entry
Returns
Error code

Definition at line 868 of file sja1105_driver.c.

◆ sja1105Init()

error_t sja1105Init ( NetInterface interface)

SJA1105 Ethernet switch initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 79 of file sja1105_driver.c.

◆ sja1105InitHook()

__weak_func error_t sja1105InitHook ( NetInterface interface)

SJA1105 custom configuration.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 126 of file sja1105_driver.c.

◆ sja1105LoadStaticConfig()

error_t sja1105LoadStaticConfig ( NetInterface interface,
const char_t data,
size_t  length 
)

Load static configuration into the device.

Parameters
[in]interfaceUnderlying network interface
[in]dataPointer to the HEX file to be loaded
[in]lengthLength of the HEX file
Returns
Error code

Definition at line 141 of file sja1105_driver.c.

◆ sja1105ReadMacConfigEntry()

error_t sja1105ReadMacConfigEntry ( NetInterface interface,
uint8_t  port 
)

Read an entry from the MAC configuration table.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Error code

Definition at line 991 of file sja1105_driver.c.

◆ sja1105ReadMultipleRegs()

void sja1105ReadMultipleRegs ( NetInterface interface,
uint32_t  address,
uint32_t *  data,
uint_t  count 
)

Read multiple registers.

Parameters
[in]interfaceUnderlying network interface
[in]addressAddress of the first register to be read
[out]dataValues of the registers
[in]countNumber of registers to read

Definition at line 1127 of file sja1105_driver.c.

◆ sja1105ReadPhyReg()

uint16_t sja1105ReadPhyReg ( NetInterface interface,
uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]phyAddrPHY address
[in]regAddrRegister address
Returns
Register value

Definition at line 1218 of file sja1105_driver.c.

◆ sja1105ReadSingleReg()

uint32_t sja1105ReadSingleReg ( NetInterface interface,
uint32_t  address 
)

Read a single register.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
Returns
Register value

Definition at line 1058 of file sja1105_driver.c.

◆ sja1105SetAgingTime()

void sja1105SetAgingTime ( NetInterface interface,
uint32_t  agingTime 
)

Set aging time for dynamic filtering entries.

Parameters
[in]interfaceUnderlying network interface
[in]agingTimeAging time, in seconds

Definition at line 788 of file sja1105_driver.c.

◆ sja1105SetPortSpeed()

void sja1105SetPortSpeed ( NetInterface interface,
uint8_t  port,
uint32_t  speed 
)

Reconfigure port speed.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]speedPort speed

Definition at line 707 of file sja1105_driver.c.

◆ sja1105SetPortState()

void sja1105SetPortState ( NetInterface interface,
uint8_t  port,
SwitchPortState  state 
)

Set port state.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]statePort state

Definition at line 761 of file sja1105_driver.c.

◆ sja1105SetUnknownMcastFwdPorts()

void sja1105SetUnknownMcastFwdPorts ( NetInterface interface,
bool_t  enable,
uint32_t  forwardPorts 
)

Set forward ports for unknown multicast packets.

Parameters
[in]interfaceUnderlying network interface
[in]enableEnable or disable forwarding of unknown multicast packets
[in]forwardPortsPort map

Definition at line 894 of file sja1105_driver.c.

◆ sja1105TagFrame()

error_t sja1105TagFrame ( NetInterface interface,
NetBuffer buffer,
size_t *  offset,
NetTxAncillary ancillary 
)

Add tail tag to Ethernet frame.

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

Definition at line 631 of file sja1105_driver.c.

◆ sja1105Tick()

void sja1105Tick ( NetInterface interface)

SJA1105 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 524 of file sja1105_driver.c.

◆ sja1105UntagFrame()

error_t sja1105UntagFrame ( NetInterface interface,
uint8_t **  frame,
size_t *  length,
NetRxAncillary ancillary 
)

Decode tail tag from incoming Ethernet frame.

Parameters
[in]interfaceUnderlying network interface
[in,out]framePointer to the received Ethernet frame
[in,out]lengthLength of the frame, in bytes
[in,out]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 649 of file sja1105_driver.c.

◆ sja1105WriteMacConfigEntry()

error_t sja1105WriteMacConfigEntry ( NetInterface interface,
uint8_t  port 
)

Reconfigure an entry in the MAC configuration table.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Error code

Definition at line 936 of file sja1105_driver.c.

◆ sja1105WriteMultipleRegs()

void sja1105WriteMultipleRegs ( NetInterface interface,
uint32_t  address,
const uint32_t *  data,
uint_t  count 
)

Write multiple registers.

Parameters
[in]interfaceUnderlying network interface
[in]addressAddress of the first register to be written
[in]dataValues of the registers
[in]countNumber of registers to write

Definition at line 1079 of file sja1105_driver.c.

◆ sja1105WritePhyReg()

void sja1105WritePhyReg ( NetInterface interface,
uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]phyAddrPHY address
[in]regAddrRegister address
[in]dataRegister value

Definition at line 1193 of file sja1105_driver.c.

◆ sja1105WriteSingleReg()

void sja1105WriteSingleReg ( NetInterface interface,
uint32_t  address,
uint32_t  data 
)

Write a single register.

Parameters
[in]interfaceUnderlying network interface
[in]addressRegister address
[in]dataRegister value

Definition at line 1043 of file sja1105_driver.c.

Variable Documentation

◆ sja1105SwitchDriver

error_t sja1105DeleteStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Remove an entry from the static MAC table.
error_t sja1105AddStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Add a new entry to the static MAC table.
void sja1105EventHandler(NetInterface *interface)
SJA1105 event handler.
void sja1105DisableIrq(NetInterface *interface)
Disable interrupts.
void sja1105EnableIgmpSnooping(NetInterface *interface, bool_t enable)
Enable IGMP snooping.
void sja1105SetAgingTime(NetInterface *interface, uint32_t agingTime)
Set aging time for dynamic filtering entries.
SwitchPortState sja1105GetPortState(NetInterface *interface, uint8_t port)
Get port state.
void sja1105FlushStaticFdbTable(NetInterface *interface)
Flush static MAC table.
error_t sja1105UntagFrame(NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
Decode tail tag from incoming Ethernet frame.
error_t sja1105Init(NetInterface *interface)
SJA1105 Ethernet switch initialization.
void sja1105FlushDynamicFdbTable(NetInterface *interface, uint8_t port)
Flush dynamic MAC table.
__weak_func bool_t sja1105GetLinkState(NetInterface *interface, uint8_t port)
Get link state.
error_t sja1105TagFrame(NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
Add tail tag to Ethernet frame.
void sja1105EnableRsvdMcastTable(NetInterface *interface, bool_t enable)
Enable reserved multicast table.
NicDuplexMode sja1105GetDuplexMode(NetInterface *interface, uint8_t port)
Get duplex mode.
void sja1105Tick(NetInterface *interface)
SJA1105 timer handler.
error_t sja1105GetStaticFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the static MAC table.
error_t sja1105GetDynamicFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the dynamic MAC table.
void sja1105EnableMldSnooping(NetInterface *interface, bool_t enable)
Enable MLD snooping.
void sja1105SetUnknownMcastFwdPorts(NetInterface *interface, bool_t enable, uint32_t forwardPorts)
Set forward ports for unknown multicast packets.
__weak_func uint32_t sja1105GetLinkSpeed(NetInterface *interface, uint8_t port)
Get link speed.
void sja1105SetPortState(NetInterface *interface, uint8_t port, SwitchPortState state)
Set port state.
void sja1105EnableIrq(NetInterface *interface)
Enable interrupts.