1/*
2 * Copyright (c) 2008, ETH Zurich. All rights reserved.
3 *
4 * This file is distributed under the terms in the attached LICENSE file.
5 * If you do not find this file, copies can be found by writing to:
6 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
7 */
8
9#ifndef __E1000_DESC_H__
10#define __E1000_DESC_H__
11
12typedef union {
13    uint16_t   vlan;
14    struct {
15        uint16_t vlan :12;
16        uint16_t cfi  :1;
17        uint16_t pri  :3;
18    } __attribute__((packed)) bits;
19} __attribute__((packed)) vlan_tag_t;
20
21
22union rx_desc {
23    uint64_t raw[2] __attribute__((packed));
24    struct {
25        uint64_t buffer_address;
26        struct {
27            uint16_t   length;
28            uint16_t   checksum;        /* reserved on: 82544GC/EI */
29            struct {
30                unsigned int   dd      :1;
31                unsigned int   eop     :1;
32                unsigned int   ixsm    :1;
33                unsigned int   vp      :1;
34                unsigned int   udpcs   :1;  /* reserved on: 8254x */
35                unsigned int   tcpcs   :1;
36                unsigned int   ipcs    :1;
37                unsigned int   pif     :1;
38            } __attribute__ ((packed)) status;
39
40            union {
41                uint8_t errors;
42                struct {
43                    uint8_t ce   :1;
44                    uint8_t seq  :1;        /* reserved on: 82541xx, 82547GI/EI, and 82540EP/EM only. */
45                    uint8_t res0 :1;        /* reserved on: 8254x */
46                    uint8_t cxe  :1;        /* 82544GC/EI only */
47                    uint8_t tcpe :1;
48                    uint8_t ipe  :1;
49                    uint8_t rxe  :1;
50                } __attribute__ ((packed)) bits;
51            } __attribute__ ((packed)) errors;
52            vlan_tag_t vlan;
53        } __attribute__ ((packed)) info;
54    } __attribute__ ((packed)) rx_read_format;
55} __attribute__ ((packed));
56
57
58struct tx_desc {
59    uint64_t buffer_address;
60    union {
61        uint64_t raw;
62        struct {
63            uint16_t data_len;
64            uint8_t cso;
65            union {
66                uint8_t raw;
67                struct {
68                    uint8_t eop  :1;
69                    uint8_t ifcs :1;
70                    uint8_t ic   :1;
71                    uint8_t rs   :1;
72                    uint8_t rsv  :1;
73                    uint8_t dext :1;
74                    uint8_t vle  :1;
75                    uint8_t ide  :1;
76                } __attribute__ ((packed)) d;
77            } __attribute__ ((packed)) cmd;
78            union {
79                uint8_t raw;
80                struct {
81                    uint8_t dd  :1;
82                    uint8_t ec  :1;
83                    uint8_t lc  :1;
84                    uint8_t res :5;
85                } __attribute__ ((packed)) d;
86            } __attribute__ ((packed)) stat_rsv;
87            uint8_t  css;
88            uint16_t special;
89        } __attribute__ ((packed)) legacy;
90
91        struct {
92            uint64_t data_len :20;
93            uint64_t dtyp     :4;
94            union {
95                uint8_t raw;
96                struct {
97                    uint8_t eop  :1;
98                    uint8_t ifcs :1;
99                    uint8_t tse  :1;
100                    uint8_t rs   :1;
101                    uint8_t rsv  :1;
102                    uint8_t dext :1;
103                    uint8_t vle  :1;
104                    uint8_t ide  :1;
105                } __attribute__ ((packed)) d;
106            } __attribute__ ((packed)) dcmd;
107            union {
108                uint8_t raw;
109                struct {
110                    uint8_t dd  :1;
111                    uint8_t res :7;
112                } __attribute__ ((packed)) d;
113            } __attribute__ ((packed)) stat_rsv;
114            union {
115                uint8_t  raw;
116                struct {
117                    uint8_t ixsm : 1;
118                    uint8_t txsm : 1;
119                    uint8_t  res : 6;
120                } __attribute__ ((packed)) d;
121            } __attribute__ ((packed)) popts;
122            vlan_tag_t vlan;
123        } __attribute__ ((packed)) extended_data;
124
125        struct {
126            uint16_t dtalen;
127            union {
128                uint8_t raw;
129                struct {
130                    uint8_t rsv  :2;
131                    uint8_t mac  :2;
132                    uint8_t dtyp :4;
133                } __attribute__ ((packed)) d;
134            } __attribute__ ((packed)) dtyp;
135            union {
136                uint8_t raw;
137                struct {
138                    uint8_t eop  :1;
139                    uint8_t ifcs :1;
140                    uint8_t rsv1 :1;
141                    uint8_t rs   :1;
142                    uint8_t rsv2 :1;
143                    uint8_t dext :1;
144                    uint8_t vle  :1;
145                    uint8_t tse  :1;
146                } __attribute__ ((packed)) d;
147            } __attribute__ ((packed)) dcmd;
148
149            union {
150                uint8_t raw;
151                struct {
152                    uint8_t dd   :1;
153                    uint8_t rsv1 :3;
154                    uint8_t idx  :3;
155                    uint8_t rsv2 :1;
156                } __attribute__ ((packed)) d;
157            } __attribute__ ((packed)) stat_idx;
158
159            union {
160                uint8_t raw[3];
161                struct {
162                    uint8_t ixsm : 1;
163                    uint8_t txsm : 1;
164                    uint8_t ipsec: 1;
165                    uint8_t rsv  : 3;
166                    uint32_t paylen:18;
167                } __attribute__ ((packed)) d;
168            } __attribute__ ((packed)) popts_paylen;
169        } __attribute__ ((packed)) advanced_data;
170    } __attribute__ ((packed)) ctrl;
171} __attribute__ ((packed));
172
173/*
174 * TCP/IP Context Descriptor Layout
175 *
176 * Provides access to enhanced checksum offload facility
177 * available in the Ethernet controllerfor TCP and UDP packets.
178 */
179union context_desc {
180    uint64_t raw;
181    struct {
182        uint8_t ipcss;
183        uint8_t ipcso;
184        uint16_t ipcse;
185        uint8_t tucss;
186        uint8_t tucso;
187        uint16_t tucse;
188        struct {
189            uint32_t paylen :20;
190            uint32_t dtype  :4;
191        } __attribute__ ((packed)) pd;
192
193        union {
194            uint8_t raw;
195            struct {
196                uint8_t tcp  :1;
197                uint8_t ip   :1;
198                uint8_t tse  :1;
199                uint8_t rs   :1;
200                uint8_t rsv  :1;
201                uint8_t dext :1;
202                uint8_t snap :1;
203                uint8_t ide  :1;
204            } __attribute__ ((packed)) d;
205        } __attribute__ ((packed)) tucmd;
206
207        union {
208            uint8_t raw;
209            struct {
210                uint8_t dd  :1;
211                uint8_t res :7;
212            } __attribute__ ((packed)) d;
213        } __attribute__ ((packed)) stat_rsv;
214
215        uint8_t hdrlen;
216        uint16_t mss;
217
218    } __attribute__ ((packed)) d;
219} __attribute__ ((packed));
220
221#endif
222