xref: /linux/drivers/net/ethernet/chelsio/cxgb/gmac.h (revision 2da68a77)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*****************************************************************************
3  *                                                                           *
4  * File: gmac.h                                                              *
5  * $Revision: 1.6 $                                                          *
6  * $Date: 2005/06/21 18:29:47 $                                              *
7  * Description:                                                              *
8  *  Generic MAC functionality.                                               *
9  *  part of the Chelsio 10Gb Ethernet Driver.                                *
10  *                                                                           *
11  *                                                                           *
12  * http://www.chelsio.com                                                    *
13  *                                                                           *
14  * Copyright (c) 2003 - 2005 Chelsio Communications, Inc.                    *
15  * All rights reserved.                                                      *
16  *                                                                           *
17  * Maintainers: maintainers@chelsio.com                                      *
18  *                                                                           *
19  * Authors: Dimitrios Michailidis   <dm@chelsio.com>                         *
20  *          Tina Yang               <tainay@chelsio.com>                     *
21  *          Felix Marti             <felix@chelsio.com>                      *
22  *          Scott Bardone           <sbardone@chelsio.com>                   *
23  *          Kurt Ottaway            <kottaway@chelsio.com>                   *
24  *          Frank DiMambro          <frank@chelsio.com>                      *
25  *                                                                           *
26  * History:                                                                  *
27  *                                                                           *
28  ****************************************************************************/
29 
30 #ifndef _CXGB_GMAC_H_
31 #define _CXGB_GMAC_H_
32 
33 #include "common.h"
34 
35 enum {
36 	MAC_STATS_UPDATE_FAST,
37 	MAC_STATS_UPDATE_FULL
38 };
39 
40 enum {
41 	MAC_DIRECTION_RX = 1,
42 	MAC_DIRECTION_TX = 2
43 };
44 
45 struct cmac_statistics {
46 	/* Transmit */
47 	u64 TxOctetsOK;
48 	u64 TxOctetsBad;
49 	u64 TxUnicastFramesOK;
50 	u64 TxMulticastFramesOK;
51 	u64 TxBroadcastFramesOK;
52 	u64 TxPauseFrames;
53 	u64 TxFramesWithDeferredXmissions;
54 	u64 TxLateCollisions;
55 	u64 TxTotalCollisions;
56 	u64 TxFramesAbortedDueToXSCollisions;
57 	u64 TxUnderrun;
58 	u64 TxLengthErrors;
59 	u64 TxInternalMACXmitError;
60 	u64 TxFramesWithExcessiveDeferral;
61 	u64 TxFCSErrors;
62 	u64 TxJumboFramesOK;
63 	u64 TxJumboOctetsOK;
64 
65 	/* Receive */
66 	u64 RxOctetsOK;
67 	u64 RxOctetsBad;
68 	u64 RxUnicastFramesOK;
69 	u64 RxMulticastFramesOK;
70 	u64 RxBroadcastFramesOK;
71 	u64 RxPauseFrames;
72 	u64 RxFCSErrors;
73 	u64 RxAlignErrors;
74 	u64 RxSymbolErrors;
75 	u64 RxDataErrors;
76 	u64 RxSequenceErrors;
77 	u64 RxRuntErrors;
78 	u64 RxJabberErrors;
79 	u64 RxInternalMACRcvError;
80 	u64 RxInRangeLengthErrors;
81 	u64 RxOutOfRangeLengthField;
82 	u64 RxFrameTooLongErrors;
83 	u64 RxJumboFramesOK;
84 	u64 RxJumboOctetsOK;
85 };
86 
87 struct cmac_ops {
88 	void (*destroy)(struct cmac *);
89 	int (*reset)(struct cmac *);
90 	int (*interrupt_enable)(struct cmac *);
91 	int (*interrupt_disable)(struct cmac *);
92 	int (*interrupt_clear)(struct cmac *);
93 	int (*interrupt_handler)(struct cmac *);
94 
95 	int (*enable)(struct cmac *, int);
96 	int (*disable)(struct cmac *, int);
97 
98 	int (*loopback_enable)(struct cmac *);
99 	int (*loopback_disable)(struct cmac *);
100 
101 	int (*set_mtu)(struct cmac *, int mtu);
102 	int (*set_rx_mode)(struct cmac *, struct t1_rx_mode *rm);
103 
104 	int (*set_speed_duplex_fc)(struct cmac *, int speed, int duplex, int fc);
105 	int (*get_speed_duplex_fc)(struct cmac *, int *speed, int *duplex,
106 				   int *fc);
107 
108 	const struct cmac_statistics *(*statistics_update)(struct cmac *, int);
109 
110 	int (*macaddress_get)(struct cmac *, u8 mac_addr[6]);
111 	int (*macaddress_set)(struct cmac *, const u8 mac_addr[6]);
112 };
113 
114 typedef struct _cmac_instance cmac_instance;
115 
116 struct cmac {
117 	struct cmac_statistics stats;
118 	adapter_t *adapter;
119 	const struct cmac_ops *ops;
120 	cmac_instance *instance;
121 };
122 
123 struct gmac {
124 	unsigned int stats_update_period;
125 	struct cmac *(*create)(adapter_t *adapter, int index);
126 	int (*reset)(adapter_t *);
127 };
128 
129 extern const struct gmac t1_pm3393_ops;
130 extern const struct gmac t1_vsc7326_ops;
131 
132 #endif /* _CXGB_GMAC_H_ */
133