diff options
author | Christoph Lameter <christoph@graphe.net> | 2005-03-30 16:34:31 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-05-15 19:15:02 -0400 |
commit | 8199d3a79c224bbe5943fa08684e1f93a17881b0 (patch) | |
tree | 77726ddade7ca4282bc12315abcb01fdf241be74 /drivers/net/chelsio/tp.c | |
parent | 88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff) |
[PATCH] A new 10GB Ethernet Driver by Chelsio Communications
A Linux driver for the Chelsio 10Gb Ethernet Network Controller by Chelsio
(http://www.chelsio.com). This driver supports the Chelsio N210 NIC and is
backward compatible with the Chelsio N110 model 10Gb NICs. It supports
AMD64, EM64T and x86 systems.
Signed-off-by: Tina Yang <tinay@chelsio.com>
Signed-off-by: Scott Bardone <sbardone@chelsio.com>
Signed-off-by: Christoph Lameter <christoph@lameter.com>
Adrian said:
- my3126.c is unused (because t1_my3126_ops isn't used anywhere)
- what are the EXTRA_CFLAGS in drivers/net/chelsio/Makefile for?
- $(cxgb-y) in drivers/net/chelsio/Makefile seems to be unneeded
- completely unused global functions:
- espi.c: t1_espi_get_intr_counts
- sge.c: t1_sge_get_intr_counts
- the following functions can be made static:
- sge.c: t1_espi_workaround
- sge.c: t1_sge_tx
- subr.c: __t1_tpi_read
- subr.c: __t1_tpi_write
- subr.c: t1_wait_op_done
shemminger said:
The performance recommendations in cxgb.txt are common to all fast devices,
and should be in one file rather than just for this device. I would rather
see ip-sysctl.txt updated or a new file on tuning recommendations started.
Some of them have consequences that aren't documented well.
For example, turning off TCP timestamps risks data corruption from sequence wrap.
A new driver shouldn't need so may #ifdef's unless you want to putit on older
vendor versions of 2.4
Some accessor and wrapper functions like:
t1_pci_read_config_4
adapter_name
t1_malloc
are just annoying noise.
Why have useless dead code like:
/* Interrupt handler */
+static int pm3393_interrupt_handler(struct cmac *cmac)
+{
+ u32 master_intr_status;
+/*
+ 1. Read master interrupt register.
+ 2. Read BLOCK's interrupt status registers.
+ 3. Handle BLOCK interrupts.
+*/
Jeff said:
step 1: kill all the OS wrappers.
And do you really need hooks for multiple MACs, when only one MAC is
really supported? Typically these hooks are at a higher level anyway --
struct net_device.
From: Christoph Lameter <christoph@lameter
Driver modified as suggested by Pekka Enberg, Stephen Hemminger and Andrian
Bunk. Reduces the size of the driver to ~260k.
- clean up tabs
- removed my3126.c
- removed 85% of suni1x10gexp_regs.h
- removed 80% of regs.h
- removed various calls, renamed variables/functions.
- removed system specific and other wrappers (usleep, msleep)
- removed dead code
- dropped redundant casts in osdep.h
- dropped redundant check of kfree
- dropped weird code (MODVERSIONS stuff)
- reduced number of #ifdefs
- use kcalloc now instead of kmalloc
- Add information about known issues with the driver
- Add information about authors
Signed-off-by: Scott Bardone <sbardone@chelsio.com>
Signed-off-by: Christoph Lameter <christoph@lameter.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
diff -puN /dev/null Documentation/networking/cxgb.txt
Diffstat (limited to 'drivers/net/chelsio/tp.c')
-rw-r--r-- | drivers/net/chelsio/tp.c | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/drivers/net/chelsio/tp.c b/drivers/net/chelsio/tp.c new file mode 100644 index 000000000000..9ad5c539fd28 --- /dev/null +++ b/drivers/net/chelsio/tp.c | |||
@@ -0,0 +1,188 @@ | |||
1 | /***************************************************************************** | ||
2 | * * | ||
3 | * File: tp.c * | ||
4 | * $Revision: 1.6 $ * | ||
5 | * $Date: 2005/03/23 07:15:59 $ * | ||
6 | * Description: * | ||
7 | * Core ASIC Management. * | ||
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, write to the Free Software Foundation, Inc., * | ||
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | ||
17 | * * | ||
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * | ||
19 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * | ||
20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * | ||
21 | * * | ||
22 | * http://www.chelsio.com * | ||
23 | * * | ||
24 | * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. * | ||
25 | * All rights reserved. * | ||
26 | * * | ||
27 | * Maintainers: maintainers@chelsio.com * | ||
28 | * * | ||
29 | * Authors: Dimitrios Michailidis <dm@chelsio.com> * | ||
30 | * Tina Yang <tainay@chelsio.com> * | ||
31 | * Felix Marti <felix@chelsio.com> * | ||
32 | * Scott Bardone <sbardone@chelsio.com> * | ||
33 | * Kurt Ottaway <kottaway@chelsio.com> * | ||
34 | * Frank DiMambro <frank@chelsio.com> * | ||
35 | * * | ||
36 | * History: * | ||
37 | * * | ||
38 | ****************************************************************************/ | ||
39 | |||
40 | #include "common.h" | ||
41 | #include "regs.h" | ||
42 | #include "tp.h" | ||
43 | |||
44 | struct petp { | ||
45 | adapter_t *adapter; | ||
46 | }; | ||
47 | |||
48 | /* Pause deadlock avoidance parameters */ | ||
49 | #define DROP_MSEC 16 | ||
50 | #define DROP_PKTS_CNT 1 | ||
51 | |||
52 | |||
53 | static void tp_init(adapter_t *ap, const struct tp_params *p, | ||
54 | unsigned int tp_clk) | ||
55 | { | ||
56 | if (t1_is_asic(ap)) { | ||
57 | u32 val; | ||
58 | |||
59 | val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM | | ||
60 | F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET; | ||
61 | if (!p->pm_size) | ||
62 | val |= F_OFFLOAD_DISABLE; | ||
63 | else | ||
64 | val |= F_TP_IN_ESPI_CHECK_IP_CSUM | | ||
65 | F_TP_IN_ESPI_CHECK_TCP_CSUM; | ||
66 | t1_write_reg_4(ap, A_TP_IN_CONFIG, val); | ||
67 | t1_write_reg_4(ap, A_TP_OUT_CONFIG, F_TP_OUT_CSPI_CPL | | ||
68 | F_TP_OUT_ESPI_ETHERNET | | ||
69 | F_TP_OUT_ESPI_GENERATE_IP_CSUM | | ||
70 | F_TP_OUT_ESPI_GENERATE_TCP_CSUM); | ||
71 | t1_write_reg_4(ap, A_TP_GLOBAL_CONFIG, V_IP_TTL(64) | | ||
72 | F_PATH_MTU /* IP DF bit */ | | ||
73 | V_5TUPLE_LOOKUP(p->use_5tuple_mode) | | ||
74 | V_SYN_COOKIE_PARAMETER(29)); | ||
75 | |||
76 | /* | ||
77 | * Enable pause frame deadlock prevention. | ||
78 | */ | ||
79 | if (is_T2(ap)) { | ||
80 | u32 drop_ticks = DROP_MSEC * (tp_clk / 1000); | ||
81 | |||
82 | t1_write_reg_4(ap, A_TP_TX_DROP_CONFIG, | ||
83 | F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR | | ||
84 | V_DROP_TICKS_CNT(drop_ticks) | | ||
85 | V_NUM_PKTS_DROPPED(DROP_PKTS_CNT)); | ||
86 | } | ||
87 | |||
88 | } | ||
89 | } | ||
90 | |||
91 | void t1_tp_destroy(struct petp *tp) | ||
92 | { | ||
93 | kfree(tp); | ||
94 | } | ||
95 | |||
96 | struct petp * __devinit t1_tp_create(adapter_t *adapter, struct tp_params *p) | ||
97 | { | ||
98 | struct petp *tp = kmalloc(sizeof(*tp), GFP_KERNEL); | ||
99 | if (!tp) | ||
100 | return NULL; | ||
101 | memset(tp, 0, sizeof(*tp)); | ||
102 | tp->adapter = adapter; | ||
103 | |||
104 | return tp; | ||
105 | } | ||
106 | |||
107 | void t1_tp_intr_enable(struct petp *tp) | ||
108 | { | ||
109 | u32 tp_intr = t1_read_reg_4(tp->adapter, A_PL_ENABLE); | ||
110 | |||
111 | { | ||
112 | /* We don't use any TP interrupts */ | ||
113 | t1_write_reg_4(tp->adapter, A_TP_INT_ENABLE, 0); | ||
114 | t1_write_reg_4(tp->adapter, A_PL_ENABLE, | ||
115 | tp_intr | F_PL_INTR_TP); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | void t1_tp_intr_disable(struct petp *tp) | ||
120 | { | ||
121 | u32 tp_intr = t1_read_reg_4(tp->adapter, A_PL_ENABLE); | ||
122 | |||
123 | { | ||
124 | t1_write_reg_4(tp->adapter, A_TP_INT_ENABLE, 0); | ||
125 | t1_write_reg_4(tp->adapter, A_PL_ENABLE, | ||
126 | tp_intr & ~F_PL_INTR_TP); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | void t1_tp_intr_clear(struct petp *tp) | ||
131 | { | ||
132 | t1_write_reg_4(tp->adapter, A_TP_INT_CAUSE, 0xffffffff); | ||
133 | t1_write_reg_4(tp->adapter, A_PL_CAUSE, F_PL_INTR_TP); | ||
134 | } | ||
135 | |||
136 | int t1_tp_intr_handler(struct petp *tp) | ||
137 | { | ||
138 | u32 cause; | ||
139 | |||
140 | |||
141 | cause = t1_read_reg_4(tp->adapter, A_TP_INT_CAUSE); | ||
142 | t1_write_reg_4(tp->adapter, A_TP_INT_CAUSE, cause); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable) | ||
147 | { | ||
148 | u32 val = t1_read_reg_4(tp->adapter, A_TP_GLOBAL_CONFIG); | ||
149 | |||
150 | if (enable) | ||
151 | val |= csum_bit; | ||
152 | else | ||
153 | val &= ~csum_bit; | ||
154 | t1_write_reg_4(tp->adapter, A_TP_GLOBAL_CONFIG, val); | ||
155 | } | ||
156 | |||
157 | void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable) | ||
158 | { | ||
159 | set_csum_offload(tp, F_IP_CSUM, enable); | ||
160 | } | ||
161 | |||
162 | void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable) | ||
163 | { | ||
164 | set_csum_offload(tp, F_UDP_CSUM, enable); | ||
165 | } | ||
166 | |||
167 | void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable) | ||
168 | { | ||
169 | set_csum_offload(tp, F_TCP_CSUM, enable); | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Initialize TP state. tp_params contains initial settings for some TP | ||
174 | * parameters, particularly the one-time PM and CM settings. | ||
175 | */ | ||
176 | int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk) | ||
177 | { | ||
178 | int busy = 0; | ||
179 | adapter_t *adapter = tp->adapter; | ||
180 | |||
181 | tp_init(adapter, p, tp_clk); | ||
182 | if (!busy) | ||
183 | t1_write_reg_4(adapter, A_TP_RESET, F_TP_RESET); | ||
184 | else | ||
185 | CH_ERR("%s: TP initialization timed out\n", | ||
186 | adapter->name); | ||
187 | return busy; | ||
188 | } | ||