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
118
119
120
121
122
123
124
125
126
127
|
/*
<:copyright-broadcom
Copyright (c) 2002 Broadcom Corporation
All Rights Reserved
No portions of this material may be reproduced in any form without the
written permission of:
Broadcom Corporation
16215 Alton Parkway
Irvine, California 92619
All information contained in this document is Broadcom Corporation
company private, proprietary, and trade secret.
:>
*/
#ifndef __BCM63XX_ETH_H
#define __BCM63XX_ETH_H
#include "bcm_hwdefs.h"
#include "bcm_map.h"
#include "boardparms.h"
// from linux if_ether.h
#define ETH_ALEN 6 /* Octets in one ethernet addr */
#define ETH_HLEN 14 /* Total octets in header. */
#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
#define ETH_DATA_LEN 1500 /* Max. octets in payload */
#define ETH_CRC_LEN 4 /* CRC length */
// end if_ether.h
/*---------------------------------------------------------------------*/
/* specify number of BDs and buffers to use */
/*---------------------------------------------------------------------*/
#define NR_TX_BDS 20
#define NR_RX_BDS 20
#define ENET_MAX_MTU_SIZE 1522 /* Body(1500) + EH_SIZE(14) + FCS(4) + VLAN(4) */
#define DMA_MAX_BURST_LENGTH 8 /* in 64 bit words */
#define ENET_BUF_SIZE ((ENET_MAX_MTU_SIZE + 63) & ~63)
#define DMA_FC_THRESH_LO 5
#define DMA_FC_THRESH_HI 10
#define EMAC_TX_WATERMARK 32
#define MAKE4(x) ((x[3] & 0xFF) | ((x[2] & 0xFF) << 8) | ((x[1] & 0xFF) << 16) | ((x[0] & 0xFF) << 24))
#define MAKE2(x) ((x[1] & 0xFF) | ((x[0] & 0xFF) << 8))
#define ERROR(x) xsprintf x
#ifndef ASSERT
#define ASSERT(x) if (x); else ERROR(("assert: "__FILE__" line %d\n", __LINE__));
#endif
//#define DUMP_TRACE
#if defined(DUMP_TRACE)
#define TRACE (x) xprintf x
#else
#define TRACE(x)
#endif
typedef struct PM_Addr {
uint16 valid; /* 1 indicates the corresponding address is valid */
unsigned char dAddr[ETH_ALEN];/* perfect match register's destination address */
unsigned int ref; /* reference count */
} PM_Addr;
#define MAX_PMADDR 4 /* # of perfect match address */
#define NUM_PORTS 1
typedef struct gpio_reg_addrs_t {
volatile uint16 *gpio_direction_reg;/* GPIO direction register */
volatile uint16 *gpio_value_reg; /* GPIO value register */
} gpio_reg_addrs_t;
typedef struct ethsw_info_t {
gpio_reg_addrs_t sbh;
uint32 ssl, clk, mosi, miso; /* GPIO mapping */
int cid, page; /* Current chip ID and page */
} ethsw_info_t;
typedef struct bcmenet_softc {
volatile DmaRegs *dmaCtrl;
/* transmit variables */
volatile DmaChannelCfg *txDma; /* location of transmit DMA register set */
volatile DmaDesc *txBds; /* Memory location of tx Dma BD ring */
volatile DmaDesc *txFirstBdPtr; /* ptr to first allocated Tx BD */
volatile DmaDesc *txNextBdPtr; /* ptr to next Tx BD to transmit with */
volatile DmaDesc *txLastBdPtr; /* ptr to last allocated Tx BD */
/* receive variables */
volatile DmaChannelCfg *rxDma; /* location of receive DMA register set */
volatile DmaDesc *rxBds; /* Memory location of rx bd ring */
volatile DmaDesc *rxFirstBdPtr; /* ptr to first allocated rx bd */
volatile DmaDesc *rxBdReadPtr; /* ptr to next rx bd to be processed */
volatile DmaDesc *rxLastBdPtr; /* ptr to last allocated rx bd */
uint32_t rxBuffers;
uint32_t txBuffers;
uint16 chipId; /* chip's id */
uint16 chipRev; /* step */
uint8_t hwaddr[ETH_ALEN];
ethsw_info_t ethSwitch; /* external switch */
ETHERNET_MAC_INFO EnetInfo;
uint32_t dmaPort;
uint32_t linkCheck;
} bcmenet_softc;
#define IncRxBdPtr(x, s) if (x == ((bcmenet_softc *)s)->rxLastBdPtr) \
x = ((bcmenet_softc *)s)->rxBds; \
else x++
#define InctxBdPtr(x, s) if (x == ((bcmenet_softc *)s)->txLastBdPtr) \
x = ((bcmenet_softc *)s)->txBds; \
else x++
// extern and function prototype
extern int32_t _getticks(void);
#ifdef DUMP_DATA
static void hexdump( unsigned char * src, int srclen, int rowlen, int rows );
#endif
#endif // __BCM63XX_ETH_H
|