blob: 26993e9a626e1d9d0913857b9cf4c8268a853f70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#ifndef EMAC_H_
#define EMAC_H_
#include <stdbool.h>
#include "netif/etharp.h"
#include "lwip/sys.h"
#include "bsp/tms570.h"
/*to rtems*/
#define EMAC_CTRL_RAM_BASE (0xFC520000U)
#define SIZE_EMAC_CTRL_RAM 0x2000U
/* Packet Flags EMAC_Desc - tx and rx */
#define EMAC_DSC_FLAG_SOP 0x80000000u
#define EMAC_DSC_FLAG_EOP 0x40000000u
#define EMAC_DSC_FLAG_OWNER 0x20000000u
#define EMAC_DSC_FLAG_EOQ 0x10000000u
#define EMAC_DSC_FLAG_TDOWNCMPLT 0x08000000u
#define EMAC_DSC_FLAG_PASSCRC 0x04000000u
/* Packet Flags - in addition to rx */
#define EMAC_DSC_FLAG_JABBER 0x02000000u
#define EMAC_DSC_FLAG_OVERSIZE 0x01000000u
#define EMAC_DSC_FLAG_FRAGMENT 0x00800000u
#define EMAC_DSC_FLAG_UNDERSIZED 0x00400000u
#define EMAC_DSC_FLAG_CONTROL 0x00200000u
#define EMAC_DSC_FLAG_OVERRUN 0x00100000u
#define EMAC_DSC_FLAG_CODEERROR 0x00080000u
#define EMAC_DSC_FLAG_ALIGNERROR 0x00040000u
#define EMAC_DSC_FLAG_CRCERROR 0x00020000u
#define EMAC_DSC_FLAG_NOMATCH 0x00010000u
/********** TI structs ***********/
/* EMAC TX Buffer descriptor data structure */
struct emac_tx_bd {
volatile struct emac_tx_bd *next;
volatile u8_t *bufptr;
volatile u32_t bufoff_len;
volatile u32_t flags_pktlen;
/* helper to know which pbuf this tx bd corresponds to */
struct pbuf *pbuf;
};
/* EMAC RX Buffer descriptor data structure */
struct emac_rx_bd {
volatile struct emac_rx_bd *next;
volatile u8_t *bufptr;
volatile u32_t bufoff_len;
volatile u32_t flags_pktlen;
/* helper to know which pbuf this rx bd corresponds to */
struct pbuf *pbuf;
};
/**
* Helper struct to hold the data used to operate on a particular
* receive channel
*/
struct rxch{
volatile struct emac_rx_bd *active_head;
volatile struct emac_rx_bd *active_tail;
volatile struct emac_rx_bd *inactive_head;
volatile struct emac_rx_bd *inactive_tail;
s32_t freed_pbuf_len;
};
/**
* Helper struct to hold the data used to operate on a particular
* transmit channel
*/
struct txch {
volatile struct emac_tx_bd *active_head;
volatile struct emac_tx_bd *active_tail;
volatile struct emac_tx_bd *inactive_head;
volatile struct emac_tx_bd *inactive_tail;
};
/**
* Helper struct to hold private data used to operate the ethernet interface.
*/
struct tms570_netif_state {
/* emac instance number */
u32_t inst_num;
/* EMAC configuration register-window base address */
volatile tms570_emacm_t *emac_base;
/* EMAC controller base address */
volatile tms570_emacc_t *emac_ctrl_base;
volatile u32_t emac_ctrl_ram;
/* MDIO base address */
volatile tms570_mdio_t *mdio_base;
/* The RX/TX channel 0 state description
* (keeps track of used/freed Buffer Descriptors)
*/
struct txch txch;
struct rxch rxch;
/* Semaphores used for waking up the threads processing
* RX/TX packets in teh deferred manner.
* Semgive is called in particular RX/TX interrupt
*/
sys_sem_t intPend_sem;
u32_t phy_addr;
uint32_t waitTicksForPHYAneg;
};
/********************************************** End of Statistics **********************************************/
#endif /* EMAC_H_ */
|