aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/chelsio/common.h
diff options
context:
space:
mode:
authorScott Bardone <sbardone@chelsio.com>2005-06-23 01:40:19 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-06-23 01:40:19 -0400
commit559fb51ba7e66fe298b8355fabde1275b7def35f (patch)
treee1de3eb86ea5e6ac8c5f27dc32140a0c2aacc51e /drivers/net/chelsio/common.h
parenta5324343955997d1439f26518ddac567cd5d134b (diff)
Update Chelsio gige net driver.
- Use extern prefix for functions required. - Removed a lot of wrappers, including t1_read/write_reg_4. - Removed various macros, using native kernel calls now. - Enumerated various #defines. - Removed a lot of shared code which is not currently used in "NIC only" mode. - Removed dead code. Documentation/networking/cxgb.txt: - Updated release notes for version 2.1.1 drivers/net/chelsio/ch_ethtool.h - removed file, no longer using ETHTOOL namespace. drivers/net/chelsio/common.h - moved code from osdep.h to common.h - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/cphy.h - removed dead code. - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/cxgb2.c - use DMA_{32,64}BIT_MASK in include/linux/dma-mapping.h. - removed unused code. - use printk message for link info resembling drivers/net/mii.c. - no longer using the MODULE_xxx namespace. - no longer using "pci_" namespace. - no longer using ETHTOOL namespace. drivers/net/chelsio/cxgb2.h - removed file, merged into common.h drivers/net/chelsio/elmer0.h - removed dead code. - added various enums. - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/espi.c - removed various macros, using native kernel calls now. - removed a lot of wrappers, including t1_read/write_reg_4. drivers/net/chelsio/espi.h - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/gmac.h - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/mv88x201x.c - changes to sync with Chelsio TOT. drivers/net/chelsio/osdep.h - removed file, consolidation. osdep was used to translate wrapper functions since our code supports multiple OSs. removed wrappers. drivers/net/chelsio/pm3393.c - removed various macros, using native kernel calls now. - removed a lot of wrappers, including t1_read/write_reg_4. - removed unused code. drivers/net/chelsio/regs.h - added a few register entries for future and current feature support. - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/sge.c - rewrote large portion of scatter-gather engine to stabilize performance. - using u8/u16/u32 kernel types instead of __u8/__u16/__u32 compiler types. drivers/net/chelsio/sge.h - rewrote large portion of scatter-gather engine to stabilize performance. - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/subr.c - merged tp.c into subr.c - removed various macros, using native kernel calls now. - removed a lot of wrappers, including t1_read/write_reg_4. - removed unused code. drivers/net/chelsio/suni1x10gexp_regs.h - modified copyright and authorship of file. - added comment to #endif indicating which symbol it closes. drivers/net/chelsio/tp.c - removed file, merged into subr.c. drivers/net/chelsio/tp.h - removed file. include/linux/pci_ids.h - patched to include PCI_VENDOR_ID_CHELSIO 0x1425, removed define from our code.
Diffstat (limited to 'drivers/net/chelsio/common.h')
-rw-r--r--drivers/net/chelsio/common.h259
1 files changed, 152 insertions, 107 deletions
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index 017684ff48dc..f09348802b46 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -1,8 +1,8 @@
1/***************************************************************************** 1/*****************************************************************************
2 * * 2 * *
3 * File: common.h * 3 * File: common.h *
4 * $Revision: 1.5 $ * 4 * $Revision: 1.21 $ *
5 * $Date: 2005/03/23 07:41:27 $ * 5 * $Date: 2005/06/22 00:43:25 $ *
6 * Description: * 6 * Description: *
7 * part of the Chelsio 10Gb Ethernet Driver. * 7 * part of the Chelsio 10Gb Ethernet Driver. *
8 * * 8 * *
@@ -36,74 +36,101 @@
36 * * 36 * *
37 ****************************************************************************/ 37 ****************************************************************************/
38 38
39#ifndef CHELSIO_COMMON_H 39#ifndef _CXGB_COMMON_H_
40#define CHELSIO_COMMON_H 40#define _CXGB_COMMON_H_
41
42#include <linux/config.h>
43#include <linux/module.h>
44#include <linux/netdevice.h>
45#include <linux/types.h>
46#include <linux/delay.h>
47#include <linux/pci.h>
48#include <linux/ethtool.h>
49#include <linux/mii.h>
50#include <linux/crc32.h>
51#include <linux/init.h>
52#include <asm/io.h>
53#include <linux/pci_ids.h>
54
55#define DRV_DESCRIPTION "Chelsio 10Gb Ethernet Driver"
56#define DRV_NAME "cxgb"
57#define DRV_VERSION "2.1.1"
58#define PFX DRV_NAME ": "
59
60#define CH_ERR(fmt, ...) printk(KERN_ERR PFX fmt, ## __VA_ARGS__)
61#define CH_WARN(fmt, ...) printk(KERN_WARNING PFX fmt, ## __VA_ARGS__)
62#define CH_ALERT(fmt, ...) printk(KERN_ALERT PFX fmt, ## __VA_ARGS__)
63
64#define CH_DEVICE(devid, ssid, idx) \
65 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx }
66
67#define SUPPORTED_PAUSE (1 << 13)
68#define SUPPORTED_LOOPBACK (1 << 15)
69
70#define ADVERTISED_PAUSE (1 << 13)
71#define ADVERTISED_ASYM_PAUSE (1 << 14)
72
73typedef struct adapter adapter_t;
74
75void t1_elmer0_ext_intr(adapter_t *adapter);
76void t1_link_changed(adapter_t *adapter, int port_id, int link_status,
77 int speed, int duplex, int fc);
78
79struct t1_rx_mode {
80 struct net_device *dev;
81 u32 idx;
82 struct dev_mc_list *list;
83};
84
85#define t1_rx_mode_promisc(rm) (rm->dev->flags & IFF_PROMISC)
86#define t1_rx_mode_allmulti(rm) (rm->dev->flags & IFF_ALLMULTI)
87#define t1_rx_mode_mc_cnt(rm) (rm->dev->mc_count)
88
89static inline u8 *t1_get_next_mcaddr(struct t1_rx_mode *rm)
90{
91 u8 *addr = 0;
41 92
42#define DIMOF(x) (sizeof(x)/sizeof(x[0])) 93 if (rm->idx++ < rm->dev->mc_count) {
94 addr = rm->list->dmi_addr;
95 rm->list = rm->list->next;
96 }
97 return addr;
98}
99
100#define MAX_NPORTS 4
43 101
44#define NMTUS 8 102#define SPEED_INVALID 0xffff
45#define MAX_NPORTS 4 103#define DUPLEX_INVALID 0xff
46#define TCB_SIZE 128
47 104
48enum { 105enum {
49 CHBT_BOARD_7500,
50 CHBT_BOARD_8000,
51 CHBT_BOARD_CHT101,
52 CHBT_BOARD_CHT110,
53 CHBT_BOARD_CHT210,
54 CHBT_BOARD_CHT204,
55 CHBT_BOARD_N110, 106 CHBT_BOARD_N110,
56 CHBT_BOARD_N210, 107 CHBT_BOARD_N210
57 CHBT_BOARD_COUGAR,
58 CHBT_BOARD_6800,
59 CHBT_BOARD_SIMUL
60}; 108};
61 109
62enum { 110enum {
63 CHBT_TERM_FPGA,
64 CHBT_TERM_T1, 111 CHBT_TERM_T1,
65 CHBT_TERM_T2, 112 CHBT_TERM_T2
66 CHBT_TERM_T3
67}; 113};
68 114
69enum { 115enum {
70 CHBT_MAC_CHELSIO_A,
71 CHBT_MAC_IXF1010,
72 CHBT_MAC_PM3393, 116 CHBT_MAC_PM3393,
73 CHBT_MAC_VSC7321,
74 CHBT_MAC_DUMMY
75}; 117};
76 118
77enum { 119enum {
78 CHBT_PHY_88E1041,
79 CHBT_PHY_88E1111,
80 CHBT_PHY_88X2010, 120 CHBT_PHY_88X2010,
81 CHBT_PHY_XPAK,
82 CHBT_PHY_MY3126,
83 CHBT_PHY_DUMMY
84}; 121};
85 122
86enum { 123enum {
87 PAUSE_RX = 1, 124 PAUSE_RX = 1 << 0,
88 PAUSE_TX = 2, 125 PAUSE_TX = 1 << 1,
89 PAUSE_AUTONEG = 4 126 PAUSE_AUTONEG = 1 << 2
90}; 127};
91 128
92/* Revisions of T1 chip */ 129/* Revisions of T1 chip */
93#define TERM_T1A 0 130enum {
94#define TERM_T1B 1 131 TERM_T1A = 0,
95#define TERM_T2 3 132 TERM_T1B = 1,
96 133 TERM_T2 = 3
97struct tp_params {
98 unsigned int pm_size;
99 unsigned int cm_size;
100 unsigned int pm_rx_base;
101 unsigned int pm_tx_base;
102 unsigned int pm_rx_pg_size;
103 unsigned int pm_tx_pg_size;
104 unsigned int pm_rx_num_pgs;
105 unsigned int pm_tx_num_pgs;
106 unsigned int use_5tuple_mode;
107}; 134};
108 135
109struct sge_params { 136struct sge_params {
@@ -118,17 +145,7 @@ struct sge_params {
118 unsigned int polling; 145 unsigned int polling;
119}; 146};
120 147
121struct mc5_params { 148struct chelsio_pci_params {
122 unsigned int mode; /* selects MC5 width */
123 unsigned int nservers; /* size of server region */
124 unsigned int nroutes; /* size of routing region */
125};
126
127/* Default MC5 region sizes */
128#define DEFAULT_SERVER_REGION_LEN 256
129#define DEFAULT_RT_REGION_LEN 1024
130
131struct pci_params {
132 unsigned short speed; 149 unsigned short speed;
133 unsigned char width; 150 unsigned char width;
134 unsigned char is_pcix; 151 unsigned char is_pcix;
@@ -136,31 +153,14 @@ struct pci_params {
136 153
137struct adapter_params { 154struct adapter_params {
138 struct sge_params sge; 155 struct sge_params sge;
139 struct mc5_params mc5; 156 struct chelsio_pci_params pci;
140 struct tp_params tp;
141 struct pci_params pci;
142 157
143 const struct board_info *brd_info; 158 const struct board_info *brd_info;
144 159
145 unsigned short mtus[NMTUS]; 160 unsigned int nports; /* # of ethernet ports */
146 unsigned int nports; /* # of ethernet ports */
147 unsigned int stats_update_period; 161 unsigned int stats_update_period;
148 unsigned short chip_revision; 162 unsigned short chip_revision;
149 unsigned char chip_version; 163 unsigned char chip_version;
150 unsigned char is_asic;
151};
152
153struct pci_err_cnt {
154 unsigned int master_parity_err;
155 unsigned int sig_target_abort;
156 unsigned int rcv_target_abort;
157 unsigned int rcv_master_abort;
158 unsigned int sig_sys_err;
159 unsigned int det_parity_err;
160 unsigned int pio_parity_err;
161 unsigned int wf_parity_err;
162 unsigned int rf_parity_err;
163 unsigned int cf_parity_err;
164}; 164};
165 165
166struct link_config { 166struct link_config {
@@ -175,8 +175,60 @@ struct link_config {
175 unsigned char autoneg; /* autonegotiating? */ 175 unsigned char autoneg; /* autonegotiating? */
176}; 176};
177 177
178#define SPEED_INVALID 0xffff 178struct cmac;
179#define DUPLEX_INVALID 0xff 179struct cphy;
180
181struct port_info {
182 struct net_device *dev;
183 struct cmac *mac;
184 struct cphy *phy;
185 struct link_config link_config;
186 struct net_device_stats netstats;
187};
188
189struct sge;
190struct peespi;
191
192struct adapter {
193 u8 *regs;
194 struct pci_dev *pdev;
195 unsigned long registered_device_map;
196 unsigned long open_device_map;
197 unsigned long flags;
198
199 const char *name;
200 int msg_enable;
201 u32 mmio_len;
202
203 struct work_struct ext_intr_handler_task;
204 struct adapter_params params;
205
206 struct vlan_group *vlan_grp;
207
208 /* Terminator modules. */
209 struct sge *sge;
210 struct peespi *espi;
211
212 struct port_info port[MAX_NPORTS];
213 struct work_struct stats_update_task;
214 struct timer_list stats_update_timer;
215
216 struct semaphore mib_mutex;
217 spinlock_t tpi_lock;
218 spinlock_t work_lock;
219 /* guards async operations */
220 spinlock_t async_lock ____cacheline_aligned;
221 u32 slow_intr_mask;
222};
223
224enum { /* adapter flags */
225 FULL_INIT_DONE = 1 << 0,
226 TSO_CAPABLE = 1 << 2,
227 TCP_CSUM_CAPABLE = 1 << 3,
228 UDP_CSUM_CAPABLE = 1 << 4,
229 VLAN_ACCEL_CAPABLE = 1 << 5,
230 RX_CSUM_ENABLED = 1 << 6,
231};
180 232
181struct mdio_ops; 233struct mdio_ops;
182struct gmac; 234struct gmac;
@@ -205,19 +257,8 @@ struct board_info {
205 const char *desc; 257 const char *desc;
206}; 258};
207 259
208#include "osdep.h"
209
210#ifndef PCI_VENDOR_ID_CHELSIO
211#define PCI_VENDOR_ID_CHELSIO 0x1425
212#endif
213
214extern struct pci_device_id t1_pci_tbl[]; 260extern struct pci_device_id t1_pci_tbl[];
215 261
216static inline int t1_is_asic(const adapter_t *adapter)
217{
218 return adapter->params.is_asic;
219}
220
221static inline int adapter_matches_type(const adapter_t *adapter, 262static inline int adapter_matches_type(const adapter_t *adapter,
222 int version, int revision) 263 int version, int revision)
223{ 264{
@@ -245,25 +286,29 @@ static inline unsigned int core_ticks_per_usec(const adapter_t *adap)
245 return board_info(adap)->clock_core / 1000000; 286 return board_info(adap)->clock_core / 1000000;
246} 287}
247 288
248int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value); 289extern int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
249int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value); 290extern int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value);
250 291
251void t1_interrupts_enable(adapter_t *adapter); 292extern void t1_interrupts_enable(adapter_t *adapter);
252void t1_interrupts_disable(adapter_t *adapter); 293extern void t1_interrupts_disable(adapter_t *adapter);
253void t1_interrupts_clear(adapter_t *adapter); 294extern void t1_interrupts_clear(adapter_t *adapter);
254int elmer0_ext_intr_handler(adapter_t *adapter); 295extern int elmer0_ext_intr_handler(adapter_t *adapter);
255int t1_slow_intr_handler(adapter_t *adapter); 296extern int t1_slow_intr_handler(adapter_t *adapter);
256 297
257int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc); 298extern int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
258const struct board_info *t1_get_board_info(unsigned int board_id); 299extern const struct board_info *t1_get_board_info(unsigned int board_id);
259const struct board_info *t1_get_board_info_from_ids(unsigned int devid, 300extern const struct board_info *t1_get_board_info_from_ids(unsigned int devid,
260 unsigned short ssid); 301 unsigned short ssid);
261int t1_seeprom_read(adapter_t *adapter, u32 addr, u32 *data); 302extern int t1_seeprom_read(adapter_t *adapter, u32 addr, u32 *data);
262int t1_get_board_rev(adapter_t *adapter, const struct board_info *bi, 303extern int t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
263 struct adapter_params *p); 304 struct adapter_params *p);
264int t1_init_hw_modules(adapter_t *adapter); 305extern int t1_init_hw_modules(adapter_t *adapter);
265int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi); 306extern int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi);
266void t1_free_sw_modules(adapter_t *adapter); 307extern void t1_free_sw_modules(adapter_t *adapter);
267void t1_fatal_err(adapter_t *adapter); 308extern void t1_fatal_err(adapter_t *adapter);
268#endif 309
310extern void t1_tp_set_udp_checksum_offload(adapter_t *adapter, int enable);
311extern void t1_tp_set_tcp_checksum_offload(adapter_t *adapter, int enable);
312extern void t1_tp_set_ip_checksum_offload(adapter_t *adapter, int enable);
269 313
314#endif /* _CXGB_COMMON_H_ */