Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[linux-drm-fsl-dcu.git] / drivers / net / ethernet / chelsio / cxgb / gmac.h
1 /*****************************************************************************
2  *                                                                           *
3  * File: gmac.h                                                              *
4  * $Revision: 1.6 $                                                          *
5  * $Date: 2005/06/21 18:29:47 $                                              *
6  * Description:                                                              *
7  *  Generic MAC functionality.                                               *
8  *  part of the Chelsio 10Gb Ethernet Driver.                                *
9  *                                                                           *
10  * This program is free software; you can redistribute it and/or modify      *
11  * it under the terms of the GNU General Public License, version 2, as       *
12  * published by the Free Software Foundation.                                *
13  *                                                                           *
14  * You should have received a copy of the GNU General Public License along   *
15  * with this program; if not, see <http://www.gnu.org/licenses/>.            *
16  *                                                                           *
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED    *
18  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF      *
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.                     *
20  *                                                                           *
21  * http://www.chelsio.com                                                    *
22  *                                                                           *
23  * Copyright (c) 2003 - 2005 Chelsio Communications, Inc.                    *
24  * All rights reserved.                                                      *
25  *                                                                           *
26  * Maintainers: maintainers@chelsio.com                                      *
27  *                                                                           *
28  * Authors: Dimitrios Michailidis   <dm@chelsio.com>                         *
29  *          Tina Yang               <tainay@chelsio.com>                     *
30  *          Felix Marti             <felix@chelsio.com>                      *
31  *          Scott Bardone           <sbardone@chelsio.com>                   *
32  *          Kurt Ottaway            <kottaway@chelsio.com>                   *
33  *          Frank DiMambro          <frank@chelsio.com>                      *
34  *                                                                           *
35  * History:                                                                  *
36  *                                                                           *
37  ****************************************************************************/
38
39 #ifndef _CXGB_GMAC_H_
40 #define _CXGB_GMAC_H_
41
42 #include "common.h"
43
44 enum {
45         MAC_STATS_UPDATE_FAST,
46         MAC_STATS_UPDATE_FULL
47 };
48
49 enum {
50         MAC_DIRECTION_RX = 1,
51         MAC_DIRECTION_TX = 2
52 };
53
54 struct cmac_statistics {
55         /* Transmit */
56         u64 TxOctetsOK;
57         u64 TxOctetsBad;
58         u64 TxUnicastFramesOK;
59         u64 TxMulticastFramesOK;
60         u64 TxBroadcastFramesOK;
61         u64 TxPauseFrames;
62         u64 TxFramesWithDeferredXmissions;
63         u64 TxLateCollisions;
64         u64 TxTotalCollisions;
65         u64 TxFramesAbortedDueToXSCollisions;
66         u64 TxUnderrun;
67         u64 TxLengthErrors;
68         u64 TxInternalMACXmitError;
69         u64 TxFramesWithExcessiveDeferral;
70         u64 TxFCSErrors;
71         u64 TxJumboFramesOK;
72         u64 TxJumboOctetsOK;
73
74         /* Receive */
75         u64 RxOctetsOK;
76         u64 RxOctetsBad;
77         u64 RxUnicastFramesOK;
78         u64 RxMulticastFramesOK;
79         u64 RxBroadcastFramesOK;
80         u64 RxPauseFrames;
81         u64 RxFCSErrors;
82         u64 RxAlignErrors;
83         u64 RxSymbolErrors;
84         u64 RxDataErrors;
85         u64 RxSequenceErrors;
86         u64 RxRuntErrors;
87         u64 RxJabberErrors;
88         u64 RxInternalMACRcvError;
89         u64 RxInRangeLengthErrors;
90         u64 RxOutOfRangeLengthField;
91         u64 RxFrameTooLongErrors;
92         u64 RxJumboFramesOK;
93         u64 RxJumboOctetsOK;
94 };
95
96 struct cmac_ops {
97         void (*destroy)(struct cmac *);
98         int (*reset)(struct cmac *);
99         int (*interrupt_enable)(struct cmac *);
100         int (*interrupt_disable)(struct cmac *);
101         int (*interrupt_clear)(struct cmac *);
102         int (*interrupt_handler)(struct cmac *);
103
104         int (*enable)(struct cmac *, int);
105         int (*disable)(struct cmac *, int);
106
107         int (*loopback_enable)(struct cmac *);
108         int (*loopback_disable)(struct cmac *);
109
110         int (*set_mtu)(struct cmac *, int mtu);
111         int (*set_rx_mode)(struct cmac *, struct t1_rx_mode *rm);
112
113         int (*set_speed_duplex_fc)(struct cmac *, int speed, int duplex, int fc);
114         int (*get_speed_duplex_fc)(struct cmac *, int *speed, int *duplex,
115                                    int *fc);
116
117         const struct cmac_statistics *(*statistics_update)(struct cmac *, int);
118
119         int (*macaddress_get)(struct cmac *, u8 mac_addr[6]);
120         int (*macaddress_set)(struct cmac *, u8 mac_addr[6]);
121 };
122
123 typedef struct _cmac_instance cmac_instance;
124
125 struct cmac {
126         struct cmac_statistics stats;
127         adapter_t *adapter;
128         const struct cmac_ops *ops;
129         cmac_instance *instance;
130 };
131
132 struct gmac {
133         unsigned int stats_update_period;
134         struct cmac *(*create)(adapter_t *adapter, int index);
135         int (*reset)(adapter_t *);
136 };
137
138 extern const struct gmac t1_pm3393_ops;
139 extern const struct gmac t1_vsc7326_ops;
140
141 #endif /* _CXGB_GMAC_H_ */