Professional Documents
Culture Documents
ksz8864 Driver
ksz8864 Driver
* @file ksz8864_driver.h
* @brief KSZ8864 4-port Ethernet switch driver
*
* @section License
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Copyright (C) 2010-2020 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.8
**/
#ifndef _KSZ8864_DRIVER_H
#define _KSZ8864_DRIVER_H
//Dependencies
#include "core/nic.h"
//Port identifiers
#define KSZ8864_PORT1 1
#define KSZ8864_PORT2 2
#define KSZ8864_PORT3 3
#define KSZ8864_PORT4 4
//Port masks
#define KSZ8864_PORT_MASK 0x0F
#define KSZ8864_PORT1_MASK 0x01
#define KSZ8864_PORT2_MASK 0x02
#define KSZ8864_PORT3_MASK 0x04
#define KSZ8864_PORT4_MASK 0x08
//Identification register
#define KSZ8864_ID_REVISION_ID 0xF0
#define KSZ8864_ID_REVISION_ID_CNX_REV_A2 0x40
#define KSZ8864_ID_REVISION_ID_RMNUB_REV_B2 0x40
#define KSZ8864_ID_REVISION_ID_CNX_REV_A3 0x50
#define KSZ8864_ID_REVISION_ID_CNX_REV_A4 0x60
//C++ guard
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Static MAC table entry (read operation)
**/
typedef struct
{
#ifdef _CPU_BIG_ENDIAN
uint8_t fid : 7; //0
uint8_t useFid : 1;
uint8_t reserved1 : 1; //1
uint8_t override : 1;
uint8_t valid : 1;
uint8_t forwardPorts : 4;
uint8_t reserved2 : 1;
#else
uint8_t useFid : 1; //0
uint8_t fid : 7;
uint8_t reserved2 : 1; //1
uint8_t forwardPorts : 4;
uint8_t valid : 1;
uint8_t override : 1;
uint8_t reserved1 : 1;
#endif
MacAddr macAddr; //2-7
} Ksz8864StaticMacEntryR;
/**
* @brief Static MAC table entry (write operation)
**/
typedef struct
{
uint8_t fid; //0
#ifdef _CPU_BIG_ENDIAN
uint8_t useFid : 1; //1
uint8_t override : 1;
uint8_t valid : 1;
uint8_t forwardPorts : 4;
uint8_t reserved : 1;
#else
uint8_t reserved : 1; //1
uint8_t forwardPorts : 4;
uint8_t valid : 1;
uint8_t override : 1;
uint8_t useFid : 1;
#endif
MacAddr macAddr; //2-7
} Ksz8864StaticMacEntryW;
/**
* @brief Dynamic MAC table entry
**/
typedef struct
{
#ifdef _CPU_BIG_ENDIAN
uint8_t macEmpty : 1; //0
uint8_t numValidEntriesH : 7;
uint8_t numValidEntriesL : 3; //1
uint8_t timestamp : 2;
uint8_t sourcePort : 3;
uint8_t dataNotReady : 1; //2
uint8_t fid : 7;
#else
uint8_t numValidEntriesH : 7; //0
uint8_t macEmpty : 1;
uint8_t sourcePort : 3; //1
uint8_t timestamp : 2;
uint8_t numValidEntriesL : 3;
uint8_t fid : 7; //2
uint8_t dataNotReady : 1;
#endif
MacAddr macAddr; //3-8
} Ksz8864DynamicMacEntry;
//C++ guard
#ifdef __cplusplus
}
#endif
#endif