mv88e6060_driver.c File Reference

88E6060 6-port Ethernet switch driver More...

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

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t mv88e6060Init (NetInterface *interface)
 88E6060 Ethernet switch initialization More...
 
__weak_func void mv88e6060InitHook (NetInterface *interface)
 88E6060 custom configuration More...
 
void mv88e6060Tick (NetInterface *interface)
 88E6060 timer handler More...
 
void mv88e6060EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void mv88e6060DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void mv88e6060EventHandler (NetInterface *interface)
 88E6060 event handler More...
 
error_t mv88e6060TagFrame (NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
 Add ingress trailer to Ethernet frame. More...
 
error_t mv88e6060UntagFrame (NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
 Decode egress trailer from incoming Ethernet frame. More...
 
bool_t mv88e6060GetLinkState (NetInterface *interface, uint8_t port)
 Get link state. More...
 
uint32_t mv88e6060GetLinkSpeed (NetInterface *interface, uint8_t port)
 Get link speed. More...
 
NicDuplexMode mv88e6060GetDuplexMode (NetInterface *interface, uint8_t port)
 Get duplex mode. More...
 
void mv88e6060SetPortState (NetInterface *interface, uint8_t port, SwitchPortState state)
 Set port state. More...
 
SwitchPortState mv88e6060GetPortState (NetInterface *interface, uint8_t port)
 Get port state. More...
 
void mv88e6060SetAgingTime (NetInterface *interface, uint32_t agingTime)
 Set aging time for dynamic filtering entries. More...
 
void mv88e6060EnableIgmpSnooping (NetInterface *interface, bool_t enable)
 Enable IGMP snooping. More...
 
void mv88e6060EnableMldSnooping (NetInterface *interface, bool_t enable)
 Enable MLD snooping. More...
 
void mv88e6060EnableRsvdMcastTable (NetInterface *interface, bool_t enable)
 Enable reserved multicast table. More...
 
error_t mv88e6060AddStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry)
 Add a new entry to the static MAC table. More...
 
error_t mv88e6060DeleteStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry)
 Remove an entry from the static MAC table. More...
 
error_t mv88e6060GetStaticFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
 Read an entry from the static MAC table. More...
 
void mv88e6060FlushStaticFdbTable (NetInterface *interface)
 Flush static MAC table. More...
 
error_t mv88e6060GetDynamicFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
 Read an entry from the dynamic MAC table. More...
 
void mv88e6060FlushDynamicFdbTable (NetInterface *interface, uint8_t port)
 Flush dynamic MAC table. More...
 
void mv88e6060SetUnknownMcastFwdPorts (NetInterface *interface, bool_t enable, uint32_t forwardPorts)
 Set forward ports for unknown multicast packets. More...
 
void mv88e6060WriteSmiReg (NetInterface *interface, uint8_t deviceAddr, uint8_t regAddr, uint16_t data)
 Write SMI register. More...
 
uint16_t mv88e6060ReadSmiReg (NetInterface *interface, uint8_t deviceAddr, uint8_t regAddr)
 Read SMI register. More...
 
void mv88e6060WritePhyReg (NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
 Write PHY register. More...
 
uint16_t mv88e6060ReadPhyReg (NetInterface *interface, uint8_t port, uint8_t address)
 Read PHY register. More...
 
void mv88e6060DumpPhyReg (NetInterface *interface, uint8_t port)
 Dump PHY registers for debugging purpose. More...
 
void mv88e6060WriteSwitchPortReg (NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
 Write switch port register. More...
 
uint16_t mv88e6060ReadSwitchPortReg (NetInterface *interface, uint8_t port, uint8_t address)
 Read switch port register. More...
 
void mv88e6060WriteSwitchGlobalReg (NetInterface *interface, uint8_t address, uint16_t data)
 Write switch global register. More...
 
uint16_t mv88e6060ReadSwitchGlobalReg (NetInterface *interface, uint8_t address)
 Read switch global register. More...
 

Variables

const SwitchDriver mv88e6060SwitchDriver
 88E6060 Ethernet switch driver More...
 
const uint32_t mv88e6060IngressTrailer [6]
 Ingress trailer (CPU to 88E6060) More...
 

Detailed Description

88E6060 6-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 mv88e6060_driver.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file mv88e6060_driver.c.

Function Documentation

◆ mv88e6060AddStaticFdbEntry()

error_t mv88e6060AddStaticFdbEntry ( 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 834 of file mv88e6060_driver.c.

◆ mv88e6060DeleteStaticFdbEntry()

error_t mv88e6060DeleteStaticFdbEntry ( 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 918 of file mv88e6060_driver.c.

◆ mv88e6060DisableIrq()

void mv88e6060DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 299 of file mv88e6060_driver.c.

◆ mv88e6060DumpPhyReg()

void mv88e6060DumpPhyReg ( NetInterface interface,
uint8_t  port 
)

Dump PHY registers for debugging purpose.

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

Definition at line 1511 of file mv88e6060_driver.c.

◆ mv88e6060EnableIgmpSnooping()

void mv88e6060EnableIgmpSnooping ( NetInterface interface,
bool_t  enable 
)

Enable IGMP snooping.

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

Definition at line 768 of file mv88e6060_driver.c.

◆ mv88e6060EnableIrq()

void mv88e6060EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 289 of file mv88e6060_driver.c.

◆ mv88e6060EnableMldSnooping()

void mv88e6060EnableMldSnooping ( NetInterface interface,
bool_t  enable 
)

Enable MLD snooping.

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

Definition at line 780 of file mv88e6060_driver.c.

◆ mv88e6060EnableRsvdMcastTable()

void mv88e6060EnableRsvdMcastTable ( NetInterface interface,
bool_t  enable 
)

Enable reserved multicast table.

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

Definition at line 792 of file mv88e6060_driver.c.

◆ mv88e6060EventHandler()

void mv88e6060EventHandler ( NetInterface interface)

88E6060 event handler

Parameters
[in]interfaceUnderlying network interface

Definition at line 309 of file mv88e6060_driver.c.

◆ mv88e6060FlushDynamicFdbTable()

void mv88e6060FlushDynamicFdbTable ( NetInterface interface,
uint8_t  port 
)

Flush dynamic MAC table.

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

Definition at line 1289 of file mv88e6060_driver.c.

◆ mv88e6060FlushStaticFdbTable()

void mv88e6060FlushStaticFdbTable ( NetInterface interface)

Flush static MAC table.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1102 of file mv88e6060_driver.c.

◆ mv88e6060GetDuplexMode()

NicDuplexMode mv88e6060GetDuplexMode ( NetInterface interface,
uint8_t  port 
)

Get duplex mode.

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

Definition at line 598 of file mv88e6060_driver.c.

◆ mv88e6060GetDynamicFdbEntry()

error_t mv88e6060GetDynamicFdbEntry ( 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 1137 of file mv88e6060_driver.c.

◆ mv88e6060GetLinkSpeed()

uint32_t mv88e6060GetLinkSpeed ( NetInterface interface,
uint8_t  port 
)

Get link speed.

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

Definition at line 559 of file mv88e6060_driver.c.

◆ mv88e6060GetLinkState()

bool_t mv88e6060GetLinkState ( NetInterface interface,
uint8_t  port 
)

Get link state.

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

Definition at line 527 of file mv88e6060_driver.c.

◆ mv88e6060GetPortState()

SwitchPortState mv88e6060GetPortState ( NetInterface interface,
uint8_t  port 
)

Get port state.

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

Definition at line 688 of file mv88e6060_driver.c.

◆ mv88e6060GetStaticFdbEntry()

error_t mv88e6060GetStaticFdbEntry ( 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 975 of file mv88e6060_driver.c.

◆ mv88e6060Init()

error_t mv88e6060Init ( NetInterface interface)

88E6060 Ethernet switch initialization

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 94 of file mv88e6060_driver.c.

◆ mv88e6060InitHook()

__weak_func void mv88e6060InitHook ( NetInterface interface)

88E6060 custom configuration

Parameters
[in]interfaceUnderlying network interface

Definition at line 209 of file mv88e6060_driver.c.

◆ mv88e6060ReadPhyReg()

uint16_t mv88e6060ReadPhyReg ( NetInterface interface,
uint8_t  port,
uint8_t  address 
)

Read PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressPHY register address
Returns
Register value

Definition at line 1482 of file mv88e6060_driver.c.

◆ mv88e6060ReadSmiReg()

uint16_t mv88e6060ReadSmiReg ( NetInterface interface,
uint8_t  deviceAddr,
uint8_t  regAddr 
)

Read SMI register.

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

Definition at line 1426 of file mv88e6060_driver.c.

◆ mv88e6060ReadSwitchGlobalReg()

uint16_t mv88e6060ReadSwitchGlobalReg ( NetInterface interface,
uint8_t  address 
)

Read switch global register.

Parameters
[in]interfaceUnderlying network interface
[in]addressSwitch global register address
Returns
Register value

Definition at line 1609 of file mv88e6060_driver.c.

◆ mv88e6060ReadSwitchPortReg()

uint16_t mv88e6060ReadSwitchPortReg ( NetInterface interface,
uint8_t  port,
uint8_t  address 
)

Read switch port register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressSwitch port register address
Returns
Register value

Definition at line 1562 of file mv88e6060_driver.c.

◆ mv88e6060SetAgingTime()

void mv88e6060SetAgingTime ( 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 740 of file mv88e6060_driver.c.

◆ mv88e6060SetPortState()

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

Set port state.

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

Definition at line 637 of file mv88e6060_driver.c.

◆ mv88e6060SetUnknownMcastFwdPorts()

void mv88e6060SetUnknownMcastFwdPorts ( 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 1385 of file mv88e6060_driver.c.

◆ mv88e6060TagFrame()

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

Add ingress trailer 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 425 of file mv88e6060_driver.c.

◆ mv88e6060Tick()

void mv88e6060Tick ( NetInterface interface)

88E6060 timer handler

Parameters
[in]interfaceUnderlying network interface

Definition at line 219 of file mv88e6060_driver.c.

◆ mv88e6060UntagFrame()

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

Decode egress trailer 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 480 of file mv88e6060_driver.c.

◆ mv88e6060WritePhyReg()

void mv88e6060WritePhyReg ( NetInterface interface,
uint8_t  port,
uint8_t  address,
uint16_t  data 
)

Write PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressPHY register address
[in]dataRegister value

Definition at line 1457 of file mv88e6060_driver.c.

◆ mv88e6060WriteSmiReg()

void mv88e6060WriteSmiReg ( NetInterface interface,
uint8_t  deviceAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write SMI register.

Parameters
[in]interfaceUnderlying network interface
[in]deviceAddrSMI device address
[in]regAddrRegister address
[in]dataRegister value

Definition at line 1400 of file mv88e6060_driver.c.

◆ mv88e6060WriteSwitchGlobalReg()

void mv88e6060WriteSwitchGlobalReg ( NetInterface interface,
uint8_t  address,
uint16_t  data 
)

Write switch global register.

Parameters
[in]interfaceUnderlying network interface
[in]addressSwitch global register address
[in]dataRegister value

Definition at line 1593 of file mv88e6060_driver.c.

◆ mv88e6060WriteSwitchPortReg()

void mv88e6060WriteSwitchPortReg ( NetInterface interface,
uint8_t  port,
uint8_t  address,
uint16_t  data 
)

Write switch port register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressSwitch port register address
[in]dataRegister value

Definition at line 1536 of file mv88e6060_driver.c.

Variable Documentation

◆ mv88e6060IngressTrailer

◆ mv88e6060SwitchDriver

NicDuplexMode mv88e6060GetDuplexMode(NetInterface *interface, uint8_t port)
Get duplex mode.
void mv88e6060Tick(NetInterface *interface)
88E6060 timer handler
#define MV88E6060_IG_OVERRIDE
void mv88e6060SetAgingTime(NetInterface *interface, uint32_t agingTime)
Set aging time for dynamic filtering entries.
void mv88e6060SetPortState(NetInterface *interface, uint8_t port, SwitchPortState state)
Set port state.
void mv88e6060EnableIgmpSnooping(NetInterface *interface, bool_t enable)
Enable IGMP snooping.
error_t mv88e6060GetDynamicFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the dynamic MAC table.
error_t mv88e6060DeleteStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Remove an entry from the static MAC table.
error_t mv88e6060UntagFrame(NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary)
Decode egress trailer from incoming Ethernet frame.
error_t mv88e6060AddStaticFdbEntry(NetInterface *interface, const SwitchFdbEntry *entry)
Add a new entry to the static MAC table.
#define MV88E6060_IG_MGMT
void mv88e6060SetUnknownMcastFwdPorts(NetInterface *interface, bool_t enable, uint32_t forwardPorts)
Set forward ports for unknown multicast packets.
error_t mv88e6060TagFrame(NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary)
Add ingress trailer to Ethernet frame.
#define MV88E6060_IG_DPV_PORT2
#define HTONL(value)
Definition: cpu_endian.h:411
void mv88e6060EventHandler(NetInterface *interface)
88E6060 event handler
#define MV88E6060_IG_DPV_PORT0
void mv88e6060FlushDynamicFdbTable(NetInterface *interface, uint8_t port)
Flush dynamic MAC table.
void mv88e6060EnableIrq(NetInterface *interface)
Enable interrupts.
void mv88e6060EnableMldSnooping(NetInterface *interface, bool_t enable)
Enable MLD snooping.
void mv88e6060DisableIrq(NetInterface *interface)
Disable interrupts.
error_t mv88e6060Init(NetInterface *interface)
88E6060 Ethernet switch initialization
SwitchPortState mv88e6060GetPortState(NetInterface *interface, uint8_t port)
Get port state.
#define MV88E6060_IG_DPV_PORT3
void mv88e6060FlushStaticFdbTable(NetInterface *interface)
Flush static MAC table.
#define MV88E6060_IG_DPV_PORT1
uint32_t mv88e6060GetLinkSpeed(NetInterface *interface, uint8_t port)
Get link speed.
error_t mv88e6060GetStaticFdbEntry(NetInterface *interface, uint_t index, SwitchFdbEntry *entry)
Read an entry from the static MAC table.
void mv88e6060EnableRsvdMcastTable(NetInterface *interface, bool_t enable)
Enable reserved multicast table.
bool_t mv88e6060GetLinkState(NetInterface *interface, uint8_t port)
Get link state.