Professional Documents
Culture Documents
* @file ksz8895_driver.h
* @brief KSZ8895 5-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 _KSZ8895_DRIVER_H
#define _KSZ8895_DRIVER_H
//Dependencies
#include "core/nic.h"
//Port identifiers
#define KSZ8895_PORT1 1
#define KSZ8895_PORT2 2
#define KSZ8895_PORT3 3
#define KSZ8895_PORT4 4
#define KSZ8895_PORT5 5
//Port masks
#define KSZ8895_PORT_MASK 0x1F
#define KSZ8895_PORT1_MASK 0x01
#define KSZ8895_PORT2_MASK 0x02
#define KSZ8895_PORT3_MASK 0x04
#define KSZ8895_PORT4_MASK 0x08
#define KSZ8895_PORT5_MASK 0x10
//Identification register
#define KSZ8895_ID_REVISION_ID 0xF0
#define KSZ8895_ID_REVISION_ID_MQX_RQX_FQX_REV_A2 0x40
#define KSZ8895_ID_REVISION_ID_ML_REV_B2 0x40
#define KSZ8895_ID_REVISION_ID_MQX_RQX_FQX_REV_A3 0x50
#define KSZ8895_ID_REVISION_ID_ML_REV_B3 0x50
#define KSZ8895_ID_REVISION_ID_MQX_RQX_FQX_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 reserved : 1; //1
uint8_t override : 1;
uint8_t valid : 1;
uint8_t forwardPorts : 5;
#else
uint8_t useFid : 1; //0
uint8_t fid : 7;
uint8_t forwardPorts : 5; //1
uint8_t valid : 1;
uint8_t override : 1;
uint8_t reserved : 1;
#endif
MacAddr macAddr; //2-7
} Ksz8895StaticMacEntryR;
/**
* @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 : 5;
#else
uint8_t forwardPorts : 5; //1
uint8_t valid : 1;
uint8_t override : 1;
uint8_t useFid : 1;
#endif
MacAddr macAddr; //2-7
} Ksz8895StaticMacEntryW;
/**
* @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
} Ksz8895DynamicMacEntry;
//C++ guard
#ifdef __cplusplus
}
#endif
#endif