Network interface controller abstraction layer. More...

#include "core/net.h"

Go to the source code of this file.

Data Structures

struct  NicDriver
 NIC driver. More...
 
struct  PhyDriver
 PHY driver. More...
 
struct  SpiDriver
 SPI driver. More...
 
struct  UartDriver
 UART driver. More...
 
struct  ExtIntDriver
 External interrupt line driver. More...
 

Macros

#define NIC_TICK_INTERVAL   1000
 
#define NIC_MAX_BLOCKING_TIME   INFINITE_DELAY
 
#define NIC_CONTEXT_SIZE   16
 

Typedefs

typedef error_t(* NicInit) (NetInterface *interface)
 
typedef void(* NicTick) (NetInterface *interface)
 
typedef void(* NicEnableIrq) (NetInterface *interface)
 
typedef void(* NicDisableIrq) (NetInterface *interface)
 
typedef void(* NicEventHandler) (NetInterface *interface)
 
typedef error_t(* NicSendPacket) (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 
typedef error_t(* NicUpdateMacAddrFilter) (NetInterface *interface)
 
typedef error_t(* NicUpdateMacConfig) (NetInterface *interface)
 
typedef void(* NicWritePhyReg) (uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 
typedef uint16_t(* NicReadPhyReg) (uint8_t phyAddr, uint8_t regAddr)
 
typedef error_t(* PhyInit) (NetInterface *interface)
 
typedef void(* PhyTick) (NetInterface *interface)
 
typedef void(* PhyEnableIrq) (NetInterface *interface)
 
typedef void(* PhyDisableIrq) (NetInterface *interface)
 
typedef void(* PhyEventHandler) (NetInterface *interface)
 
typedef error_t(* PhyTagFrame) (NetInterface **interface, NetBuffer *buffer, size_t *offset, uint16_t *type)
 
typedef error_t(* PhyUntagFrame) (NetInterface **interface, uint8_t **frame, size_t *length)
 
typedef error_t(* SpiInit) (void)
 
typedef error_t(* SpiSetMode) (uint_t mode)
 
typedef error_t(* SpiSetBitrate) (uint_t bitrate)
 
typedef void(* SpiAssertCs) (void)
 
typedef void(* SpiDeassertCs) (void)
 
typedef uint8_t(* SpiTransfer) (uint8_t data)
 
typedef error_t(* UartInit) (void)
 
typedef void(* UartEnableIrq) (void)
 
typedef void(* UartDisableIrq) (void)
 
typedef void(* UartStartTx) (void)
 
typedef error_t(* ExtIntInit) (void)
 
typedef void(* ExtIntEnableIrq) (void)
 
typedef void(* ExtIntDisableIrq) (void)
 

Enumerations

enum  NicType { NIC_TYPE_UNKNOWN = 0, NIC_TYPE_ETHERNET = 1, NIC_TYPE_PPP = 2, NIC_TYPE_6LOWPAN = 3 }
 NIC types. More...
 
enum  NicLinkState { NIC_LINK_STATE_DOWN = 0, NIC_LINK_STATE_UP = 1, NIC_LINK_STATE_AUTO = 2 }
 Link state. More...
 
enum  NicLinkSpeed { NIC_LINK_SPEED_UNKNOWN = 0, NIC_LINK_SPEED_10MBPS = 10000000, NIC_LINK_SPEED_100MBPS = 100000000, NIC_LINK_SPEED_1GBPS = 1000000000 }
 Link speed. More...
 
enum  NicDuplexMode { NIC_UNKNOWN_DUPLEX_MODE = 0, NIC_HALF_DUPLEX_MODE = 1, NIC_FULL_DUPLEX_MODE = 2 }
 Duplex mode. More...
 

Functions

NetInterfacenicGetLogicalInterface (NetInterface *interface)
 Retrieve logical interface. More...
 
NetInterfacenicGetPhysicalInterface (NetInterface *interface)
 Retrieve physical interface. More...
 
void nicTick (NetInterface *interface)
 Network controller timer handler. More...
 
error_t nicSendPacket (NetInterface *interface, const NetBuffer *buffer, size_t offset)
 Send a packet to the network controller. More...
 
error_t nicUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
void nicProcessPacket (NetInterface *interface, void *packet, size_t length)
 Handle a packet received by the network controller. More...
 
void nicNotifyLinkChange (NetInterface *interface)
 Process link state change event. More...
 

Variables

systime_t nicTickCounter
 

Detailed Description

Network interface controller abstraction layer.

License

Copyright (C) 2010-2018 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.0

Definition in file nic.h.

Macro Definition Documentation

◆ NIC_CONTEXT_SIZE

#define NIC_CONTEXT_SIZE   16

Definition at line 51 of file nic.h.

◆ NIC_MAX_BLOCKING_TIME

#define NIC_MAX_BLOCKING_TIME   INFINITE_DELAY

Definition at line 44 of file nic.h.

◆ NIC_TICK_INTERVAL

#define NIC_TICK_INTERVAL   1000

Definition at line 37 of file nic.h.

Typedef Documentation

◆ ExtIntDisableIrq

typedef void(* ExtIntDisableIrq) (void)

Definition at line 154 of file nic.h.

◆ ExtIntEnableIrq

typedef void(* ExtIntEnableIrq) (void)

Definition at line 153 of file nic.h.

◆ ExtIntInit

typedef error_t(* ExtIntInit) (void)

Definition at line 152 of file nic.h.

◆ NicDisableIrq

typedef void(* NicDisableIrq) (NetInterface *interface)

Definition at line 116 of file nic.h.

◆ NicEnableIrq

typedef void(* NicEnableIrq) (NetInterface *interface)

Definition at line 115 of file nic.h.

◆ NicEventHandler

typedef void(* NicEventHandler) (NetInterface *interface)

Definition at line 117 of file nic.h.

◆ NicInit

typedef error_t(* NicInit) (NetInterface *interface)

Definition at line 113 of file nic.h.

◆ NicReadPhyReg

typedef uint16_t(* NicReadPhyReg) (uint8_t phyAddr, uint8_t regAddr)

Definition at line 122 of file nic.h.

◆ NicSendPacket

typedef error_t(* NicSendPacket) (NetInterface *interface, const NetBuffer *buffer, size_t offset)

Definition at line 118 of file nic.h.

◆ NicTick

typedef void(* NicTick) (NetInterface *interface)

Definition at line 114 of file nic.h.

◆ NicUpdateMacAddrFilter

typedef error_t(* NicUpdateMacAddrFilter) (NetInterface *interface)

Definition at line 119 of file nic.h.

◆ NicUpdateMacConfig

typedef error_t(* NicUpdateMacConfig) (NetInterface *interface)

Definition at line 120 of file nic.h.

◆ NicWritePhyReg

typedef void(* NicWritePhyReg) (uint8_t phyAddr, uint8_t regAddr, uint16_t data)

Definition at line 121 of file nic.h.

◆ PhyDisableIrq

typedef void(* PhyDisableIrq) (NetInterface *interface)

Definition at line 128 of file nic.h.

◆ PhyEnableIrq

typedef void(* PhyEnableIrq) (NetInterface *interface)

Definition at line 127 of file nic.h.

◆ PhyEventHandler

typedef void(* PhyEventHandler) (NetInterface *interface)

Definition at line 129 of file nic.h.

◆ PhyInit

typedef error_t(* PhyInit) (NetInterface *interface)

Definition at line 125 of file nic.h.

◆ PhyTagFrame

typedef error_t(* PhyTagFrame) (NetInterface **interface, NetBuffer *buffer, size_t *offset, uint16_t *type)

Definition at line 131 of file nic.h.

◆ PhyTick

typedef void(* PhyTick) (NetInterface *interface)

Definition at line 126 of file nic.h.

◆ PhyUntagFrame

typedef error_t(* PhyUntagFrame) (NetInterface **interface, uint8_t **frame, size_t *length)

Definition at line 134 of file nic.h.

◆ SpiAssertCs

typedef void(* SpiAssertCs) (void)

Definition at line 141 of file nic.h.

◆ SpiDeassertCs

typedef void(* SpiDeassertCs) (void)

Definition at line 142 of file nic.h.

◆ SpiInit

typedef error_t(* SpiInit) (void)

Definition at line 138 of file nic.h.

◆ SpiSetBitrate

typedef error_t(* SpiSetBitrate) (uint_t bitrate)

Definition at line 140 of file nic.h.

◆ SpiSetMode

typedef error_t(* SpiSetMode) (uint_t mode)

Definition at line 139 of file nic.h.

◆ SpiTransfer

typedef uint8_t(* SpiTransfer) (uint8_t data)

Definition at line 143 of file nic.h.

◆ UartDisableIrq

typedef void(* UartDisableIrq) (void)

Definition at line 148 of file nic.h.

◆ UartEnableIrq

typedef void(* UartEnableIrq) (void)

Definition at line 147 of file nic.h.

◆ UartInit

typedef error_t(* UartInit) (void)

Definition at line 146 of file nic.h.

◆ UartStartTx

typedef void(* UartStartTx) (void)

Definition at line 149 of file nic.h.

Enumeration Type Documentation

◆ NicDuplexMode

Duplex mode.

Enumerator
NIC_UNKNOWN_DUPLEX_MODE 
NIC_HALF_DUPLEX_MODE 
NIC_FULL_DUPLEX_MODE 

Definition at line 104 of file nic.h.

◆ NicLinkSpeed

Link speed.

Enumerator
NIC_LINK_SPEED_UNKNOWN 
NIC_LINK_SPEED_10MBPS 
NIC_LINK_SPEED_100MBPS 
NIC_LINK_SPEED_1GBPS 

Definition at line 91 of file nic.h.

◆ NicLinkState

Link state.

Enumerator
NIC_LINK_STATE_DOWN 
NIC_LINK_STATE_UP 
NIC_LINK_STATE_AUTO 

Definition at line 79 of file nic.h.

◆ NicType

enum NicType

NIC types.

Enumerator
NIC_TYPE_UNKNOWN 

Unknown interface type.

NIC_TYPE_ETHERNET 

Ethernet interface.

NIC_TYPE_PPP 

PPP interface.

NIC_TYPE_6LOWPAN 

6LoWPAN interface

Definition at line 66 of file nic.h.

Function Documentation

◆ nicGetLogicalInterface()

NetInterface* nicGetLogicalInterface ( NetInterface interface)

Retrieve logical interface.

Parameters
[in]interfacePointer to the network interface
Returns
Pointer to the physical interface

Definition at line 60 of file nic.c.

◆ nicGetPhysicalInterface()

NetInterface* nicGetPhysicalInterface ( NetInterface interface)

Retrieve physical interface.

Parameters
[in]interfacePointer to the network interface
Returns
Pointer to the physical interface

Definition at line 85 of file nic.c.

◆ nicNotifyLinkChange()

void nicNotifyLinkChange ( NetInterface interface)

Process link state change event.

Parameters
[in]interfaceUnderlying network interface

Definition at line 298 of file nic.c.

◆ nicProcessPacket()

void nicProcessPacket ( NetInterface interface,
void *  packet,
size_t  length 
)

Handle a packet received by the network controller.

Parameters
[in]interfaceUnderlying network interface
[in]packetIncoming packet to process
[in]lengthTotal packet length

Definition at line 239 of file nic.c.

◆ nicSendPacket()

error_t nicSendPacket ( NetInterface interface,
const NetBuffer buffer,
size_t  offset 
)

Send a packet to the network controller.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
Returns
Error code

Definition at line 148 of file nic.c.

◆ nicTick()

void nicTick ( NetInterface interface)

Network controller timer handler.

This routine is periodically called by the TCP/IP stack to handle periodic operations such as polling the link state

Parameters
[in]interfaceUnderlying network interface

Definition at line 122 of file nic.c.

◆ nicUpdateMacAddrFilter()

error_t nicUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 204 of file nic.c.

Variable Documentation

◆ nicTickCounter

systime_t nicTickCounter

Definition at line 51 of file nic.c.