1 /*****************************************************************************
5 * $Date: 2005/03/23 07:15:59 $ *
7 * Core ASIC Management. *
8 * part of the Chelsio 10Gb Ethernet Driver. *
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. *
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. *
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. *
22 * http://www.chelsio.com *
24 * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
25 * All rights reserved. *
27 * Maintainers: maintainers@chelsio.com *
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> *
38 ****************************************************************************/
48 /* Pause deadlock avoidance parameters */
50 #define DROP_PKTS_CNT 1
53 static void tp_init(adapter_t *ap, const struct tp_params *p,
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;
62 val |= F_OFFLOAD_DISABLE;
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));
77 * Enable pause frame deadlock prevention.
80 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
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));
91 void t1_tp_destroy(struct petp *tp)
96 struct petp * __devinit t1_tp_create(adapter_t *adapter, struct tp_params *p)
98 struct petp *tp = kmalloc(sizeof(*tp), GFP_KERNEL);
101 memset(tp, 0, sizeof(*tp));
102 tp->adapter = adapter;
107 void t1_tp_intr_enable(struct petp *tp)
109 u32 tp_intr = t1_read_reg_4(tp->adapter, A_PL_ENABLE);
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);
119 void t1_tp_intr_disable(struct petp *tp)
121 u32 tp_intr = t1_read_reg_4(tp->adapter, A_PL_ENABLE);
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);
130 void t1_tp_intr_clear(struct petp *tp)
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);
136 int t1_tp_intr_handler(struct petp *tp)
141 cause = t1_read_reg_4(tp->adapter, A_TP_INT_CAUSE);
142 t1_write_reg_4(tp->adapter, A_TP_INT_CAUSE, cause);
146 static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable)
148 u32 val = t1_read_reg_4(tp->adapter, A_TP_GLOBAL_CONFIG);
154 t1_write_reg_4(tp->adapter, A_TP_GLOBAL_CONFIG, val);
157 void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable)
159 set_csum_offload(tp, F_IP_CSUM, enable);
162 void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable)
164 set_csum_offload(tp, F_UDP_CSUM, enable);
167 void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable)
169 set_csum_offload(tp, F_TCP_CSUM, enable);
173 * Initialize TP state. tp_params contains initial settings for some TP
174 * parameters, particularly the one-time PM and CM settings.
176 int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
179 adapter_t *adapter = tp->adapter;
181 tp_init(adapter, p, tp_clk);
183 t1_write_reg_4(adapter, A_TP_RESET, F_TP_RESET);
185 CH_ERR("%s: TP initialization timed out\n",