38#ifndef NIC_TICK_INTERVAL
39 #define NIC_TICK_INTERVAL 1000
40#elif (NIC_TICK_INTERVAL < 10)
41 #error NIC_TICK_INTERVAL parameter is not valid
45#ifndef NIC_MAX_BLOCKING_TIME
46 #define NIC_MAX_BLOCKING_TIME INFINITE_DELAY
47#elif (NIC_MAX_BLOCKING_TIME < 0)
48 #error NIC_MAX_BLOCKING_TIME parameter is not valid
52#ifndef NIC_CONTEXT_SIZE
53 #define NIC_CONTEXT_SIZE 16
54#elif (NIC_CONTEXT_SIZE < 1)
55 #error NIC_CONTEXT_SIZE parameter is not valid
59#define SWITCH_CPU_PORT 32
60#define SWITCH_CPU_PORT_MASK 0x80000000
63#define SMI_SYNC 0xFFFFFFFF
66#define SMI_OPCODE_WRITE 1
67#define SMI_OPCODE_READ 2
98 NIC_LINK_STATE_DOWN = 0,
99 NIC_LINK_STATE_UP = 1,
100 NIC_LINK_STATE_AUTO = 2
110 NIC_LINK_SPEED_UNKNOWN = 0,
111 NIC_LINK_SPEED_10MBPS = 10000000,
112 NIC_LINK_SPEED_100MBPS = 100000000,
113 NIC_LINK_SPEED_1GBPS = 1000000000
123 NIC_UNKNOWN_DUPLEX_MODE = 0,
124 NIC_HALF_DUPLEX_MODE = 1,
125 NIC_FULL_DUPLEX_MODE = 2
135 SWITCH_PORT_STATE_UNKNOWN = 0,
136 SWITCH_PORT_STATE_DISABLED = 1,
137 SWITCH_PORT_STATE_BLOCKING = 2,
138 SWITCH_PORT_STATE_LISTENING = 3,
139 SWITCH_PORT_STATE_LEARNING = 4,
140 SWITCH_PORT_STATE_FORWARDING = 5
171typedef error_t (*NicInit)(NetInterface *interface);
172typedef void (*NicTick)(NetInterface *interface);
173typedef void (*NicEnableIrq)(NetInterface *interface);
174typedef void (*NicDisableIrq)(NetInterface *interface);
175typedef void (*NicEventHandler)(NetInterface *interface);
177typedef error_t (*NicSendPacket)(NetInterface *interface,
178 const NetBuffer *buffer,
size_t offset, NetTxAncillary *ancillary);
180typedef error_t (*NicUpdateMacAddrFilter)(NetInterface *interface);
181typedef error_t (*NicUpdateMacConfig)(NetInterface *interface);
183typedef void (*NicWritePhyReg)(uint8_t opcode, uint8_t phyAddr,
184 uint8_t regAddr, uint16_t data);
186typedef uint16_t (*NicReadPhyReg)(uint8_t opcode, uint8_t phyAddr,
190typedef error_t (*PhyInit)(NetInterface *interface);
191typedef void (*PhyTick)(NetInterface *interface);
192typedef void (*PhyEnableIrq)(NetInterface *interface);
193typedef void (*PhyDisableIrq)(NetInterface *interface);
194typedef void (*PhyEventHandler)(NetInterface *interface);
197typedef error_t (*SwitchInit)(NetInterface *interface);
198typedef void (*SwitchTick)(NetInterface *interface);
199typedef void (*SwitchEnableIrq)(NetInterface *interface);
200typedef void (*SwitchDisableIrq)(NetInterface *interface);
201typedef void (*SwitchEventHandler)(NetInterface *interface);
203typedef error_t (*SwitchTagFrame)(NetInterface *interface,
NetBuffer *buffer,
204 size_t *offset, NetTxAncillary *ancillary);
206typedef error_t (*SwitchUntagFrame)(NetInterface *interface, uint8_t **frame,
207 size_t *length, NetRxAncillary *ancillary);
209typedef bool_t (*SwitchGetLinkState)(NetInterface *interface, uint8_t port);
210typedef uint32_t (*SwitchGetLinkSpeed)(NetInterface *interface, uint8_t port);
212typedef NicDuplexMode (*SwitchGetDuplexMode)(NetInterface *interface,
215typedef void (*SwitchSetPortState)(NetInterface *interface, uint8_t port,
221typedef void (*SwitchSetAgingTime)(NetInterface *interface, uint32_t agingTime);
223typedef void (*SwitchEnableIgmpSnooping)(NetInterface *interface,
226typedef void (*SwitchEnableMldSnooping)(NetInterface *interface,
229typedef void (*SwitchEnableRsvdMcastTable)(NetInterface *interface,
232typedef error_t (*SwitchAddFdbEntry)(NetInterface *interface,
235typedef error_t (*SwitchDeleteFdbEntry)(NetInterface *interface,
238typedef error_t (*SwitchGetFdbEntry)(NetInterface *interface, uint_t index,
241typedef void (*SwitchFlushStaticFdbTable)(NetInterface *interface);
243typedef void (*SwitchFlushDynamicFdbTable)(NetInterface *interface,
246typedef void (*SwitchSetUnknownMcastFwdPorts)(NetInterface *interface,
247 bool_t enable, uint32_t forwardPorts);
250typedef error_t (*SmiInit)(void);
252typedef void (*SmiWritePhyReg)(uint8_t opcode, uint8_t phyAddr,
253 uint8_t regAddr, uint16_t data);
255typedef uint16_t (*SmiReadPhyReg)(uint8_t opcode, uint8_t phyAddr,
259typedef error_t (*SpiInit)(void);
260typedef error_t (*SpiSetMode)(uint_t mode);
261typedef error_t (*SpiSetBitrate)(uint_t bitrate);
262typedef void (*SpiAssertCs)(void);
263typedef void (*SpiDeassertCs)(void);
264typedef uint8_t (*SpiTransfer)(uint8_t data);
267typedef error_t (*UartInit)(void);
268typedef void (*UartEnableIrq)(void);
269typedef void (*UartDisableIrq)(void);
270typedef void (*UartStartTx)(void);
273typedef error_t (*ExtIntInit)(void);
274typedef void (*ExtIntEnableIrq)(void);
275typedef void (*ExtIntDisableIrq)(void);
288 NicEnableIrq enableIrq;
289 NicDisableIrq disableIrq;
290 NicEventHandler eventHandler;
291 NicSendPacket sendPacket;
292 NicUpdateMacAddrFilter updateMacAddrFilter;
293 NicUpdateMacConfig updateMacConfig;
294 NicWritePhyReg writePhyReg;
295 NicReadPhyReg readPhyReg;
311 PhyEnableIrq enableIrq;
312 PhyDisableIrq disableIrq;
313 PhyEventHandler eventHandler;
325 SwitchEnableIrq enableIrq;
326 SwitchDisableIrq disableIrq;
327 SwitchEventHandler eventHandler;
328 SwitchTagFrame tagFrame;
329 SwitchUntagFrame untagFrame;
330 SwitchGetLinkState getLinkState;
331 SwitchGetLinkSpeed getLinkSpeed;
332 SwitchGetDuplexMode getDuplexMode;
333 SwitchSetPortState setPortState;
334 SwitchGetPortState getPortState;
335 SwitchSetAgingTime setAgingTime;
336 SwitchEnableIgmpSnooping enableIgmpSnooping;
337 SwitchEnableMldSnooping enableMldSnooping;
338 SwitchEnableRsvdMcastTable enableRsvdMcastTable;
339 SwitchAddFdbEntry addStaticFdbEntry;
340 SwitchDeleteFdbEntry deleteStaticFdbEntry;
341 SwitchGetFdbEntry getStaticFdbEntry;
342 SwitchFlushStaticFdbTable flushStaticFdbTable;
343 SwitchGetFdbEntry getDynamicFdbEntry;
344 SwitchFlushDynamicFdbTable flushDynamicFdbTable;
345 SwitchSetUnknownMcastFwdPorts setUnknownMcastFwdPorts;
356 SmiWritePhyReg writePhyReg;
357 SmiReadPhyReg readPhyReg;
369 SpiSetBitrate setBitrate;
370 SpiAssertCs assertCs;
371 SpiDeassertCs deassertCs;
372 SpiTransfer transfer;
383 UartEnableIrq enableIrq;
384 UartDisableIrq disableIrq;
396 ExtIntEnableIrq enableIrq;
397 ExtIntDisableIrq disableIrq;
405NetInterface *nicGetLogicalInterface(NetInterface *interface);
406NetInterface *nicGetPhysicalInterface(NetInterface *interface);
407uint8_t nicGetSwitchPort(NetInterface *interface);
408uint16_t nicGetVlanId(NetInterface *interface);
409uint16_t nicGetVmanId(NetInterface *interface);
411bool_t nicIsParentInterface(NetInterface *interface, NetInterface *parent);
413void nicTick(NetInterface *interface);
416 size_t offset, NetTxAncillary *ancillary);
418error_t nicUpdateMacAddrFilter(NetInterface *interface);
420void nicProcessPacket(NetInterface *interface, uint8_t *packet,
size_t length,
421 NetRxAncillary *ancillary);
423void nicNotifyLinkChange(NetInterface *interface);
error_t
Error codes.
Definition error.h:43
NicLinkState
Link state.
Definition nic.h:97
NicType
NIC types.
Definition nic.h:81
@ NIC_TYPE_UNKNOWN
Unknown interface type.
Definition nic.h:82
@ NIC_TYPE_LOOPBACK
Loopback interface.
Definition nic.h:88
@ NIC_TYPE_6LOWPAN
6LoWPAN interface
Definition nic.h:87
@ NIC_TYPE_IPV6
IPv6 interface.
Definition nic.h:86
@ NIC_TYPE_IPV4
IPv4 interface.
Definition nic.h:85
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition nic.h:83
@ NIC_TYPE_PPP
PPP interface.
Definition nic.h:84
NicDuplexMode
Duplex mode.
Definition nic.h:122
SwitchPortState
Switch port state.
Definition nic.h:134
NicLinkSpeed
Link speed.
Definition nic.h:109
uint32_t systime_t
System time.
Definition os_port_none.h:90
External interrupt line driver.
Definition nic.h:394
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
NIC driver.
Definition nic.h:283
Ethernet PHY driver.
Definition nic.h:308
SMI driver.
Definition nic.h:354
SPI driver.
Definition nic.h:366
Ethernet switch driver.
Definition nic.h:322
Forwarding database entry.
Definition nic.h:149
VLAN entry.
Definition nic.h:162
UART driver.
Definition nic.h:381