aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/chelsio/tp.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2006-12-01 19:36:16 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-02 00:24:49 -0500
commitf1d3d38af75789f1b82969b83b69cab540609789 (patch)
tree47d31e8a55fb65cf33797197b92a332630cfc3ef /drivers/net/chelsio/tp.c
parent415294ecbb32ddbd0a7a2b7bae0b60fedfa09cc4 (diff)
[PATCH] chelsio: add support for other 10G boards
Add support for other versions of the 10G Chelsio boards. This is basically a port of the vendor driver with the TOE features removed. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/chelsio/tp.c')
-rw-r--r--drivers/net/chelsio/tp.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/drivers/net/chelsio/tp.c b/drivers/net/chelsio/tp.c
new file mode 100644
index 000000000000..04a7073e9d15
--- /dev/null
+++ b/drivers/net/chelsio/tp.c
@@ -0,0 +1,145 @@
1/* $Date: 2006/02/07 04:21:54 $ $RCSfile: tp.c,v $ $Revision: 1.73 $ */
2#include "common.h"
3#include "regs.h"
4#include "tp.h"
5
6struct petp {
7 adapter_t *adapter;
8};
9
10/* Pause deadlock avoidance parameters */
11#define DROP_MSEC 16
12#define DROP_PKTS_CNT 1
13
14static void tp_init(adapter_t * ap, const struct tp_params *p,
15 unsigned int tp_clk)
16{
17 if (t1_is_asic(ap)) {
18 u32 val;
19
20 val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM |
21 F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET;
22 if (!p->pm_size)
23 val |= F_OFFLOAD_DISABLE;
24 else
25 val |= F_TP_IN_ESPI_CHECK_IP_CSUM |
26 F_TP_IN_ESPI_CHECK_TCP_CSUM;
27 writel(val, ap->regs + A_TP_IN_CONFIG);
28 writel(F_TP_OUT_CSPI_CPL |
29 F_TP_OUT_ESPI_ETHERNET |
30 F_TP_OUT_ESPI_GENERATE_IP_CSUM |
31 F_TP_OUT_ESPI_GENERATE_TCP_CSUM,
32 ap->regs + A_TP_OUT_CONFIG);
33 writel(V_IP_TTL(64) |
34 F_PATH_MTU /* IP DF bit */ |
35 V_5TUPLE_LOOKUP(p->use_5tuple_mode) |
36 V_SYN_COOKIE_PARAMETER(29),
37 ap->regs + A_TP_GLOBAL_CONFIG);
38 /*
39 * Enable pause frame deadlock prevention.
40 */
41 if (is_T2(ap) && ap->params.nports > 1) {
42 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
43
44 writel(F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR |
45 V_DROP_TICKS_CNT(drop_ticks) |
46 V_NUM_PKTS_DROPPED(DROP_PKTS_CNT),
47 ap->regs + A_TP_TX_DROP_CONFIG);
48 }
49
50 }
51}
52
53void t1_tp_destroy(struct petp *tp)
54{
55 kfree(tp);
56}
57
58struct petp *__devinit t1_tp_create(adapter_t * adapter, struct tp_params *p)
59{
60 struct petp *tp = kzalloc(sizeof(*tp), GFP_KERNEL);
61 if (!tp)
62 return NULL;
63
64 tp->adapter = adapter;
65
66 return tp;
67}
68
69void t1_tp_intr_enable(struct petp *tp)
70{
71 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
72
73 {
74 /* We don't use any TP interrupts */
75 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
76 writel(tp_intr | F_PL_INTR_TP,
77 tp->adapter->regs + A_PL_ENABLE);
78 }
79}
80
81void t1_tp_intr_disable(struct petp *tp)
82{
83 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
84
85 {
86 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
87 writel(tp_intr & ~F_PL_INTR_TP,
88 tp->adapter->regs + A_PL_ENABLE);
89 }
90}
91
92void t1_tp_intr_clear(struct petp *tp)
93{
94 writel(0xffffffff, tp->adapter->regs + A_TP_INT_CAUSE);
95 writel(F_PL_INTR_TP, tp->adapter->regs + A_PL_CAUSE);
96}
97
98int t1_tp_intr_handler(struct petp *tp)
99{
100 u32 cause;
101
102
103 cause = readl(tp->adapter->regs + A_TP_INT_CAUSE);
104 writel(cause, tp->adapter->regs + A_TP_INT_CAUSE);
105 return 0;
106}
107
108static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable)
109{
110 u32 val = readl(tp->adapter->regs + A_TP_GLOBAL_CONFIG);
111
112 if (enable)
113 val |= csum_bit;
114 else
115 val &= ~csum_bit;
116 writel(val, tp->adapter->regs + A_TP_GLOBAL_CONFIG);
117}
118
119void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable)
120{
121 set_csum_offload(tp, F_IP_CSUM, enable);
122}
123
124void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable)
125{
126 set_csum_offload(tp, F_UDP_CSUM, enable);
127}
128
129void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable)
130{
131 set_csum_offload(tp, F_TCP_CSUM, enable);
132}
133
134/*
135 * Initialize TP state. tp_params contains initial settings for some TP
136 * parameters, particularly the one-time PM and CM settings.
137 */
138int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
139{
140 adapter_t *adapter = tp->adapter;
141
142 tp_init(adapter, p, tp_clk);
143 writel(F_TP_RESET, adapter->regs + A_TP_RESET);
144 return 0;
145}