1 /* $Date: 2006/02/07 04:21:54 $ $RCSfile: tp.c,v $ $Revision: 1.73 $ */
10 /* Pause deadlock avoidance parameters */
12 #define DROP_PKTS_CNT 1
14 static void tp_init(adapter_t * ap, const struct tp_params *p,
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;
23 val |= F_OFFLOAD_DISABLE;
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);
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);
39 * Enable pause frame deadlock prevention.
41 if (is_T2(ap) && ap->params.nports > 1) {
42 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
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);
53 void t1_tp_destroy(struct petp *tp)
58 struct petp *__devinit t1_tp_create(adapter_t * adapter, struct tp_params *p)
60 struct petp *tp = kzalloc(sizeof(*tp), GFP_KERNEL);
64 tp->adapter = adapter;
69 void t1_tp_intr_enable(struct petp *tp)
71 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
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);
81 void t1_tp_intr_disable(struct petp *tp)
83 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
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);
92 void t1_tp_intr_clear(struct petp *tp)
94 writel(0xffffffff, tp->adapter->regs + A_TP_INT_CAUSE);
95 writel(F_PL_INTR_TP, tp->adapter->regs + A_PL_CAUSE);
98 int t1_tp_intr_handler(struct petp *tp)
103 cause = readl(tp->adapter->regs + A_TP_INT_CAUSE);
104 writel(cause, tp->adapter->regs + A_TP_INT_CAUSE);
108 static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable)
110 u32 val = readl(tp->adapter->regs + A_TP_GLOBAL_CONFIG);
116 writel(val, tp->adapter->regs + A_TP_GLOBAL_CONFIG);
119 void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable)
121 set_csum_offload(tp, F_IP_CSUM, enable);
124 void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable)
126 set_csum_offload(tp, F_UDP_CSUM, enable);
129 void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable)
131 set_csum_offload(tp, F_TCP_CSUM, enable);
135 * Initialize TP state. tp_params contains initial settings for some TP
136 * parameters, particularly the one-time PM and CM settings.
138 int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
140 adapter_t *adapter = tp->adapter;
142 tp_init(adapter, p, tp_clk);
143 writel(F_TP_RESET, adapter->regs + A_TP_RESET);