KSZ8775 5-port Ethernet switch driver. More...
#include "core/net.h"
#include "core/ethernet_misc.h"
#include "drivers/switch/ksz8775_driver.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL NIC_TRACE_LEVEL |
Functions | |
error_t | ksz8775Init (NetInterface *interface) |
KSZ8775 Ethernet switch initialization. More... | |
__weak_func void | ksz8775InitHook (NetInterface *interface) |
KSZ8775 custom configuration. More... | |
void | ksz8775Tick (NetInterface *interface) |
KSZ8775 timer handler. More... | |
void | ksz8775EnableIrq (NetInterface *interface) |
Enable interrupts. More... | |
void | ksz8775DisableIrq (NetInterface *interface) |
Disable interrupts. More... | |
void | ksz8775EventHandler (NetInterface *interface) |
KSZ8775 event handler. More... | |
error_t | ksz8775TagFrame (NetInterface *interface, NetBuffer *buffer, size_t *offset, NetTxAncillary *ancillary) |
Add tail tag to Ethernet frame. More... | |
error_t | ksz8775UntagFrame (NetInterface *interface, uint8_t **frame, size_t *length, NetRxAncillary *ancillary) |
Decode tail tag from incoming Ethernet frame. More... | |
bool_t | ksz8775GetLinkState (NetInterface *interface, uint8_t port) |
Get link state. More... | |
uint32_t | ksz8775GetLinkSpeed (NetInterface *interface, uint8_t port) |
Get link speed. More... | |
NicDuplexMode | ksz8775GetDuplexMode (NetInterface *interface, uint8_t port) |
Get duplex mode. More... | |
void | ksz8775SetPortState (NetInterface *interface, uint8_t port, SwitchPortState state) |
Set port state. More... | |
SwitchPortState | ksz8775GetPortState (NetInterface *interface, uint8_t port) |
Get port state. More... | |
void | ksz8775SetAgingTime (NetInterface *interface, uint32_t agingTime) |
Set aging time for dynamic filtering entries. More... | |
void | ksz8775EnableIgmpSnooping (NetInterface *interface, bool_t enable) |
Enable IGMP snooping. More... | |
void | ksz8775EnableMldSnooping (NetInterface *interface, bool_t enable) |
Enable MLD snooping. More... | |
void | ksz8775EnableRsvdMcastTable (NetInterface *interface, bool_t enable) |
Enable reserved multicast table. More... | |
error_t | ksz8775AddStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry) |
Add a new entry to the static MAC table. More... | |
error_t | ksz8775DeleteStaticFdbEntry (NetInterface *interface, const SwitchFdbEntry *entry) |
Remove an entry from the static MAC table. More... | |
error_t | ksz8775GetStaticFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry) |
Read an entry from the static MAC table. More... | |
void | ksz8775FlushStaticFdbTable (NetInterface *interface) |
Flush static MAC table. More... | |
error_t | ksz8775GetDynamicFdbEntry (NetInterface *interface, uint_t index, SwitchFdbEntry *entry) |
Read an entry from the dynamic MAC table. More... | |
void | ksz8775FlushDynamicFdbTable (NetInterface *interface, uint8_t port) |
Flush dynamic MAC table. More... | |
void | ksz8775SetUnknownMcastFwdPorts (NetInterface *interface, bool_t enable, uint32_t forwardPorts) |
Set forward ports for unknown multicast packets. More... | |
void | ksz8775WritePhyReg (NetInterface *interface, uint8_t port, uint8_t address, uint16_t data) |
Write PHY register. More... | |
uint16_t | ksz8775ReadPhyReg (NetInterface *interface, uint8_t port, uint8_t address) |
Read PHY register. More... | |
void | ksz8775DumpPhyReg (NetInterface *interface, uint8_t port) |
Dump PHY registers for debugging purpose. More... | |
void | ksz8775WriteSwitchReg (NetInterface *interface, uint16_t address, uint8_t data) |
Write switch register. More... | |
uint8_t | ksz8775ReadSwitchReg (NetInterface *interface, uint16_t address) |
Read switch register. More... | |
void | ksz8775DumpSwitchReg (NetInterface *interface) |
Dump switch registers for debugging purpose. More... | |
Variables | |
const SwitchDriver | ksz8775SwitchDriver |
KSZ8775 Ethernet switch driver. More... | |
const uint8_t | ksz8775IngressTailTag [5] |
Tail tag rules (host to KSZ8775) More... | |
Detailed Description
KSZ8775 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.
- Version
- 2.4.4
Definition in file ksz8775_driver.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL NIC_TRACE_LEVEL |
Definition at line 32 of file ksz8775_driver.c.
Function Documentation
◆ ksz8775AddStaticFdbEntry()
error_t ksz8775AddStaticFdbEntry | ( | NetInterface * | interface, |
const SwitchFdbEntry * | entry | ||
) |
Add a new entry to the static MAC table.
- Parameters
-
[in] interface Underlying network interface [in] entry Pointer to the forwarding database entry
- Returns
- Error code
Definition at line 1001 of file ksz8775_driver.c.
◆ ksz8775DeleteStaticFdbEntry()
error_t ksz8775DeleteStaticFdbEntry | ( | NetInterface * | interface, |
const SwitchFdbEntry * | entry | ||
) |
Remove an entry from the static MAC table.
- Parameters
-
[in] interface Underlying network interface [in] entry Forwarding database entry to remove from the table
- Returns
- Error code
Definition at line 1103 of file ksz8775_driver.c.
◆ ksz8775DisableIrq()
void ksz8775DisableIrq | ( | NetInterface * | interface | ) |
Disable interrupts.
- Parameters
-
[in] interface Underlying network interface
Definition at line 300 of file ksz8775_driver.c.
◆ ksz8775DumpPhyReg()
void ksz8775DumpPhyReg | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Dump PHY registers for debugging purpose.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
Definition at line 1499 of file ksz8775_driver.c.
◆ ksz8775DumpSwitchReg()
void ksz8775DumpSwitchReg | ( | NetInterface * | interface | ) |
Dump switch registers for debugging purpose.
- Parameters
-
[in] interface Underlying network interface
Definition at line 1607 of file ksz8775_driver.c.
◆ ksz8775EnableIgmpSnooping()
void ksz8775EnableIgmpSnooping | ( | NetInterface * | interface, |
bool_t | enable | ||
) |
Enable IGMP snooping.
- Parameters
-
[in] interface Underlying network interface [in] enable Enable or disable IGMP snooping
Definition at line 903 of file ksz8775_driver.c.
◆ ksz8775EnableIrq()
void ksz8775EnableIrq | ( | NetInterface * | interface | ) |
Enable interrupts.
- Parameters
-
[in] interface Underlying network interface
Definition at line 290 of file ksz8775_driver.c.
◆ ksz8775EnableMldSnooping()
void ksz8775EnableMldSnooping | ( | NetInterface * | interface, |
bool_t | enable | ||
) |
Enable MLD snooping.
- Parameters
-
[in] interface Underlying network interface [in] enable Enable or disable MLD snooping
Definition at line 931 of file ksz8775_driver.c.
◆ ksz8775EnableRsvdMcastTable()
void ksz8775EnableRsvdMcastTable | ( | NetInterface * | interface, |
bool_t | enable | ||
) |
Enable reserved multicast table.
- Parameters
-
[in] interface Underlying network interface [in] enable Enable or disable reserved group addresses
Definition at line 959 of file ksz8775_driver.c.
◆ ksz8775EventHandler()
void ksz8775EventHandler | ( | NetInterface * | interface | ) |
KSZ8775 event handler.
- Parameters
-
[in] interface Underlying network interface
Definition at line 310 of file ksz8775_driver.c.
◆ ksz8775FlushDynamicFdbTable()
void ksz8775FlushDynamicFdbTable | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Flush dynamic MAC table.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
Definition at line 1358 of file ksz8775_driver.c.
◆ ksz8775FlushStaticFdbTable()
void ksz8775FlushStaticFdbTable | ( | NetInterface * | interface | ) |
Flush static MAC table.
- Parameters
-
[in] interface Underlying network interface
Definition at line 1234 of file ksz8775_driver.c.
◆ ksz8775GetDuplexMode()
NicDuplexMode ksz8775GetDuplexMode | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Get duplex mode.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
- Returns
- Duplex mode
Definition at line 693 of file ksz8775_driver.c.
◆ ksz8775GetDynamicFdbEntry()
error_t ksz8775GetDynamicFdbEntry | ( | NetInterface * | interface, |
uint_t | index, | ||
SwitchFdbEntry * | entry | ||
) |
Read an entry from the dynamic MAC table.
- Parameters
-
[in] interface Underlying network interface [in] index Zero-based index of the entry to read [out] entry Pointer to the forwarding database entry
- Returns
- Error code
Definition at line 1274 of file ksz8775_driver.c.
◆ ksz8775GetLinkSpeed()
uint32_t ksz8775GetLinkSpeed | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Get link speed.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
- Returns
- Link speed
Definition at line 595 of file ksz8775_driver.c.
◆ ksz8775GetLinkState()
bool_t ksz8775GetLinkState | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Get link state.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
- Returns
- Link state
Definition at line 546 of file ksz8775_driver.c.
◆ ksz8775GetPortState()
SwitchPortState ksz8775GetPortState | ( | NetInterface * | interface, |
uint8_t | port | ||
) |
Get port state.
- Parameters
-
[in] interface Underlying network interface [in] port Port number
- Returns
- Port state
Definition at line 828 of file ksz8775_driver.c.
◆ ksz8775GetStaticFdbEntry()
error_t ksz8775GetStaticFdbEntry | ( | NetInterface * | interface, |
uint_t | index, | ||
SwitchFdbEntry * | entry | ||
) |
Read an entry from the static MAC table.
- Parameters
-
[in] interface Underlying network interface [in] index Zero-based index of the entry to read [out] entry Pointer to the forwarding database entry
- Returns
- Error code
Definition at line 1172 of file ksz8775_driver.c.
◆ ksz8775Init()
error_t ksz8775Init | ( | NetInterface * | interface | ) |
KSZ8775 Ethernet switch initialization.
- Parameters
-
[in] interface Underlying network interface
- Returns
- Error code
Definition at line 93 of file ksz8775_driver.c.
◆ ksz8775InitHook()
__weak_func void ksz8775InitHook | ( | NetInterface * | interface | ) |
KSZ8775 custom configuration.
- Parameters
-
[in] interface Underlying network interface
Definition at line 210 of file ksz8775_driver.c.
◆ ksz8775ReadPhyReg()
uint16_t ksz8775ReadPhyReg | ( | NetInterface * | interface, |
uint8_t | port, | ||
uint8_t | address | ||
) |
Read PHY register.
- Parameters
-
[in] interface Underlying network interface [in] port Port number [in] address PHY register address
- Returns
- Register value
Definition at line 1473 of file ksz8775_driver.c.
◆ ksz8775ReadSwitchReg()
uint8_t ksz8775ReadSwitchReg | ( | NetInterface * | interface, |
uint16_t | address | ||
) |
Read switch register.
- Parameters
-
[in] interface Underlying network interface [in] address Switch register address
- Returns
- Register value
Definition at line 1564 of file ksz8775_driver.c.
◆ ksz8775SetAgingTime()
void ksz8775SetAgingTime | ( | NetInterface * | interface, |
uint32_t | agingTime | ||
) |
Set aging time for dynamic filtering entries.
- Parameters
-
[in] interface Underlying network interface [in] agingTime Aging time, in seconds
Definition at line 891 of file ksz8775_driver.c.
◆ ksz8775SetPortState()
void ksz8775SetPortState | ( | NetInterface * | interface, |
uint8_t | port, | ||
SwitchPortState | state | ||
) |
Set port state.
- Parameters
-
[in] interface Underlying network interface [in] port Port number [in] state Port state
Definition at line 772 of file ksz8775_driver.c.
◆ ksz8775SetUnknownMcastFwdPorts()
void ksz8775SetUnknownMcastFwdPorts | ( | NetInterface * | interface, |
bool_t | enable, | ||
uint32_t | forwardPorts | ||
) |
Set forward ports for unknown multicast packets.
- Parameters
-
[in] interface Underlying network interface [in] enable Enable or disable forwarding of unknown multicast packets [in] forwardPorts Port map
Definition at line 1405 of file ksz8775_driver.c.
◆ ksz8775TagFrame()
error_t ksz8775TagFrame | ( | NetInterface * | interface, |
NetBuffer * | buffer, | ||
size_t * | offset, | ||
NetTxAncillary * | ancillary | ||
) |
Add tail tag to Ethernet frame.
- Parameters
-
[in] interface Underlying network interface [in] buffer Multi-part buffer containing the payload [in,out] offset Offset to the first payload byte [in] ancillary Additional options passed to the stack along with the packet
- Returns
- Error code
Definition at line 435 of file ksz8775_driver.c.
◆ ksz8775Tick()
void ksz8775Tick | ( | NetInterface * | interface | ) |
KSZ8775 timer handler.
- Parameters
-
[in] interface Underlying network interface
Definition at line 220 of file ksz8775_driver.c.
◆ ksz8775UntagFrame()
error_t ksz8775UntagFrame | ( | NetInterface * | interface, |
uint8_t ** | frame, | ||
size_t * | length, | ||
NetRxAncillary * | ancillary | ||
) |
Decode tail tag from incoming Ethernet frame.
- Parameters
-
[in] interface Underlying network interface [in,out] frame Pointer to the received Ethernet frame [in,out] length Length of the frame, in bytes [in,out] ancillary Additional options passed to the stack along with the packet
- Returns
- Error code
Definition at line 494 of file ksz8775_driver.c.
◆ ksz8775WritePhyReg()
void ksz8775WritePhyReg | ( | NetInterface * | interface, |
uint8_t | port, | ||
uint8_t | address, | ||
uint16_t | data | ||
) |
Write PHY register.
- Parameters
-
[in] interface Underlying network interface [in] port Port number [in] address PHY register address [in] data Register value
Definition at line 1450 of file ksz8775_driver.c.
◆ ksz8775WriteSwitchReg()
void ksz8775WriteSwitchReg | ( | NetInterface * | interface, |
uint16_t | address, | ||
uint8_t | data | ||
) |
Write switch register.
- Parameters
-
[in] interface Underlying network interface [in] address Switch register address [in] data Register value
Definition at line 1523 of file ksz8775_driver.c.
Variable Documentation
◆ ksz8775IngressTailTag
const uint8_t ksz8775IngressTailTag[5] |
Tail tag rules (host to KSZ8775)
Definition at line 77 of file ksz8775_driver.c.
◆ ksz8775SwitchDriver
const SwitchDriver ksz8775SwitchDriver |