OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [peripheral/] [ethernet_i.h] - Blame information for rev 406

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 346 erez
/* ethernet_i.h -- Definition of internal types and structures for Ethernet MAC
2
   Copyright (C) 2001 Erez Volk, erez@mailandnews.comopencores.org
3
 
4
   This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
*/
20
 
21
#ifndef __OR1KSIM_PERIPHERAL_ETHERNET_I_H
22
#define __OR1KSIM_PERIPHERAL_ETHERNET_I_H
23
 
24
#include "ethernet.h"
25
#include "config.h"
26
 
27
/*
28
 * Ethernet protocol definitions
29
 */
30
#if HAVE_NET_ETHERNET_H
31
# include <net/ethernet.h>
32
#else /* !HAVE_NET_ETHERNET_H -*/
33
 
34
#include <sys/types.h>
35
 
36
#define ETH_ALEN 6
37
 
38
struct ether_addr
39
{
40
  u_int8_t ether_addr_octet[ETH_ALEN];
41
};
42
 
43
struct ether_header
44
{
45
  u_int8_t  ether_dhost[ETH_ALEN];      /* destination eth addr */
46
  u_int8_t  ether_shost[ETH_ALEN];      /* source ether addr    */
47
  u_int16_t ether_type;                 /* packet type ID field */
48
};
49
 
50
/* Ethernet protocol ID's */
51
#define ETHERTYPE_PUP           0x0200          /* Xerox PUP */
52
#define ETHERTYPE_IP            0x0800          /* IP */
53
#define ETHERTYPE_ARP           0x0806          /* Address resolution */
54
#define ETHERTYPE_REVARP        0x8035          /* Reverse ARP */
55
 
56
#define ETHER_ADDR_LEN  ETH_ALEN                 /* size of ethernet addr */
57
#define ETHER_TYPE_LEN  2                        /* bytes in type field */
58
#define ETHER_CRC_LEN   4                        /* bytes in CRC field */
59
#define ETHER_HDR_LEN   ETH_HLEN                 /* total octets in header */
60
#define ETHER_MIN_LEN   (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
61
#define ETHER_MAX_LEN   (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
62
 
63
/* make sure ethenet length is valid */
64
#define ETHER_IS_VALID_LEN(foo) \
65
        ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
66
 
67
/*
68
 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
69
 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
70
 * by an ETHER type (as given above) and then the (variable-length) header.
71
 */
72
#define ETHERTYPE_TRAIL         0x1000          /* Trailer packet */
73
#define ETHERTYPE_NTRAILER      16
74
 
75
#define ETHERMTU        ETH_DATA_LEN
76
#define ETHERMIN        (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
77
 
78
#endif /* HAVE_NET_ETHERNET_H */
79
 
80
 
81
/*
82
 * Implementatino of Ethernet MAC Registers and State
83
 */
84
struct eth_device
85
{
86
  /* Base address in memory */
87
  unsigned long baseaddr;
88
 
89
  /* Which Ethernet MAC is this? */
90
  unsigned eth_number;
91
 
92
  /* Which DMA controller is this MAC connected to */
93
  unsigned dma;
94
        unsigned tx_channel;
95
        unsigned rx_channel;
96
 
97
        /* Our address */
98
        unsigned char mac_address[ETH_ALEN];
99
 
100
  /* RX and TX file names and handles */
101
  const char *rxfile, *txfile;
102
        int txfd;
103
        int rxfd;
104
        off_t loopback_offset;
105
 
106
        /* Current TX state */
107
        struct
108
        {
109
                unsigned long bd_index;
110
                unsigned long bd;
111
                unsigned working, waiting_for_ack, error;
112
                unsigned packet_length;
113
                unsigned minimum_length, maximum_length;
114
                unsigned add_crc;
115
                unsigned long crc_value;
116
                unsigned bytes_left, bytes_sent;
117
        } tx;
118
 
119
        /* Current RX state */
120
        struct
121
        {
122
                unsigned long bd_index;
123
                unsigned long bd;
124
                int fd;
125
                off_t *offset;
126
                unsigned working, error, waiting_for_ack;
127
                unsigned packet_length, bytes_read, bytes_left;
128
        } rx;
129
 
130
  /* Visible registers */
131
  struct
132
  {
133
    unsigned long moder;
134
    unsigned long int_source;
135
    unsigned long int_mask;
136
    unsigned long ipgt;
137
    unsigned long ipgr1;
138
    unsigned long ipgr2;
139
    unsigned long packetlen;
140
    unsigned long collconf;
141 406 erez
    unsigned long rx_bd_num;
142 346 erez
    unsigned long controlmoder;
143
    unsigned long miimoder;
144
    unsigned long miicommand;
145
    unsigned long miiaddress;
146
    unsigned long miitx_data;
147
    unsigned long miirx_data;
148
    unsigned long miistatus;
149
 
150
                /* Buffer descriptors */
151
                unsigned long bd_ram[ETH_BD_SPACE / 4];
152
  } regs;
153
};
154
 
155
 
156
 
157
 
158
#endif /* __OR1KSIM_PERIPHERAL_ETHERNET_I_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.