View | Details | Raw Unified | Return to bug 116305
Collapse All | Expand All

(-)old/drivers/net/s2io-regs.h (-24 / +68 lines)
Lines 1-6 Link Here
1
/************************************************************************
1
/************************************************************************
2
 * regs.h: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC
2
 * regs.h: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC
3
 * Copyright 2002 Raghavendra Koushik (raghavendra.koushik@s2io.com)
3
 * Copyright(c) 2002-2005 Neterion Inc.
4
4
5
 * This software may be used and distributed according to the terms of
5
 * This software may be used and distributed according to the terms of
6
 * the GNU General Public License (GPL), incorporated herein by reference.
6
 * the GNU General Public License (GPL), incorporated herein by reference.
Lines 62-67 typedef struct _XENA_dev_config { Link Here
62
#define ADAPTER_STATUS_RMAC_REMOTE_FAULT   BIT(6)
62
#define ADAPTER_STATUS_RMAC_REMOTE_FAULT   BIT(6)
63
#define ADAPTER_STATUS_RMAC_LOCAL_FAULT    BIT(7)
63
#define ADAPTER_STATUS_RMAC_LOCAL_FAULT    BIT(7)
64
#define ADAPTER_STATUS_RMAC_PCC_IDLE       vBIT(0xFF,8,8)
64
#define ADAPTER_STATUS_RMAC_PCC_IDLE       vBIT(0xFF,8,8)
65
#define ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE  vBIT(0x0F,8,8)
65
#define ADAPTER_STATUS_RC_PRC_QUIESCENT    vBIT(0xFF,16,8)
66
#define ADAPTER_STATUS_RC_PRC_QUIESCENT    vBIT(0xFF,16,8)
66
#define ADAPTER_STATUS_MC_DRAM_READY       BIT(24)
67
#define ADAPTER_STATUS_MC_DRAM_READY       BIT(24)
67
#define ADAPTER_STATUS_MC_QUEUES_READY     BIT(25)
68
#define ADAPTER_STATUS_MC_QUEUES_READY     BIT(25)
Lines 77-97 typedef struct _XENA_dev_config { Link Here
77
#define ADAPTER_ECC_EN                     BIT(55)
78
#define ADAPTER_ECC_EN                     BIT(55)
78
79
79
	u64 serr_source;
80
	u64 serr_source;
80
#define SERR_SOURCE_PIC					BIT(0)
81
#define SERR_SOURCE_PIC			BIT(0)
81
#define SERR_SOURCE_TXDMA				BIT(1)
82
#define SERR_SOURCE_TXDMA		BIT(1)
82
#define SERR_SOURCE_RXDMA				BIT(2)
83
#define SERR_SOURCE_RXDMA		BIT(2)
83
#define SERR_SOURCE_MAC                 BIT(3)
84
#define SERR_SOURCE_MAC                 BIT(3)
84
#define SERR_SOURCE_MC                  BIT(4)
85
#define SERR_SOURCE_MC                  BIT(4)
85
#define SERR_SOURCE_XGXS                BIT(5)
86
#define SERR_SOURCE_XGXS                BIT(5)
86
#define	SERR_SOURCE_ANY					(SERR_SOURCE_PIC		| \
87
#define	SERR_SOURCE_ANY			(SERR_SOURCE_PIC	| \
87
										SERR_SOURCE_TXDMA	| \
88
					SERR_SOURCE_TXDMA	| \
88
										SERR_SOURCE_RXDMA	| \
89
					SERR_SOURCE_RXDMA	| \
89
										SERR_SOURCE_MAC		| \
90
					SERR_SOURCE_MAC		| \
90
										SERR_SOURCE_MC      | \
91
					SERR_SOURCE_MC		| \
91
										SERR_SOURCE_XGXS)
92
					SERR_SOURCE_XGXS)
93
94
	u64 pci_mode;
95
#define	GET_PCI_MODE(val)		((val & vBIT(0xF, 0, 4)) >> 60)
96
#define	PCI_MODE_PCI_33			0
97
#define	PCI_MODE_PCI_66			0x1
98
#define	PCI_MODE_PCIX_M1_66		0x2
99
#define	PCI_MODE_PCIX_M1_100		0x3
100
#define	PCI_MODE_PCIX_M1_133		0x4
101
#define	PCI_MODE_PCIX_M2_66		0x5
102
#define	PCI_MODE_PCIX_M2_100		0x6
103
#define	PCI_MODE_PCIX_M2_133		0x7
104
#define	PCI_MODE_UNSUPPORTED		BIT(0)
105
#define	PCI_MODE_32_BITS		BIT(8)
106
#define	PCI_MODE_UNKNOWN_MODE		BIT(9)
92
107
93
108
	u8 unused_0[0x800 - 0x128];
94
	u8 unused_0[0x800 - 0x120];
95
109
96
/* PCI-X Controller registers */
110
/* PCI-X Controller registers */
97
	u64 pic_int_status;
111
	u64 pic_int_status;
Lines 153-159 typedef struct _XENA_dev_config { Link Here
153
	u8 unused4[0x08];
167
	u8 unused4[0x08];
154
168
155
	u64 gpio_int_reg;
169
	u64 gpio_int_reg;
170
#define GPIO_INT_REG_LINK_DOWN                 BIT(1)
171
#define GPIO_INT_REG_LINK_UP                   BIT(2)
156
	u64 gpio_int_mask;
172
	u64 gpio_int_mask;
173
#define GPIO_INT_MASK_LINK_DOWN                BIT(1)
174
#define GPIO_INT_MASK_LINK_UP                  BIT(2)
157
	u64 gpio_alarms;
175
	u64 gpio_alarms;
158
176
159
	u8 unused5[0x38];
177
	u8 unused5[0x38];
Lines 223-241 typedef struct _XENA_dev_config { Link Here
223
	u64 xmsi_data;
241
	u64 xmsi_data;
224
242
225
	u64 rx_mat;
243
	u64 rx_mat;
244
#define RX_MAT_SET(ring, msi)			vBIT(msi, (8 * ring), 8)
226
245
227
	u8 unused6[0x8];
246
	u8 unused6[0x8];
228
247
229
	u64 tx_mat0_7;
248
	u64 tx_mat0_n[0x8];
230
	u64 tx_mat8_15;
249
#define TX_MAT_SET(fifo, msi)			vBIT(msi, (8 * fifo), 8)
231
	u64 tx_mat16_23;
232
	u64 tx_mat24_31;
233
	u64 tx_mat32_39;
234
	u64 tx_mat40_47;
235
	u64 tx_mat48_55;
236
	u64 tx_mat56_63;
237
250
238
	u8 unused_1[0x10];
251
	u8 unused_1[0x8];
252
	u64 stat_byte_cnt;
253
#define STAT_BC(n)                              vBIT(n,4,12)
239
254
240
	/* Automated statistics collection */
255
	/* Automated statistics collection */
241
	u64 stat_cfg;
256
	u64 stat_cfg;
Lines 246-251 typedef struct _XENA_dev_config { Link Here
246
#define STAT_TRSF_PER(n)           TBD
261
#define STAT_TRSF_PER(n)           TBD
247
#define	PER_SEC					   0x208d5
262
#define	PER_SEC					   0x208d5
248
#define	SET_UPDT_PERIOD(n)		   vBIT((PER_SEC*n),32,32)
263
#define	SET_UPDT_PERIOD(n)		   vBIT((PER_SEC*n),32,32)
264
#define	SET_UPDT_CLICKS(val)		   vBIT(val, 32, 32)
249
265
250
	u64 stat_addr;
266
	u64 stat_addr;
251
267
Lines 267-274 typedef struct _XENA_dev_config { Link Here
267
283
268
	u64 gpio_control;
284
	u64 gpio_control;
269
#define GPIO_CTRL_GPIO_0		BIT(8)
285
#define GPIO_CTRL_GPIO_0		BIT(8)
286
	u64 misc_control;
287
#define MISC_LINK_STABILITY_PRD(val)   vBIT(val,29,3)
288
289
	u8 unused7_1[0x240 - 0x208];
290
291
	u64 wreq_split_mask;
292
#define	WREQ_SPLIT_MASK_SET_MASK(val)	vBIT(val, 52, 12)
270
293
271
	u8 unused7[0x600];
294
	u8 unused7_2[0x800 - 0x248];
272
295
273
/* TxDMA registers */
296
/* TxDMA registers */
274
	u64 txdma_int_status;
297
	u64 txdma_int_status;
Lines 290-295 typedef struct _XENA_dev_config { Link Here
290
313
291
	u64 pcc_err_reg;
314
	u64 pcc_err_reg;
292
#define PCC_FB_ECC_DB_ERR		vBIT(0xFF, 16, 8)
315
#define PCC_FB_ECC_DB_ERR		vBIT(0xFF, 16, 8)
316
#define PCC_ENABLE_FOUR			vBIT(0x0F,0,8)
293
317
294
	u64 pcc_err_mask;
318
	u64 pcc_err_mask;
295
	u64 pcc_err_alarm;
319
	u64 pcc_err_alarm;
Lines 468-473 typedef struct _XENA_dev_config { Link Here
468
#define PRC_CTRL_NO_SNOOP                      (BIT(22)|BIT(23))
492
#define PRC_CTRL_NO_SNOOP                      (BIT(22)|BIT(23))
469
#define PRC_CTRL_NO_SNOOP_DESC                 BIT(22)
493
#define PRC_CTRL_NO_SNOOP_DESC                 BIT(22)
470
#define PRC_CTRL_NO_SNOOP_BUFF                 BIT(23)
494
#define PRC_CTRL_NO_SNOOP_BUFF                 BIT(23)
495
#define PRC_CTRL_BIMODAL_INTERRUPT             BIT(37)
471
#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val)     vBIT(val,40,24)
496
#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val)     vBIT(val,40,24)
472
497
473
	u64 prc_alarm_action;
498
	u64 prc_alarm_action;
Lines 688-696 typedef struct _XENA_dev_config { Link Here
688
	u64 mc_err_reg;
713
	u64 mc_err_reg;
689
#define MC_ERR_REG_ECC_DB_ERR_L            BIT(14)
714
#define MC_ERR_REG_ECC_DB_ERR_L            BIT(14)
690
#define MC_ERR_REG_ECC_DB_ERR_U            BIT(15)
715
#define MC_ERR_REG_ECC_DB_ERR_U            BIT(15)
716
#define MC_ERR_REG_MIRI_ECC_DB_ERR_0       BIT(18)
717
#define MC_ERR_REG_MIRI_ECC_DB_ERR_1       BIT(20)
691
#define MC_ERR_REG_MIRI_CRI_ERR_0          BIT(22)
718
#define MC_ERR_REG_MIRI_CRI_ERR_0          BIT(22)
692
#define MC_ERR_REG_MIRI_CRI_ERR_1          BIT(23)
719
#define MC_ERR_REG_MIRI_CRI_ERR_1          BIT(23)
693
#define MC_ERR_REG_SM_ERR                  BIT(31)
720
#define MC_ERR_REG_SM_ERR                  BIT(31)
721
#define MC_ERR_REG_ECC_ALL_SNG		   (BIT(2) | BIT(3) | BIT(4) | BIT(5) |\
722
					    BIT(6) | BIT(7) | BIT(17) | BIT(19))
723
#define MC_ERR_REG_ECC_ALL_DBL		   (BIT(10) | BIT(11) | BIT(12) |\
724
					    BIT(13) | BIT(14) | BIT(15) |\
725
					    BIT(18) | BIT(20))
694
	u64 mc_err_mask;
726
	u64 mc_err_mask;
695
	u64 mc_err_alarm;
727
	u64 mc_err_alarm;
696
728
Lines 736-742 typedef struct _XENA_dev_config { Link Here
736
	u64 mc_rldram_test_d1;
768
	u64 mc_rldram_test_d1;
737
	u8 unused24[0x300 - 0x288];
769
	u8 unused24[0x300 - 0x288];
738
	u64 mc_rldram_test_d2;
770
	u64 mc_rldram_test_d2;
739
	u8 unused25[0x700 - 0x308];
771
772
	u8 unused24_1[0x360 - 0x308];
773
	u64 mc_rldram_ctrl;
774
#define	MC_RLDRAM_ENABLE_ODT		BIT(7)
775
776
	u8 unused24_2[0x640 - 0x368];
777
	u64 mc_rldram_ref_per_herc;
778
#define	MC_RLDRAM_SET_REF_PERIOD(val)	vBIT(val, 0, 16)
779
780
	u8 unused24_3[0x660 - 0x648];
781
	u64 mc_rldram_mrs_herc;
782
783
	u8 unused25[0x700 - 0x668];
740
	u64 mc_debug_ctrl;
784
	u64 mc_debug_ctrl;
741
785
742
	u8 unused26[0x3000 - 0x2f08];
786
	u8 unused26[0x3000 - 0x2f08];
(-)old/drivers/net/s2io.c (-2351 / +2313 lines)
Lines 1-6 Link Here
1
/************************************************************************
1
/************************************************************************
2
 * s2io.c: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC
2
 * s2io.c: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC
3
 * Copyright(c) 2002-2005 S2IO Technologies
3
 * Copyright(c) 2002-2005 Neterion Inc.
4
4
5
 * This software may be used and distributed according to the terms of
5
 * This software may be used and distributed according to the terms of
6
 * the GNU General Public License (GPL), incorporated herein by reference.
6
 * the GNU General Public License (GPL), incorporated herein by reference.
Lines 11-98 Link Here
11
 * See the file COPYING in this distribution for more information.
11
 * See the file COPYING in this distribution for more information.
12
 *
12
 *
13
 * Credits:
13
 * Credits:
14
 * Jeff Garzik		: For pointing out the improper error condition 
14
 * Jeff Garzik		: For pointing out the improper error condition
15
 *			  check in the s2io_xmit routine and also some 
15
 *			  check in the s2io_xmit routine and also some
16
 * 			  issues in the Tx watch dog function. Also for
16
 *			  issues in the Tx watch dog function. Also for
17
 *			  patiently answering all those innumerable 
17
 *			  patiently answering all those innumerable
18
 *			  questions regaring the 2.6 porting issues.
18
 *			  questions regaring the 2.6 porting issues.
19
 * Stephen Hemminger	: Providing proper 2.6 porting mechanism for some
19
 * Stephen Hemminger	: Providing proper 2.6 porting mechanism for some
20
 *			  macros available only in 2.6 Kernel.
20
 *			  macros available only in 2.6 Kernel.
21
 * Francois Romieu	: For pointing out all code part that were 
21
 * Francois Romieu	: For pointing out all code part that were
22
 *			  deprecated and also styling related comments.
22
 *			  deprecated and also styling related comments.
23
 * Grant Grundler	: For helping me get rid of some Architecture 
23
 * Grant Grundler	: For helping me get rid of some Architecture
24
 *			  dependent code.
24
 *			  dependent code.
25
 * Christopher Hellwig	: Some more 2.6 specific issues in the driver.
25
 * Christopher Hellwig	: Some more 2.6 specific issues in the driver.
26
 *			  	
26
 *
27
 * The module loadable parameters that are supported by the driver and a brief
27
 * The module loadable parameters that are supported by the driver and a brief
28
 * explaination of all the variables.
28
 * explaination of all the variables.
29
 * ring_num : This can be used to program the number of receive rings used 
29
 * rx_ring_num : This can be used to program the number of receive rings used
30
 * in the driver.  					
30
 * in the driver.
31
 * frame_len: This is an array of size 8. Using this we can set the maximum 
31
 * rx_ring_sz: This defines the number of descriptors each ring can have. This
32
 * size of the received frame that can be steered into the corrsponding 
33
 * receive ring.
34
 * ring_len: This defines the number of descriptors each ring can have. This 
35
 * is also an array of size 8.
32
 * is also an array of size 8.
36
 * fifo_num: This defines the number of Tx FIFOs thats used int the driver.
33
 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
37
 * fifo_len: This too is an array of 8. Each element defines the number of 
34
 * tx_fifo_len: This too is an array of 8. Each element defines the number of
38
 * Tx descriptors that can be associated with each corresponding FIFO.
35
 * Tx descriptors that can be associated with each corresponding FIFO.
39
 * latency_timer: This input is programmed into the Latency timer register
40
 * in PCI Configuration space.
41
 ************************************************************************/
36
 ************************************************************************/
42
37
43
#include<linux/config.h>
38
#include <linux/config.h>
44
#include<linux/module.h>
39
#include <linux/module.h>
45
#include<linux/types.h>
40
#include <linux/types.h>
46
#include<linux/errno.h>
41
#include <linux/errno.h>
47
#include<linux/ioport.h>
42
#include <linux/ioport.h>
48
#include<linux/pci.h>
43
#include <linux/pci.h>
49
#include<linux/kernel.h>
44
#include <linux/dma-mapping.h>
50
#include<linux/netdevice.h>
45
#include <linux/kernel.h>
51
#include<linux/etherdevice.h>
46
#include <linux/netdevice.h>
52
#include<linux/skbuff.h>
47
#include <linux/etherdevice.h>
53
#include<linux/init.h>
48
#include <linux/skbuff.h>
54
#include<linux/delay.h>
49
#include <linux/init.h>
55
#include<linux/stddef.h>
50
#include <linux/delay.h>
56
#include<linux/ioctl.h>
51
#include <linux/stddef.h>
57
#include<linux/timex.h>
52
#include <linux/ioctl.h>
58
#include<linux/sched.h>
53
#include <linux/timex.h>
59
#include<linux/ethtool.h>
54
#include <linux/sched.h>
60
#include<asm/system.h>
55
#include <linux/ethtool.h>
61
#include<asm/uaccess.h>
56
#include <linux/version.h>
62
#include<linux/version.h>
57
#include <linux/workqueue.h>
63
#include<asm/io.h>
58
#include <linux/if_vlan.h>
64
#include<linux/proc_fs.h>
59
#include <linux/moduleparam.h>
65
#include<linux/workqueue.h>
60
61
#include <asm/system.h>
62
#include <asm/uaccess.h>
63
#include <asm/io.h>
66
64
67
/* local include */
65
/* local include */
68
#include "s2io.h"
66
#include "s2io.h"
69
#include "s2io-regs.h"
67
#include "s2io-regs.h"
70
68
71
/* S2io Driver name & version. */
69
/* S2io Driver name & version. */
72
static char s2io_driver_name[] = "s2io";
70
static char s2io_driver_name[] = "Neterion";
73
static char s2io_driver_version[] = "Version 1.7.5.1";
71
static char s2io_driver_version[] = "Version 2.0.8.1";
72
73
static inline int RXD_IS_UP2DT(RxD_t *rxdp)
74
{
75
	int ret;
76
77
	ret = ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
78
		(GET_RXD_MARKER(rxdp->Control_2) != THE_RXD_MARK));
79
80
	return ret;
81
}
74
82
75
/* 
83
/*
76
 * Cards with following subsystem_id have a link state indication
84
 * Cards with following subsystem_id have a link state indication
77
 * problem, 600B, 600C, 600D, 640B, 640C and 640D.
85
 * problem, 600B, 600C, 600D, 640B, 640C and 640D.
78
 * macro below identifies these cards given the subsystem_id.
86
 * macro below identifies these cards given the subsystem_id.
79
 */
87
 */
80
#define CARDS_WITH_FAULTY_LINK_INDICATORS(subid) \
88
#define CARDS_WITH_FAULTY_LINK_INDICATORS(dev_type, subid) \
81
		(((subid >= 0x600B) && (subid <= 0x600D)) || \
89
	(dev_type == XFRAME_I_DEVICE) ?			\
82
		 ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0
90
		((((subid >= 0x600B) && (subid <= 0x600D)) || \
91
		 ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0) : 0
83
92
84
#define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \
93
#define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \
85
				      ADAPTER_STATUS_RMAC_LOCAL_FAULT)))
94
				      ADAPTER_STATUS_RMAC_LOCAL_FAULT)))
86
#define TASKLET_IN_USE test_and_set_bit(0, \
95
#define TASKLET_IN_USE test_and_set_bit(0, (&sp->tasklet_status))
87
				(unsigned long *)(&sp->tasklet_status))
88
#define PANIC	1
96
#define PANIC	1
89
#define LOW	2
97
#define LOW	2
90
static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring)
98
static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring)
91
{
99
{
92
	int level = 0;
100
	int level = 0;
93
	if ((sp->pkt_cnt[ring] - rxb_size) > 16) {
101
	mac_info_t *mac_control;
102
103
	mac_control = &sp->mac_control;
104
	if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16) {
94
		level = LOW;
105
		level = LOW;
95
		if ((sp->pkt_cnt[ring] - rxb_size) < MAX_RXDS_PER_BLOCK) {
106
		if (rxb_size <= MAX_RXDS_PER_BLOCK) {
96
			level = PANIC;
107
			level = PANIC;
97
		}
108
		}
98
	}
109
	}
Lines 149-154 static char ethtool_stats_keys[][ETH_GST Link Here
149
	{"rmac_pause_cnt"},
160
	{"rmac_pause_cnt"},
150
	{"rmac_accepted_ip"},
161
	{"rmac_accepted_ip"},
151
	{"rmac_err_tcp"},
162
	{"rmac_err_tcp"},
163
	{"\n DRIVER STATISTICS"},
164
	{"single_bit_ecc_errs"},
165
	{"double_bit_ecc_errs"},
152
};
166
};
153
167
154
#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN
168
#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN
Lines 157-172 static char ethtool_stats_keys[][ETH_GST Link Here
157
#define S2IO_TEST_LEN	sizeof(s2io_gstrings) / ETH_GSTRING_LEN
171
#define S2IO_TEST_LEN	sizeof(s2io_gstrings) / ETH_GSTRING_LEN
158
#define S2IO_STRINGS_LEN	S2IO_TEST_LEN * ETH_GSTRING_LEN
172
#define S2IO_STRINGS_LEN	S2IO_TEST_LEN * ETH_GSTRING_LEN
159
173
174
#define S2IO_TIMER_CONF(timer, handle, arg, exp)		\
175
			init_timer(&timer);			\
176
			timer.function = handle;		\
177
			timer.data = (unsigned long) arg;	\
178
			mod_timer(&timer, (jiffies + exp))	\
179
180
/* Add the vlan */
181
static void s2io_vlan_rx_register(struct net_device *dev,
182
					struct vlan_group *grp)
183
{
184
	nic_t *nic = dev->priv;
185
	unsigned long flags;
186
187
	spin_lock_irqsave(&nic->tx_lock, flags);
188
	nic->vlgrp = grp;
189
	spin_unlock_irqrestore(&nic->tx_lock, flags);
190
}
191
192
/* Unregister the vlan */
193
static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
194
{
195
	nic_t *nic = dev->priv;
196
	unsigned long flags;
197
198
	spin_lock_irqsave(&nic->tx_lock, flags);
199
	if (nic->vlgrp)
200
		nic->vlgrp->vlan_devices[vid] = NULL;
201
	spin_unlock_irqrestore(&nic->tx_lock, flags);
202
}
160
203
161
/* 
204
/*
162
 * Constants to be programmed into the Xena's registers to configure
205
 * Constants to be programmed into the Xena's registers, to configure
163
 * the XAUI.
206
 * the XAUI.
164
 */
207
 */
165
208
166
#define SWITCH_SIGN	0xA5A5A5A5A5A5A5A5ULL
209
#define SWITCH_SIGN	0xA5A5A5A5A5A5A5A5ULL
167
#define	END_SIGN	0x0
210
#define	END_SIGN	0x0
168
211
169
static u64 default_mdio_cfg[] = {
212
static u64 herc_act_dtx_cfg[] = {
213
	/* Set address */
214
	0x8000051536750000ULL, 0x80000515367500E0ULL,
215
	/* Write data */
216
	0x8000051536750004ULL, 0x80000515367500E4ULL,
217
	/* Set address */
218
	0x80010515003F0000ULL, 0x80010515003F00E0ULL,
219
	/* Write data */
220
	0x80010515003F0004ULL, 0x80010515003F00E4ULL,
221
	/* Set address */
222
	0x801205150D440000ULL, 0x801205150D4400E0ULL,
223
	/* Write data */
224
	0x801205150D440004ULL, 0x801205150D4400E4ULL,
225
	/* Set address */
226
	0x80020515F2100000ULL, 0x80020515F21000E0ULL,
227
	/* Write data */
228
	0x80020515F2100004ULL, 0x80020515F21000E4ULL,
229
	/* Done */
230
	END_SIGN
231
};
232
233
static u64 xena_mdio_cfg[] = {
170
	/* Reset PMA PLL */
234
	/* Reset PMA PLL */
171
	0xC001010000000000ULL, 0xC0010100000000E0ULL,
235
	0xC001010000000000ULL, 0xC0010100000000E0ULL,
172
	0xC0010100008000E4ULL,
236
	0xC0010100008000E4ULL,
Lines 176-182 static u64 default_mdio_cfg[] = { Link Here
176
	END_SIGN
240
	END_SIGN
177
};
241
};
178
242
179
static u64 default_dtx_cfg[] = {
243
static u64 xena_dtx_cfg[] = {
180
	0x8000051500000000ULL, 0x80000515000000E0ULL,
244
	0x8000051500000000ULL, 0x80000515000000E0ULL,
181
	0x80000515D93500E4ULL, 0x8001051500000000ULL,
245
	0x80000515D93500E4ULL, 0x8001051500000000ULL,
182
	0x80010515000000E0ULL, 0x80010515001E00E4ULL,
246
	0x80010515000000E0ULL, 0x80010515001E00E4ULL,
Lines 200-207 static u64 default_dtx_cfg[] = { Link Here
200
	END_SIGN
264
	END_SIGN
201
};
265
};
202
266
203
267
/*
204
/* 
205
 * Constants for Fixing the MacAddress problem seen mostly on
268
 * Constants for Fixing the MacAddress problem seen mostly on
206
 * Alpha machines.
269
 * Alpha machines.
207
 */
270
 */
Lines 224-319 static u64 fix_mac[] = { Link Here
224
};
287
};
225
288
226
/* Module Loadable parameters. */
289
/* Module Loadable parameters. */
227
static u32 frame_len[MAX_RX_RINGS];
290
static unsigned int tx_fifo_num = 1;
228
static u32 rx_prio;
291
static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
229
static u32 tx_prio;
292
    {[0 ...(MAX_TX_FIFOS - 1)] = 0 };
230
293
static unsigned int rx_ring_num = 1;
231
static unsigned int lso_enable = 1;
294
static unsigned int rx_ring_sz[MAX_RX_RINGS] =
232
#ifndef CONFIG_S2IO_NAPI
295
    {[0 ...(MAX_RX_RINGS - 1)] = 0 };
233
static unsigned int indicate_max_pkts = 0;
296
static unsigned int rts_frm_len[MAX_RX_RINGS] =
234
#endif
297
    {[0 ...(MAX_RX_RINGS - 1)] = 0 };
235
static unsigned int cksum_offload_enable = 1;
298
static unsigned int use_continuous_tx_intrs = 1;
236
static unsigned int TxFifoNum = 1;
237
static unsigned int TxFIFOLen_0 = DEFAULT_FIFO_LEN;
238
static unsigned int TxFIFOLen_1 = 0;
239
static unsigned int TxFIFOLen_2 = 0;
240
static unsigned int TxFIFOLen_3 = 0;
241
static unsigned int TxFIFOLen_4 = 0;
242
static unsigned int TxFIFOLen_5 = 0;
243
static unsigned int TxFIFOLen_6 = 0;
244
static unsigned int TxFIFOLen_7 = 0;
245
static unsigned int MaxTxDs = MAX_SKB_FRAGS;
246
static unsigned int RxRingNum = 1;
247
static unsigned int RxRingSz_0 = SMALL_BLK_CNT;
248
static unsigned int RxRingSz_1 = 0;
249
static unsigned int RxRingSz_2 = 0;
250
static unsigned int RxRingSz_3 = 0;
251
static unsigned int RxRingSz_4 = 0;
252
static unsigned int RxRingSz_5 = 0;
253
static unsigned int RxRingSz_6 = 0;
254
static unsigned int RxRingSz_7 = 0;
255
static unsigned int Stats_refresh_time = 4;
256
static unsigned int rmac_pause_time = 65535;
299
static unsigned int rmac_pause_time = 65535;
257
static unsigned int mc_pause_threshold_q0q3 = 187;
300
static unsigned int mc_pause_threshold_q0q3 = 187;
258
static unsigned int mc_pause_threshold_q4q7 = 187;
301
static unsigned int mc_pause_threshold_q4q7 = 187;
259
static unsigned int shared_splits = 0;
302
static unsigned int shared_splits;
260
#if defined(__ia64__)
261
static unsigned int max_splits_trans = XENA_THREE_SPLIT_TRANSACTION;
262
#else
263
static unsigned int max_splits_trans = XENA_TWO_SPLIT_TRANSACTION;
264
#endif
265
static unsigned int tmac_util_period = 5;
303
static unsigned int tmac_util_period = 5;
266
static unsigned int rmac_util_period = 5;
304
static unsigned int rmac_util_period = 5;
267
static unsigned int tx_timer_val = 0xFFF;
305
static unsigned int bimodal = 0;
268
static unsigned int tx_utilz_periodic = 1;
306
#ifndef CONFIG_S2IO_NAPI
269
static unsigned int rx_timer_val = 0xFFF;
307
static unsigned int indicate_max_pkts;
270
static unsigned int rx_utilz_periodic = 1;
308
#endif
271
static unsigned int tx_urange_a = 0xA;
309
/* Frequency of Rx desc syncs expressed as power of 2 */
272
static unsigned int tx_ufc_a = 0x10;
310
static unsigned int rxsync_frequency = 3;
273
static unsigned int tx_urange_b = 0x10;
274
static unsigned int tx_ufc_b = 0x20;
275
static unsigned int tx_urange_c = 0x30;
276
static unsigned int tx_ufc_c = 0x40;
277
static unsigned int tx_ufc_d = 0x80;
278
static unsigned int rx_urange_a = 0xA;
279
static unsigned int rx_ufc_a = 0x1;
280
static unsigned int rx_urange_b = 0x10;
281
static unsigned int rx_ufc_b = 0x2;
282
static unsigned int rx_urange_c = 0x30;
283
static unsigned int rx_ufc_c = 0x40;
284
static unsigned int rx_ufc_d = 0x80;
285
static u8 latency_timer = 0xf8;
286
static u8 max_read_byte_cnt = 2;
287
311
288
/* 
312
/*
289
 * S2IO device table.
313
 * S2IO device table.
290
 * This table lists all the devices that this driver supports. 
314
 * This table lists all the devices that this driver supports.
291
 */
315
 */
292
static struct pci_device_id s2io_tbl[] __devinitdata = {
316
static struct pci_device_id s2io_tbl[] __devinitdata = {
293
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN,
317
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN,
294
	 PCI_ANY_ID, PCI_ANY_ID},
318
	 PCI_ANY_ID, PCI_ANY_ID},
295
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI,
319
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI,
296
	 PCI_ANY_ID, PCI_ANY_ID},
320
	 PCI_ANY_ID, PCI_ANY_ID},
321
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_WIN,
322
         PCI_ANY_ID, PCI_ANY_ID},
323
        {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_UNI,
324
         PCI_ANY_ID, PCI_ANY_ID},
297
	{0,}
325
	{0,}
298
};
326
};
299
327
300
MODULE_DEVICE_TABLE(pci, s2io_tbl);
328
MODULE_DEVICE_TABLE(pci, s2io_tbl);
301
329
302
static struct pci_driver s2io_driver = {
330
static struct pci_driver s2io_driver = {
303
	name:"S2IO",
331
      .name = "S2IO",
304
	id_table:s2io_tbl,
332
      .id_table = s2io_tbl,
305
	probe:s2io_init_nic,
333
      .probe = s2io_init_nic,
306
	remove:__devexit_p(s2io_rem_nic),
334
      .remove = __devexit_p(s2io_rem_nic),
307
};
335
};
308
336
309
/* A simplifier macro used both by init and free shared_mem Fns(). */
337
/* A simplifier macro used both by init and free shared_mem Fns(). */
310
#define container_index(len, per_each) ((len+per_each - 1) / per_each)
338
#define TXD_MEM_PAGE_CNT(len, per_each) ((len+per_each - 1) / per_each)
311
339
312
/**
340
/**
313
 * init_shared_mem - Allocation and Initialization of Memory
341
 * init_shared_mem - Allocation and Initialization of Memory
314
 * @nic: Device private variable.
342
 * @nic: Device private variable.
315
 * Description: The function allocates the all memory areas shared 
343
 * Description: The function allocates all the memory areas shared
316
 * between the NIC and the driver. This includes Tx descriptors, 
344
 * between the NIC and the driver. This includes Tx descriptors,
317
 * Rx descriptors and the statistics block.
345
 * Rx descriptors and the statistics block.
318
 */
346
 */
319
347
Lines 323-329 static int init_shared_mem(struct s2io_n Link Here
323
	void *tmp_v_addr, *tmp_v_addr_next;
351
	void *tmp_v_addr, *tmp_v_addr_next;
324
	dma_addr_t tmp_p_addr, tmp_p_addr_next;
352
	dma_addr_t tmp_p_addr, tmp_p_addr_next;
325
	RxD_block_t *pre_rxd_blk = NULL;
353
	RxD_block_t *pre_rxd_blk = NULL;
326
	int i, j, blk_cnt;
354
	int i, j, blk_cnt, rx_sz, tx_sz;
327
	int lst_size, lst_per_page;
355
	int lst_size, lst_per_page;
328
	struct net_device *dev = nic->dev;
356
	struct net_device *dev = nic->dev;
329
#ifdef CONFIG_2BUFF_MODE
357
#ifdef CONFIG_2BUFF_MODE
Lines 340-379 static int init_shared_mem(struct s2io_n Link Here
340
368
341
	/* Allocation and initialization of TXDLs in FIOFs */
369
	/* Allocation and initialization of TXDLs in FIOFs */
342
	size = 0;
370
	size = 0;
343
	for (i = 0; i < config->TxFIFONum; i++) {
371
	for (i = 0; i < config->tx_fifo_num; i++) {
344
		size += config->tx_cfg[i].FifoLen;
372
		size += config->tx_cfg[i].fifo_len;
345
	}
373
	}
346
	if (size > MAX_AVAILABLE_TXDS) {
374
	if (size > MAX_AVAILABLE_TXDS) {
347
		DBG_PRINT(ERR_DBG, "%s: Total number of Tx FIFOs ",
375
		DBG_PRINT(ERR_DBG, "%s: Requested TxDs too high, ",
348
			  dev->name);
376
			  __FUNCTION__);
349
		DBG_PRINT(ERR_DBG, "exceeds the maximum value ");
377
		DBG_PRINT(ERR_DBG, "Requested: %d, max supported: 8192\n", size);
350
		DBG_PRINT(ERR_DBG, "that can be used\n");
351
		return FAILURE;
378
		return FAILURE;
352
	}
379
	}
353
380
354
	lst_size = (sizeof(TxD_t) * config->MaxTxDs);
381
	lst_size = (sizeof(TxD_t) * config->max_txds);
382
	tx_sz = lst_size * size;
355
	lst_per_page = PAGE_SIZE / lst_size;
383
	lst_per_page = PAGE_SIZE / lst_size;
356
384
357
	for (i = 0; i < config->TxFIFONum; i++) {
385
	for (i = 0; i < config->tx_fifo_num; i++) {
358
		int fifo_len = config->tx_cfg[i].FifoLen;
386
		int fifo_len = config->tx_cfg[i].fifo_len;
359
		int list_holder_size = fifo_len * sizeof(list_info_hold_t);
387
		int list_holder_size = fifo_len * sizeof(list_info_hold_t);
360
		nic->list_info[i] = kmalloc(list_holder_size, GFP_KERNEL);
388
		mac_control->fifos[i].list_info = kmalloc(list_holder_size,
361
		if (!nic->list_info[i]) {
389
							  GFP_KERNEL);
390
		if (!mac_control->fifos[i].list_info) {
362
			DBG_PRINT(ERR_DBG,
391
			DBG_PRINT(ERR_DBG,
363
				  "Malloc failed for list_info\n");
392
				  "Malloc failed for list_info\n");
364
			return -ENOMEM;
393
			return -ENOMEM;
365
		}
394
		}
366
		memset(nic->list_info[i], 0, list_holder_size);
395
		memset(mac_control->fifos[i].list_info, 0, list_holder_size);
367
	}
396
	}
368
	for (i = 0; i < config->TxFIFONum; i++) {
397
	for (i = 0; i < config->tx_fifo_num; i++) {
369
		int page_num = container_index(config->tx_cfg[i].FifoLen,
398
		int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
370
					       lst_per_page);
399
						lst_per_page);
371
		mac_control->tx_curr_put_info[i].offset = 0;
400
		mac_control->fifos[i].tx_curr_put_info.offset = 0;
372
		mac_control->tx_curr_put_info[i].fifo_len =
401
		mac_control->fifos[i].tx_curr_put_info.fifo_len =
373
		    config->tx_cfg[i].FifoLen - 1;
402
		    config->tx_cfg[i].fifo_len - 1;
374
		mac_control->tx_curr_get_info[i].offset = 0;
403
		mac_control->fifos[i].tx_curr_get_info.offset = 0;
375
		mac_control->tx_curr_get_info[i].fifo_len =
404
		mac_control->fifos[i].tx_curr_get_info.fifo_len =
376
		    config->tx_cfg[i].FifoLen - 1;
405
		    config->tx_cfg[i].fifo_len - 1;
406
		mac_control->fifos[i].fifo_no = i;
407
		mac_control->fifos[i].nic = nic;
408
		mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 1;
409
377
		for (j = 0; j < page_num; j++) {
410
		for (j = 0; j < page_num; j++) {
378
			int k = 0;
411
			int k = 0;
379
			dma_addr_t tmp_p;
412
			dma_addr_t tmp_p;
Lines 386-435 static int init_shared_mem(struct s2io_n Link Here
386
				DBG_PRINT(ERR_DBG, "failed for TxDL\n");
419
				DBG_PRINT(ERR_DBG, "failed for TxDL\n");
387
				return -ENOMEM;
420
				return -ENOMEM;
388
			}
421
			}
422
			/* If we got a zero DMA address(can happen on
423
			 * certain platforms like PPC), reallocate.
424
			 * Store virtual address of page we don't want,
425
			 * to be freed later.
426
			 */
427
			if (!tmp_p) {
428
				mac_control->zerodma_virt_addr = tmp_v;
429
				DBG_PRINT(INIT_DBG, 
430
				"%s: Zero DMA address for TxDL. ", dev->name);
431
				DBG_PRINT(INIT_DBG, 
432
				"Virtual address %llx\n", (u64)tmp_v);
433
				tmp_v = pci_alloc_consistent(nic->pdev,
434
						     PAGE_SIZE, &tmp_p);
435
				if (!tmp_v) {
436
					DBG_PRINT(ERR_DBG,
437
					  "pci_alloc_consistent ");
438
					DBG_PRINT(ERR_DBG, "failed for TxDL\n");
439
					return -ENOMEM;
440
				}
441
			}
389
			while (k < lst_per_page) {
442
			while (k < lst_per_page) {
390
				int l = (j * lst_per_page) + k;
443
				int l = (j * lst_per_page) + k;
391
				if (l == config->tx_cfg[i].FifoLen)
444
				if (l == config->tx_cfg[i].fifo_len)
392
					goto end_txd_alloc;
445
					break;
393
				nic->list_info[i][l].list_virt_addr =
446
				mac_control->fifos[i].list_info[l].list_virt_addr =
394
				    tmp_v + (k * lst_size);
447
				    tmp_v + (k * lst_size);
395
				nic->list_info[i][l].list_phy_addr =
448
				mac_control->fifos[i].list_info[l].list_phy_addr =
396
				    tmp_p + (k * lst_size);
449
				    tmp_p + (k * lst_size);
397
				k++;
450
				k++;
398
			}
451
			}
399
		}
452
		}
400
	}
453
	}
401
      end_txd_alloc:
402
454
403
	/* Allocation and initialization of RXDs in Rings */
455
	/* Allocation and initialization of RXDs in Rings */
404
	size = 0;
456
	size = 0;
405
	for (i = 0; i < config->RxRingNum; i++) {
457
	for (i = 0; i < config->rx_ring_num; i++) {
406
		if (config->rx_cfg[i].NumRxd % (MAX_RXDS_PER_BLOCK + 1)) {
458
		if (config->rx_cfg[i].num_rxd % (MAX_RXDS_PER_BLOCK + 1)) {
407
			DBG_PRINT(ERR_DBG, "%s: RxD count of ", dev->name);
459
			DBG_PRINT(ERR_DBG, "%s: RxD count of ", dev->name);
408
			DBG_PRINT(ERR_DBG, "Ring%d is not a multiple of ",
460
			DBG_PRINT(ERR_DBG, "Ring%d is not a multiple of ",
409
				  i);
461
				  i);
410
			DBG_PRINT(ERR_DBG, "RxDs per Block");
462
			DBG_PRINT(ERR_DBG, "RxDs per Block");
411
			return FAILURE;
463
			return FAILURE;
412
		}
464
		}
413
		size += config->rx_cfg[i].NumRxd;
465
		size += config->rx_cfg[i].num_rxd;
414
		nic->block_count[i] =
466
		mac_control->rings[i].block_count =
415
		    config->rx_cfg[i].NumRxd / (MAX_RXDS_PER_BLOCK + 1);
467
		    config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
416
		nic->pkt_cnt[i] =
468
		mac_control->rings[i].pkt_cnt =
417
		    config->rx_cfg[i].NumRxd - nic->block_count[i];
469
		    config->rx_cfg[i].num_rxd - mac_control->rings[i].block_count;
418
	}
470
	}
419
	size = (size * (sizeof(RxD_t)));
471
	size = (size * (sizeof(RxD_t)));
420
	mac_control->rxd_ring_mem_sz = size;
472
	rx_sz = size;
473
474
	for (i = 0; i < config->rx_ring_num; i++) {
475
		mac_control->rings[i].rx_curr_get_info.block_index = 0;
476
		mac_control->rings[i].rx_curr_get_info.offset = 0;
477
		mac_control->rings[i].rx_curr_get_info.ring_len =
478
		    config->rx_cfg[i].num_rxd - 1;
479
		mac_control->rings[i].rx_curr_put_info.block_index = 0;
480
		mac_control->rings[i].rx_curr_put_info.offset = 0;
481
		mac_control->rings[i].rx_curr_put_info.ring_len =
482
		    config->rx_cfg[i].num_rxd - 1;
483
		mac_control->rings[i].nic = nic;
484
		mac_control->rings[i].ring_no = i;
421
485
422
	for (i = 0; i < config->RxRingNum; i++) {
423
		mac_control->rx_curr_get_info[i].block_index = 0;
424
		mac_control->rx_curr_get_info[i].offset = 0;
425
		mac_control->rx_curr_get_info[i].ring_len =
426
		    config->rx_cfg[i].NumRxd - 1;
427
		mac_control->rx_curr_put_info[i].block_index = 0;
428
		mac_control->rx_curr_put_info[i].offset = 0;
429
		mac_control->rx_curr_put_info[i].ring_len =
430
		    config->rx_cfg[i].NumRxd - 1;
431
		blk_cnt =
486
		blk_cnt =
432
		    config->rx_cfg[i].NumRxd / (MAX_RXDS_PER_BLOCK + 1);
487
		    config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
433
		/*  Allocating all the Rx blocks */
488
		/*  Allocating all the Rx blocks */
434
		for (j = 0; j < blk_cnt; j++) {
489
		for (j = 0; j < blk_cnt; j++) {
435
#ifndef CONFIG_2BUFF_MODE
490
#ifndef CONFIG_2BUFF_MODE
Lines 441-472 static int init_shared_mem(struct s2io_n Link Here
441
							  &tmp_p_addr);
496
							  &tmp_p_addr);
442
			if (tmp_v_addr == NULL) {
497
			if (tmp_v_addr == NULL) {
443
				/*
498
				/*
444
				 * In case of failure, free_shared_mem() 
499
				 * In case of failure, free_shared_mem()
445
				 * is called, which should free any 
500
				 * is called, which should free any
446
				 * memory that was alloced till the 
501
				 * memory that was alloced till the
447
				 * failure happened.
502
				 * failure happened.
448
				 */
503
				 */
449
				nic->rx_blocks[i][j].block_virt_addr =
504
				mac_control->rings[i].rx_blocks[j].block_virt_addr =
450
				    tmp_v_addr;
505
				    tmp_v_addr;
451
				return -ENOMEM;
506
				return -ENOMEM;
452
			}
507
			}
453
			memset(tmp_v_addr, 0, size);
508
			memset(tmp_v_addr, 0, size);
454
			nic->rx_blocks[i][j].block_virt_addr = tmp_v_addr;
509
			mac_control->rings[i].rx_blocks[j].block_virt_addr =
455
			nic->rx_blocks[i][j].block_dma_addr = tmp_p_addr;
510
				tmp_v_addr;
511
			mac_control->rings[i].rx_blocks[j].block_dma_addr =
512
				tmp_p_addr;
456
		}
513
		}
457
		/* Interlinking all Rx Blocks */
514
		/* Interlinking all Rx Blocks */
458
		for (j = 0; j < blk_cnt; j++) {
515
		for (j = 0; j < blk_cnt; j++) {
459
			tmp_v_addr = nic->rx_blocks[i][j].block_virt_addr;
516
			tmp_v_addr =
517
				mac_control->rings[i].rx_blocks[j].block_virt_addr;
460
			tmp_v_addr_next =
518
			tmp_v_addr_next =
461
			    nic->rx_blocks[i][(j + 1) %
519
				mac_control->rings[i].rx_blocks[(j + 1) %
462
					      blk_cnt].block_virt_addr;
520
					      blk_cnt].block_virt_addr;
463
			tmp_p_addr = nic->rx_blocks[i][j].block_dma_addr;
521
			tmp_p_addr =
522
				mac_control->rings[i].rx_blocks[j].block_dma_addr;
464
			tmp_p_addr_next =
523
			tmp_p_addr_next =
465
			    nic->rx_blocks[i][(j + 1) %
524
				mac_control->rings[i].rx_blocks[(j + 1) %
466
					      blk_cnt].block_dma_addr;
525
					      blk_cnt].block_dma_addr;
467
526
468
			pre_rxd_blk = (RxD_block_t *) tmp_v_addr;
527
			pre_rxd_blk = (RxD_block_t *) tmp_v_addr;
469
			pre_rxd_blk->reserved_1 = END_OF_BLOCK;	/* last RxD 
528
			pre_rxd_blk->reserved_1 = END_OF_BLOCK;	/* last RxD
470
								 * marker.
529
								 * marker.
471
								 */
530
								 */
472
#ifndef	CONFIG_2BUFF_MODE
531
#ifndef	CONFIG_2BUFF_MODE
Lines 479-507 static int init_shared_mem(struct s2io_n Link Here
479
	}
538
	}
480
539
481
#ifdef CONFIG_2BUFF_MODE
540
#ifdef CONFIG_2BUFF_MODE
482
	/* 
541
	/*
483
	 * Allocation of Storages for buffer addresses in 2BUFF mode
542
	 * Allocation of Storages for buffer addresses in 2BUFF mode
484
	 * and the buffers as well.
543
	 * and the buffers as well.
485
	 */
544
	 */
486
	for (i = 0; i < config->RxRingNum; i++) {
545
	for (i = 0; i < config->rx_ring_num; i++) {
487
		blk_cnt =
546
		blk_cnt =
488
		    config->rx_cfg[i].NumRxd / (MAX_RXDS_PER_BLOCK + 1);
547
		    config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
489
		nic->ba[i] = kmalloc((sizeof(buffAdd_t *) * blk_cnt),
548
		mac_control->rings[i].ba = kmalloc((sizeof(buffAdd_t *) * blk_cnt),
490
				     GFP_KERNEL);
549
				     GFP_KERNEL);
491
		if (!nic->ba[i])
550
		if (!mac_control->rings[i].ba)
492
			return -ENOMEM;
551
			return -ENOMEM;
493
		for (j = 0; j < blk_cnt; j++) {
552
		for (j = 0; j < blk_cnt; j++) {
494
			int k = 0;
553
			int k = 0;
495
			nic->ba[i][j] = kmalloc((sizeof(buffAdd_t) *
554
			mac_control->rings[i].ba[j] = kmalloc((sizeof(buffAdd_t) *
496
						 (MAX_RXDS_PER_BLOCK + 1)),
555
						 (MAX_RXDS_PER_BLOCK + 1)),
497
						GFP_KERNEL);
556
						GFP_KERNEL);
498
			if (!nic->ba[i][j])
557
			if (!mac_control->rings[i].ba[j])
499
				return -ENOMEM;
558
				return -ENOMEM;
500
			while (k != MAX_RXDS_PER_BLOCK) {
559
			while (k != MAX_RXDS_PER_BLOCK) {
501
				ba = &nic->ba[i][j][k];
560
				ba = &mac_control->rings[i].ba[j][k];
502
561
503
				ba->ba_0_org = (void *) kmalloc
562
				ba->ba_0_org = (void *) kmalloc
504
				    (BUF0_LEN + ALIGN_SIZE, GFP_ATOMIC);
563
				    (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL);
505
				if (!ba->ba_0_org)
564
				if (!ba->ba_0_org)
506
					return -ENOMEM;
565
					return -ENOMEM;
507
				tmp = (u64) ba->ba_0_org;
566
				tmp = (u64) ba->ba_0_org;
Lines 510-516 static int init_shared_mem(struct s2io_n Link Here
510
				ba->ba_0 = (void *) tmp;
569
				ba->ba_0 = (void *) tmp;
511
570
512
				ba->ba_1_org = (void *) kmalloc
571
				ba->ba_1_org = (void *) kmalloc
513
				    (BUF1_LEN + ALIGN_SIZE, GFP_ATOMIC);
572
				    (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL);
514
				if (!ba->ba_1_org)
573
				if (!ba->ba_1_org)
515
					return -ENOMEM;
574
					return -ENOMEM;
516
				tmp = (u64) ba->ba_1_org;
575
				tmp = (u64) ba->ba_1_org;
Lines 529-537 static int init_shared_mem(struct s2io_n Link Here
529
	    (nic->pdev, size, &mac_control->stats_mem_phy);
588
	    (nic->pdev, size, &mac_control->stats_mem_phy);
530
589
531
	if (!mac_control->stats_mem) {
590
	if (!mac_control->stats_mem) {
532
		/* 
591
		/*
533
		 * In case of failure, free_shared_mem() is called, which 
592
		 * In case of failure, free_shared_mem() is called, which
534
		 * should free any memory that was alloced till the 
593
		 * should free any memory that was alloced till the
535
		 * failure happened.
594
		 * failure happened.
536
		 */
595
		 */
537
		return -ENOMEM;
596
		return -ENOMEM;
Lines 541-559 static int init_shared_mem(struct s2io_n Link Here
541
	tmp_v_addr = mac_control->stats_mem;
600
	tmp_v_addr = mac_control->stats_mem;
542
	mac_control->stats_info = (StatInfo_t *) tmp_v_addr;
601
	mac_control->stats_info = (StatInfo_t *) tmp_v_addr;
543
	memset(tmp_v_addr, 0, size);
602
	memset(tmp_v_addr, 0, size);
544
#ifdef SNMP_SUPPORT
545
	nic->nMemorySize = mac_control->txd_list_mem_sz +
546
	    mac_control->stats_mem_sz + mac_control->rxd_ring_mem_sz;
547
#endif
548
549
	DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name,
603
	DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name,
550
		  (unsigned long long) tmp_p_addr);
604
		  (unsigned long long) tmp_p_addr);
551
605
552
	return SUCCESS;
606
	return SUCCESS;
553
}
607
}
554
608
555
/**  
609
/**
556
 * free_shared_mem - Free the allocated Memory 
610
 * free_shared_mem - Free the allocated Memory
557
 * @nic:  Device private variable.
611
 * @nic:  Device private variable.
558
 * Description: This function is to free all memory locations allocated by
612
 * Description: This function is to free all memory locations allocated by
559
 * the init_shared_mem() function and return it to the kernel.
613
 * the init_shared_mem() function and return it to the kernel.
Lines 567-573 static void free_shared_mem(struct s2io_ Link Here
567
	mac_info_t *mac_control;
621
	mac_info_t *mac_control;
568
	struct config_param *config;
622
	struct config_param *config;
569
	int lst_size, lst_per_page;
623
	int lst_size, lst_per_page;
570
624
	struct net_device *dev = nic->dev;
571
625
572
	if (!nic)
626
	if (!nic)
573
		return;
627
		return;
Lines 575-597 static void free_shared_mem(struct s2io_ Link Here
575
	mac_control = &nic->mac_control;
629
	mac_control = &nic->mac_control;
576
	config = &nic->config;
630
	config = &nic->config;
577
631
578
	lst_size = (sizeof(TxD_t) * config->MaxTxDs);
632
	lst_size = (sizeof(TxD_t) * config->max_txds);
579
	lst_per_page = PAGE_SIZE / lst_size;
633
	lst_per_page = PAGE_SIZE / lst_size;
580
634
581
	for (i = 0; i < config->TxFIFONum; i++) {
635
	for (i = 0; i < config->tx_fifo_num; i++) {
582
		int page_num = container_index(config->tx_cfg[i].FifoLen,
636
		int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
583
					       lst_per_page);
637
						lst_per_page);
584
		for (j = 0; j < page_num; j++) {
638
		for (j = 0; j < page_num; j++) {
585
			int mem_blks = (j * lst_per_page);
639
			int mem_blks = (j * lst_per_page);
586
			if (!nic->list_info[i][mem_blks].list_virt_addr)
640
			if (!mac_control->fifos[i].list_info)
641
				return;	
642
			if (!mac_control->fifos[i].list_info[mem_blks].
643
				 list_virt_addr)
587
				break;
644
				break;
588
			pci_free_consistent(nic->pdev, PAGE_SIZE,
645
			pci_free_consistent(nic->pdev, PAGE_SIZE,
589
					    nic->list_info[i][mem_blks].
646
					    mac_control->fifos[i].
647
					    list_info[mem_blks].
590
					    list_virt_addr,
648
					    list_virt_addr,
591
					    nic->list_info[i][mem_blks].
649
					    mac_control->fifos[i].
650
					    list_info[mem_blks].
592
					    list_phy_addr);
651
					    list_phy_addr);
593
		}
652
		}
594
		kfree(nic->list_info[i]);
653
		/* If we got a zero DMA address during allocation,
654
		 * free the page now
655
		 */
656
		if (mac_control->zerodma_virt_addr) {
657
			pci_free_consistent(nic->pdev, PAGE_SIZE,
658
					    mac_control->zerodma_virt_addr,
659
					    (dma_addr_t)0);
660
			DBG_PRINT(INIT_DBG, 
661
			"%s: Freeing TxDL with zero DMA addr. ", dev->name);
662
			DBG_PRINT(INIT_DBG, "Virtual address %llx\n",
663
			(u64)(mac_control->zerodma_virt_addr));
664
		}
665
		kfree(mac_control->fifos[i].list_info);
595
	}
666
	}
596
667
597
#ifndef CONFIG_2BUFF_MODE
668
#ifndef CONFIG_2BUFF_MODE
Lines 599-609 static void free_shared_mem(struct s2io_ Link Here
599
#else
670
#else
600
	size = SIZE_OF_BLOCK;
671
	size = SIZE_OF_BLOCK;
601
#endif
672
#endif
602
	for (i = 0; i < config->RxRingNum; i++) {
673
	for (i = 0; i < config->rx_ring_num; i++) {
603
		blk_cnt = nic->block_count[i];
674
		blk_cnt = mac_control->rings[i].block_count;
604
		for (j = 0; j < blk_cnt; j++) {
675
		for (j = 0; j < blk_cnt; j++) {
605
			tmp_v_addr = nic->rx_blocks[i][j].block_virt_addr;
676
			tmp_v_addr = mac_control->rings[i].rx_blocks[j].
606
			tmp_p_addr = nic->rx_blocks[i][j].block_dma_addr;
677
				block_virt_addr;
678
			tmp_p_addr = mac_control->rings[i].rx_blocks[j].
679
				block_dma_addr;
607
			if (tmp_v_addr == NULL)
680
			if (tmp_v_addr == NULL)
608
				break;
681
				break;
609
			pci_free_consistent(nic->pdev, size,
682
			pci_free_consistent(nic->pdev, size,
Lines 613-635 static void free_shared_mem(struct s2io_ Link Here
613
686
614
#ifdef CONFIG_2BUFF_MODE
687
#ifdef CONFIG_2BUFF_MODE
615
	/* Freeing buffer storage addresses in 2BUFF mode. */
688
	/* Freeing buffer storage addresses in 2BUFF mode. */
616
	for (i = 0; i < config->RxRingNum; i++) {
689
	for (i = 0; i < config->rx_ring_num; i++) {
617
		blk_cnt =
690
		blk_cnt =
618
		    config->rx_cfg[i].NumRxd / (MAX_RXDS_PER_BLOCK + 1);
691
		    config->rx_cfg[i].num_rxd / (MAX_RXDS_PER_BLOCK + 1);
619
		for (j = 0; j < blk_cnt; j++) {
692
		for (j = 0; j < blk_cnt; j++) {
620
			int k = 0;
693
			int k = 0;
621
			if (!nic->ba[i][j])
694
			if (!mac_control->rings[i].ba[j])
622
				continue;
695
				continue;
623
			while (k != MAX_RXDS_PER_BLOCK) {
696
			while (k != MAX_RXDS_PER_BLOCK) {
624
				buffAdd_t *ba = &nic->ba[i][j][k];
697
				buffAdd_t *ba = &mac_control->rings[i].ba[j][k];
625
				kfree(ba->ba_0_org);
698
				kfree(ba->ba_0_org);
626
				kfree(ba->ba_1_org);
699
				kfree(ba->ba_1_org);
627
				k++;
700
				k++;
628
			}
701
			}
629
			kfree(nic->ba[i][j]);
702
			kfree(mac_control->rings[i].ba[j]);
630
		}
703
		}
631
		if (nic->ba[i])
704
		if (mac_control->rings[i].ba)
632
			kfree(nic->ba[i]);
705
			kfree(mac_control->rings[i].ba);
633
	}
706
	}
634
#endif
707
#endif
635
708
Lines 641-750 static void free_shared_mem(struct s2io_ Link Here
641
	}
714
	}
642
}
715
}
643
716
644
/**  
717
/**
645
 *  init_nic - Initialization of hardware 
718
 * s2io_verify_pci_mode -
719
 */
720
721
static int s2io_verify_pci_mode(nic_t *nic)
722
{
723
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
724
	register u64 val64 = 0;
725
	int     mode;
726
727
	val64 = readq(&bar0->pci_mode);
728
	mode = (u8)GET_PCI_MODE(val64);
729
730
	if ( val64 & PCI_MODE_UNKNOWN_MODE)
731
		return -1;      /* Unknown PCI mode */
732
	return mode;
733
}
734
735
736
/**
737
 * s2io_print_pci_mode -
738
 */
739
static int s2io_print_pci_mode(nic_t *nic)
740
{
741
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
742
	register u64 val64 = 0;
743
	int	mode;
744
	struct config_param *config = &nic->config;
745
746
	val64 = readq(&bar0->pci_mode);
747
	mode = (u8)GET_PCI_MODE(val64);
748
749
	if ( val64 & PCI_MODE_UNKNOWN_MODE)
750
		return -1;	/* Unknown PCI mode */
751
752
	if (val64 & PCI_MODE_32_BITS) {
753
		DBG_PRINT(ERR_DBG, "%s: Device is on 32 bit ", nic->dev->name);
754
	} else {
755
		DBG_PRINT(ERR_DBG, "%s: Device is on 64 bit ", nic->dev->name);
756
	}
757
758
	switch(mode) {
759
		case PCI_MODE_PCI_33:
760
			DBG_PRINT(ERR_DBG, "33MHz PCI bus\n");
761
			config->bus_speed = 33;
762
			break;
763
		case PCI_MODE_PCI_66:
764
			DBG_PRINT(ERR_DBG, "66MHz PCI bus\n");
765
			config->bus_speed = 133;
766
			break;
767
		case PCI_MODE_PCIX_M1_66:
768
			DBG_PRINT(ERR_DBG, "66MHz PCIX(M1) bus\n");
769
			config->bus_speed = 133; /* Herc doubles the clock rate */
770
			break;
771
		case PCI_MODE_PCIX_M1_100:
772
			DBG_PRINT(ERR_DBG, "100MHz PCIX(M1) bus\n");
773
			config->bus_speed = 200;
774
			break;
775
		case PCI_MODE_PCIX_M1_133:
776
			DBG_PRINT(ERR_DBG, "133MHz PCIX(M1) bus\n");
777
			config->bus_speed = 266;
778
			break;
779
		case PCI_MODE_PCIX_M2_66:
780
			DBG_PRINT(ERR_DBG, "133MHz PCIX(M2) bus\n");
781
			config->bus_speed = 133;
782
			break;
783
		case PCI_MODE_PCIX_M2_100:
784
			DBG_PRINT(ERR_DBG, "200MHz PCIX(M2) bus\n");
785
			config->bus_speed = 200;
786
			break;
787
		case PCI_MODE_PCIX_M2_133:
788
			DBG_PRINT(ERR_DBG, "266MHz PCIX(M2) bus\n");
789
			config->bus_speed = 266;
790
			break;
791
		default:
792
			return -1;	/* Unsupported bus speed */
793
	}
794
795
	return mode;
796
}
797
798
/**
799
 *  init_nic - Initialization of hardware
646
 *  @nic: device peivate variable
800
 *  @nic: device peivate variable
647
 *  Description: The function sequentially configures every block 
801
 *  Description: The function sequentially configures every block
648
 *  of the H/W from their reset values. 
802
 *  of the H/W from their reset values.
649
 *  Returns:  SUCCESS on success and 
803
 *  Return Value:  SUCCESS on success and
650
 *  '-1' on failure (endian settings incorrect).
804
 *  '-1' on failure (endian settings incorrect).
651
 */
805
 */
652
806
653
static int init_nic(struct s2io_nic *nic)
807
static int init_nic(struct s2io_nic *nic)
654
{
808
{
655
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
809
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
656
	struct net_device *dev = nic->dev;
810
	struct net_device *dev = nic->dev;
657
	register u64 val64 = 0;
811
	register u64 val64 = 0;
658
	void *add;
812
	void __iomem *add;
659
	u32 time;
813
	u32 time;
660
	int i, j;
814
	int i, j;
661
	mac_info_t *mac_control;
815
	mac_info_t *mac_control;
662
	struct config_param *config;
816
	struct config_param *config;
663
	int mdio_cnt = 0, dtx_cnt = 0;
817
	int mdio_cnt = 0, dtx_cnt = 0;
664
	unsigned long long print_var, mem_share;
818
	unsigned long long mem_share;
819
	int mem_size;
665
820
666
	mac_control = &nic->mac_control;
821
	mac_control = &nic->mac_control;
667
	config = &nic->config;
822
	config = &nic->config;
668
823
669
	/* 
824
	/* to set the swapper controle on the card */
670
	 * Set proper endian settings and verify the same by 
825
	if(s2io_set_swapper(nic)) {
671
	 * reading the PIF Feed-back register.
826
		DBG_PRINT(ERR_DBG,"ERROR: Setting Swapper failed\n");
672
	 */
827
		return -1;
673
#ifdef  __BIG_ENDIAN
828
	}
674
	/*
675
	 * The device by default set to a big endian format, so 
676
	 * a big endian driver need not set anything.
677
	 */
678
	writeq(0xffffffffffffffffULL, &bar0->swapper_ctrl);
679
	val64 = (SWAPPER_CTRL_PIF_R_FE |
680
		 SWAPPER_CTRL_PIF_R_SE |
681
		 SWAPPER_CTRL_PIF_W_FE |
682
		 SWAPPER_CTRL_PIF_W_SE |
683
		 SWAPPER_CTRL_TXP_FE |
684
		 SWAPPER_CTRL_TXP_SE |
685
		 SWAPPER_CTRL_TXD_R_FE |
686
		 SWAPPER_CTRL_TXD_W_FE |
687
		 SWAPPER_CTRL_TXF_R_FE |
688
		 SWAPPER_CTRL_RXD_R_FE |
689
		 SWAPPER_CTRL_RXD_W_FE |
690
		 SWAPPER_CTRL_RXF_W_FE |
691
		 SWAPPER_CTRL_XMSI_FE |
692
		 SWAPPER_CTRL_XMSI_SE |
693
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
694
	writeq(val64, &bar0->swapper_ctrl);
695
#else
696
	/* 
697
	 * Initially we enable all bits to make it accessible by 
698
	 * the driver, then we selectively enable only those bits 
699
	 * that we want to set.
700
	 */
701
	writeq(0xffffffffffffffffULL, &bar0->swapper_ctrl);
702
	val64 = (SWAPPER_CTRL_PIF_R_FE |
703
		 SWAPPER_CTRL_PIF_R_SE |
704
		 SWAPPER_CTRL_PIF_W_FE |
705
		 SWAPPER_CTRL_PIF_W_SE |
706
		 SWAPPER_CTRL_TXP_FE |
707
		 SWAPPER_CTRL_TXP_SE |
708
		 SWAPPER_CTRL_TXD_R_FE |
709
		 SWAPPER_CTRL_TXD_R_SE |
710
		 SWAPPER_CTRL_TXD_W_FE |
711
		 SWAPPER_CTRL_TXD_W_SE |
712
		 SWAPPER_CTRL_TXF_R_FE |
713
		 SWAPPER_CTRL_RXD_R_FE |
714
		 SWAPPER_CTRL_RXD_R_SE |
715
		 SWAPPER_CTRL_RXD_W_FE |
716
		 SWAPPER_CTRL_RXD_W_SE |
717
		 SWAPPER_CTRL_RXF_W_FE |
718
		 SWAPPER_CTRL_XMSI_FE |
719
		 SWAPPER_CTRL_XMSI_SE |
720
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
721
	writeq(val64, &bar0->swapper_ctrl);
722
#endif
723
829
724
	/* 
830
	/*
725
	 * Verifying if endian settings are accurate by 
831
	 * Herc requires EOI to be removed from reset before XGXS, so..
726
	 * reading a feedback register.
727
	 */
832
	 */
728
	val64 = readq(&bar0->pif_rd_swapper_fb);
833
	if (nic->device_type & XFRAME_II_DEVICE) {
729
	if (val64 != 0x0123456789ABCDEFULL) {
834
		val64 = 0xA500000000ULL;
730
		/* Endian settings are incorrect, calls for another dekko. */
835
		writeq(val64, &bar0->sw_reset);
731
		print_var = (unsigned long long) val64;
836
		msleep(500);
732
		DBG_PRINT(INIT_DBG, "%s: Endian settings are wrong",
837
		val64 = readq(&bar0->sw_reset);
733
			  dev->name);
734
		DBG_PRINT(ERR_DBG, ", feedback read %llx\n", print_var);
735
736
		return FAILURE;
737
	}
838
	}
738
839
739
	/* Remove XGXS from reset state */
840
	/* Remove XGXS from reset state */
740
	val64 = 0;
841
	val64 = 0;
741
	writeq(val64, &bar0->sw_reset);
842
	writeq(val64, &bar0->sw_reset);
843
	msleep(500);
742
	val64 = readq(&bar0->sw_reset);
844
	val64 = readq(&bar0->sw_reset);
743
	set_current_state(TASK_UNINTERRUPTIBLE);
744
	schedule_timeout(HZ / 2);
745
845
746
	/*  Enable Receiving broadcasts */
846
	/*  Enable Receiving broadcasts */
747
	add = (void *) &bar0->mac_cfg;
847
	add = &bar0->mac_cfg;
748
	val64 = readq(&bar0->mac_cfg);
848
	val64 = readq(&bar0->mac_cfg);
749
	val64 |= MAC_RMAC_BCAST_ENABLE;
849
	val64 |= MAC_RMAC_BCAST_ENABLE;
750
	writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key);
850
	writeq(RMAC_CFG_KEY(0x4C0D), &bar0->rmac_cfg_key);
Lines 761-808 static int init_nic(struct s2io_nic *nic Link Here
761
	val64 = dev->mtu;
861
	val64 = dev->mtu;
762
	writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
862
	writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
763
863
764
	/* 
864
	/*
765
	 * Configuring the XAUI Interface of Xena. 
865
	 * Configuring the XAUI Interface of Xena.
766
	 * ***************************************
866
	 * ***************************************
767
	 * To Configure the Xena's XAUI, one has to write a series 
867
	 * To Configure the Xena's XAUI, one has to write a series
768
	 * of 64 bit values into two registers in a particular 
868
	 * of 64 bit values into two registers in a particular
769
	 * sequence. Hence a macro 'SWITCH_SIGN' has been defined 
869
	 * sequence. Hence a macro 'SWITCH_SIGN' has been defined
770
	 * which will be defined in the array of configuration values 
870
	 * which will be defined in the array of configuration values
771
	 * (default_dtx_cfg & default_mdio_cfg) at appropriate places 
871
	 * (xena_dtx_cfg & xena_mdio_cfg) at appropriate places
772
	 * to switch writing from one regsiter to another. We continue 
872
	 * to switch writing from one regsiter to another. We continue
773
	 * writing these values until we encounter the 'END_SIGN' macro.
873
	 * writing these values until we encounter the 'END_SIGN' macro.
774
	 * For example, After making a series of 21 writes into 
874
	 * For example, After making a series of 21 writes into
775
	 * dtx_control register the 'SWITCH_SIGN' appears and hence we 
875
	 * dtx_control register the 'SWITCH_SIGN' appears and hence we
776
	 * start writing into mdio_control until we encounter END_SIGN.
876
	 * start writing into mdio_control until we encounter END_SIGN.
777
	 */
877
	 */
778
	while (1) {
878
	if (nic->device_type & XFRAME_II_DEVICE) {
779
	      dtx_cfg:
879
		while (herc_act_dtx_cfg[dtx_cnt] != END_SIGN) {
780
		while (default_dtx_cfg[dtx_cnt] != END_SIGN) {
880
			SPECIAL_REG_WRITE(herc_act_dtx_cfg[dtx_cnt],
781
			if (default_dtx_cfg[dtx_cnt] == SWITCH_SIGN) {
782
				dtx_cnt++;
783
				goto mdio_cfg;
784
			}
785
			SPECIAL_REG_WRITE(default_dtx_cfg[dtx_cnt],
786
					  &bar0->dtx_control, UF);
881
					  &bar0->dtx_control, UF);
787
			val64 = readq(&bar0->dtx_control);
882
			if (dtx_cnt & 0x1)
883
				msleep(1); /* Necessary!! */
788
			dtx_cnt++;
884
			dtx_cnt++;
789
		}
885
		}
790
	      mdio_cfg:
886
	} else {
791
		while (default_mdio_cfg[mdio_cnt] != END_SIGN) {
887
		while (1) {
792
			if (default_mdio_cfg[mdio_cnt] == SWITCH_SIGN) {
888
		      dtx_cfg:
889
			while (xena_dtx_cfg[dtx_cnt] != END_SIGN) {
890
				if (xena_dtx_cfg[dtx_cnt] == SWITCH_SIGN) {
891
					dtx_cnt++;
892
					goto mdio_cfg;
893
				}
894
				SPECIAL_REG_WRITE(xena_dtx_cfg[dtx_cnt],
895
						  &bar0->dtx_control, UF);
896
				val64 = readq(&bar0->dtx_control);
897
				dtx_cnt++;
898
			}
899
		      mdio_cfg:
900
			while (xena_mdio_cfg[mdio_cnt] != END_SIGN) {
901
				if (xena_mdio_cfg[mdio_cnt] == SWITCH_SIGN) {
902
					mdio_cnt++;
903
					goto dtx_cfg;
904
				}
905
				SPECIAL_REG_WRITE(xena_mdio_cfg[mdio_cnt],
906
						  &bar0->mdio_control, UF);
907
				val64 = readq(&bar0->mdio_control);
793
				mdio_cnt++;
908
				mdio_cnt++;
909
			}
910
			if ((xena_dtx_cfg[dtx_cnt] == END_SIGN) &&
911
			    (xena_mdio_cfg[mdio_cnt] == END_SIGN)) {
912
				break;
913
			} else {
794
				goto dtx_cfg;
914
				goto dtx_cfg;
795
			}
915
			}
796
			SPECIAL_REG_WRITE(default_mdio_cfg[mdio_cnt],
797
					  &bar0->mdio_control, UF);
798
			val64 = readq(&bar0->mdio_control);
799
			mdio_cnt++;
800
		}
801
		if ((default_dtx_cfg[dtx_cnt] == END_SIGN) &&
802
		    (default_mdio_cfg[mdio_cnt] == END_SIGN)) {
803
			break;
804
		} else {
805
			goto dtx_cfg;
806
		}
916
		}
807
	}
917
	}
808
918
Lines 814-826 static int init_nic(struct s2io_nic *nic Link Here
814
	writeq(val64, &bar0->tx_fifo_partition_3);
924
	writeq(val64, &bar0->tx_fifo_partition_3);
815
925
816
926
817
	for (i = 0, j = 0; i < config->TxFIFONum; i++) {
927
	for (i = 0, j = 0; i < config->tx_fifo_num; i++) {
818
		val64 |=
928
		val64 |=
819
		    vBIT(config->tx_cfg[i].FifoLen - 1, ((i * 32) + 19),
929
		    vBIT(config->tx_cfg[i].fifo_len - 1, ((i * 32) + 19),
820
			 13) | vBIT(config->tx_cfg[i].FifoPriority,
930
			 13) | vBIT(config->tx_cfg[i].fifo_priority,
821
				    ((i * 32) + 5), 3);
931
				    ((i * 32) + 5), 3);
822
932
823
		if (i == (config->TxFIFONum - 1)) {
933
		if (i == (config->tx_fifo_num - 1)) {
824
			if (i % 2 == 0)
934
			if (i % 2 == 0)
825
				i++;
935
				i++;
826
		}
936
		}
Lines 849-860 static int init_nic(struct s2io_nic *nic Link Here
849
	val64 |= BIT(0);	/* To enable the FIFO partition. */
959
	val64 |= BIT(0);	/* To enable the FIFO partition. */
850
	writeq(val64, &bar0->tx_fifo_partition_0);
960
	writeq(val64, &bar0->tx_fifo_partition_0);
851
961
962
	/*
963
	 * Disable 4 PCCs for Xena1, 2 and 3 as per H/W bug
964
	 * SXE-008 TRANSMIT DMA ARBITRATION ISSUE.
965
	 */
966
	if ((nic->device_type == XFRAME_I_DEVICE) &&
967
		(get_xena_rev_id(nic->pdev) < 4))
968
		writeq(PCC_ENABLE_FOUR, &bar0->pcc_enable);
969
852
	val64 = readq(&bar0->tx_fifo_partition_0);
970
	val64 = readq(&bar0->tx_fifo_partition_0);
853
	DBG_PRINT(INIT_DBG, "Fifo partition at: 0x%p is: 0x%llx\n",
971
	DBG_PRINT(INIT_DBG, "Fifo partition at: 0x%p is: 0x%llx\n",
854
		  &bar0->tx_fifo_partition_0, (unsigned long long) val64);
972
		  &bar0->tx_fifo_partition_0, (unsigned long long) val64);
855
973
856
	/* 
974
	/*
857
	 * Initialization of Tx_PA_CONFIG register to ignore packet 
975
	 * Initialization of Tx_PA_CONFIG register to ignore packet
858
	 * integrity checking.
976
	 * integrity checking.
859
	 */
977
	 */
860
	val64 = readq(&bar0->tx_pa_cfg);
978
	val64 = readq(&bar0->tx_pa_cfg);
Lines 864-963 static int init_nic(struct s2io_nic *nic Link Here
864
982
865
	/* Rx DMA intialization. */
983
	/* Rx DMA intialization. */
866
	val64 = 0;
984
	val64 = 0;
867
	for (i = 0; i < config->RxRingNum; i++) {
985
	for (i = 0; i < config->rx_ring_num; i++) {
868
		val64 |=
986
		val64 |=
869
		    vBIT(config->rx_cfg[i].RingPriority, (5 + (i * 8)), 3);
987
		    vBIT(config->rx_cfg[i].ring_priority, (5 + (i * 8)),
988
			 3);
870
	}
989
	}
871
	writeq(val64, &bar0->rx_queue_priority);
990
	writeq(val64, &bar0->rx_queue_priority);
872
991
873
	/* 
992
	/*
874
	 * Allocating equal share of memory to all the 
993
	 * Allocating equal share of memory to all the
875
	 * configured Rings.
994
	 * configured Rings.
876
	 */
995
	 */
877
	val64 = 0;
996
	val64 = 0;
878
	for (i = 0; i < config->RxRingNum; i++) {
997
	if (nic->device_type & XFRAME_II_DEVICE)
998
		mem_size = 32;
999
	else
1000
		mem_size = 64;
1001
1002
	for (i = 0; i < config->rx_ring_num; i++) {
879
		switch (i) {
1003
		switch (i) {
880
		case 0:
1004
		case 0:
881
			mem_share = (64 / config->RxRingNum +
1005
			mem_share = (mem_size / config->rx_ring_num +
882
				     64 % config->RxRingNum);
1006
				     mem_size % config->rx_ring_num);
883
			val64 |= RX_QUEUE_CFG_Q0_SZ(mem_share);
1007
			val64 |= RX_QUEUE_CFG_Q0_SZ(mem_share);
884
			continue;
1008
			continue;
885
		case 1:
1009
		case 1:
886
			mem_share = (64 / config->RxRingNum);
1010
			mem_share = (mem_size / config->rx_ring_num);
887
			val64 |= RX_QUEUE_CFG_Q1_SZ(mem_share);
1011
			val64 |= RX_QUEUE_CFG_Q1_SZ(mem_share);
888
			continue;
1012
			continue;
889
		case 2:
1013
		case 2:
890
			mem_share = (64 / config->RxRingNum);
1014
			mem_share = (mem_size / config->rx_ring_num);
891
			val64 |= RX_QUEUE_CFG_Q2_SZ(mem_share);
1015
			val64 |= RX_QUEUE_CFG_Q2_SZ(mem_share);
892
			continue;
1016
			continue;
893
		case 3:
1017
		case 3:
894
			mem_share = (64 / config->RxRingNum);
1018
			mem_share = (mem_size / config->rx_ring_num);
895
			val64 |= RX_QUEUE_CFG_Q3_SZ(mem_share);
1019
			val64 |= RX_QUEUE_CFG_Q3_SZ(mem_share);
896
			continue;
1020
			continue;
897
		case 4:
1021
		case 4:
898
			mem_share = (64 / config->RxRingNum);
1022
			mem_share = (mem_size / config->rx_ring_num);
899
			val64 |= RX_QUEUE_CFG_Q4_SZ(mem_share);
1023
			val64 |= RX_QUEUE_CFG_Q4_SZ(mem_share);
900
			continue;
1024
			continue;
901
		case 5:
1025
		case 5:
902
			mem_share = (64 / config->RxRingNum);
1026
			mem_share = (mem_size / config->rx_ring_num);
903
			val64 |= RX_QUEUE_CFG_Q5_SZ(mem_share);
1027
			val64 |= RX_QUEUE_CFG_Q5_SZ(mem_share);
904
			continue;
1028
			continue;
905
		case 6:
1029
		case 6:
906
			mem_share = (64 / config->RxRingNum);
1030
			mem_share = (mem_size / config->rx_ring_num);
907
			val64 |= RX_QUEUE_CFG_Q6_SZ(mem_share);
1031
			val64 |= RX_QUEUE_CFG_Q6_SZ(mem_share);
908
			continue;
1032
			continue;
909
		case 7:
1033
		case 7:
910
			mem_share = (64 / config->RxRingNum);
1034
			mem_share = (mem_size / config->rx_ring_num);
911
			val64 |= RX_QUEUE_CFG_Q7_SZ(mem_share);
1035
			val64 |= RX_QUEUE_CFG_Q7_SZ(mem_share);
912
			continue;
1036
			continue;
913
		}
1037
		}
914
	}
1038
	}
915
	writeq(val64, &bar0->rx_queue_cfg);
1039
	writeq(val64, &bar0->rx_queue_cfg);
916
1040
917
	/* 
1041
	/*
918
	 * Initializing the Tx round robin registers to 0.
1042
	 * Filling Tx round robin registers
919
	 * Filling Tx and Rx round robin registers as per the 
1043
	 * as per the number of FIFOs
920
	 * number of FIFOs and Rings is still TODO.
1044
	 */
921
	 */
1045
	switch (config->tx_fifo_num) {
922
	writeq(0, &bar0->tx_w_round_robin_0);
1046
	case 1:
923
	writeq(0, &bar0->tx_w_round_robin_1);
1047
		val64 = 0x0000000000000000ULL;
924
	writeq(0, &bar0->tx_w_round_robin_2);
1048
		writeq(val64, &bar0->tx_w_round_robin_0);
925
	writeq(0, &bar0->tx_w_round_robin_3);
1049
		writeq(val64, &bar0->tx_w_round_robin_1);
926
	writeq(0, &bar0->tx_w_round_robin_4);
1050
		writeq(val64, &bar0->tx_w_round_robin_2);
927
1051
		writeq(val64, &bar0->tx_w_round_robin_3);
928
	/* 
1052
		writeq(val64, &bar0->tx_w_round_robin_4);
929
	 * TODO
1053
		break;
930
	 * Disable Rx steering. Hard coding all packets be steered to
1054
	case 2:
931
	 * Queue 0 for now. 
1055
		val64 = 0x0000010000010000ULL;
932
	 */
1056
		writeq(val64, &bar0->tx_w_round_robin_0);
933
	if (rx_prio) {
1057
		val64 = 0x0100000100000100ULL;
934
		u64 def = 0x8000000000000000ULL, tmp;
1058
		writeq(val64, &bar0->tx_w_round_robin_1);
935
		for (i = 0; i < MAX_RX_RINGS; i++) {
1059
		val64 = 0x0001000001000001ULL;
936
			tmp = (u64) (def >> (i % config->RxRingNum));
1060
		writeq(val64, &bar0->tx_w_round_robin_2);
937
			val64 |= (u64) (tmp >> (i * 8));
1061
		val64 = 0x0000010000010000ULL;
938
		}
1062
		writeq(val64, &bar0->tx_w_round_robin_3);
939
		writeq(val64, &bar0->rts_qos_steering);
1063
		val64 = 0x0100000000000000ULL;
940
	} else {
1064
		writeq(val64, &bar0->tx_w_round_robin_4);
1065
		break;
1066
	case 3:
1067
		val64 = 0x0001000102000001ULL;
1068
		writeq(val64, &bar0->tx_w_round_robin_0);
1069
		val64 = 0x0001020000010001ULL;
1070
		writeq(val64, &bar0->tx_w_round_robin_1);
1071
		val64 = 0x0200000100010200ULL;
1072
		writeq(val64, &bar0->tx_w_round_robin_2);
1073
		val64 = 0x0001000102000001ULL;
1074
		writeq(val64, &bar0->tx_w_round_robin_3);
1075
		val64 = 0x0001020000000000ULL;
1076
		writeq(val64, &bar0->tx_w_round_robin_4);
1077
		break;
1078
	case 4:
1079
		val64 = 0x0001020300010200ULL;
1080
		writeq(val64, &bar0->tx_w_round_robin_0);
1081
		val64 = 0x0100000102030001ULL;
1082
		writeq(val64, &bar0->tx_w_round_robin_1);
1083
		val64 = 0x0200010000010203ULL;
1084
		writeq(val64, &bar0->tx_w_round_robin_2);
1085
		val64 = 0x0001020001000001ULL;
1086
		writeq(val64, &bar0->tx_w_round_robin_3);
1087
		val64 = 0x0203000100000000ULL;
1088
		writeq(val64, &bar0->tx_w_round_robin_4);
1089
		break;
1090
	case 5:
1091
		val64 = 0x0001000203000102ULL;
1092
		writeq(val64, &bar0->tx_w_round_robin_0);
1093
		val64 = 0x0001020001030004ULL;
1094
		writeq(val64, &bar0->tx_w_round_robin_1);
1095
		val64 = 0x0001000203000102ULL;
1096
		writeq(val64, &bar0->tx_w_round_robin_2);
1097
		val64 = 0x0001020001030004ULL;
1098
		writeq(val64, &bar0->tx_w_round_robin_3);
1099
		val64 = 0x0001000000000000ULL;
1100
		writeq(val64, &bar0->tx_w_round_robin_4);
1101
		break;
1102
	case 6:
1103
		val64 = 0x0001020304000102ULL;
1104
		writeq(val64, &bar0->tx_w_round_robin_0);
1105
		val64 = 0x0304050001020001ULL;
1106
		writeq(val64, &bar0->tx_w_round_robin_1);
1107
		val64 = 0x0203000100000102ULL;
1108
		writeq(val64, &bar0->tx_w_round_robin_2);
1109
		val64 = 0x0304000102030405ULL;
1110
		writeq(val64, &bar0->tx_w_round_robin_3);
1111
		val64 = 0x0001000200000000ULL;
1112
		writeq(val64, &bar0->tx_w_round_robin_4);
1113
		break;
1114
	case 7:
1115
		val64 = 0x0001020001020300ULL;
1116
		writeq(val64, &bar0->tx_w_round_robin_0);
1117
		val64 = 0x0102030400010203ULL;
1118
		writeq(val64, &bar0->tx_w_round_robin_1);
1119
		val64 = 0x0405060001020001ULL;
1120
		writeq(val64, &bar0->tx_w_round_robin_2);
1121
		val64 = 0x0304050000010200ULL;
1122
		writeq(val64, &bar0->tx_w_round_robin_3);
1123
		val64 = 0x0102030000000000ULL;
1124
		writeq(val64, &bar0->tx_w_round_robin_4);
1125
		break;
1126
	case 8:
1127
		val64 = 0x0001020300040105ULL;
1128
		writeq(val64, &bar0->tx_w_round_robin_0);
1129
		val64 = 0x0200030106000204ULL;
1130
		writeq(val64, &bar0->tx_w_round_robin_1);
1131
		val64 = 0x0103000502010007ULL;
1132
		writeq(val64, &bar0->tx_w_round_robin_2);
1133
		val64 = 0x0304010002060500ULL;
1134
		writeq(val64, &bar0->tx_w_round_robin_3);
1135
		val64 = 0x0103020400000000ULL;
1136
		writeq(val64, &bar0->tx_w_round_robin_4);
1137
		break;
1138
	}
1139
1140
	/* Filling the Rx round robin registers as per the
1141
	 * number of Rings and steering based on QoS.
1142
         */
1143
	switch (config->rx_ring_num) {
1144
	case 1:
941
		val64 = 0x8080808080808080ULL;
1145
		val64 = 0x8080808080808080ULL;
942
		writeq(val64, &bar0->rts_qos_steering);
1146
		writeq(val64, &bar0->rts_qos_steering);
1147
		break;
1148
	case 2:
1149
		val64 = 0x0000010000010000ULL;
1150
		writeq(val64, &bar0->rx_w_round_robin_0);
1151
		val64 = 0x0100000100000100ULL;
1152
		writeq(val64, &bar0->rx_w_round_robin_1);
1153
		val64 = 0x0001000001000001ULL;
1154
		writeq(val64, &bar0->rx_w_round_robin_2);
1155
		val64 = 0x0000010000010000ULL;
1156
		writeq(val64, &bar0->rx_w_round_robin_3);
1157
		val64 = 0x0100000000000000ULL;
1158
		writeq(val64, &bar0->rx_w_round_robin_4);
1159
1160
		val64 = 0x8080808040404040ULL;
1161
		writeq(val64, &bar0->rts_qos_steering);
1162
		break;
1163
	case 3:
1164
		val64 = 0x0001000102000001ULL;
1165
		writeq(val64, &bar0->rx_w_round_robin_0);
1166
		val64 = 0x0001020000010001ULL;
1167
		writeq(val64, &bar0->rx_w_round_robin_1);
1168
		val64 = 0x0200000100010200ULL;
1169
		writeq(val64, &bar0->rx_w_round_robin_2);
1170
		val64 = 0x0001000102000001ULL;
1171
		writeq(val64, &bar0->rx_w_round_robin_3);
1172
		val64 = 0x0001020000000000ULL;
1173
		writeq(val64, &bar0->rx_w_round_robin_4);
1174
1175
		val64 = 0x8080804040402020ULL;
1176
		writeq(val64, &bar0->rts_qos_steering);
1177
		break;
1178
	case 4:
1179
		val64 = 0x0001020300010200ULL;
1180
		writeq(val64, &bar0->rx_w_round_robin_0);
1181
		val64 = 0x0100000102030001ULL;
1182
		writeq(val64, &bar0->rx_w_round_robin_1);
1183
		val64 = 0x0200010000010203ULL;
1184
		writeq(val64, &bar0->rx_w_round_robin_2);
1185
		val64 = 0x0001020001000001ULL;	
1186
		writeq(val64, &bar0->rx_w_round_robin_3);
1187
		val64 = 0x0203000100000000ULL;
1188
		writeq(val64, &bar0->rx_w_round_robin_4);
1189
1190
		val64 = 0x8080404020201010ULL;
1191
		writeq(val64, &bar0->rts_qos_steering);
1192
		break;
1193
	case 5:
1194
		val64 = 0x0001000203000102ULL;
1195
		writeq(val64, &bar0->rx_w_round_robin_0);
1196
		val64 = 0x0001020001030004ULL;
1197
		writeq(val64, &bar0->rx_w_round_robin_1);
1198
		val64 = 0x0001000203000102ULL;
1199
		writeq(val64, &bar0->rx_w_round_robin_2);
1200
		val64 = 0x0001020001030004ULL;
1201
		writeq(val64, &bar0->rx_w_round_robin_3);
1202
		val64 = 0x0001000000000000ULL;
1203
		writeq(val64, &bar0->rx_w_round_robin_4);
1204
1205
		val64 = 0x8080404020201008ULL;
1206
		writeq(val64, &bar0->rts_qos_steering);
1207
		break;
1208
	case 6:
1209
		val64 = 0x0001020304000102ULL;
1210
		writeq(val64, &bar0->rx_w_round_robin_0);
1211
		val64 = 0x0304050001020001ULL;
1212
		writeq(val64, &bar0->rx_w_round_robin_1);
1213
		val64 = 0x0203000100000102ULL;
1214
		writeq(val64, &bar0->rx_w_round_robin_2);
1215
		val64 = 0x0304000102030405ULL;
1216
		writeq(val64, &bar0->rx_w_round_robin_3);
1217
		val64 = 0x0001000200000000ULL;
1218
		writeq(val64, &bar0->rx_w_round_robin_4);
1219
1220
		val64 = 0x8080404020100804ULL;
1221
		writeq(val64, &bar0->rts_qos_steering);
1222
		break;
1223
	case 7:
1224
		val64 = 0x0001020001020300ULL;
1225
		writeq(val64, &bar0->rx_w_round_robin_0);
1226
		val64 = 0x0102030400010203ULL;
1227
		writeq(val64, &bar0->rx_w_round_robin_1);
1228
		val64 = 0x0405060001020001ULL;
1229
		writeq(val64, &bar0->rx_w_round_robin_2);
1230
		val64 = 0x0304050000010200ULL;
1231
		writeq(val64, &bar0->rx_w_round_robin_3);
1232
		val64 = 0x0102030000000000ULL;
1233
		writeq(val64, &bar0->rx_w_round_robin_4);
1234
1235
		val64 = 0x8080402010080402ULL;
1236
		writeq(val64, &bar0->rts_qos_steering);
1237
		break;
1238
	case 8:
1239
		val64 = 0x0001020300040105ULL;
1240
		writeq(val64, &bar0->rx_w_round_robin_0);
1241
		val64 = 0x0200030106000204ULL;
1242
		writeq(val64, &bar0->rx_w_round_robin_1);
1243
		val64 = 0x0103000502010007ULL;
1244
		writeq(val64, &bar0->rx_w_round_robin_2);
1245
		val64 = 0x0304010002060500ULL;
1246
		writeq(val64, &bar0->rx_w_round_robin_3);
1247
		val64 = 0x0103020400000000ULL;
1248
		writeq(val64, &bar0->rx_w_round_robin_4);
1249
1250
		val64 = 0x8040201008040201ULL;
1251
		writeq(val64, &bar0->rts_qos_steering);
1252
		break;
943
	}
1253
	}
944
1254
945
	/* UDP Fix */
1255
	/* UDP Fix */
946
	val64 = 0;
1256
	val64 = 0;
947
	for (i = 1; i < 8; i++)
1257
	for (i = 0; i < 8; i++)
1258
		writeq(val64, &bar0->rts_frm_len_n[i]);
1259
1260
	/* Set the default rts frame length for the rings configured */
1261
	val64 = MAC_RTS_FRM_LEN_SET(dev->mtu+22);
1262
	for (i = 0 ; i < config->rx_ring_num ; i++)
948
		writeq(val64, &bar0->rts_frm_len_n[i]);
1263
		writeq(val64, &bar0->rts_frm_len_n[i]);
949
1264
950
	/* Set rts_frm_len register for fifo 0 */
1265
	/* Set the frame length for the configured rings
951
	writeq(MAC_RTS_FRM_LEN_SET(dev->mtu + 22),
1266
	 * desired by the user
952
	       &bar0->rts_frm_len_n[0]);
1267
	 */
1268
	for (i = 0; i < config->rx_ring_num; i++) {
1269
		/* If rts_frm_len[i] == 0 then it is assumed that user not
1270
		 * specified frame length steering.
1271
		 * If the user provides the frame length then program
1272
		 * the rts_frm_len register for those values or else
1273
		 * leave it as it is.
1274
		 */
1275
		if (rts_frm_len[i] != 0) {
1276
			writeq(MAC_RTS_FRM_LEN_SET(rts_frm_len[i]),
1277
				&bar0->rts_frm_len_n[i]);
1278
		}
1279
	}
953
1280
954
	/* Enable statistics */
1281
	/* Program statistics memory */
955
	writeq(mac_control->stats_mem_phy, &bar0->stat_addr);
1282
	writeq(mac_control->stats_mem_phy, &bar0->stat_addr);
956
	val64 = SET_UPDT_PERIOD(Stats_refresh_time) |
957
	    STAT_CFG_STAT_RO | STAT_CFG_STAT_EN;
958
	writeq(val64, &bar0->stat_cfg);
959
1283
960
	/* 
1284
	if (nic->device_type == XFRAME_II_DEVICE) {
1285
		val64 = STAT_BC(0x320);
1286
		writeq(val64, &bar0->stat_byte_cnt);
1287
	}
1288
1289
	/*
961
	 * Initializing the sampling rate for the device to calculate the
1290
	 * Initializing the sampling rate for the device to calculate the
962
	 * bandwidth utilization.
1291
	 * bandwidth utilization.
963
	 */
1292
	 */
Lines 966-994 static int init_nic(struct s2io_nic *nic Link Here
966
	writeq(val64, &bar0->mac_link_util);
1295
	writeq(val64, &bar0->mac_link_util);
967
1296
968
1297
969
	/* 
1298
	/*
970
	 * Initializing the Transmit and Receive Traffic Interrupt 
1299
	 * Initializing the Transmit and Receive Traffic Interrupt
971
	 * Scheme.
1300
	 * Scheme.
972
	 */
1301
	 */
973
	/* TTI Initialization */
1302
	/*
974
	val64 = TTI_DATA1_MEM_TX_TIMER_VAL(tx_timer_val) |
1303
	 * TTI Initialization. Default Tx timer gets us about
975
	    TTI_DATA1_MEM_TX_URNG_A(tx_urange_a) |
1304
	 * 250 interrupts per sec. Continuous interrupts are enabled
976
	    TTI_DATA1_MEM_TX_URNG_B(tx_urange_b) |
1305
	 * by default.
977
	    TTI_DATA1_MEM_TX_URNG_C(tx_urange_c);
1306
	 */
978
	if (tx_utilz_periodic)
1307
	if (nic->device_type == XFRAME_II_DEVICE) {
979
		val64 |= TTI_DATA1_MEM_TX_TIMER_AC_EN;
1308
		int count = (nic->config.bus_speed * 125)/2;
1309
		val64 = TTI_DATA1_MEM_TX_TIMER_VAL(count);
1310
	} else {
1311
1312
		val64 = TTI_DATA1_MEM_TX_TIMER_VAL(0x2078);
1313
	}
1314
	val64 |= TTI_DATA1_MEM_TX_URNG_A(0xA) |
1315
	    TTI_DATA1_MEM_TX_URNG_B(0x10) |
1316
	    TTI_DATA1_MEM_TX_URNG_C(0x30) | TTI_DATA1_MEM_TX_TIMER_AC_EN;
1317
		if (use_continuous_tx_intrs)
1318
			val64 |= TTI_DATA1_MEM_TX_TIMER_CI_EN;
980
	writeq(val64, &bar0->tti_data1_mem);
1319
	writeq(val64, &bar0->tti_data1_mem);
981
1320
982
	val64 = TTI_DATA2_MEM_TX_UFC_A(tx_ufc_a) |
1321
	val64 = TTI_DATA2_MEM_TX_UFC_A(0x10) |
983
	    TTI_DATA2_MEM_TX_UFC_B(tx_ufc_b) |
1322
	    TTI_DATA2_MEM_TX_UFC_B(0x20) |
984
	    TTI_DATA2_MEM_TX_UFC_C(tx_ufc_c) |
1323
	    TTI_DATA2_MEM_TX_UFC_C(0x70) | TTI_DATA2_MEM_TX_UFC_D(0x80);
985
	    TTI_DATA2_MEM_TX_UFC_D(tx_ufc_d);
986
	writeq(val64, &bar0->tti_data2_mem);
1324
	writeq(val64, &bar0->tti_data2_mem);
987
1325
988
	val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
1326
	val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
989
	writeq(val64, &bar0->tti_command_mem);
1327
	writeq(val64, &bar0->tti_command_mem);
990
1328
991
	/* 
1329
	/*
992
	 * Once the operation completes, the Strobe bit of the command
1330
	 * Once the operation completes, the Strobe bit of the command
993
	 * register will be reset. We poll for this particular condition
1331
	 * register will be reset. We poll for this particular condition
994
	 * We wait for a maximum of 500ms for the operation to complete,
1332
	 * We wait for a maximum of 500ms for the operation to complete,
Lines 1005-1058 static int init_nic(struct s2io_nic *nic Link Here
1005
				  dev->name);
1343
				  dev->name);
1006
			return -1;
1344
			return -1;
1007
		}
1345
		}
1008
		set_current_state(TASK_UNINTERRUPTIBLE);
1346
		msleep(50);
1009
		schedule_timeout(HZ / 20);
1010
		time++;
1347
		time++;
1011
	}
1348
	}
1012
1349
1013
	/* RTI Initialization */
1350
	if (nic->config.bimodal) {
1014
	val64 = RTI_DATA1_MEM_RX_TIMER_VAL(rx_timer_val) |
1351
		int k = 0;
1015
	    RTI_DATA1_MEM_RX_URNG_A(rx_urange_a) |
1352
		for (k = 0; k < config->rx_ring_num; k++) {
1016
	    RTI_DATA1_MEM_RX_URNG_B(rx_urange_b) |
1353
			val64 = TTI_CMD_MEM_WE | TTI_CMD_MEM_STROBE_NEW_CMD;
1017
	    RTI_DATA1_MEM_RX_URNG_C(rx_urange_c);
1354
			val64 |= TTI_CMD_MEM_OFFSET(0x38+k);
1018
	if (rx_utilz_periodic)
1355
			writeq(val64, &bar0->tti_command_mem);
1019
		val64 |= RTI_DATA1_MEM_RX_TIMER_AC_EN;
1356
1020
1357
		/*
1021
	writeq(val64, &bar0->rti_data1_mem);
1358
		 * Once the operation completes, the Strobe bit of the command
1022
1359
		 * register will be reset. We poll for this particular condition
1023
	val64 = RTI_DATA2_MEM_RX_UFC_A(rx_ufc_a) |
1360
		 * We wait for a maximum of 500ms for the operation to complete,
1024
	    RTI_DATA2_MEM_RX_UFC_B(rx_ufc_b) |
1361
		 * if it's not complete by then we return error.
1025
	    RTI_DATA2_MEM_RX_UFC_C(rx_ufc_c) |
1362
		*/
1026
	    RTI_DATA2_MEM_RX_UFC_D(rx_ufc_d);
1363
			time = 0;
1027
	writeq(val64, &bar0->rti_data2_mem);
1364
			while (TRUE) {
1028
1365
				val64 = readq(&bar0->tti_command_mem);
1029
	val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD;
1366
				if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) {
1030
	writeq(val64, &bar0->rti_command_mem);
1367
					break;
1368
				}
1369
				if (time > 10) {
1370
					DBG_PRINT(ERR_DBG,
1371
						"%s: TTI init Failed\n",
1372
					dev->name);
1373
					return -1;
1374
				}
1375
				time++;
1376
				msleep(50);
1377
			}
1378
		}
1379
	} else {
1031
1380
1032
	/* 
1381
		/* RTI Initialization */
1033
	 * Once the operation completes, the Strobe bit of the command
1382
		if (nic->device_type == XFRAME_II_DEVICE) {
1034
	 * register will be reset. We poll for this particular condition
1383
			/*
1035
	 * We wait for a maximum of 500ms for the operation to complete,
1384
			 * Programmed to generate Apprx 500 Intrs per
1036
	 * if it's not complete by then we return error.
1385
			 * second
1037
	 */
1386
			 */
1038
	time = 0;
1387
			int count = (nic->config.bus_speed * 125)/4;
1039
	while (TRUE) {
1388
			val64 = RTI_DATA1_MEM_RX_TIMER_VAL(count);
1040
		val64 = readq(&bar0->rti_command_mem);
1389
		} else {
1041
		if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) {
1390
			val64 = RTI_DATA1_MEM_RX_TIMER_VAL(0xFFF);
1042
			break;
1043
		}
1391
		}
1044
		if (time > 10) {
1392
		val64 |= RTI_DATA1_MEM_RX_URNG_A(0xA) |
1045
			DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n",
1393
		    RTI_DATA1_MEM_RX_URNG_B(0x10) |
1046
				  dev->name);
1394
		    RTI_DATA1_MEM_RX_URNG_C(0x30) | RTI_DATA1_MEM_RX_TIMER_AC_EN;
1047
			return -1;
1395
1396
		writeq(val64, &bar0->rti_data1_mem);
1397
1398
		val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
1399
		    RTI_DATA2_MEM_RX_UFC_B(0x2) |
1400
		    RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80);
1401
		writeq(val64, &bar0->rti_data2_mem);
1402
1403
		for (i = 0; i < config->rx_ring_num; i++) {
1404
			val64 = RTI_CMD_MEM_WE | RTI_CMD_MEM_STROBE_NEW_CMD
1405
					| RTI_CMD_MEM_OFFSET(i);
1406
			writeq(val64, &bar0->rti_command_mem);
1407
1408
			/*
1409
			 * Once the operation completes, the Strobe bit of the
1410
			 * command register will be reset. We poll for this
1411
			 * particular condition. We wait for a maximum of 500ms
1412
			 * for the operation to complete, if it's not complete
1413
			 * by then we return error.
1414
			 */
1415
			time = 0;
1416
			while (TRUE) {
1417
				val64 = readq(&bar0->rti_command_mem);
1418
				if (!(val64 & RTI_CMD_MEM_STROBE_NEW_CMD)) {
1419
					break;
1420
				}
1421
				if (time > 10) {
1422
					DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n",
1423
						  dev->name);
1424
					return -1;
1425
				}
1426
				time++;
1427
				msleep(50);
1428
			}
1048
		}
1429
		}
1049
		time++;
1050
		set_current_state(TASK_UNINTERRUPTIBLE);
1051
		schedule_timeout(HZ / 20);
1052
	}
1430
	}
1053
1431
1054
	/* 
1432
	/*
1055
	 * Initializing proper values as Pause threshold into all 
1433
	 * Initializing proper values as Pause threshold into all
1056
	 * the 8 Queues on Rx side.
1434
	 * the 8 Queues on Rx side.
1057
	 */
1435
	 */
1058
	writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q0q3);
1436
	writeq(0xffbbffbbffbbffbbULL, &bar0->mc_pause_thresh_q0q3);
Lines 1068-1075 static int init_nic(struct s2io_nic *nic Link Here
1068
	writel((u32) (val64 >> 32), (add + 4));
1446
	writel((u32) (val64 >> 32), (add + 4));
1069
	val64 = readq(&bar0->mac_cfg);
1447
	val64 = readq(&bar0->mac_cfg);
1070
1448
1071
	/* 
1449
	/*
1072
	 * Set the time value to be inserted in the pause frame 
1450
	 * Set the time value to be inserted in the pause frame
1073
	 * generated by xena.
1451
	 * generated by xena.
1074
	 */
1452
	 */
1075
	val64 = readq(&bar0->rmac_pause_cfg);
1453
	val64 = readq(&bar0->rmac_pause_cfg);
Lines 1077-1083 static int init_nic(struct s2io_nic *nic Link Here
1077
	val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time);
1455
	val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time);
1078
	writeq(val64, &bar0->rmac_pause_cfg);
1456
	writeq(val64, &bar0->rmac_pause_cfg);
1079
1457
1080
	/* 
1458
	/*
1081
	 * Set the Threshold Limit for Generating the pause frame
1459
	 * Set the Threshold Limit for Generating the pause frame
1082
	 * If the amount of data in any Queue exceeds ratio of
1460
	 * If the amount of data in any Queue exceeds ratio of
1083
	 * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256
1461
	 * (mac_control.mc_pause_threshold_q0q3 or q4q7)/256
Lines 1101-1131 static int init_nic(struct s2io_nic *nic Link Here
1101
	}
1479
	}
1102
	writeq(val64, &bar0->mc_pause_thresh_q4q7);
1480
	writeq(val64, &bar0->mc_pause_thresh_q4q7);
1103
1481
1104
	/* 
1482
	/*
1105
	 * TxDMA will stop Read request if the number of read split has 
1483
	 * TxDMA will stop Read request if the number of read split has
1106
	 * exceeded the limit pointed by shared_splits
1484
	 * exceeded the limit pointed by shared_splits
1107
	 */
1485
	 */
1108
	val64 = readq(&bar0->pic_control);
1486
	val64 = readq(&bar0->pic_control);
1109
	val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits);
1487
	val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits);
1110
	writeq(val64, &bar0->pic_control);
1488
	writeq(val64, &bar0->pic_control);
1111
1489
1490
	/*
1491
	 * Programming the Herc to split every write transaction
1492
	 * that does not start on an ADB to reduce disconnects.
1493
	 */
1494
	if (nic->device_type == XFRAME_II_DEVICE) {
1495
		val64 = WREQ_SPLIT_MASK_SET_MASK(255);
1496
		writeq(val64, &bar0->wreq_split_mask);
1497
	}
1498
1499
	/* Setting Link stability period to 64 ms */ 
1500
	if (nic->device_type == XFRAME_II_DEVICE) {
1501
		val64 = MISC_LINK_STABILITY_PRD(3);
1502
		writeq(val64, &bar0->misc_control);
1503
	}
1504
1112
	return SUCCESS;
1505
	return SUCCESS;
1113
}
1506
}
1507
#define LINK_UP_DOWN_INTERRUPT		1
1508
#define MAC_RMAC_ERR_TIMER		2
1114
1509
1115
/**  
1510
#if defined(CONFIG_MSI_MODE) || defined(CONFIG_MSIX_MODE)
1116
 *  en_dis_able_nic_intrs - Enable or Disable the interrupts 
1511
#define s2io_link_fault_indication(x) MAC_RMAC_ERR_TIMER
1117
 *  @nic: device private variable,
1512
#else
1513
int s2io_link_fault_indication(nic_t *nic)
1514
{
1515
	if (nic->device_type == XFRAME_II_DEVICE)
1516
		return LINK_UP_DOWN_INTERRUPT;
1517
	else
1518
		return MAC_RMAC_ERR_TIMER;
1519
}
1520
#endif
1521
1522
/**
1523
 *  en_dis_able_nic_intrs - Enable or Disable the interrupts
1524
 *  @nic: device private variable,
1118
 *  @mask: A mask indicating which Intr block must be modified and,
1525
 *  @mask: A mask indicating which Intr block must be modified and,
1119
 *  @flag: A flag indicating whether to enable or disable the Intrs.
1526
 *  @flag: A flag indicating whether to enable or disable the Intrs.
1120
 *  Description: This function will either disable or enable the interrupts
1527
 *  Description: This function will either disable or enable the interrupts
1121
 *  depending on the flag argument. The mask argument can be used to 
1528
 *  depending on the flag argument. The mask argument can be used to
1122
 *  enable/disable any Intr block. 
1529
 *  enable/disable any Intr block.
1123
 *  Return Value: NONE.
1530
 *  Return Value: NONE.
1124
 */
1531
 */
1125
1532
1126
static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1533
static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag)
1127
{
1534
{
1128
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
1535
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
1129
	register u64 val64 = 0, temp64 = 0;
1536
	register u64 val64 = 0, temp64 = 0;
1130
1537
1131
	/*  Top level interrupt classification */
1538
	/*  Top level interrupt classification */
Lines 1137-1156 static void en_dis_able_nic_intrs(struct Link Here
1137
			temp64 = readq(&bar0->general_int_mask);
1544
			temp64 = readq(&bar0->general_int_mask);
1138
			temp64 &= ~((u64) val64);
1545
			temp64 &= ~((u64) val64);
1139
			writeq(temp64, &bar0->general_int_mask);
1546
			writeq(temp64, &bar0->general_int_mask);
1140
			/*  
1547
			/*
1141
			 * Disabled all PCIX, Flash, MDIO, IIC and GPIO
1548
			 * If Hercules adapter enable GPIO otherwise
1142
			 * interrupts for now. 
1549
			 * disabled all PCIX, Flash, MDIO, IIC and GPIO
1143
			 * TODO 
1550
			 * interrupts for now.
1551
			 * TODO
1144
			 */
1552
			 */
1145
			writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1553
			if (s2io_link_fault_indication(nic) ==
1146
			/* 
1554
					LINK_UP_DOWN_INTERRUPT ) {
1555
				temp64 = readq(&bar0->pic_int_mask);
1556
				temp64 &= ~((u64) PIC_INT_GPIO);
1557
				writeq(temp64, &bar0->pic_int_mask);
1558
				temp64 = readq(&bar0->gpio_int_mask);
1559
				temp64 &= ~((u64) GPIO_INT_MASK_LINK_UP);
1560
				writeq(temp64, &bar0->gpio_int_mask);
1561
			} else {
1562
				writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1563
			}
1564
			/*
1147
			 * No MSI Support is available presently, so TTI and
1565
			 * No MSI Support is available presently, so TTI and
1148
			 * RTI interrupts are also disabled.
1566
			 * RTI interrupts are also disabled.
1149
			 */
1567
			 */
1150
		} else if (flag == DISABLE_INTRS) {
1568
		} else if (flag == DISABLE_INTRS) {
1151
			/*  
1569
			/*
1152
			 * Disable PIC Intrs in the general 
1570
			 * Disable PIC Intrs in the general
1153
			 * intr mask register 
1571
			 * intr mask register
1154
			 */
1572
			 */
1155
			writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1573
			writeq(DISABLE_ALL_INTRS, &bar0->pic_int_mask);
1156
			temp64 = readq(&bar0->general_int_mask);
1574
			temp64 = readq(&bar0->general_int_mask);
Lines 1168-1194 static void en_dis_able_nic_intrs(struct Link Here
1168
			temp64 = readq(&bar0->general_int_mask);
1586
			temp64 = readq(&bar0->general_int_mask);
1169
			temp64 &= ~((u64) val64);
1587
			temp64 &= ~((u64) val64);
1170
			writeq(temp64, &bar0->general_int_mask);
1588
			writeq(temp64, &bar0->general_int_mask);
1171
			/* 
1589
			/*
1172
			 * Keep all interrupts other than PFC interrupt 
1590
			 * Keep all interrupts other than PFC interrupt
1173
			 * and PCC interrupt disabled in DMA level.
1591
			 * and PCC interrupt disabled in DMA level.
1174
			 */
1592
			 */
1175
			val64 = DISABLE_ALL_INTRS & ~(TXDMA_PFC_INT_M |
1593
			val64 = DISABLE_ALL_INTRS & ~(TXDMA_PFC_INT_M |
1176
						      TXDMA_PCC_INT_M);
1594
						      TXDMA_PCC_INT_M);
1177
			writeq(val64, &bar0->txdma_int_mask);
1595
			writeq(val64, &bar0->txdma_int_mask);
1178
			/* 
1596
			/*
1179
			 * Enable only the MISC error 1 interrupt in PFC block 
1597
			 * Enable only the MISC error 1 interrupt in PFC block
1180
			 */
1598
			 */
1181
			val64 = DISABLE_ALL_INTRS & (~PFC_MISC_ERR_1);
1599
			val64 = DISABLE_ALL_INTRS & (~PFC_MISC_ERR_1);
1182
			writeq(val64, &bar0->pfc_err_mask);
1600
			writeq(val64, &bar0->pfc_err_mask);
1183
			/* 
1601
			/*
1184
			 * Enable only the FB_ECC error interrupt in PCC block 
1602
			 * Enable only the FB_ECC error interrupt in PCC block
1185
			 */
1603
			 */
1186
			val64 = DISABLE_ALL_INTRS & (~PCC_FB_ECC_ERR);
1604
			val64 = DISABLE_ALL_INTRS & (~PCC_FB_ECC_ERR);
1187
			writeq(val64, &bar0->pcc_err_mask);
1605
			writeq(val64, &bar0->pcc_err_mask);
1188
		} else if (flag == DISABLE_INTRS) {
1606
		} else if (flag == DISABLE_INTRS) {
1189
			/* 
1607
			/*
1190
			 * Disable TxDMA Intrs in the general intr mask 
1608
			 * Disable TxDMA Intrs in the general intr mask
1191
			 * register 
1609
			 * register
1192
			 */
1610
			 */
1193
			writeq(DISABLE_ALL_INTRS, &bar0->txdma_int_mask);
1611
			writeq(DISABLE_ALL_INTRS, &bar0->txdma_int_mask);
1194
			writeq(DISABLE_ALL_INTRS, &bar0->pfc_err_mask);
1612
			writeq(DISABLE_ALL_INTRS, &bar0->pfc_err_mask);
Lines 1206-1220 static void en_dis_able_nic_intrs(struct Link Here
1206
			temp64 = readq(&bar0->general_int_mask);
1624
			temp64 = readq(&bar0->general_int_mask);
1207
			temp64 &= ~((u64) val64);
1625
			temp64 &= ~((u64) val64);
1208
			writeq(temp64, &bar0->general_int_mask);
1626
			writeq(temp64, &bar0->general_int_mask);
1209
			/* 
1627
			/*
1210
			 * All RxDMA block interrupts are disabled for now 
1628
			 * All RxDMA block interrupts are disabled for now
1211
			 * TODO 
1629
			 * TODO
1212
			 */
1630
			 */
1213
			writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1631
			writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1214
		} else if (flag == DISABLE_INTRS) {
1632
		} else if (flag == DISABLE_INTRS) {
1215
			/*  
1633
			/*
1216
			 * Disable RxDMA Intrs in the general intr mask 
1634
			 * Disable RxDMA Intrs in the general intr mask
1217
			 * register 
1635
			 * register
1218
			 */
1636
			 */
1219
			writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1637
			writeq(DISABLE_ALL_INTRS, &bar0->rxdma_int_mask);
1220
			temp64 = readq(&bar0->general_int_mask);
1638
			temp64 = readq(&bar0->general_int_mask);
Lines 1231-1252 static void en_dis_able_nic_intrs(struct Link Here
1231
			temp64 = readq(&bar0->general_int_mask);
1649
			temp64 = readq(&bar0->general_int_mask);
1232
			temp64 &= ~((u64) val64);
1650
			temp64 &= ~((u64) val64);
1233
			writeq(temp64, &bar0->general_int_mask);
1651
			writeq(temp64, &bar0->general_int_mask);
1234
			/* 
1652
			/*
1235
			 * All MAC block error interrupts are disabled for now 
1653
			 * All MAC block error interrupts are disabled for now
1236
			 * except the link status change interrupt.
1237
			 * TODO
1654
			 * TODO
1238
			 */
1655
			 */
1239
			val64 = MAC_INT_STATUS_RMAC_INT;
1240
			temp64 = readq(&bar0->mac_int_mask);
1241
			temp64 &= ~((u64) val64);
1242
			writeq(temp64, &bar0->mac_int_mask);
1243
1244
			val64 = readq(&bar0->mac_rmac_err_mask);
1245
			val64 &= ~((u64) RMAC_LINK_STATE_CHANGE_INT);
1246
			writeq(val64, &bar0->mac_rmac_err_mask);
1247
		} else if (flag == DISABLE_INTRS) {
1656
		} else if (flag == DISABLE_INTRS) {
1248
			/*  
1657
			/*
1249
			 * Disable MAC Intrs in the general intr mask register 
1658
			 * Disable MAC Intrs in the general intr mask register
1250
			 */
1659
			 */
1251
			writeq(DISABLE_ALL_INTRS, &bar0->mac_int_mask);
1660
			writeq(DISABLE_ALL_INTRS, &bar0->mac_int_mask);
1252
			writeq(DISABLE_ALL_INTRS,
1661
			writeq(DISABLE_ALL_INTRS,
Lines 1265-1278 static void en_dis_able_nic_intrs(struct Link Here
1265
			temp64 = readq(&bar0->general_int_mask);
1674
			temp64 = readq(&bar0->general_int_mask);
1266
			temp64 &= ~((u64) val64);
1675
			temp64 &= ~((u64) val64);
1267
			writeq(temp64, &bar0->general_int_mask);
1676
			writeq(temp64, &bar0->general_int_mask);
1268
			/* 
1677
			/*
1269
			 * All XGXS block error interrupts are disabled for now
1678
			 * All XGXS block error interrupts are disabled for now
1270
			 * TODO 
1679
			 * TODO
1271
			 */
1680
			 */
1272
			writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1681
			writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1273
		} else if (flag == DISABLE_INTRS) {
1682
		} else if (flag == DISABLE_INTRS) {
1274
			/*  
1683
			/*
1275
			 * Disable MC Intrs in the general intr mask register 
1684
			 * Disable MC Intrs in the general intr mask register
1276
			 */
1685
			 */
1277
			writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1686
			writeq(DISABLE_ALL_INTRS, &bar0->xgxs_int_mask);
1278
			temp64 = readq(&bar0->general_int_mask);
1687
			temp64 = readq(&bar0->general_int_mask);
Lines 1288-1298 static void en_dis_able_nic_intrs(struct Link Here
1288
			temp64 = readq(&bar0->general_int_mask);
1697
			temp64 = readq(&bar0->general_int_mask);
1289
			temp64 &= ~((u64) val64);
1698
			temp64 &= ~((u64) val64);
1290
			writeq(temp64, &bar0->general_int_mask);
1699
			writeq(temp64, &bar0->general_int_mask);
1291
			/* 
1700
			/*
1292
			 * All MC block error interrupts are disabled for now
1701
			 * Enable all MC Intrs.
1293
			 * TODO 
1294
			 */
1702
			 */
1295
			writeq(DISABLE_ALL_INTRS, &bar0->mc_int_mask);
1703
			writeq(0x0, &bar0->mc_int_mask);
1704
			writeq(0x0, &bar0->mc_err_mask);
1296
		} else if (flag == DISABLE_INTRS) {
1705
		} else if (flag == DISABLE_INTRS) {
1297
			/*
1706
			/*
1298
			 * Disable MC Intrs in the general intr mask register
1707
			 * Disable MC Intrs in the general intr mask register
Lines 1312-1325 static void en_dis_able_nic_intrs(struct Link Here
1312
			temp64 = readq(&bar0->general_int_mask);
1721
			temp64 = readq(&bar0->general_int_mask);
1313
			temp64 &= ~((u64) val64);
1722
			temp64 &= ~((u64) val64);
1314
			writeq(temp64, &bar0->general_int_mask);
1723
			writeq(temp64, &bar0->general_int_mask);
1315
			/* 
1724
			/*
1316
			 * Enable all the Tx side interrupts
1725
			 * Enable all the Tx side interrupts
1317
			 * writing 0 Enables all 64 TX interrupt levels 
1726
			 * writing 0 Enables all 64 TX interrupt levels
1318
			 */
1727
			 */
1319
			writeq(0x0, &bar0->tx_traffic_mask);
1728
			writeq(0x0, &bar0->tx_traffic_mask);
1320
		} else if (flag == DISABLE_INTRS) {
1729
		} else if (flag == DISABLE_INTRS) {
1321
			/* 
1730
			/*
1322
			 * Disable Tx Traffic Intrs in the general intr mask 
1731
			 * Disable Tx Traffic Intrs in the general intr mask
1323
			 * register.
1732
			 * register.
1324
			 */
1733
			 */
1325
			writeq(DISABLE_ALL_INTRS, &bar0->tx_traffic_mask);
1734
			writeq(DISABLE_ALL_INTRS, &bar0->tx_traffic_mask);
Lines 1339-1346 static void en_dis_able_nic_intrs(struct Link Here
1339
			/* writing 0 Enables all 8 RX interrupt levels */
1748
			/* writing 0 Enables all 8 RX interrupt levels */
1340
			writeq(0x0, &bar0->rx_traffic_mask);
1749
			writeq(0x0, &bar0->rx_traffic_mask);
1341
		} else if (flag == DISABLE_INTRS) {
1750
		} else if (flag == DISABLE_INTRS) {
1342
			/*  
1751
			/*
1343
			 * Disable Rx Traffic Intrs in the general intr mask 
1752
			 * Disable Rx Traffic Intrs in the general intr mask
1344
			 * register.
1753
			 * register.
1345
			 */
1754
			 */
1346
			writeq(DISABLE_ALL_INTRS, &bar0->rx_traffic_mask);
1755
			writeq(DISABLE_ALL_INTRS, &bar0->rx_traffic_mask);
Lines 1351-1374 static void en_dis_able_nic_intrs(struct Link Here
1351
	}
1760
	}
1352
}
1761
}
1353
1762
1354
/**  
1763
static int check_prc_pcc_state(u64 val64, int flag, int rev_id, int herc)
1355
 *  verify_xena_quiescence - Checks whether the H/W is ready 
1764
{
1765
	int ret = 0;
1766
1767
	if (flag == FALSE) {
1768
		if ((!herc && (rev_id >= 4)) || herc) {
1769
			if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1770
			    ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1771
			     ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1772
				ret = 1;
1773
			}
1774
		}else {
1775
			if (!(val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) &&
1776
			    ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1777
			     ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1778
				ret = 1;
1779
			}
1780
		}
1781
	} else {
1782
		if ((!herc && (rev_id >= 4)) || herc) {
1783
			if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) ==
1784
			     ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1785
			    (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1786
			     ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1787
			      ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1788
				ret = 1;
1789
			}
1790
		} else {
1791
			if (((val64 & ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) ==
1792
			     ADAPTER_STATUS_RMAC_PCC_FOUR_IDLE) &&
1793
			    (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1794
			     ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1795
			      ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1796
				ret = 1;
1797
			}
1798
		}
1799
	}
1800
1801
	return ret;
1802
}
1803
/**
1804
 *  verify_xena_quiescence - Checks whether the H/W is ready
1356
 *  @val64 :  Value read from adapter status register.
1805
 *  @val64 :  Value read from adapter status register.
1357
 *  @flag : indicates if the adapter enable bit was ever written once
1806
 *  @flag : indicates if the adapter enable bit was ever written once
1358
 *  before.
1807
 *  before.
1359
 *  Description: Returns whether the H/W is ready to go or not. Depending
1808
 *  Description: Returns whether the H/W is ready to go or not. Depending
1360
 *  on whether adapter enable bit was written or not the comparison 
1809
 *  on whether adapter enable bit was written or not the comparison
1361
 *  differs and the calling function passes the input argument flag to
1810
 *  differs and the calling function passes the input argument flag to
1362
 *  indicate this.
1811
 *  indicate this.
1363
 *  Return: 1 If xena is quiescence 
1812
 *  Return: 1 If xena is quiescence
1364
 *          0 If Xena is not quiescence
1813
 *          0 If Xena is not quiescence
1365
 */
1814
 */
1366
1815
1367
static int verify_xena_quiescence(u64 val64, int flag)
1816
static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag)
1368
{
1817
{
1369
	int ret = 0;
1818
	int ret = 0, herc;
1370
	u64 tmp64 = ~((u64) val64);
1819
	u64 tmp64 = ~((u64) val64);
1820
	int rev_id = get_xena_rev_id(sp->pdev);
1371
1821
1822
	herc = (sp->device_type == XFRAME_II_DEVICE);
1372
	if (!
1823
	if (!
1373
	    (tmp64 &
1824
	    (tmp64 &
1374
	     (ADAPTER_STATUS_TDMA_READY | ADAPTER_STATUS_RDMA_READY |
1825
	     (ADAPTER_STATUS_TDMA_READY | ADAPTER_STATUS_RDMA_READY |
Lines 1376-1400 static int verify_xena_quiescence(u64 va Link Here
1376
	      ADAPTER_STATUS_PIC_QUIESCENT | ADAPTER_STATUS_MC_DRAM_READY |
1827
	      ADAPTER_STATUS_PIC_QUIESCENT | ADAPTER_STATUS_MC_DRAM_READY |
1377
	      ADAPTER_STATUS_MC_QUEUES_READY | ADAPTER_STATUS_M_PLL_LOCK |
1828
	      ADAPTER_STATUS_MC_QUEUES_READY | ADAPTER_STATUS_M_PLL_LOCK |
1378
	      ADAPTER_STATUS_P_PLL_LOCK))) {
1829
	      ADAPTER_STATUS_P_PLL_LOCK))) {
1379
		if (flag == FALSE) {
1830
		ret = check_prc_pcc_state(val64, flag, rev_id, herc);
1380
			if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1381
			    ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1382
			     ADAPTER_STATUS_RC_PRC_QUIESCENT)) {
1383
1384
				ret = 1;
1385
1386
			}
1387
		} else {
1388
			if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) ==
1389
			     ADAPTER_STATUS_RMAC_PCC_IDLE) &&
1390
			    (!(val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ||
1391
			     ((val64 & ADAPTER_STATUS_RC_PRC_QUIESCENT) ==
1392
			      ADAPTER_STATUS_RC_PRC_QUIESCENT))) {
1393
1394
				ret = 1;
1395
1396
			}
1397
		}
1398
	}
1831
	}
1399
1832
1400
	return ret;
1833
	return ret;
Lines 1403-1445 static int verify_xena_quiescence(u64 va Link Here
1403
/**
1836
/**
1404
 * fix_mac_address -  Fix for Mac addr problem on Alpha platforms
1837
 * fix_mac_address -  Fix for Mac addr problem on Alpha platforms
1405
 * @sp: Pointer to device specifc structure
1838
 * @sp: Pointer to device specifc structure
1406
 * Description : 
1839
 * Description :
1407
 * New procedure to clear mac address reading  problems on Alpha platforms
1840
 * New procedure to clear mac address reading  problems on Alpha platforms
1408
 *
1841
 *
1409
 */
1842
 */
1410
1843
1411
void fix_mac_address(nic_t * sp)
1844
void fix_mac_address(nic_t * sp)
1412
{
1845
{
1413
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
1846
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
1414
	u64 val64;
1847
	u64 val64;
1415
	int i = 0;
1848
	int i = 0;
1416
1849
1417
	while (fix_mac[i] != END_SIGN) {
1850
	while (fix_mac[i] != END_SIGN) {
1418
		writeq(fix_mac[i++], &bar0->gpio_control);
1851
		writeq(fix_mac[i++], &bar0->gpio_control);
1852
		udelay(10);
1419
		val64 = readq(&bar0->gpio_control);
1853
		val64 = readq(&bar0->gpio_control);
1420
	}
1854
	}
1421
}
1855
}
1422
1856
1423
/**
1857
/**
1424
 *  start_nic - Turns the device on   
1858
 *  start_nic - Turns the device on
1425
 *  @nic : device private variable.
1859
 *  @nic : device private variable.
1426
 *  Description: 
1860
 *  Description:
1427
 *  This function actually turns the device on. Before this  function is 
1861
 *  This function actually turns the device on. Before this  function is
1428
 *  called,all Registers are configured from their reset states 
1862
 *  called,all Registers are configured from their reset states
1429
 *  and shared memory is allocated but the NIC is still quiescent. On 
1863
 *  and shared memory is allocated but the NIC is still quiescent. On
1430
 *  calling this function, the device interrupts are cleared and the NIC is
1864
 *  calling this function, the device interrupts are cleared and the NIC is
1431
 *  literally switched on by writing into the adapter control register.
1865
 *  literally switched on by writing into the adapter control register.
1432
 *  Return Value: 
1866
 *  Return Value:
1433
 *  SUCCESS on success and -1 on failure.
1867
 *  SUCCESS on success and -1 on failure.
1434
 */
1868
 */
1435
1869
1436
static int start_nic(struct s2io_nic *nic)
1870
static int start_nic(struct s2io_nic *nic)
1437
{
1871
{
1438
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
1872
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
1439
	struct net_device *dev = nic->dev;
1873
	struct net_device *dev = nic->dev;
1440
	register u64 val64 = 0;
1874
	register u64 val64 = 0;
1441
	u16 interruptible, i;
1875
	u16 interruptible;
1442
	u16 subid;
1876
	u16 subid, i;
1443
	mac_info_t *mac_control;
1877
	mac_info_t *mac_control;
1444
	struct config_param *config;
1878
	struct config_param *config;
1445
1879
Lines 1447-1457 static int start_nic(struct s2io_nic *ni Link Here
1447
	config = &nic->config;
1881
	config = &nic->config;
1448
1882
1449
	/*  PRC Initialization and configuration */
1883
	/*  PRC Initialization and configuration */
1450
	for (i = 0; i < config->RxRingNum; i++) {
1884
	for (i = 0; i < config->rx_ring_num; i++) {
1451
		writeq((u64) nic->rx_blocks[i][0].block_dma_addr,
1885
		writeq((u64) mac_control->rings[i].rx_blocks[0].block_dma_addr,
1452
		       &bar0->prc_rxd0_n[i]);
1886
		       &bar0->prc_rxd0_n[i]);
1453
1887
1454
		val64 = readq(&bar0->prc_ctrl_n[i]);
1888
		val64 = readq(&bar0->prc_ctrl_n[i]);
1889
		if (nic->config.bimodal)
1890
			val64 |= PRC_CTRL_BIMODAL_INTERRUPT;
1455
#ifndef CONFIG_2BUFF_MODE
1891
#ifndef CONFIG_2BUFF_MODE
1456
		val64 |= PRC_CTRL_RC_ENABLED;
1892
		val64 |= PRC_CTRL_RC_ENABLED;
1457
#else
1893
#else
Lines 1467-1473 static int start_nic(struct s2io_nic *ni Link Here
1467
	writeq(val64, &bar0->rx_pa_cfg);
1903
	writeq(val64, &bar0->rx_pa_cfg);
1468
#endif
1904
#endif
1469
1905
1470
	/* 
1906
	/*
1471
	 * Enabling MC-RLDRAM. After enabling the device, we timeout
1907
	 * Enabling MC-RLDRAM. After enabling the device, we timeout
1472
	 * for around 100ms, which is approximately the time required
1908
	 * for around 100ms, which is approximately the time required
1473
	 * for the device to be ready for operation.
1909
	 * for the device to be ready for operation.
Lines 1477-1504 static int start_nic(struct s2io_nic *ni Link Here
1477
	SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF);
1913
	SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF);
1478
	val64 = readq(&bar0->mc_rldram_mrs);
1914
	val64 = readq(&bar0->mc_rldram_mrs);
1479
1915
1480
	set_current_state(TASK_UNINTERRUPTIBLE);
1916
	msleep(100);	/* Delay by around 100 ms. */
1481
	schedule_timeout(HZ / 10);	/* Delay by around 100 ms. */
1482
1917
1483
	/* Enabling ECC Protection. */
1918
	/* Enabling ECC Protection. */
1484
	val64 = readq(&bar0->adapter_control);
1919
	val64 = readq(&bar0->adapter_control);
1485
	val64 &= ~ADAPTER_ECC_EN;
1920
	val64 &= ~ADAPTER_ECC_EN;
1486
	writeq(val64, &bar0->adapter_control);
1921
	writeq(val64, &bar0->adapter_control);
1487
1922
1488
	/* 
1923
	/*
1489
	 * Clearing any possible Link state change interrupts that 
1924
	 * Clearing any possible Link state change interrupts that
1490
	 * could have popped up just before Enabling the card.
1925
	 * could have popped up just before Enabling the card.
1491
	 */
1926
	 */
1492
	val64 = readq(&bar0->mac_rmac_err_reg);
1927
	val64 = readq(&bar0->mac_rmac_err_reg);
1493
	if (val64)
1928
	if (val64)
1494
		writeq(val64, &bar0->mac_rmac_err_reg);
1929
		writeq(val64, &bar0->mac_rmac_err_reg);
1495
1930
1496
	/* 
1931
	/*
1497
	 * Verify if the device is ready to be enabled, if so enable 
1932
	 * Verify if the device is ready to be enabled, if so enable
1498
	 * it.
1933
	 * it.
1499
	 */
1934
	 */
1500
	val64 = readq(&bar0->adapter_status);
1935
	val64 = readq(&bar0->adapter_status);
1501
	if (!verify_xena_quiescence(val64, nic->device_enabled_once)) {
1936
	if (!verify_xena_quiescence(nic, val64, nic->device_enabled_once)) {
1502
		DBG_PRINT(ERR_DBG, "%s: device is not ready, ", dev->name);
1937
		DBG_PRINT(ERR_DBG, "%s: device is not ready, ", dev->name);
1503
		DBG_PRINT(ERR_DBG, "Adapter status reads: 0x%llx\n",
1938
		DBG_PRINT(ERR_DBG, "Adapter status reads: 0x%llx\n",
1504
			  (unsigned long long) val64);
1939
			  (unsigned long long) val64);
Lines 1506-1521 static int start_nic(struct s2io_nic *ni Link Here
1506
	}
1941
	}
1507
1942
1508
	/*  Enable select interrupts */
1943
	/*  Enable select interrupts */
1509
	interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR | TX_MAC_INTR |
1944
	interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1510
	    RX_MAC_INTR;
1945
	interruptible |= TX_PIC_INTR | RX_PIC_INTR;
1946
	interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1947
1511
	en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS);
1948
	en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS);
1512
1949
1513
	/* 
1950
	/*
1514
	 * With some switches, link might be already up at this point.
1951
	 * With some switches, link might be already up at this point.
1515
	 * Because of this weird behavior, when we enable laser, 
1952
	 * Because of this weird behavior, when we enable laser,
1516
	 * we may not get link. We need to handle this. We cannot 
1953
	 * we may not get link. We need to handle this. We cannot
1517
	 * figure out which switch is misbehaving. So we are forced to 
1954
	 * figure out which switch is misbehaving. So we are forced to
1518
	 * make a global change. 
1955
	 * make a global change.
1519
	 */
1956
	 */
1520
1957
1521
	/* Enabling Laser. */
1958
	/* Enabling Laser. */
Lines 1525-1575 static int start_nic(struct s2io_nic *ni Link Here
1525
1962
1526
	/* SXE-002: Initialize link and activity LED */
1963
	/* SXE-002: Initialize link and activity LED */
1527
	subid = nic->pdev->subsystem_device;
1964
	subid = nic->pdev->subsystem_device;
1528
	if ((subid & 0xFF) >= 0x07) {
1965
	if (((subid & 0xFF) >= 0x07) &&
1966
	    (nic->device_type == XFRAME_I_DEVICE)) {
1529
		val64 = readq(&bar0->gpio_control);
1967
		val64 = readq(&bar0->gpio_control);
1530
		val64 |= 0x0000800000000000ULL;
1968
		val64 |= 0x0000800000000000ULL;
1531
		writeq(val64, &bar0->gpio_control);
1969
		writeq(val64, &bar0->gpio_control);
1532
		val64 = 0x0411040400000000ULL;
1970
		val64 = 0x0411040400000000ULL;
1533
		writeq(val64, (void *) ((u8 *) bar0 + 0x2700));
1971
		writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
1534
	}
1972
	}
1535
1973
1536
	/* 
1974
	/*
1537
	 * Don't see link state interrupts on certain switches, so
1975
	 * Don't see link state interrupts on certain switches, so
1538
	 * directly scheduling a link state task from here.
1976
	 * directly scheduling a link state task from here.
1539
	 */
1977
	 */
1540
#ifdef INIT_TQUEUE
1541
	schedule_task(&nic->set_link_task);
1542
#else
1543
	schedule_work(&nic->set_link_task);
1978
	schedule_work(&nic->set_link_task);
1544
#endif
1545
1546
	/* 
1547
	 * Here we are performing soft reset on XGXS to 
1548
	 * force link down. Since link is already up, we will get
1549
	 * link state change interrupt after this reset
1550
	 */
1551
	SPECIAL_REG_WRITE(0x80010515001E0000ULL, &bar0->dtx_control, UF);
1552
	val64 = readq(&bar0->dtx_control);
1553
	udelay(50);
1554
	SPECIAL_REG_WRITE(0x80010515001E00E0ULL, &bar0->dtx_control, UF);
1555
	val64 = readq(&bar0->dtx_control);
1556
	udelay(50);
1557
	SPECIAL_REG_WRITE(0x80070515001F00E4ULL, &bar0->dtx_control, UF);
1558
	val64 = readq(&bar0->dtx_control);
1559
	udelay(50);
1560
1979
1561
	return SUCCESS;
1980
	return SUCCESS;
1562
}
1981
}
1563
1982
1564
/** 
1983
/**
1565
 *  free_tx_buffers - Free all queued Tx buffers 
1984
 *  free_tx_buffers - Free all queued Tx buffers
1566
 *  @nic : device private variable.
1985
 *  @nic : device private variable.
1567
 *  Description: 
1986
 *  Description:
1568
 *  Free all queued Tx buffers.
1987
 *  Free all queued Tx buffers.
1569
 *  Return Value: void 
1988
 *  Return Value: void
1570
*/
1989
*/
1571
1990
1572
void free_tx_buffers(struct s2io_nic *nic)
1991
static void free_tx_buffers(struct s2io_nic *nic)
1573
{
1992
{
1574
	struct net_device *dev = nic->dev;
1993
	struct net_device *dev = nic->dev;
1575
	struct sk_buff *skb;
1994
	struct sk_buff *skb;
Lines 1577-1615 void free_tx_buffers(struct s2io_nic *ni Link Here
1577
	int i, j;
1996
	int i, j;
1578
	mac_info_t *mac_control;
1997
	mac_info_t *mac_control;
1579
	struct config_param *config;
1998
	struct config_param *config;
1580
	int cnt = 0;
1999
	int cnt = 0, frg_cnt;
1581
2000
1582
	mac_control = &nic->mac_control;
2001
	mac_control = &nic->mac_control;
1583
	config = &nic->config;
2002
	config = &nic->config;
1584
2003
1585
	for (i = 0; i < config->TxFIFONum; i++) {
2004
	for (i = 0; i < config->tx_fifo_num; i++) {
1586
		for (j = 0; j < config->tx_cfg[i].FifoLen - 1; j++) {
2005
		for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
1587
			txdp = (TxD_t *) nic->list_info[i][j].
2006
			txdp = (TxD_t *) mac_control->fifos[i].list_info[j].
1588
			    list_virt_addr;
2007
			    list_virt_addr;
1589
			skb =
2008
			skb =
1590
			    (struct sk_buff *) ((unsigned long) txdp->
2009
			    (struct sk_buff *) ((unsigned long) txdp->
1591
						Host_Control);
2010
						Host_Control);
1592
			if (skb == NULL) {
2011
			if (skb == NULL) {
1593
				memset(txdp, 0, sizeof(TxD_t));
2012
				memset(txdp, 0, sizeof(TxD_t) *
2013
				       config->max_txds);
1594
				continue;
2014
				continue;
1595
			}
2015
			}
2016
			frg_cnt = skb_shinfo(skb)->nr_frags;
2017
			pci_unmap_single(nic->pdev, (dma_addr_t)
2018
					 txdp->Buffer_Pointer,
2019
					 skb->len - skb->data_len,
2020
					 PCI_DMA_TODEVICE);
2021
			if (frg_cnt) {
2022
				TxD_t *temp;
2023
				temp = txdp;
2024
				txdp++;
2025
				for (j = 0; j < frg_cnt; j++, txdp++) {
2026
					skb_frag_t *frag =
2027
					    &skb_shinfo(skb)->frags[j];
2028
					pci_unmap_page(nic->pdev,
2029
						       (dma_addr_t)
2030
						       txdp->
2031
						       Buffer_Pointer,
2032
						       frag->size,
2033
						       PCI_DMA_TODEVICE);
2034
				}
2035
				txdp = temp;
2036
			}
1596
			dev_kfree_skb(skb);
2037
			dev_kfree_skb(skb);
1597
			memset(txdp, 0, sizeof(TxD_t));
2038
			memset(txdp, 0, sizeof(TxD_t) * config->max_txds);
1598
			cnt++;
2039
			cnt++;
1599
		}
2040
		}
1600
		DBG_PRINT(INTR_DBG,
2041
		DBG_PRINT(INTR_DBG,
1601
			  "%s:forcibly freeing %d skbs on FIFO%d\n",
2042
			  "%s:forcibly freeing %d skbs on FIFO%d\n",
1602
			  dev->name, cnt, i);
2043
			  dev->name, cnt, i);
1603
		mac_control->tx_curr_get_info[i].offset = 0;
2044
		mac_control->fifos[i].tx_curr_get_info.offset = 0;
1604
		mac_control->tx_curr_put_info[i].offset = 0;
2045
		mac_control->fifos[i].tx_curr_put_info.offset = 0;
1605
	}
2046
	}
1606
}
2047
}
1607
2048
1608
/**  
2049
/**
1609
 *   stop_nic -  To stop the nic  
2050
 *   stop_nic -  To stop the nic
1610
 *   @nic ; device private variable.
2051
 *   @nic ; device private variable.
1611
 *   Description: 
2052
 *   Description:
1612
 *   This function does exactly the opposite of what the start_nic() 
2053
 *   This function does exactly the opposite of what the start_nic()
1613
 *   function does. This function is called to stop the device.
2054
 *   function does. This function is called to stop the device.
1614
 *   Return Value:
2055
 *   Return Value:
1615
 *   void.
2056
 *   void.
Lines 1617-1623 void free_tx_buffers(struct s2io_nic *ni Link Here
1617
2058
1618
static void stop_nic(struct s2io_nic *nic)
2059
static void stop_nic(struct s2io_nic *nic)
1619
{
2060
{
1620
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
2061
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
1621
	register u64 val64 = 0;
2062
	register u64 val64 = 0;
1622
	u16 interruptible, i;
2063
	u16 interruptible, i;
1623
	mac_info_t *mac_control;
2064
	mac_info_t *mac_control;
Lines 1627-1649 static void stop_nic(struct s2io_nic *ni Link Here
1627
	config = &nic->config;
2068
	config = &nic->config;
1628
2069
1629
	/*  Disable all interrupts */
2070
	/*  Disable all interrupts */
1630
	interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR | TX_MAC_INTR |
2071
	interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1631
	    RX_MAC_INTR;
2072
	interruptible |= TX_PIC_INTR | RX_PIC_INTR;
2073
	interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1632
	en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS);
2074
	en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS);
1633
2075
1634
	/*  Disable PRCs */
2076
	/*  Disable PRCs */
1635
	for (i = 0; i < config->RxRingNum; i++) {
2077
	for (i = 0; i < config->rx_ring_num; i++) {
1636
		val64 = readq(&bar0->prc_ctrl_n[i]);
2078
		val64 = readq(&bar0->prc_ctrl_n[i]);
1637
		val64 &= ~((u64) PRC_CTRL_RC_ENABLED);
2079
		val64 &= ~((u64) PRC_CTRL_RC_ENABLED);
1638
		writeq(val64, &bar0->prc_ctrl_n[i]);
2080
		writeq(val64, &bar0->prc_ctrl_n[i]);
1639
	}
2081
	}
1640
}
2082
}
1641
2083
1642
/**  
2084
/**
1643
 *  fill_rx_buffers - Allocates the Rx side skbs 
2085
 *  fill_rx_buffers - Allocates the Rx side skbs
1644
 *  @nic:  device private variable
2086
 *  @nic:  device private variable
1645
 *  @ring_no: ring number 
2087
 *  @ring_no: ring number
1646
 *  Description: 
2088
 *  Description:
1647
 *  The function allocates Rx side skbs and puts the physical
2089
 *  The function allocates Rx side skbs and puts the physical
1648
 *  address of these buffers into the RxD buffer pointers, so that the NIC
2090
 *  address of these buffers into the RxD buffer pointers, so that the NIC
1649
 *  can DMA the received frame into these locations.
2091
 *  can DMA the received frame into these locations.
Lines 1651-1658 static void stop_nic(struct s2io_nic *ni Link Here
1651
 *  1. single buffer,
2093
 *  1. single buffer,
1652
 *  2. three buffer and
2094
 *  2. three buffer and
1653
 *  3. Five buffer modes.
2095
 *  3. Five buffer modes.
1654
 *  Each mode defines how many fragments the received frame will be split 
2096
 *  Each mode defines how many fragments the received frame will be split
1655
 *  up into by the NIC. The frame is split into L3 header, L4 Header, 
2097
 *  up into by the NIC. The frame is split into L3 header, L4 Header,
1656
 *  L4 payload in three buffer mode and in 5 buffer mode, L4 payload itself
2098
 *  L4 payload in three buffer mode and in 5 buffer mode, L4 payload itself
1657
 *  is split into 3 fragments. As of now only single buffer mode is
2099
 *  is split into 3 fragments. As of now only single buffer mode is
1658
 *  supported.
2100
 *  supported.
Lines 1668-1675 int fill_rx_buffers(struct s2io_nic *nic Link Here
1668
	int off, off1, size, block_no, block_no1;
2110
	int off, off1, size, block_no, block_no1;
1669
	int offset, offset1;
2111
	int offset, offset1;
1670
	u32 alloc_tab = 0;
2112
	u32 alloc_tab = 0;
1671
	u32 alloc_cnt = nic->pkt_cnt[ring_no] -
2113
	u32 alloc_cnt;
1672
	    atomic_read(&nic->rx_bufs_left[ring_no]);
1673
	mac_info_t *mac_control;
2114
	mac_info_t *mac_control;
1674
	struct config_param *config;
2115
	struct config_param *config;
1675
#ifdef CONFIG_2BUFF_MODE
2116
#ifdef CONFIG_2BUFF_MODE
Lines 1682-1708 int fill_rx_buffers(struct s2io_nic *nic Link Here
1682
#ifndef CONFIG_S2IO_NAPI
2123
#ifndef CONFIG_S2IO_NAPI
1683
	unsigned long flags;
2124
	unsigned long flags;
1684
#endif
2125
#endif
2126
	RxD_t *first_rxdp = NULL;
1685
2127
1686
	mac_control = &nic->mac_control;
2128
	mac_control = &nic->mac_control;
1687
	config = &nic->config;
2129
	config = &nic->config;
1688
2130
	alloc_cnt = mac_control->rings[ring_no].pkt_cnt -
1689
	if (frame_len[ring_no]) {
2131
	    atomic_read(&nic->rx_bufs_left[ring_no]);
1690
		if (frame_len[ring_no] > dev->mtu)
2132
	size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE +
1691
			dev->mtu = frame_len[ring_no];
2133
	    HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
1692
		size = frame_len[ring_no] + HEADER_ETHERNET_II_802_3_SIZE +
1693
		    HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
1694
	} else {
1695
		size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE +
1696
		    HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
1697
	}
1698
2134
1699
	while (alloc_tab < alloc_cnt) {
2135
	while (alloc_tab < alloc_cnt) {
1700
		block_no = mac_control->rx_curr_put_info[ring_no].
2136
		block_no = mac_control->rings[ring_no].rx_curr_put_info.
1701
		    block_index;
2137
		    block_index;
1702
		block_no1 = mac_control->rx_curr_get_info[ring_no].
2138
		block_no1 = mac_control->rings[ring_no].rx_curr_get_info.
1703
		    block_index;
2139
		    block_index;
1704
		off = mac_control->rx_curr_put_info[ring_no].offset;
2140
		off = mac_control->rings[ring_no].rx_curr_put_info.offset;
1705
		off1 = mac_control->rx_curr_get_info[ring_no].offset;
2141
		off1 = mac_control->rings[ring_no].rx_curr_get_info.offset;
1706
#ifndef CONFIG_2BUFF_MODE
2142
#ifndef CONFIG_2BUFF_MODE
1707
		offset = block_no * (MAX_RXDS_PER_BLOCK + 1) + off;
2143
		offset = block_no * (MAX_RXDS_PER_BLOCK + 1) + off;
1708
		offset1 = block_no1 * (MAX_RXDS_PER_BLOCK + 1) + off1;
2144
		offset1 = block_no1 * (MAX_RXDS_PER_BLOCK + 1) + off1;
Lines 1711-1717 int fill_rx_buffers(struct s2io_nic *nic Link Here
1711
		offset1 = block_no1 * (MAX_RXDS_PER_BLOCK) + off1;
2147
		offset1 = block_no1 * (MAX_RXDS_PER_BLOCK) + off1;
1712
#endif
2148
#endif
1713
2149
1714
		rxdp = nic->rx_blocks[ring_no][block_no].
2150
		rxdp = mac_control->rings[ring_no].rx_blocks[block_no].
1715
		    block_virt_addr + off;
2151
		    block_virt_addr + off;
1716
		if ((offset == offset1) && (rxdp->Host_Control)) {
2152
		if ((offset == offset1) && (rxdp->Host_Control)) {
1717
			DBG_PRINT(INTR_DBG, "%s: Get and Put", dev->name);
2153
			DBG_PRINT(INTR_DBG, "%s: Get and Put", dev->name);
Lines 1720-1734 int fill_rx_buffers(struct s2io_nic *nic Link Here
1720
		}
2156
		}
1721
#ifndef	CONFIG_2BUFF_MODE
2157
#ifndef	CONFIG_2BUFF_MODE
1722
		if (rxdp->Control_1 == END_OF_BLOCK) {
2158
		if (rxdp->Control_1 == END_OF_BLOCK) {
1723
			mac_control->rx_curr_put_info[ring_no].
2159
			mac_control->rings[ring_no].rx_curr_put_info.
1724
			    block_index++;
2160
			    block_index++;
1725
			mac_control->rx_curr_put_info[ring_no].
2161
			mac_control->rings[ring_no].rx_curr_put_info.
1726
			    block_index %= nic->block_count[ring_no];
2162
			    block_index %= mac_control->rings[ring_no].block_count;
1727
			block_no = mac_control->rx_curr_put_info
2163
			block_no = mac_control->rings[ring_no].rx_curr_put_info.
1728
			    [ring_no].block_index;
2164
				block_index;
1729
			off++;
2165
			off++;
1730
			off %= (MAX_RXDS_PER_BLOCK + 1);
2166
			off %= (MAX_RXDS_PER_BLOCK + 1);
1731
			mac_control->rx_curr_put_info[ring_no].offset =
2167
			mac_control->rings[ring_no].rx_curr_put_info.offset =
1732
			    off;
2168
			    off;
1733
			rxdp = (RxD_t *) ((unsigned long) rxdp->Control_2);
2169
			rxdp = (RxD_t *) ((unsigned long) rxdp->Control_2);
1734
			DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n",
2170
			DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n",
Lines 1736-1764 int fill_rx_buffers(struct s2io_nic *nic Link Here
1736
		}
2172
		}
1737
#ifndef CONFIG_S2IO_NAPI
2173
#ifndef CONFIG_S2IO_NAPI
1738
		spin_lock_irqsave(&nic->put_lock, flags);
2174
		spin_lock_irqsave(&nic->put_lock, flags);
1739
		nic->put_pos = (block_no * (MAX_RXDS_PER_BLOCK + 1)) + off;
2175
		mac_control->rings[ring_no].put_pos =
2176
		    (block_no * (MAX_RXDS_PER_BLOCK + 1)) + off;
1740
		spin_unlock_irqrestore(&nic->put_lock, flags);
2177
		spin_unlock_irqrestore(&nic->put_lock, flags);
1741
#endif
2178
#endif
1742
#else
2179
#else
1743
		if (rxdp->Host_Control == END_OF_BLOCK) {
2180
		if (rxdp->Host_Control == END_OF_BLOCK) {
1744
			mac_control->rx_curr_put_info[ring_no].
2181
			mac_control->rings[ring_no].rx_curr_put_info.
1745
			    block_index++;
2182
			    block_index++;
1746
			mac_control->rx_curr_put_info[ring_no].
2183
			mac_control->rings[ring_no].rx_curr_put_info.block_index
1747
			    block_index %= nic->block_count[ring_no];
2184
			    %= mac_control->rings[ring_no].block_count;
1748
			block_no = mac_control->rx_curr_put_info
2185
			block_no = mac_control->rings[ring_no].rx_curr_put_info
1749
			    [ring_no].block_index;
2186
			    .block_index;
1750
			off = 0;
2187
			off = 0;
1751
			DBG_PRINT(INTR_DBG, "%s: block%d at: 0x%llx\n",
2188
			DBG_PRINT(INTR_DBG, "%s: block%d at: 0x%llx\n",
1752
				  dev->name, block_no,
2189
				  dev->name, block_no,
1753
				  (unsigned long long) rxdp->Control_1);
2190
				  (unsigned long long) rxdp->Control_1);
1754
			mac_control->rx_curr_put_info[ring_no].offset =
2191
			mac_control->rings[ring_no].rx_curr_put_info.offset =
1755
			    off;
2192
			    off;
1756
			rxdp = nic->rx_blocks[ring_no][block_no].
2193
			rxdp = mac_control->rings[ring_no].rx_blocks[block_no].
1757
			    block_virt_addr;
2194
			    block_virt_addr;
1758
		}
2195
		}
1759
#ifndef CONFIG_S2IO_NAPI
2196
#ifndef CONFIG_S2IO_NAPI
1760
		spin_lock_irqsave(&nic->put_lock, flags);
2197
		spin_lock_irqsave(&nic->put_lock, flags);
1761
		nic->put_pos = (block_no * (MAX_RXDS_PER_BLOCK + 1)) + off;
2198
		mac_control->rings[ring_no].put_pos = (block_no *
2199
					 (MAX_RXDS_PER_BLOCK + 1)) + off;
1762
		spin_unlock_irqrestore(&nic->put_lock, flags);
2200
		spin_unlock_irqrestore(&nic->put_lock, flags);
1763
#endif
2201
#endif
1764
#endif
2202
#endif
Lines 1769-1795 int fill_rx_buffers(struct s2io_nic *nic Link Here
1769
		if (rxdp->Control_2 & BIT(0))
2207
		if (rxdp->Control_2 & BIT(0))
1770
#endif
2208
#endif
1771
		{
2209
		{
1772
			mac_control->rx_curr_put_info[ring_no].
2210
			mac_control->rings[ring_no].rx_curr_put_info.
1773
			    offset = off;
2211
			    offset = off;
1774
			goto end;
2212
			goto end;
1775
		}
2213
		}
1776
#ifdef	CONFIG_2BUFF_MODE
2214
#ifdef	CONFIG_2BUFF_MODE
1777
		/* 
2215
		/*
1778
		 * RxDs Spanning cache lines will be replenished only 
2216
		 * RxDs Spanning cache lines will be replenished only
1779
		 * if the succeeding RxD is also owned by Host. It 
2217
		 * if the succeeding RxD is also owned by Host. It
1780
		 * will always be the ((8*i)+3) and ((8*i)+6) 
2218
		 * will always be the ((8*i)+3) and ((8*i)+6)
1781
		 * descriptors for the 48 byte descriptor. The offending 
2219
		 * descriptors for the 48 byte descriptor. The offending
1782
		 * decsriptor is of-course the 3rd descriptor.
2220
		 * decsriptor is of-course the 3rd descriptor.
1783
		 */
2221
		 */
1784
		rxdpphys = nic->rx_blocks[ring_no][block_no].
2222
		rxdpphys = mac_control->rings[ring_no].rx_blocks[block_no].
1785
		    block_dma_addr + (off * sizeof(RxD_t));
2223
		    block_dma_addr + (off * sizeof(RxD_t));
1786
		if (((u64) (rxdpphys)) % 128 > 80) {
2224
		if (((u64) (rxdpphys)) % 128 > 80) {
1787
			rxdpnext = nic->rx_blocks[ring_no][block_no].
2225
			rxdpnext = mac_control->rings[ring_no].rx_blocks[block_no].
1788
			    block_virt_addr + (off + 1);
2226
			    block_virt_addr + (off + 1);
1789
			if (rxdpnext->Host_Control == END_OF_BLOCK) {
2227
			if (rxdpnext->Host_Control == END_OF_BLOCK) {
1790
				nextblk = (block_no + 1) %
2228
				nextblk = (block_no + 1) %
1791
				    (nic->block_count[ring_no]);
2229
				    (mac_control->rings[ring_no].block_count);
1792
				rxdpnext = nic->rx_blocks[ring_no]
2230
				rxdpnext = mac_control->rings[ring_no].rx_blocks
1793
				    [nextblk].block_virt_addr;
2231
				    [nextblk].block_virt_addr;
1794
			}
2232
			}
1795
			if (rxdpnext->Control_2 & BIT(0))
2233
			if (rxdpnext->Control_2 & BIT(0))
Lines 1798-1835 int fill_rx_buffers(struct s2io_nic *nic Link Here
1798
#endif
2236
#endif
1799
2237
1800
#ifndef	CONFIG_2BUFF_MODE
2238
#ifndef	CONFIG_2BUFF_MODE
1801
		skb = dev_alloc_skb(size + HEADER_ALIGN_LAYER_3);
2239
		skb = dev_alloc_skb(size + NET_IP_ALIGN);
1802
#else
2240
#else
1803
		skb = dev_alloc_skb(dev->mtu + ALIGN_SIZE +
2241
		skb = dev_alloc_skb(dev->mtu + ALIGN_SIZE + BUF0_LEN + 4);
1804
				    /*BUF0_LEN + */ 22);
1805
#endif
2242
#endif
1806
		if (!skb) {
2243
		if (!skb) {
1807
			DBG_PRINT(ERR_DBG, "%s: Out of ", dev->name);
2244
			DBG_PRINT(ERR_DBG, "%s: Out of ", dev->name);
1808
			DBG_PRINT(ERR_DBG, "memory to allocate SKBs\n");
2245
			DBG_PRINT(ERR_DBG, "memory to allocate SKBs\n");
2246
			if (first_rxdp) {
2247
				wmb();
2248
				first_rxdp->Control_1 |= RXD_OWN_XENA;
2249
			}
1809
			return -ENOMEM;
2250
			return -ENOMEM;
1810
		}
2251
		}
1811
#ifndef	CONFIG_2BUFF_MODE
2252
#ifndef	CONFIG_2BUFF_MODE
1812
		skb_reserve(skb, HEADER_ALIGN_LAYER_3);
2253
		skb_reserve(skb, NET_IP_ALIGN);
1813
		memset(rxdp, 0, sizeof(RxD_t));
2254
		memset(rxdp, 0, sizeof(RxD_t));
1814
		rxdp->Buffer0_ptr = pci_map_single
2255
		rxdp->Buffer0_ptr = pci_map_single
1815
		    (nic->pdev, skb->data, size, PCI_DMA_FROMDEVICE);
2256
		    (nic->pdev, skb->data, size, PCI_DMA_FROMDEVICE);
1816
		rxdp->Control_2 &= (~MASK_BUFFER0_SIZE);
2257
		rxdp->Control_2 &= (~MASK_BUFFER0_SIZE);
1817
		rxdp->Control_2 |= SET_BUFFER0_SIZE(size);
2258
		rxdp->Control_2 |= SET_BUFFER0_SIZE(size);
1818
		rxdp->Host_Control = (unsigned long) (skb);
2259
		rxdp->Host_Control = (unsigned long) (skb);
1819
		rxdp->Control_1 |= RXD_OWN_XENA;
2260
		if (alloc_tab & ((1 << rxsync_frequency) - 1))
2261
			rxdp->Control_1 |= RXD_OWN_XENA;
1820
		off++;
2262
		off++;
1821
		off %= (MAX_RXDS_PER_BLOCK + 1);
2263
		off %= (MAX_RXDS_PER_BLOCK + 1);
1822
		mac_control->rx_curr_put_info[ring_no].offset = off;
2264
		mac_control->rings[ring_no].rx_curr_put_info.offset = off;
1823
#else
2265
#else
1824
		ba = &nic->ba[ring_no][block_no][off];
2266
		ba = &mac_control->rings[ring_no].ba[block_no][off];
1825
		tmp = (u64) skb->data;
2267
		skb_reserve(skb, BUF0_LEN);
1826
		tmp += ALIGN_SIZE;
2268
		tmp = ((unsigned long) skb->data & ALIGN_SIZE);
1827
		tmp &= ~ALIGN_SIZE;
2269
		if (tmp)
1828
		skb->data = (void *) tmp;
2270
			skb_reserve(skb, (ALIGN_SIZE + 1) - tmp);
1829
2271
1830
		memset(rxdp, 0, sizeof(RxD_t));
2272
		memset(rxdp, 0, sizeof(RxD_t));
1831
		rxdp->Buffer2_ptr = pci_map_single
2273
		rxdp->Buffer2_ptr = pci_map_single
1832
		    (nic->pdev, skb->data, dev->mtu + 22,
2274
		    (nic->pdev, skb->data, dev->mtu + BUF0_LEN + 4,
1833
		     PCI_DMA_FROMDEVICE);
2275
		     PCI_DMA_FROMDEVICE);
1834
		rxdp->Buffer0_ptr =
2276
		rxdp->Buffer0_ptr =
1835
		    pci_map_single(nic->pdev, ba->ba_0, BUF0_LEN,
2277
		    pci_map_single(nic->pdev, ba->ba_0, BUF0_LEN,
Lines 1838-1864 int fill_rx_buffers(struct s2io_nic *nic Link Here
1838
		    pci_map_single(nic->pdev, ba->ba_1, BUF1_LEN,
2280
		    pci_map_single(nic->pdev, ba->ba_1, BUF1_LEN,
1839
				   PCI_DMA_FROMDEVICE);
2281
				   PCI_DMA_FROMDEVICE);
1840
2282
1841
		rxdp->Control_2 = SET_BUFFER2_SIZE(dev->mtu + 22);
2283
		rxdp->Control_2 = SET_BUFFER2_SIZE(dev->mtu + 4);
1842
		rxdp->Control_2 |= SET_BUFFER0_SIZE(BUF0_LEN);
2284
		rxdp->Control_2 |= SET_BUFFER0_SIZE(BUF0_LEN);
1843
		rxdp->Control_2 |= SET_BUFFER1_SIZE(1);	/* dummy. */
2285
		rxdp->Control_2 |= SET_BUFFER1_SIZE(1);	/* dummy. */
1844
		rxdp->Control_2 |= BIT(0);	/* Set Buffer_Empty bit. */
2286
		rxdp->Control_2 |= BIT(0);	/* Set Buffer_Empty bit. */
1845
		rxdp->Host_Control = (u64) ((unsigned long) (skb));
2287
		rxdp->Host_Control = (u64) ((unsigned long) (skb));
1846
		rxdp->Control_1 |= RXD_OWN_XENA;
2288
		if (alloc_tab & ((1 << rxsync_frequency) - 1))
2289
			rxdp->Control_1 |= RXD_OWN_XENA;
1847
		off++;
2290
		off++;
1848
		mac_control->rx_curr_put_info[ring_no].offset = off;
2291
		mac_control->rings[ring_no].rx_curr_put_info.offset = off;
1849
#endif
2292
#endif
2293
		rxdp->Control_2 |= SET_RXD_MARKER;
2294
2295
		if (!(alloc_tab & ((1 << rxsync_frequency) - 1))) {
2296
			if (first_rxdp) {
2297
				wmb();
2298
				first_rxdp->Control_1 |= RXD_OWN_XENA;
2299
			}
2300
			first_rxdp = rxdp;
2301
		}
1850
		atomic_inc(&nic->rx_bufs_left[ring_no]);
2302
		atomic_inc(&nic->rx_bufs_left[ring_no]);
1851
		alloc_tab++;
2303
		alloc_tab++;
1852
	}
2304
	}
1853
2305
1854
      end:
2306
      end:
2307
	/* Transfer ownership of first descriptor to adapter just before
2308
	 * exiting. Before that, use memory barrier so that ownership
2309
	 * and other fields are seen by adapter correctly.
2310
	 */
2311
	if (first_rxdp) {
2312
		wmb();
2313
		first_rxdp->Control_1 |= RXD_OWN_XENA;
2314
	}
2315
1855
	return SUCCESS;
2316
	return SUCCESS;
1856
}
2317
}
1857
2318
1858
/**
2319
/**
1859
 *  free_rx_buffers - Frees all Rx buffers   
2320
 *  free_rx_buffers - Frees all Rx buffers
1860
 *  @sp: device private variable.
2321
 *  @sp: device private variable.
1861
 *  Description: 
2322
 *  Description:
1862
 *  This function will free all Rx buffers allocated by host.
2323
 *  This function will free all Rx buffers allocated by host.
1863
 *  Return Value:
2324
 *  Return Value:
1864
 *  NONE.
2325
 *  NONE.
Lines 1879-1888 static void free_rx_buffers(struct s2io_ Link Here
1879
	mac_control = &sp->mac_control;
2340
	mac_control = &sp->mac_control;
1880
	config = &sp->config;
2341
	config = &sp->config;
1881
2342
1882
	for (i = 0; i < config->RxRingNum; i++) {
2343
	for (i = 0; i < config->rx_ring_num; i++) {
1883
		for (j = 0, blk = 0; j < config->rx_cfg[i].NumRxd; j++) {
2344
		for (j = 0, blk = 0; j < config->rx_cfg[i].num_rxd; j++) {
1884
			off = j % (MAX_RXDS_PER_BLOCK + 1);
2345
			off = j % (MAX_RXDS_PER_BLOCK + 1);
1885
			rxdp = sp->rx_blocks[i][blk].block_virt_addr + off;
2346
			rxdp = mac_control->rings[i].rx_blocks[blk].
2347
				block_virt_addr + off;
1886
2348
1887
#ifndef CONFIG_2BUFF_MODE
2349
#ifndef CONFIG_2BUFF_MODE
1888
			if (rxdp->Control_1 == END_OF_BLOCK) {
2350
			if (rxdp->Control_1 == END_OF_BLOCK) {
Lines 1917-1923 static void free_rx_buffers(struct s2io_ Link Here
1917
						 HEADER_SNAP_SIZE,
2379
						 HEADER_SNAP_SIZE,
1918
						 PCI_DMA_FROMDEVICE);
2380
						 PCI_DMA_FROMDEVICE);
1919
#else
2381
#else
1920
				ba = &sp->ba[i][blk][off];
2382
				ba = &mac_control->rings[i].ba[blk][off];
1921
				pci_unmap_single(sp->pdev, (dma_addr_t)
2383
				pci_unmap_single(sp->pdev, (dma_addr_t)
1922
						 rxdp->Buffer0_ptr,
2384
						 rxdp->Buffer0_ptr,
1923
						 BUF0_LEN,
2385
						 BUF0_LEN,
Lines 1928-1934 static void free_rx_buffers(struct s2io_ Link Here
1928
						 PCI_DMA_FROMDEVICE);
2390
						 PCI_DMA_FROMDEVICE);
1929
				pci_unmap_single(sp->pdev, (dma_addr_t)
2391
				pci_unmap_single(sp->pdev, (dma_addr_t)
1930
						 rxdp->Buffer2_ptr,
2392
						 rxdp->Buffer2_ptr,
1931
						 dev->mtu + 22,
2393
						 dev->mtu + BUF0_LEN + 4,
1932
						 PCI_DMA_FROMDEVICE);
2394
						 PCI_DMA_FROMDEVICE);
1933
#endif
2395
#endif
1934
				dev_kfree_skb(skb);
2396
				dev_kfree_skb(skb);
Lines 1937-1946 static void free_rx_buffers(struct s2io_ Link Here
1937
			}
2399
			}
1938
			memset(rxdp, 0, sizeof(RxD_t));
2400
			memset(rxdp, 0, sizeof(RxD_t));
1939
		}
2401
		}
1940
		mac_control->rx_curr_put_info[i].block_index = 0;
2402
		mac_control->rings[i].rx_curr_put_info.block_index = 0;
1941
		mac_control->rx_curr_get_info[i].block_index = 0;
2403
		mac_control->rings[i].rx_curr_get_info.block_index = 0;
1942
		mac_control->rx_curr_put_info[i].offset = 0;
2404
		mac_control->rings[i].rx_curr_put_info.offset = 0;
1943
		mac_control->rx_curr_get_info[i].offset = 0;
2405
		mac_control->rings[i].rx_curr_get_info.offset = 0;
1944
		atomic_set(&sp->rx_bufs_left[i], 0);
2406
		atomic_set(&sp->rx_bufs_left[i], 0);
1945
		DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n",
2407
		DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n",
1946
			  dev->name, buf_cnt, i);
2408
			  dev->name, buf_cnt, i);
Lines 1950-1956 static void free_rx_buffers(struct s2io_ Link Here
1950
/**
2412
/**
1951
 * s2io_poll - Rx interrupt handler for NAPI support
2413
 * s2io_poll - Rx interrupt handler for NAPI support
1952
 * @dev : pointer to the device structure.
2414
 * @dev : pointer to the device structure.
1953
 * @budget : The number of packets that were budgeted to be processed 
2415
 * @budget : The number of packets that were budgeted to be processed
1954
 * during  one pass through the 'Poll" function.
2416
 * during  one pass through the 'Poll" function.
1955
 * Description:
2417
 * Description:
1956
 * Comes into picture only if NAPI support has been incorporated. It does
2418
 * Comes into picture only if NAPI support has been incorporated. It does
Lines 1960-2131 static void free_rx_buffers(struct s2io_ Link Here
1960
 * 0 on success and 1 if there are No Rx packets to be processed.
2422
 * 0 on success and 1 if there are No Rx packets to be processed.
1961
 */
2423
 */
1962
2424
1963
#ifdef CONFIG_S2IO_NAPI
2425
#if defined(CONFIG_S2IO_NAPI)
1964
static int s2io_poll(struct net_device *dev, int *budget)
2426
static int s2io_poll(struct net_device *dev, int *budget)
1965
{
2427
{
1966
	nic_t *nic = dev->priv;
2428
	nic_t *nic = dev->priv;
1967
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
2429
	int pkt_cnt = 0, org_pkts_to_process;
1968
	int pkts_to_process = *budget, pkt_cnt = 0;
1969
	register u64 val64 = 0;
1970
	rx_curr_get_info_t get_info, put_info;
1971
	int i, get_block, put_block, get_offset, put_offset, ring_bufs;
1972
#ifndef CONFIG_2BUFF_MODE
1973
	u16 val16, cksum;
1974
#endif
1975
	struct sk_buff *skb;
1976
	RxD_t *rxdp;
1977
	mac_info_t *mac_control;
2430
	mac_info_t *mac_control;
1978
	struct config_param *config;
2431
	struct config_param *config;
1979
#ifdef CONFIG_2BUFF_MODE
2432
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
1980
	buffAdd_t *ba;
2433
	u64 val64;
1981
#endif
2434
	int i;
1982
2435
2436
	atomic_inc(&nic->isr_cnt);
1983
	mac_control = &nic->mac_control;
2437
	mac_control = &nic->mac_control;
1984
	config = &nic->config;
2438
	config = &nic->config;
1985
2439
1986
	if (pkts_to_process > dev->quota)
2440
	nic->pkts_to_process = *budget;
1987
		pkts_to_process = dev->quota;
2441
	if (nic->pkts_to_process > dev->quota)
2442
		nic->pkts_to_process = dev->quota;
2443
	org_pkts_to_process = nic->pkts_to_process;
1988
2444
1989
	val64 = readq(&bar0->rx_traffic_int);
2445
	val64 = readq(&bar0->rx_traffic_int);
1990
	writeq(val64, &bar0->rx_traffic_int);
2446
	writeq(val64, &bar0->rx_traffic_int);
1991
2447
1992
	for (i = 0; i < config->RxRingNum; i++) {
2448
	for (i = 0; i < config->rx_ring_num; i++) {
1993
		get_info = mac_control->rx_curr_get_info[i];
2449
		rx_intr_handler(&mac_control->rings[i]);
1994
		get_block = get_info.block_index;
2450
		pkt_cnt = org_pkts_to_process - nic->pkts_to_process;
1995
		put_info = mac_control->rx_curr_put_info[i];
2451
		if (!nic->pkts_to_process) {
1996
		put_block = put_info.block_index;
2452
			/* Quota for the current iteration has been met */
1997
		ring_bufs = config->rx_cfg[i].NumRxd;
2453
			goto no_rx;
1998
		rxdp = nic->rx_blocks[i][get_block].block_virt_addr +
1999
		    get_info.offset;
2000
#ifndef	CONFIG_2BUFF_MODE
2001
		get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2002
		    get_info.offset;
2003
#ifndef CONFIG_S2IO_NAPI
2004
		spin_lock(&nic->put_lock);
2005
		put_offset = nic->put_pos;
2006
		spin_unlock(&nic->put_lock);
2007
#else
2008
		put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
2009
		    put_info.offset;
2010
#endif
2011
		while ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
2012
		       (((get_offset + 1) % ring_bufs) != put_offset)) {
2013
			if (--pkts_to_process < 0) {
2014
				goto no_rx;
2015
			}
2016
			if (rxdp->Control_1 == END_OF_BLOCK) {
2017
				rxdp =
2018
				    (RxD_t *) ((unsigned long) rxdp->
2019
					       Control_2);
2020
				get_info.offset++;
2021
				get_info.offset %=
2022
				    (MAX_RXDS_PER_BLOCK + 1);
2023
				get_block++;
2024
				get_block %= nic->block_count[i];
2025
				mac_control->rx_curr_get_info[i].
2026
				    offset = get_info.offset;
2027
				mac_control->rx_curr_get_info[i].
2028
				    block_index = get_block;
2029
				continue;
2030
			}
2031
			get_offset =
2032
			    (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2033
			    get_info.offset;
2034
			skb =
2035
			    (struct sk_buff *) ((unsigned long) rxdp->
2036
						Host_Control);
2037
			if (skb == NULL) {
2038
				DBG_PRINT(ERR_DBG, "%s: The skb is ",
2039
					  dev->name);
2040
				DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2041
				goto no_rx;
2042
			}
2043
			val64 = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
2044
			val16 = (u16) (val64 >> 48);
2045
			cksum = RXD_GET_L4_CKSUM(rxdp->Control_1);
2046
			pci_unmap_single(nic->pdev, (dma_addr_t)
2047
					 rxdp->Buffer0_ptr,
2048
					 dev->mtu +
2049
					 HEADER_ETHERNET_II_802_3_SIZE +
2050
					 HEADER_802_2_SIZE +
2051
					 HEADER_SNAP_SIZE,
2052
					 PCI_DMA_FROMDEVICE);
2053
			rx_osm_handler(nic, val16, rxdp, i);
2054
			pkt_cnt++;
2055
			get_info.offset++;
2056
			get_info.offset %= (MAX_RXDS_PER_BLOCK + 1);
2057
			rxdp =
2058
			    nic->rx_blocks[i][get_block].block_virt_addr +
2059
			    get_info.offset;
2060
			mac_control->rx_curr_get_info[i].offset =
2061
			    get_info.offset;
2062
		}
2063
#else
2064
		get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2065
		    get_info.offset;
2066
#ifndef CONFIG_S2IO_NAPI
2067
		spin_lock(&nic->put_lock);
2068
		put_offset = nic->put_pos;
2069
		spin_unlock(&nic->put_lock);
2070
#else
2071
		put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
2072
		    put_info.offset;
2073
#endif
2074
		while (((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
2075
			!(rxdp->Control_2 & BIT(0))) &&
2076
		       (((get_offset + 1) % ring_bufs) != put_offset)) {
2077
			if (--pkts_to_process < 0) {
2078
				goto no_rx;
2079
			}
2080
			skb = (struct sk_buff *) ((unsigned long)
2081
						  rxdp->Host_Control);
2082
			if (skb == NULL) {
2083
				DBG_PRINT(ERR_DBG, "%s: The skb is ",
2084
					  dev->name);
2085
				DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2086
				goto no_rx;
2087
			}
2088
2089
			pci_unmap_single(nic->pdev, (dma_addr_t)
2090
					 rxdp->Buffer0_ptr,
2091
					 BUF0_LEN, PCI_DMA_FROMDEVICE);
2092
			pci_unmap_single(nic->pdev, (dma_addr_t)
2093
					 rxdp->Buffer1_ptr,
2094
					 BUF1_LEN, PCI_DMA_FROMDEVICE);
2095
			pci_unmap_single(nic->pdev, (dma_addr_t)
2096
					 rxdp->Buffer2_ptr,
2097
					 dev->mtu + 22,
2098
					 PCI_DMA_FROMDEVICE);
2099
			ba = &nic->ba[i][get_block][get_info.offset];
2100
2101
			rx_osm_handler(nic, rxdp, i, ba);
2102
2103
			get_info.offset++;
2104
			mac_control->rx_curr_get_info[i].offset =
2105
			    get_info.offset;
2106
			rxdp =
2107
			    nic->rx_blocks[i][get_block].block_virt_addr +
2108
			    get_info.offset;
2109
2110
			if (get_info.offset &&
2111
			    (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
2112
				get_info.offset = 0;
2113
				mac_control->rx_curr_get_info[i].
2114
				    offset = get_info.offset;
2115
				get_block++;
2116
				get_block %= nic->block_count[i];
2117
				mac_control->rx_curr_get_info[i].
2118
				    block_index = get_block;
2119
				rxdp =
2120
				    nic->rx_blocks[i][get_block].
2121
				    block_virt_addr;
2122
			}
2123
			get_offset =
2124
			    (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2125
			    get_info.offset;
2126
			pkt_cnt++;
2127
		}
2454
		}
2128
#endif
2129
	}
2455
	}
2130
	if (!pkt_cnt)
2456
	if (!pkt_cnt)
2131
		pkt_cnt = 1;
2457
		pkt_cnt = 1;
Lines 2134-2140 static int s2io_poll(struct net_device * Link Here
2134
	*budget -= pkt_cnt;
2460
	*budget -= pkt_cnt;
2135
	netif_rx_complete(dev);
2461
	netif_rx_complete(dev);
2136
2462
2137
	for (i = 0; i < config->RxRingNum; i++) {
2463
	for (i = 0; i < config->rx_ring_num; i++) {
2138
		if (fill_rx_buffers(nic, i) == -ENOMEM) {
2464
		if (fill_rx_buffers(nic, i) == -ENOMEM) {
2139
			DBG_PRINT(ERR_DBG, "%s:Out of memory", dev->name);
2465
			DBG_PRINT(ERR_DBG, "%s:Out of memory", dev->name);
2140
			DBG_PRINT(ERR_DBG, " in Rx Poll!!\n");
2466
			DBG_PRINT(ERR_DBG, " in Rx Poll!!\n");
Lines 2143-2438 static int s2io_poll(struct net_device * Link Here
2143
	}
2469
	}
2144
	/* Re enable the Rx interrupts. */
2470
	/* Re enable the Rx interrupts. */
2145
	en_dis_able_nic_intrs(nic, RX_TRAFFIC_INTR, ENABLE_INTRS);
2471
	en_dis_able_nic_intrs(nic, RX_TRAFFIC_INTR, ENABLE_INTRS);
2472
	atomic_dec(&nic->isr_cnt);
2146
	return 0;
2473
	return 0;
2147
2474
2148
      no_rx:
2475
no_rx:
2149
	dev->quota -= pkt_cnt;
2476
	dev->quota -= pkt_cnt;
2150
	*budget -= pkt_cnt;
2477
	*budget -= pkt_cnt;
2151
2478
2152
	for (i = 0; i < config->RxRingNum; i++) {
2479
	for (i = 0; i < config->rx_ring_num; i++) {
2153
		if (fill_rx_buffers(nic, i) == -ENOMEM) {
2480
		if (fill_rx_buffers(nic, i) == -ENOMEM) {
2154
			DBG_PRINT(ERR_DBG, "%s:Out of memory", dev->name);
2481
			DBG_PRINT(ERR_DBG, "%s:Out of memory", dev->name);
2155
			DBG_PRINT(ERR_DBG, " in Rx Poll!!\n");
2482
			DBG_PRINT(ERR_DBG, " in Rx Poll!!\n");
2156
			break;
2483
			break;
2157
		}
2484
		}
2158
	}
2485
	}
2486
	atomic_dec(&nic->isr_cnt);
2159
	return 1;
2487
	return 1;
2160
}
2488
}
2161
#else
2489
#endif
2162
/**  
2490
2491
/**
2163
 *  rx_intr_handler - Rx interrupt handler
2492
 *  rx_intr_handler - Rx interrupt handler
2164
 *  @nic: device private variable.
2493
 *  @nic: device private variable.
2165
 *  Description: 
2494
 *  Description:
2166
 *  If the interrupt is because of a received frame or if the 
2495
 *  If the interrupt is because of a received frame or if the
2167
 *  receive ring contains fresh as yet un-processed frames,this function is
2496
 *  receive ring contains fresh as yet un-processed frames,this function is
2168
 *  called. It picks out the RxD at which place the last Rx processing had 
2497
 *  called. It picks out the RxD at which place the last Rx processing had
2169
 *  stopped and sends the skb to the OSM's Rx handler and then increments 
2498
 *  stopped and sends the skb to the OSM's Rx handler and then increments
2170
 *  the offset.
2499
 *  the offset.
2171
 *  Return Value:
2500
 *  Return Value:
2172
 *  NONE.
2501
 *  NONE.
2173
 */
2502
 */
2174
2503
static void rx_intr_handler(ring_info_t *ring_data)
2175
static void rx_intr_handler(struct s2io_nic *nic)
2176
{
2504
{
2505
	nic_t *nic = ring_data->nic;
2177
	struct net_device *dev = (struct net_device *) nic->dev;
2506
	struct net_device *dev = (struct net_device *) nic->dev;
2178
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
2507
	int get_block, get_offset, put_block, put_offset, ring_bufs;
2179
	rx_curr_get_info_t get_info, put_info;
2508
	rx_curr_get_info_t get_info, put_info;
2180
	RxD_t *rxdp;
2509
	RxD_t *rxdp;
2181
	struct sk_buff *skb;
2510
	struct sk_buff *skb;
2182
#ifndef CONFIG_2BUFF_MODE
2511
#ifndef CONFIG_S2IO_NAPI
2183
	u16 val16, cksum;
2512
	int pkt_cnt = 0;
2184
#endif
2185
	register u64 val64 = 0;
2186
	int get_block, get_offset, put_block, put_offset, ring_bufs;
2187
	int i, pkt_cnt = 0;
2188
	mac_info_t *mac_control;
2189
	struct config_param *config;
2190
#ifdef CONFIG_2BUFF_MODE
2191
	buffAdd_t *ba;
2192
#endif
2513
#endif
2514
	spin_lock(&nic->rx_lock);
2515
	if (atomic_read(&nic->card_state) == CARD_DOWN) {
2516
		DBG_PRINT(INTR_DBG, "%s: %s going down for reset\n",
2517
			  __FUNCTION__, dev->name);
2518
		spin_unlock(&nic->rx_lock);
2519
		return;
2520
	}
2193
2521
2194
	mac_control = &nic->mac_control;
2522
	get_info = ring_data->rx_curr_get_info;
2195
	config = &nic->config;
2523
	get_block = get_info.block_index;
2196
2524
	put_info = ring_data->rx_curr_put_info;
2197
	/* 
2525
	put_block = put_info.block_index;
2198
	 * rx_traffic_int reg is an R1 register, hence we read and write back 
2526
	ring_bufs = get_info.ring_len+1;
2199
	 * the samevalue in the register to clear it.
2527
	rxdp = ring_data->rx_blocks[get_block].block_virt_addr +
2200
	 */
2201
	val64 = readq(&bar0->rx_traffic_int);
2202
	writeq(val64, &bar0->rx_traffic_int);
2203
2204
	for (i = 0; i < config->RxRingNum; i++) {
2205
		get_info = mac_control->rx_curr_get_info[i];
2206
		get_block = get_info.block_index;
2207
		put_info = mac_control->rx_curr_put_info[i];
2208
		put_block = put_info.block_index;
2209
		ring_bufs = config->rx_cfg[i].NumRxd;
2210
		rxdp = nic->rx_blocks[i][get_block].block_virt_addr +
2211
		    get_info.offset;
2212
#ifndef	CONFIG_2BUFF_MODE
2213
		get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2214
		    get_info.offset;
2528
		    get_info.offset;
2529
	get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2530
		get_info.offset;
2215
#ifndef CONFIG_S2IO_NAPI
2531
#ifndef CONFIG_S2IO_NAPI
2216
		spin_lock(&nic->put_lock);
2532
	spin_lock(&nic->put_lock);
2217
		put_offset = nic->put_pos;
2533
	put_offset = ring_data->put_pos;
2218
		spin_unlock(&nic->put_lock);
2534
	spin_unlock(&nic->put_lock);
2535
#else
2536
	put_offset = (put_block * (MAX_RXDS_PER_BLOCK + 1)) +
2537
		put_info.offset;
2219
#endif
2538
#endif
2220
		while ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
2539
	while (RXD_IS_UP2DT(rxdp) &&
2221
		       (((get_offset + 1) % ring_bufs) != put_offset)) {
2540
	       (((get_offset + 1) % ring_bufs) != put_offset)) {
2222
			if (rxdp->Control_1 == END_OF_BLOCK) {
2541
		skb = (struct sk_buff *) ((unsigned long)rxdp->Host_Control);
2223
				rxdp = (RxD_t *) ((unsigned long)
2542
		if (skb == NULL) {
2224
						  rxdp->Control_2);
2543
			DBG_PRINT(ERR_DBG, "%s: The skb is ",
2225
				get_info.offset++;
2544
				  dev->name);
2226
				get_info.offset %=
2545
			DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2227
				    (MAX_RXDS_PER_BLOCK + 1);
2546
			spin_unlock(&nic->rx_lock);
2228
				get_block++;
2547
			return;
2229
				get_block %= nic->block_count[i];
2230
				mac_control->rx_curr_get_info[i].
2231
				    offset = get_info.offset;
2232
				mac_control->rx_curr_get_info[i].
2233
				    block_index = get_block;
2234
				continue;
2235
			}
2236
			get_offset =
2237
			    (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2238
			    get_info.offset;
2239
			skb = (struct sk_buff *) ((unsigned long)
2240
						  rxdp->Host_Control);
2241
			if (skb == NULL) {
2242
				DBG_PRINT(ERR_DBG, "%s: The skb is ",
2243
					  dev->name);
2244
				DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2245
				return;
2246
			}
2247
			val64 = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
2248
			val16 = (u16) (val64 >> 48);
2249
			cksum = RXD_GET_L4_CKSUM(rxdp->Control_1);
2250
			pci_unmap_single(nic->pdev, (dma_addr_t)
2251
					 rxdp->Buffer0_ptr,
2252
					 dev->mtu +
2253
					 HEADER_ETHERNET_II_802_3_SIZE +
2254
					 HEADER_802_2_SIZE +
2255
					 HEADER_SNAP_SIZE,
2256
					 PCI_DMA_FROMDEVICE);
2257
			rx_osm_handler(nic, val16, rxdp, i);
2258
			get_info.offset++;
2259
			get_info.offset %= (MAX_RXDS_PER_BLOCK + 1);
2260
			rxdp =
2261
			    nic->rx_blocks[i][get_block].block_virt_addr +
2262
			    get_info.offset;
2263
			mac_control->rx_curr_get_info[i].offset =
2264
			    get_info.offset;
2265
			pkt_cnt++;
2266
			if ((indicate_max_pkts)
2267
			    && (pkt_cnt > indicate_max_pkts))
2268
				break;
2269
		}
2548
		}
2549
#ifndef CONFIG_2BUFF_MODE
2550
		pci_unmap_single(nic->pdev, (dma_addr_t)
2551
				 rxdp->Buffer0_ptr,
2552
				 dev->mtu +
2553
				 HEADER_ETHERNET_II_802_3_SIZE +
2554
				 HEADER_802_2_SIZE +
2555
				 HEADER_SNAP_SIZE,
2556
				 PCI_DMA_FROMDEVICE);
2270
#else
2557
#else
2271
		get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2558
		pci_unmap_single(nic->pdev, (dma_addr_t)
2559
				 rxdp->Buffer0_ptr,
2560
				 BUF0_LEN, PCI_DMA_FROMDEVICE);
2561
		pci_unmap_single(nic->pdev, (dma_addr_t)
2562
				 rxdp->Buffer1_ptr,
2563
				 BUF1_LEN, PCI_DMA_FROMDEVICE);
2564
		pci_unmap_single(nic->pdev, (dma_addr_t)
2565
				 rxdp->Buffer2_ptr,
2566
				 dev->mtu + BUF0_LEN + 4,
2567
				 PCI_DMA_FROMDEVICE);
2568
#endif
2569
		rx_osm_handler(ring_data, rxdp);
2570
		get_info.offset++;
2571
		ring_data->rx_curr_get_info.offset =
2272
		    get_info.offset;
2572
		    get_info.offset;
2273
#ifndef CONFIG_S2IO_NAPI
2573
		rxdp = ring_data->rx_blocks[get_block].block_virt_addr +
2274
		spin_lock(&nic->put_lock);
2574
		    get_info.offset;
2275
		put_offset = nic->put_pos;
2575
		if (get_info.offset &&
2276
		spin_unlock(&nic->put_lock);
2576
		    (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
2277
#endif
2577
			get_info.offset = 0;
2278
		while (((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
2578
			ring_data->rx_curr_get_info.offset
2279
			!(rxdp->Control_2 & BIT(0))) &&
2579
			    = get_info.offset;
2280
		       (((get_offset + 1) % ring_bufs) != put_offset)) {
2580
			get_block++;
2281
			skb = (struct sk_buff *) ((unsigned long)
2581
			get_block %= ring_data->block_count;
2282
						  rxdp->Host_Control);
2582
			ring_data->rx_curr_get_info.block_index
2283
			if (skb == NULL) {
2583
			    = get_block;
2284
				DBG_PRINT(ERR_DBG, "%s: The skb is ",
2584
			rxdp = ring_data->rx_blocks[get_block].block_virt_addr;
2285
					  dev->name);
2585
		}
2286
				DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2287
				return;
2288
			}
2289
2290
			pci_unmap_single(nic->pdev, (dma_addr_t)
2291
					 rxdp->Buffer0_ptr,
2292
					 BUF0_LEN, PCI_DMA_FROMDEVICE);
2293
			pci_unmap_single(nic->pdev, (dma_addr_t)
2294
					 rxdp->Buffer1_ptr,
2295
					 BUF1_LEN, PCI_DMA_FROMDEVICE);
2296
			pci_unmap_single(nic->pdev, (dma_addr_t)
2297
					 rxdp->Buffer2_ptr,
2298
					 dev->mtu + 22,
2299
					 PCI_DMA_FROMDEVICE);
2300
			ba = &nic->ba[i][get_block][get_info.offset];
2301
2586
2302
			rx_osm_handler(nic, rxdp, i, ba);
2587
		get_offset = (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2303
2304
			get_info.offset++;
2305
			mac_control->rx_curr_get_info[i].offset =
2306
			    get_info.offset;
2307
			rxdp =
2308
			    nic->rx_blocks[i][get_block].block_virt_addr +
2309
			    get_info.offset;
2310
2311
			if (get_info.offset &&
2312
			    (!(get_info.offset % MAX_RXDS_PER_BLOCK))) {
2313
				get_info.offset = 0;
2314
				mac_control->rx_curr_get_info[i].
2315
				    offset = get_info.offset;
2316
				get_block++;
2317
				get_block %= nic->block_count[i];
2318
				mac_control->rx_curr_get_info[i].
2319
				    block_index = get_block;
2320
				rxdp =
2321
				    nic->rx_blocks[i][get_block].
2322
				    block_virt_addr;
2323
			}
2324
			get_offset =
2325
			    (get_block * (MAX_RXDS_PER_BLOCK + 1)) +
2326
			    get_info.offset;
2588
			    get_info.offset;
2327
			pkt_cnt++;
2589
#ifdef CONFIG_S2IO_NAPI
2328
			if ((indicate_max_pkts)
2590
		nic->pkts_to_process -= 1;
2329
			    && (pkt_cnt > indicate_max_pkts))
2591
		if (!nic->pkts_to_process)
2330
				break;
2592
			break;
2331
		}
2593
#else
2332
#endif
2594
		pkt_cnt++;
2333
		if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts))
2595
		if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts))
2334
			break;
2596
			break;
2597
#endif
2335
	}
2598
	}
2599
	spin_unlock(&nic->rx_lock);
2336
}
2600
}
2337
#endif
2601
2338
/**  
2602
/**
2339
 *  tx_intr_handler - Transmit interrupt handler
2603
 *  tx_intr_handler - Transmit interrupt handler
2340
 *  @nic : device private variable
2604
 *  @nic : device private variable
2341
 *  Description: 
2605
 *  Description:
2342
 *  If an interrupt was raised to indicate DMA complete of the 
2606
 *  If an interrupt was raised to indicate DMA complete of the
2343
 *  Tx packet, this function is called. It identifies the last TxD 
2607
 *  Tx packet, this function is called. It identifies the last TxD
2344
 *  whose buffer was freed and frees all skbs whose data have already 
2608
 *  whose buffer was freed and frees all skbs whose data have already
2345
 *  DMA'ed into the NICs internal memory.
2609
 *  DMA'ed into the NICs internal memory.
2346
 *  Return Value:
2610
 *  Return Value:
2347
 *  NONE
2611
 *  NONE
2348
 */
2612
 */
2349
2613
2350
static void tx_intr_handler(struct s2io_nic *nic)
2614
static void tx_intr_handler(fifo_info_t *fifo_data)
2351
{
2615
{
2352
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
2616
	nic_t *nic = fifo_data->nic;
2353
	struct net_device *dev = (struct net_device *) nic->dev;
2617
	struct net_device *dev = (struct net_device *) nic->dev;
2354
	tx_curr_get_info_t get_info, put_info;
2618
	tx_curr_get_info_t get_info, put_info;
2355
	struct sk_buff *skb;
2619
	struct sk_buff *skb;
2356
	TxD_t *txdlp;
2620
	TxD_t *txdlp;
2357
	register u64 val64 = 0;
2358
	int i;
2359
	u16 j, frg_cnt;
2621
	u16 j, frg_cnt;
2360
	mac_info_t *mac_control;
2361
	struct config_param *config;
2362
2363
	mac_control = &nic->mac_control;
2364
	config = &nic->config;
2365
2622
2366
	/* 
2623
	get_info = fifo_data->tx_curr_get_info;
2367
	 * tx_traffic_int reg is an R1 register, hence we read and write 
2624
	put_info = fifo_data->tx_curr_put_info;
2368
	 * back the samevalue in the register to clear it.
2625
	txdlp = (TxD_t *) fifo_data->list_info[get_info.offset].
2369
	 */
2626
	    list_virt_addr;
2370
	val64 = readq(&bar0->tx_traffic_int);
2627
	while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) &&
2371
	writeq(val64, &bar0->tx_traffic_int);
2628
	       (get_info.offset != put_info.offset) &&
2372
2629
	       (txdlp->Host_Control)) {
2373
	for (i = 0; i < config->TxFIFONum; i++) {
2630
		/* Check for TxD errors */
2374
		get_info = mac_control->tx_curr_get_info[i];
2631
		if (txdlp->Control_1 & TXD_T_CODE) {
2375
		put_info = mac_control->tx_curr_put_info[i];
2632
			unsigned long long err;
2376
		txdlp = (TxD_t *) nic->list_info[i][get_info.offset].
2633
			err = txdlp->Control_1 & TXD_T_CODE;
2377
		    list_virt_addr;
2634
			if ((err >> 48) == 0xA) {
2378
		while ((!(txdlp->Control_1 & TXD_LIST_OWN_XENA)) &&
2635
				DBG_PRINT(TX_DBG, "TxD returned due \
2379
		       (get_info.offset != put_info.offset) &&
2636
						to loss of link\n");
2380
		       (txdlp->Host_Control)) {
2381
			/* Check for TxD errors */
2382
			if (txdlp->Control_1 & TXD_T_CODE) {
2383
				unsigned long long err;
2384
				err = txdlp->Control_1 & TXD_T_CODE;
2385
				DBG_PRINT(ERR_DBG, "***TxD error %llx\n",
2386
					  err);
2387
			}
2637
			}
2388
2638
			else {
2389
			skb = (struct sk_buff *) ((unsigned long)
2639
				DBG_PRINT(ERR_DBG, "***TxD error \
2390
						  txdlp->Host_Control);
2640
						%llx\n", err);
2391
			if (skb == NULL) {
2392
				DBG_PRINT(ERR_DBG, "%s: Null skb ",
2393
					  dev->name);
2394
				DBG_PRINT(ERR_DBG, "in Tx Free Intr\n");
2395
				return;
2396
			}
2641
			}
2397
			nic->tx_pkt_count++;
2642
		}
2398
2643
2399
			frg_cnt = skb_shinfo(skb)->nr_frags;
2644
		skb = (struct sk_buff *) ((unsigned long)
2645
				txdlp->Host_Control);
2646
		if (skb == NULL) {
2647
			DBG_PRINT(ERR_DBG, "%s: Null skb ",
2648
			__FUNCTION__);
2649
			DBG_PRINT(ERR_DBG, "in Tx Free Intr\n");
2650
			return;
2651
		}
2400
2652
2401
			/*  For unfragmented skb */
2653
		frg_cnt = skb_shinfo(skb)->nr_frags;
2402
			pci_unmap_single(nic->pdev, (dma_addr_t)
2654
		nic->tx_pkt_count++;
2403
					 txdlp->Buffer_Pointer,
2404
					 skb->len - skb->data_len,
2405
					 PCI_DMA_TODEVICE);
2406
			if (frg_cnt) {
2407
				TxD_t *temp = txdlp;
2408
				txdlp++;
2409
				for (j = 0; j < frg_cnt; j++, txdlp++) {
2410
					skb_frag_t *frag =
2411
					    &skb_shinfo(skb)->frags[j];
2412
					pci_unmap_page(nic->pdev,
2413
						       (dma_addr_t)
2414
						       txdlp->
2415
						       Buffer_Pointer,
2416
						       frag->size,
2417
						       PCI_DMA_TODEVICE);
2418
				}
2419
				txdlp = temp;
2420
			}
2421
			memset(txdlp, 0,
2422
			       (sizeof(TxD_t) * config->MaxTxDs));
2423
2655
2424
			/* Updating the statistics block */
2656
		pci_unmap_single(nic->pdev, (dma_addr_t)
2425
			nic->stats.tx_packets++;
2657
				 txdlp->Buffer_Pointer,
2426
			nic->stats.tx_bytes += skb->len;
2658
				 skb->len - skb->data_len,
2427
			dev_kfree_skb_irq(skb);
2659
				 PCI_DMA_TODEVICE);
2428
2660
		if (frg_cnt) {
2429
			get_info.offset++;
2661
			TxD_t *temp;
2430
			get_info.offset %= get_info.fifo_len + 1;
2662
			temp = txdlp;
2431
			txdlp = (TxD_t *) nic->list_info[i]
2663
			txdlp++;
2432
			    [get_info.offset].list_virt_addr;
2664
			for (j = 0; j < frg_cnt; j++, txdlp++) {
2433
			mac_control->tx_curr_get_info[i].offset =
2665
				skb_frag_t *frag =
2434
			    get_info.offset;
2666
				    &skb_shinfo(skb)->frags[j];
2667
				if (!txdlp->Buffer_Pointer)
2668
					break;
2669
				pci_unmap_page(nic->pdev,
2670
					       (dma_addr_t)
2671
					       txdlp->
2672
					       Buffer_Pointer,
2673
					       frag->size,
2674
					       PCI_DMA_TODEVICE);
2675
			}
2676
			txdlp = temp;
2435
		}
2677
		}
2678
		memset(txdlp, 0,
2679
		       (sizeof(TxD_t) * fifo_data->max_txds));
2680
2681
		/* Updating the statistics block */
2682
		nic->stats.tx_bytes += skb->len;
2683
		dev_kfree_skb_irq(skb);
2684
2685
		get_info.offset++;
2686
		get_info.offset %= get_info.fifo_len + 1;
2687
		txdlp = (TxD_t *) fifo_data->list_info
2688
		    [get_info.offset].list_virt_addr;
2689
		fifo_data->tx_curr_get_info.offset =
2690
		    get_info.offset;
2436
	}
2691
	}
2437
2692
2438
	spin_lock(&nic->tx_lock);
2693
	spin_lock(&nic->tx_lock);
Lines 2441-2453 static void tx_intr_handler(struct s2io_ Link Here
2441
	spin_unlock(&nic->tx_lock);
2696
	spin_unlock(&nic->tx_lock);
2442
}
2697
}
2443
2698
2444
/**  
2699
/**
2445
 *  alarm_intr_handler - Alarm Interrrupt handler
2700
 *  alarm_intr_handler - Alarm Interrrupt handler
2446
 *  @nic: device private variable
2701
 *  @nic: device private variable
2447
 *  Description: If the interrupt was neither because of Rx packet or Tx 
2702
 *  Description: If the interrupt was neither because of Rx packet or Tx
2448
 *  complete, this function is called. If the interrupt was to indicate
2703
 *  complete, this function is called. If the interrupt was to indicate
2449
 *  a loss of link, the OSM link status handler is invoked for any other 
2704
 *  a loss of link, the OSM link status handler is invoked for any other
2450
 *  alarm interrupt the block that raised the interrupt is displayed 
2705
 *  alarm interrupt the block that raised the interrupt is displayed
2451
 *  and a H/W reset is issued.
2706
 *  and a H/W reset is issued.
2452
 *  Return Value:
2707
 *  Return Value:
2453
 *  NONE
2708
 *  NONE
Lines 2456-2483 static void tx_intr_handler(struct s2io_ Link Here
2456
static void alarm_intr_handler(struct s2io_nic *nic)
2711
static void alarm_intr_handler(struct s2io_nic *nic)
2457
{
2712
{
2458
	struct net_device *dev = (struct net_device *) nic->dev;
2713
	struct net_device *dev = (struct net_device *) nic->dev;
2459
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
2714
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
2460
	register u64 val64 = 0, err_reg = 0;
2715
	register u64 val64 = 0, err_reg = 0;
2461
2716
2462
	/* Handling link status change error Intr */
2717
	/* Handling link status change error Intr */
2463
	err_reg = readq(&bar0->mac_rmac_err_reg);
2718
	if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
2464
	writeq(err_reg, &bar0->mac_rmac_err_reg);
2719
		err_reg = readq(&bar0->mac_rmac_err_reg);
2465
	if (err_reg & RMAC_LINK_STATE_CHANGE_INT) {
2720
		writeq(err_reg, &bar0->mac_rmac_err_reg);
2466
		schedule_work(&nic->set_link_task);
2721
		if (err_reg & RMAC_LINK_STATE_CHANGE_INT) {
2722
			schedule_work(&nic->set_link_task);
2723
		}
2724
	}
2725
2726
	/* Handling Ecc errors */
2727
	val64 = readq(&bar0->mc_err_reg);
2728
	writeq(val64, &bar0->mc_err_reg);
2729
	if (val64 & (MC_ERR_REG_ECC_ALL_SNG | MC_ERR_REG_ECC_ALL_DBL)) {
2730
		if (val64 & MC_ERR_REG_ECC_ALL_DBL) {
2731
			nic->mac_control.stats_info->sw_stat.
2732
				double_ecc_errs++;
2733
			DBG_PRINT(INIT_DBG, "%s: Device indicates ",
2734
				  dev->name);
2735
			DBG_PRINT(INIT_DBG, "double ECC error!!\n");
2736
			if (nic->device_type != XFRAME_II_DEVICE) {
2737
				/* Reset XframeI only if critical error */
2738
				if (val64 & (MC_ERR_REG_MIRI_ECC_DB_ERR_0 |
2739
					     MC_ERR_REG_MIRI_ECC_DB_ERR_1)) {
2740
					netif_stop_queue(dev);
2741
					schedule_work(&nic->rst_timer_task);
2742
				}
2743
			}
2744
		} else {
2745
			nic->mac_control.stats_info->sw_stat.
2746
				single_ecc_errs++;
2747
		}
2467
	}
2748
	}
2468
2749
2469
	/* In case of a serious error, the device will be Reset. */
2750
	/* In case of a serious error, the device will be Reset. */
2470
	val64 = readq(&bar0->serr_source);
2751
	val64 = readq(&bar0->serr_source);
2471
	if (val64 & SERR_SOURCE_ANY) {
2752
	if (val64 & SERR_SOURCE_ANY) {
2472
		DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name);
2753
		DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name);
2473
		DBG_PRINT(ERR_DBG, "serious error!!\n");
2754
		DBG_PRINT(ERR_DBG, "serious error %llx!!\n", 
2755
			  (unsigned long long)val64);
2756
		netif_stop_queue(dev);
2474
		schedule_work(&nic->rst_timer_task);
2757
		schedule_work(&nic->rst_timer_task);
2475
	}
2758
	}
2476
2759
2477
	/*
2760
	/*
2478
	 * Also as mentioned in the latest Errata sheets if the PCC_FB_ECC
2761
	 * Also as mentioned in the latest Errata sheets if the PCC_FB_ECC
2479
	 * Error occurs, the adapter will be recycled by disabling the
2762
	 * Error occurs, the adapter will be recycled by disabling the
2480
	 * adapter enable bit and enabling it again after the device 
2763
	 * adapter enable bit and enabling it again after the device
2481
	 * becomes Quiescent.
2764
	 * becomes Quiescent.
2482
	 */
2765
	 */
2483
	val64 = readq(&bar0->pcc_err_reg);
2766
	val64 = readq(&bar0->pcc_err_reg);
Lines 2493-2512 static void alarm_intr_handler(struct s2 Link Here
2493
	/* Other type of interrupts are not being handled now,  TODO */
2776
	/* Other type of interrupts are not being handled now,  TODO */
2494
}
2777
}
2495
2778
2496
/** 
2779
/**
2497
 *  wait_for_cmd_complete - waits for a command to complete.
2780
 *  wait_for_cmd_complete - waits for a command to complete.
2498
 *  @sp : private member of the device structure, which is a pointer to the 
2781
 *  @sp : private member of the device structure, which is a pointer to the
2499
 *  s2io_nic structure.
2782
 *  s2io_nic structure.
2500
 *  Description: Function that waits for a command to Write into RMAC 
2783
 *  Description: Function that waits for a command to Write into RMAC
2501
 *  ADDR DATA registers to be completed and returns either success or 
2784
 *  ADDR DATA registers to be completed and returns either success or
2502
 *  error depending on whether the command was complete or not. 
2785
 *  error depending on whether the command was complete or not.
2503
 *  Return value:
2786
 *  Return value:
2504
 *   SUCCESS on success and FAILURE on failure.
2787
 *   SUCCESS on success and FAILURE on failure.
2505
 */
2788
 */
2506
2789
2507
int wait_for_cmd_complete(nic_t * sp)
2790
int wait_for_cmd_complete(nic_t * sp)
2508
{
2791
{
2509
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
2792
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
2510
	int ret = FAILURE, cnt = 0;
2793
	int ret = FAILURE, cnt = 0;
2511
	u64 val64;
2794
	u64 val64;
2512
2795
Lines 2516-2523 int wait_for_cmd_complete(nic_t * sp) Link Here
2516
			ret = SUCCESS;
2799
			ret = SUCCESS;
2517
			break;
2800
			break;
2518
		}
2801
		}
2519
		set_current_state(TASK_UNINTERRUPTIBLE);
2802
		msleep(50);
2520
		schedule_timeout(HZ / 20);
2521
		if (cnt++ > 10)
2803
		if (cnt++ > 10)
2522
			break;
2804
			break;
2523
	}
2805
	}
Lines 2525-2587 int wait_for_cmd_complete(nic_t * sp) Link Here
2525
	return ret;
2807
	return ret;
2526
}
2808
}
2527
2809
2528
/** 
2810
/**
2529
 *  s2io_reset - Resets the card. 
2811
 *  s2io_reset - Resets the card.
2530
 *  @sp : private member of the device structure.
2812
 *  @sp : private member of the device structure.
2531
 *  Description: Function to Reset the card. This function then also
2813
 *  Description: Function to Reset the card. This function then also
2532
 *  restores the previously saved PCI configuration space registers as 
2814
 *  restores the previously saved PCI configuration space registers as
2533
 *  the card reset also resets the Configration space.
2815
 *  the card reset also resets the configuration space.
2534
 *  Return value:
2816
 *  Return value:
2535
 *  void.
2817
 *  void.
2536
 */
2818
 */
2537
2819
2538
void s2io_reset(nic_t * sp)
2820
void s2io_reset(nic_t * sp)
2539
{
2821
{
2540
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
2822
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
2541
	u64 val64;
2823
	u64 val64;
2542
	u16 subid;
2824
	u16 subid, pci_cmd;
2825
2826
	/* Back up  the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
2827
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
2543
2828
2544
	val64 = SW_RESET_ALL;
2829
	val64 = SW_RESET_ALL;
2545
	writeq(val64, &bar0->sw_reset);
2830
	writeq(val64, &bar0->sw_reset);
2546
2831
2547
	/* 
2832
	/*
2548
	 * At this stage, if the PCI write is indeed completed, the 
2833
	 * At this stage, if the PCI write is indeed completed, the
2549
	 * card is reset and so is the PCI Config space of the device. 
2834
	 * card is reset and so is the PCI Config space of the device.
2550
	 * So a read cannot be issued at this stage on any of the 
2835
	 * So a read cannot be issued at this stage on any of the
2551
	 * registers to ensure the write into "sw_reset" register
2836
	 * registers to ensure the write into "sw_reset" register
2552
	 * has gone through.
2837
	 * has gone through.
2553
	 * Question: Is there any system call that will explicitly force
2838
	 * Question: Is there any system call that will explicitly force
2554
	 * all the write commands still pending on the bus to be pushed
2839
	 * all the write commands still pending on the bus to be pushed
2555
	 * through?
2840
	 * through?
2556
	 * As of now I'am just giving a 100ms delay and hoping that the
2841
	 * As of now I'am just giving a 250ms delay and hoping that the
2557
	 * PCI write to sw_reset register is done by this time.
2842
	 * PCI write to sw_reset register is done by this time.
2558
	 */
2843
	 */
2559
	mdelay(100);
2844
	msleep(250);
2560
2845
2561
	/* Restore the PCI state saved during initializarion. */
2846
	/* Restore the PCI state saved during initialization. */
2562
	pci_restore_state(sp->pdev, sp->config_space);
2847
	pci_restore_state(sp->pdev, sp->config_space);
2848
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
2849
				     pci_cmd);
2563
	s2io_init_pci(sp);
2850
	s2io_init_pci(sp);
2564
2851
2565
	mdelay(100);
2852
	msleep(250);
2853
2854
	/* Set swapper to enable I/O register access */
2855
	s2io_set_swapper(sp);
2856
2857
	/* Clear certain PCI/PCI-X fields after reset */
2858
	if (sp->device_type == XFRAME_II_DEVICE) {
2859
		/* Clear parity err detect bit */
2860
		pci_write_config_word(sp->pdev, PCI_STATUS, 0x8000);
2861
2862
		/* Clearing PCIX Ecc status register */
2863
		pci_write_config_dword(sp->pdev, 0x68, 0x7C);
2864
2865
		/* Clearing PCI_STATUS error reflected here */
2866
		writeq(BIT(62), &bar0->txpic_int_reg);
2867
	}
2868
2869
	/* Reset device statistics maintained by OS */
2870
	memset(&sp->stats, 0, sizeof (struct net_device_stats));
2566
2871
2567
	/* SXE-002: Configure link and activity LED to turn it off */
2872
	/* SXE-002: Configure link and activity LED to turn it off */
2568
	subid = sp->pdev->subsystem_device;
2873
	subid = sp->pdev->subsystem_device;
2569
	if ((subid & 0xFF) >= 0x07) {
2874
	if (((subid & 0xFF) >= 0x07) &&
2875
	    (sp->device_type == XFRAME_I_DEVICE)) {
2570
		val64 = readq(&bar0->gpio_control);
2876
		val64 = readq(&bar0->gpio_control);
2571
		val64 |= 0x0000800000000000ULL;
2877
		val64 |= 0x0000800000000000ULL;
2572
		writeq(val64, &bar0->gpio_control);
2878
		writeq(val64, &bar0->gpio_control);
2573
		val64 = 0x0411040400000000ULL;
2879
		val64 = 0x0411040400000000ULL;
2574
		writeq(val64, (void *) ((u8 *) bar0 + 0x2700));
2880
		writeq(val64, (void __iomem *) ((u8 *) bar0 + 0x2700));
2881
	}
2882
2883
	/*
2884
	 * Clear spurious ECC interrupts that would have occured on
2885
	 * XFRAME II cards after reset.
2886
	 */
2887
	if (sp->device_type == XFRAME_II_DEVICE) {
2888
		val64 = readq(&bar0->pcc_err_reg);
2889
		writeq(val64, &bar0->pcc_err_reg);
2575
	}
2890
	}
2576
2891
2577
	sp->device_enabled_once = FALSE;
2892
	sp->device_enabled_once = FALSE;
2578
}
2893
}
2579
2894
2580
/**
2895
/**
2581
 *  s2io_set_swapper - to set the swapper controle on the card 
2896
 *  s2io_set_swapper - to set the swapper controle on the card
2582
 *  @sp : private member of the device structure, 
2897
 *  @sp : private member of the device structure,
2583
 *  pointer to the s2io_nic structure.
2898
 *  pointer to the s2io_nic structure.
2584
 *  Description: Function to set the swapper control on the card 
2899
 *  Description: Function to set the swapper control on the card
2585
 *  correctly depending on the 'endianness' of the system.
2900
 *  correctly depending on the 'endianness' of the system.
2586
 *  Return value:
2901
 *  Return value:
2587
 *  SUCCESS on success and FAILURE on failure.
2902
 *  SUCCESS on success and FAILURE on failure.
Lines 2590-2613 void s2io_reset(nic_t * sp) Link Here
2590
int s2io_set_swapper(nic_t * sp)
2905
int s2io_set_swapper(nic_t * sp)
2591
{
2906
{
2592
	struct net_device *dev = sp->dev;
2907
	struct net_device *dev = sp->dev;
2593
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
2908
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
2594
	u64 val64;
2909
	u64 val64, valt, valr;
2595
2910
2596
	/* 
2911
	/*
2597
	 * Set proper endian settings and verify the same by reading
2912
	 * Set proper endian settings and verify the same by reading
2598
	 * the PIF Feed-back register.
2913
	 * the PIF Feed-back register.
2599
	 */
2914
	 */
2915
2916
	val64 = readq(&bar0->pif_rd_swapper_fb);
2917
	if (val64 != 0x0123456789ABCDEFULL) {
2918
		int i = 0;
2919
		u64 value[] = { 0xC30000C3C30000C3ULL,   /* FE=1, SE=1 */
2920
				0x8100008181000081ULL,  /* FE=1, SE=0 */
2921
				0x4200004242000042ULL,  /* FE=0, SE=1 */
2922
				0};                     /* FE=0, SE=0 */
2923
2924
		while(i<4) {
2925
			writeq(value[i], &bar0->swapper_ctrl);
2926
			val64 = readq(&bar0->pif_rd_swapper_fb);
2927
			if (val64 == 0x0123456789ABCDEFULL)
2928
				break;
2929
			i++;
2930
		}
2931
		if (i == 4) {
2932
			DBG_PRINT(ERR_DBG, "%s: Endian settings are wrong, ",
2933
				dev->name);
2934
			DBG_PRINT(ERR_DBG, "feedback read %llx\n",
2935
				(unsigned long long) val64);
2936
			return FAILURE;
2937
		}
2938
		valr = value[i];
2939
	} else {
2940
		valr = readq(&bar0->swapper_ctrl);
2941
	}
2942
2943
	valt = 0x0123456789ABCDEFULL;
2944
	writeq(valt, &bar0->xmsi_address);
2945
	val64 = readq(&bar0->xmsi_address);
2946
2947
	if(val64 != valt) {
2948
		int i = 0;
2949
		u64 value[] = { 0x00C3C30000C3C300ULL,  /* FE=1, SE=1 */
2950
				0x0081810000818100ULL,  /* FE=1, SE=0 */
2951
				0x0042420000424200ULL,  /* FE=0, SE=1 */
2952
				0};                     /* FE=0, SE=0 */
2953
2954
		while(i<4) {
2955
			writeq((value[i] | valr), &bar0->swapper_ctrl);
2956
			writeq(valt, &bar0->xmsi_address);
2957
			val64 = readq(&bar0->xmsi_address);
2958
			if(val64 == valt)
2959
				break;
2960
			i++;
2961
		}
2962
		if(i == 4) {
2963
			unsigned long long x = val64;
2964
			DBG_PRINT(ERR_DBG, "Write failed, Xmsi_addr ");
2965
			DBG_PRINT(ERR_DBG, "reads:0x%llx\n", x);
2966
			return FAILURE;
2967
		}
2968
	}
2969
	val64 = readq(&bar0->swapper_ctrl);
2970
	val64 &= 0xFFFF000000000000ULL;
2971
2600
#ifdef  __BIG_ENDIAN
2972
#ifdef  __BIG_ENDIAN
2601
	/* 
2973
	/*
2602
	 * The device by default set to a big endian format, so a 
2974
	 * The device by default set to a big endian format, so a
2603
	 * big endian driver need not set anything.
2975
	 * big endian driver need not set anything.
2604
	 */
2976
	 */
2605
	writeq(0xffffffffffffffffULL, &bar0->swapper_ctrl);
2977
	val64 |= (SWAPPER_CTRL_TXP_FE |
2606
	val64 = (SWAPPER_CTRL_PIF_R_FE |
2607
		 SWAPPER_CTRL_PIF_R_SE |
2608
		 SWAPPER_CTRL_PIF_W_FE |
2609
		 SWAPPER_CTRL_PIF_W_SE |
2610
		 SWAPPER_CTRL_TXP_FE |
2611
		 SWAPPER_CTRL_TXP_SE |
2978
		 SWAPPER_CTRL_TXP_SE |
2612
		 SWAPPER_CTRL_TXD_R_FE |
2979
		 SWAPPER_CTRL_TXD_R_FE |
2613
		 SWAPPER_CTRL_TXD_W_FE |
2980
		 SWAPPER_CTRL_TXD_W_FE |
Lines 2620-2636 int s2io_set_swapper(nic_t * sp) Link Here
2620
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
2987
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
2621
	writeq(val64, &bar0->swapper_ctrl);
2988
	writeq(val64, &bar0->swapper_ctrl);
2622
#else
2989
#else
2623
	/* 
2990
	/*
2624
	 * Initially we enable all bits to make it accessible by the
2991
	 * Initially we enable all bits to make it accessible by the
2625
	 * driver, then we selectively enable only those bits that 
2992
	 * driver, then we selectively enable only those bits that
2626
	 * we want to set.
2993
	 * we want to set.
2627
	 */
2994
	 */
2628
	writeq(0xffffffffffffffffULL, &bar0->swapper_ctrl);
2995
	val64 |= (SWAPPER_CTRL_TXP_FE |
2629
	val64 = (SWAPPER_CTRL_PIF_R_FE |
2630
		 SWAPPER_CTRL_PIF_R_SE |
2631
		 SWAPPER_CTRL_PIF_W_FE |
2632
		 SWAPPER_CTRL_PIF_W_SE |
2633
		 SWAPPER_CTRL_TXP_FE |
2634
		 SWAPPER_CTRL_TXP_SE |
2996
		 SWAPPER_CTRL_TXP_SE |
2635
		 SWAPPER_CTRL_TXD_R_FE |
2997
		 SWAPPER_CTRL_TXD_R_FE |
2636
		 SWAPPER_CTRL_TXD_R_SE |
2998
		 SWAPPER_CTRL_TXD_R_SE |
Lines 2647-2655 int s2io_set_swapper(nic_t * sp) Link Here
2647
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
3009
		 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
2648
	writeq(val64, &bar0->swapper_ctrl);
3010
	writeq(val64, &bar0->swapper_ctrl);
2649
#endif
3011
#endif
3012
	val64 = readq(&bar0->swapper_ctrl);
2650
3013
2651
	/* 
3014
	/*
2652
	 * Verifying if endian settings are accurate by reading a 
3015
	 * Verifying if endian settings are accurate by reading a
2653
	 * feedback register.
3016
	 * feedback register.
2654
	 */
3017
	 */
2655
	val64 = readq(&bar0->pif_rd_swapper_fb);
3018
	val64 = readq(&bar0->pif_rd_swapper_fb);
Lines 2669-2681 int s2io_set_swapper(nic_t * sp) Link Here
2669
 * Functions defined below concern the OS part of the driver *
3032
 * Functions defined below concern the OS part of the driver *
2670
 * ********************************************************* */
3033
 * ********************************************************* */
2671
3034
2672
/**  
3035
/**
2673
 *  s2io-open - open entry point of the driver
3036
 *  s2io_open - open entry point of the driver
2674
 *  @dev : pointer to the device structure.
3037
 *  @dev : pointer to the device structure.
2675
 *  Description:
3038
 *  Description:
2676
 *  This function is the open entry point of the driver. It mainly calls a
3039
 *  This function is the open entry point of the driver. It mainly calls a
2677
 *  function to allocate Rx buffers and inserts them into the buffer
3040
 *  function to allocate Rx buffers and inserts them into the buffer
2678
 *  descriptors and then enables the Rx part of the NIC. 
3041
 *  descriptors and then enables the Rx part of the NIC.
2679
 *  Return value:
3042
 *  Return value:
2680
 *  0 on success and an appropriate (-)ve integer as defined in errno.h
3043
 *  0 on success and an appropriate (-)ve integer as defined in errno.h
2681
 *   file on failure.
3044
 *   file on failure.
Lines 2684-2764 int s2io_set_swapper(nic_t * sp) Link Here
2684
int s2io_open(struct net_device *dev)
3047
int s2io_open(struct net_device *dev)
2685
{
3048
{
2686
	nic_t *sp = dev->priv;
3049
	nic_t *sp = dev->priv;
2687
	int i, ret = 0, err = 0;
3050
	int err = 0;
2688
	mac_info_t *mac_control;
2689
	struct config_param *config;
2690
3051
2691
3052
	/*
2692
	/* 
3053
	 * Make sure you have link off by default every time
2693
	 * Make sure you have link off by default every time 
2694
	 * Nic is initialized
3054
	 * Nic is initialized
2695
	 */
3055
	 */
2696
	netif_carrier_off(dev);
3056
	netif_carrier_off(dev);
2697
	sp->last_link_state = LINK_DOWN;
3057
	sp->last_link_state = 0;
2698
3058
2699
	/* Initialize the H/W I/O registers */
3059
	/* Initialize H/W and enable interrupts */
2700
	if (init_nic(sp) != 0) {
3060
	if (s2io_card_up(sp)) {
2701
		DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
3061
		DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
2702
			  dev->name);
3062
			  dev->name);
2703
		return -ENODEV;
3063
		err = -ENODEV;
3064
		goto hw_init_failed;
2704
	}
3065
	}
2705
3066
2706
	/* After proper initialization of H/W, register ISR */
3067
	/* After proper initialization of H/W, register ISR */
2707
	err =
3068
	err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ,
2708
	    request_irq((int) sp->irq, s2io_isr, SA_SHIRQ, sp->name, dev);
3069
			  sp->name, dev);
2709
	if (err) {
3070
	if (err) {
2710
		s2io_reset(sp);
2711
		DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
3071
		DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
2712
			  dev->name);
3072
			  dev->name);
2713
		return err;
3073
		goto isr_registration_failed;
2714
	}
3074
	}
3075
2715
	if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) {
3076
	if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) {
2716
		DBG_PRINT(ERR_DBG, "Set Mac Address Failed\n");
3077
		DBG_PRINT(ERR_DBG, "Set Mac Address Failed\n");
2717
		s2io_reset(sp);
3078
		err = -ENODEV;
2718
		return -ENODEV;
3079
		goto setting_mac_address_failed;
2719
	}
2720
2721
2722
	/* Setting its receive mode */
2723
	s2io_set_multicast(dev);
2724
2725
	/* 
2726
	 * Initializing the Rx buffers. For now we are considering only 1 
2727
	 * Rx ring and initializing buffers into 1016 RxDs or 8 Rx blocks
2728
	 */
2729
	mac_control = &sp->mac_control;
2730
	config = &sp->config;
2731
2732
	for (i = 0; i < config->RxRingNum; i++) {
2733
		if ((ret = fill_rx_buffers(sp, i))) {
2734
			DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n",
2735
				  dev->name);
2736
			s2io_reset(sp);
2737
			free_irq(dev->irq, dev);
2738
			free_rx_buffers(sp);
2739
			return -ENOMEM;
2740
		}
2741
		DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i,
2742
			  atomic_read(&sp->rx_bufs_left[i]));
2743
	}
2744
2745
	/* Enable tasklet for the device */
2746
	tasklet_init(&sp->task, s2io_tasklet, (unsigned long) dev);
2747
2748
	/* Enable Rx Traffic and interrupts on the NIC */
2749
	if (start_nic(sp)) {
2750
		DBG_PRINT(ERR_DBG, "%s: Starting NIC failed\n", dev->name);
2751
		tasklet_kill(&sp->task);
2752
		s2io_reset(sp);
2753
		free_irq(dev->irq, dev);
2754
		free_rx_buffers(sp);
2755
		return -ENODEV;
2756
	}
3080
	}
2757
3081
2758
	sp->device_close_flag = FALSE;	/* Device is up and running. */
2759
	netif_start_queue(dev);
3082
	netif_start_queue(dev);
2760
2761
	return 0;
3083
	return 0;
3084
3085
setting_mac_address_failed:
3086
	free_irq(sp->pdev->irq, dev);
3087
isr_registration_failed:
3088
	del_timer_sync(&sp->alarm_timer);
3089
	s2io_reset(sp);
3090
hw_init_failed:
3091
	return err;
2762
}
3092
}
2763
3093
2764
/**
3094
/**
Lines 2777-2843 int s2io_open(struct net_device *dev) Link Here
2777
int s2io_close(struct net_device *dev)
3107
int s2io_close(struct net_device *dev)
2778
{
3108
{
2779
	nic_t *sp = dev->priv;
3109
	nic_t *sp = dev->priv;
2780
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3110
	flush_scheduled_work();
2781
	register u64 val64 = 0;
2782
	u16 cnt = 0;
2783
	unsigned long flags;
2784
2785
	spin_lock_irqsave(&sp->tx_lock, flags);
2786
	netif_stop_queue(dev);
3111
	netif_stop_queue(dev);
3112
	/* Reset card, kill tasklet and free Tx and Rx buffers. */
3113
	s2io_card_down(sp);
2787
3114
2788
	/* disable Tx and Rx traffic on the NIC */
3115
	free_irq(sp->pdev->irq, dev);
2789
	stop_nic(sp);
2790
2791
	/* 
2792
	 * If the device tasklet is running, wait till its done 
2793
	 * before killing it 
2794
	 */
2795
	while (atomic_read(&(sp->tasklet_status))) {
2796
		set_current_state(TASK_UNINTERRUPTIBLE);
2797
		schedule_timeout(HZ / 10);
2798
	}
2799
	tasklet_kill(&sp->task);
2800
2801
	/*  Free the Registered IRQ */
2802
	free_irq(dev->irq, dev);
2803
2804
	/* Flush all scheduled tasks */
2805
	if (sp->task_flag == 1) {
2806
		DBG_PRINT(INFO_DBG, "%s: Calling close from a task\n",
2807
			  dev->name);
2808
	} else {
2809
		flush_scheduled_work();
2810
	}
2811
2812
	/* Check if the device is Quiescent and then Reset the NIC */
2813
	do {
2814
		val64 = readq(&bar0->adapter_status);
2815
		if (verify_xena_quiescence(val64, sp->device_enabled_once)) {
2816
			break;
2817
		}
2818
2819
		set_current_state(TASK_UNINTERRUPTIBLE);
2820
		schedule_timeout(HZ / 20);
2821
		cnt++;
2822
		if (cnt == 10) {
2823
			DBG_PRINT(ERR_DBG,
2824
				  "s2io_close:Device not Quiescent ");
2825
			DBG_PRINT(ERR_DBG, "adaper status reads 0x%llx\n",
2826
				  (unsigned long long) val64);
2827
			break;
2828
		}
2829
	} while (1);
2830
	s2io_reset(sp);
2831
2832
	/* Free all Tx Buffers waiting for transmission */
2833
	free_tx_buffers(sp);
2834
2835
	/*  Free all Rx buffers allocated by host */
2836
	free_rx_buffers(sp);
2837
2838
	sp->device_close_flag = TRUE;	/* Device is shut down. */
3116
	sp->device_close_flag = TRUE;	/* Device is shut down. */
2839
	spin_unlock_irqrestore(&sp->tx_lock, flags);
2840
2841
	return 0;
3117
	return 0;
2842
}
3118
}
2843
3119
Lines 2860-2909 int s2io_xmit(struct sk_buff *skb, struc Link Here
2860
	u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off;
3136
	u16 frg_cnt, frg_len, i, queue, queue_len, put_off, get_off;
2861
	register u64 val64;
3137
	register u64 val64;
2862
	TxD_t *txdp;
3138
	TxD_t *txdp;
2863
	TxFIFO_element_t *tx_fifo;
3139
	TxFIFO_element_t __iomem *tx_fifo;
2864
	unsigned long flags;
3140
	unsigned long flags;
2865
#ifdef NETIF_F_TSO
3141
#ifdef NETIF_F_TSO
2866
	int mss;
3142
	int mss;
2867
#endif
3143
#endif
3144
	u16 vlan_tag = 0;
3145
	int vlan_priority = 0;
2868
	mac_info_t *mac_control;
3146
	mac_info_t *mac_control;
2869
	struct config_param *config;
3147
	struct config_param *config;
2870
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
2871
3148
2872
	mac_control = &sp->mac_control;
3149
	mac_control = &sp->mac_control;
2873
	config = &sp->config;
3150
	config = &sp->config;
2874
3151
2875
	DBG_PRINT(TX_DBG, "%s: In S2IO Tx routine\n", dev->name);
3152
	DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name);
2876
2877
	spin_lock_irqsave(&sp->tx_lock, flags);
3153
	spin_lock_irqsave(&sp->tx_lock, flags);
2878
	if ((netif_queue_stopped(dev)) || (!netif_carrier_ok(dev))) {
3154
	if (atomic_read(&sp->card_state) == CARD_DOWN) {
2879
		DBG_PRINT(ERR_DBG, "%s:s2io_xmit: Tx Queue stopped\n",
3155
		DBG_PRINT(TX_DBG, "%s: Card going down for reset\n",
2880
			  dev->name);
3156
			  dev->name);
2881
		dev_kfree_skb(skb);
2882
		spin_unlock_irqrestore(&sp->tx_lock, flags);
3157
		spin_unlock_irqrestore(&sp->tx_lock, flags);
3158
		dev_kfree_skb(skb);
2883
		return 0;
3159
		return 0;
2884
	}
3160
	}
2885
3161
2886
	queue = 0;
3162
	queue = 0;
2887
	/* Multi FIFO Tx is disabled for now. */
2888
	if (!queue && tx_prio) {
2889
		u8 x = (skb->data)[5];
2890
		queue = x % config->TxFIFONum;
2891
	}
2892
3163
3164
	/* Get Fifo number to Transmit based on vlan priority */
3165
	if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3166
		vlan_tag = vlan_tx_tag_get(skb);
3167
		vlan_priority = vlan_tag >> 13;
3168
		queue = config->fifo_mapping[vlan_priority];
3169
	}
2893
3170
2894
	put_off = (u16) mac_control->tx_curr_put_info[queue].offset;
3171
	put_off = (u16) mac_control->fifos[queue].tx_curr_put_info.offset;
2895
	get_off = (u16) mac_control->tx_curr_get_info[queue].offset;
3172
	get_off = (u16) mac_control->fifos[queue].tx_curr_get_info.offset;
2896
	txdp = (TxD_t *) sp->list_info[queue][put_off].list_virt_addr;
3173
	txdp = (TxD_t *) mac_control->fifos[queue].list_info[put_off].
3174
		list_virt_addr;
2897
3175
2898
	queue_len = mac_control->tx_curr_put_info[queue].fifo_len + 1;
3176
	queue_len = mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1;
2899
	/* Avoid "put" pointer going beyond "get" pointer */
3177
	/* Avoid "put" pointer going beyond "get" pointer */
2900
	if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) {
3178
	if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) {
2901
		DBG_PRINT(ERR_DBG, "Error in xmit, No free TXDs.\n");
3179
		DBG_PRINT(TX_DBG, "Error in xmit, No free TXDs.\n");
2902
		netif_stop_queue(dev);
3180
		netif_stop_queue(dev);
2903
		dev_kfree_skb(skb);
3181
		dev_kfree_skb(skb);
2904
		spin_unlock_irqrestore(&sp->tx_lock, flags);
3182
		spin_unlock_irqrestore(&sp->tx_lock, flags);
2905
		return 0;
3183
		return 0;
2906
	}
3184
	}
3185
3186
	/* A buffer with no data will be dropped */
3187
	if (!skb->len) {
3188
		DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
3189
		dev_kfree_skb(skb);
3190
		spin_unlock_irqrestore(&sp->tx_lock, flags);
3191
		return 0;
3192
	}
3193
2907
#ifdef NETIF_F_TSO
3194
#ifdef NETIF_F_TSO
2908
	mss = skb_shinfo(skb)->tso_size;
3195
	mss = skb_shinfo(skb)->tso_size;
2909
	if (mss) {
3196
	if (mss) {
Lines 2915-2930 int s2io_xmit(struct sk_buff *skb, struc Link Here
2915
	frg_cnt = skb_shinfo(skb)->nr_frags;
3202
	frg_cnt = skb_shinfo(skb)->nr_frags;
2916
	frg_len = skb->len - skb->data_len;
3203
	frg_len = skb->len - skb->data_len;
2917
3204
2918
	txdp->Host_Control = (unsigned long) skb;
2919
	txdp->Buffer_Pointer = pci_map_single
3205
	txdp->Buffer_Pointer = pci_map_single
2920
	    (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3206
	    (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3207
	txdp->Host_Control = (unsigned long) skb;
2921
	if (skb->ip_summed == CHECKSUM_HW) {
3208
	if (skb->ip_summed == CHECKSUM_HW) {
2922
		txdp->Control_2 |=
3209
		txdp->Control_2 |=
2923
		    (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN |
3210
		    (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN |
2924
		     TXD_TX_CKO_UDP_EN);
3211
		     TXD_TX_CKO_UDP_EN);
2925
	}
3212
	}
2926
3213
2927
	txdp->Control_2 |= config->TxIntrType;
3214
	txdp->Control_2 |= config->tx_intr_type;
3215
3216
	if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3217
		txdp->Control_2 |= TXD_VLAN_ENABLE;
3218
		txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag);
3219
	}
2928
3220
2929
	txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) |
3221
	txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) |
2930
			    TXD_GATHER_CODE_FIRST);
3222
			    TXD_GATHER_CODE_FIRST);
Lines 2933-2938 int s2io_xmit(struct sk_buff *skb, struc Link Here
2933
	/* For fragmented SKB. */
3225
	/* For fragmented SKB. */
2934
	for (i = 0; i < frg_cnt; i++) {
3226
	for (i = 0; i < frg_cnt; i++) {
2935
		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3227
		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3228
		/* A '0' length fragment will be ignored */
3229
		if (!frag->size)
3230
			continue;
2936
		txdp++;
3231
		txdp++;
2937
		txdp->Buffer_Pointer = (u64) pci_map_page
3232
		txdp->Buffer_Pointer = (u64) pci_map_page
2938
		    (sp->pdev, frag->page, frag->page_offset,
3233
		    (sp->pdev, frag->page, frag->page_offset,
Lines 2942-2964 int s2io_xmit(struct sk_buff *skb, struc Link Here
2942
	txdp->Control_1 |= TXD_GATHER_CODE_LAST;
3237
	txdp->Control_1 |= TXD_GATHER_CODE_LAST;
2943
3238
2944
	tx_fifo = mac_control->tx_FIFO_start[queue];
3239
	tx_fifo = mac_control->tx_FIFO_start[queue];
2945
	val64 = sp->list_info[queue][put_off].list_phy_addr;
3240
	val64 = mac_control->fifos[queue].list_info[put_off].list_phy_addr;
2946
	writeq(val64, &tx_fifo->TxDL_Pointer);
3241
	writeq(val64, &tx_fifo->TxDL_Pointer);
2947
3242
2948
	val64 = (TX_FIFO_LAST_TXD_NUM(frg_cnt) | TX_FIFO_FIRST_LIST |
3243
	val64 = (TX_FIFO_LAST_TXD_NUM(frg_cnt) | TX_FIFO_FIRST_LIST |
2949
		 TX_FIFO_LAST_LIST);
3244
		 TX_FIFO_LAST_LIST);
3245
2950
#ifdef NETIF_F_TSO
3246
#ifdef NETIF_F_TSO
2951
	if (mss)
3247
	if (mss)
2952
		val64 |= TX_FIFO_SPECIAL_FUNC;
3248
		val64 |= TX_FIFO_SPECIAL_FUNC;
2953
#endif
3249
#endif
2954
	writeq(val64, &tx_fifo->List_Control);
3250
	writeq(val64, &tx_fifo->List_Control);
2955
3251
2956
	/* Perform a PCI read to flush previous writes */
3252
	mmiowb();
2957
	val64 = readq(&bar0->general_int_status);
2958
3253
2959
	put_off++;
3254
	put_off++;
2960
	put_off %= mac_control->tx_curr_put_info[queue].fifo_len + 1;
3255
	put_off %= mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1;
2961
	mac_control->tx_curr_put_info[queue].offset = put_off;
3256
	mac_control->fifos[queue].tx_curr_put_info.offset = put_off;
2962
3257
2963
	/* Avoid "put" pointer going beyond "get" pointer */
3258
	/* Avoid "put" pointer going beyond "get" pointer */
2964
	if (((put_off + 1) % queue_len) == get_off) {
3259
	if (((put_off + 1) % queue_len) == get_off) {
Lines 2974-3032 int s2io_xmit(struct sk_buff *skb, struc Link Here
2974
	return 0;
3269
	return 0;
2975
}
3270
}
2976
3271
3272
static void
3273
s2io_alarm_handle(unsigned long data)
3274
{
3275
	nic_t *sp = (nic_t *)data;
3276
3277
	alarm_intr_handler(sp);
3278
	mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
3279
}
3280
3281
static void s2io_txpic_intr_handle(nic_t *sp)
3282
{
3283
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3284
	u64 val64;
3285
3286
	val64 = readq(&bar0->pic_int_status);
3287
	if (val64 & PIC_INT_GPIO) {
3288
		val64 = readq(&bar0->gpio_int_reg);
3289
		if ((val64 & GPIO_INT_REG_LINK_DOWN) &&
3290
		    (val64 & GPIO_INT_REG_LINK_UP)) {
3291
			val64 |=  GPIO_INT_REG_LINK_DOWN;
3292
			val64 |= GPIO_INT_REG_LINK_UP;
3293
			writeq(val64, &bar0->gpio_int_reg);
3294
			goto masking;
3295
		}
3296
3297
		if (((sp->last_link_state == LINK_UP) &&
3298
			(val64 & GPIO_INT_REG_LINK_DOWN)) ||
3299
		((sp->last_link_state == LINK_DOWN) &&
3300
		(val64 & GPIO_INT_REG_LINK_UP))) {
3301
			val64 = readq(&bar0->gpio_int_mask);
3302
			val64 |=  GPIO_INT_MASK_LINK_DOWN;
3303
			val64 |= GPIO_INT_MASK_LINK_UP;
3304
			writeq(val64, &bar0->gpio_int_mask);
3305
			s2io_set_link((unsigned long)sp);
3306
		}
3307
masking:
3308
		if (sp->last_link_state == LINK_UP) {
3309
			/*enable down interrupt */
3310
			val64 = readq(&bar0->gpio_int_mask);
3311
			/* unmasks link down intr */
3312
			val64 &=  ~GPIO_INT_MASK_LINK_DOWN;
3313
			/* masks link up intr */
3314
			val64 |= GPIO_INT_MASK_LINK_UP;
3315
			writeq(val64, &bar0->gpio_int_mask);
3316
		} else {
3317
			/*enable UP Interrupt */
3318
			val64 = readq(&bar0->gpio_int_mask);
3319
			/* unmasks link up interrupt */
3320
			val64 &= ~GPIO_INT_MASK_LINK_UP;
3321
			/* masks link down interrupt */
3322
			val64 |=  GPIO_INT_MASK_LINK_DOWN;
3323
			writeq(val64, &bar0->gpio_int_mask);
3324
		}
3325
	}
3326
}
3327
2977
/**
3328
/**
2978
 *  s2io_isr - ISR handler of the device .
3329
 *  s2io_isr - ISR handler of the device .
2979
 *  @irq: the irq of the device.
3330
 *  @irq: the irq of the device.
2980
 *  @dev_id: a void pointer to the dev structure of the NIC.
3331
 *  @dev_id: a void pointer to the dev structure of the NIC.
2981
 *  @pt_regs: pointer to the registers pushed on the stack.
3332
 *  @pt_regs: pointer to the registers pushed on the stack.
2982
 *  Description:  This function is the ISR handler of the device. It 
3333
 *  Description:  This function is the ISR handler of the device. It
2983
 *  identifies the reason for the interrupt and calls the relevant 
3334
 *  identifies the reason for the interrupt and calls the relevant
2984
 *  service routines. As a contongency measure, this ISR allocates the 
3335
 *  service routines. As a contongency measure, this ISR allocates the
2985
 *  recv buffers, if their numbers are below the panic value which is
3336
 *  recv buffers, if their numbers are below the panic value which is
2986
 *  presently set to 25% of the original number of rcv buffers allocated.
3337
 *  presently set to 25% of the original number of rcv buffers allocated.
2987
 *  Return value:
3338
 *  Return value:
2988
 *   IRQ_HANDLED: will be returned if IRQ was handled by this routine 
3339
 *   IRQ_HANDLED: will be returned if IRQ was handled by this routine
2989
 *   IRQ_NONE: will be returned if interrupt is not from our device
3340
 *   IRQ_NONE: will be returned if interrupt is not from our device
2990
 */
3341
 */
2991
static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
3342
static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
2992
{
3343
{
2993
	struct net_device *dev = (struct net_device *) dev_id;
3344
	struct net_device *dev = (struct net_device *) dev_id;
2994
	nic_t *sp = dev->priv;
3345
	nic_t *sp = dev->priv;
2995
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3346
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
2996
#ifndef CONFIG_S2IO_NAPI
3347
	int i;
2997
	int i, ret;
3348
	u64 reason = 0, val64;
2998
#endif
2999
	u64 reason = 0;
3000
	mac_info_t *mac_control;
3349
	mac_info_t *mac_control;
3001
	struct config_param *config;
3350
	struct config_param *config;
3002
3351
3352
	atomic_inc(&sp->isr_cnt);
3003
	mac_control = &sp->mac_control;
3353
	mac_control = &sp->mac_control;
3004
	config = &sp->config;
3354
	config = &sp->config;
3005
3355
3006
	/* 
3356
	/*
3007
	 * Identify the cause for interrupt and call the appropriate
3357
	 * Identify the cause for interrupt and call the appropriate
3008
	 * interrupt handler. Causes for the interrupt could be;
3358
	 * interrupt handler. Causes for the interrupt could be;
3009
	 * 1. Rx of packet.
3359
	 * 1. Rx of packet.
3010
	 * 2. Tx complete.
3360
	 * 2. Tx complete.
3011
	 * 3. Link down.
3361
	 * 3. Link down.
3012
	 * 4. Error in any functional blocks of the NIC. 
3362
	 * 4. Error in any functional blocks of the NIC.
3013
	 */
3363
	 */
3014
	reason = readq(&bar0->general_int_status);
3364
	reason = readq(&bar0->general_int_status);
3015
3365
3016
	if (!reason) {
3366
	if (!reason) {
3017
		/* The interrupt was not raised by Xena. */
3367
		/* The interrupt was not raised by Xena. */
3368
		atomic_dec(&sp->isr_cnt);
3018
		return IRQ_NONE;
3369
		return IRQ_NONE;
3019
	}
3370
	}
3020
3371
3021
	/* If Intr is because of Tx Traffic */
3022
	if (reason & GEN_INTR_TXTRAFFIC) {
3023
		tx_intr_handler(sp);
3024
	}
3025
3026
	/* If Intr is because of an error */
3027
	if (reason & (GEN_ERROR_INTR))
3028
		alarm_intr_handler(sp);
3029
3030
#ifdef CONFIG_S2IO_NAPI
3372
#ifdef CONFIG_S2IO_NAPI
3031
	if (reason & GEN_INTR_RXTRAFFIC) {
3373
	if (reason & GEN_INTR_RXTRAFFIC) {
3032
		if (netif_rx_schedule_prep(dev)) {
3374
		if (netif_rx_schedule_prep(dev)) {
Lines 3038-3054 static irqreturn_t s2io_isr(int irq, voi Link Here
3038
#else
3380
#else
3039
	/* If Intr is because of Rx Traffic */
3381
	/* If Intr is because of Rx Traffic */
3040
	if (reason & GEN_INTR_RXTRAFFIC) {
3382
	if (reason & GEN_INTR_RXTRAFFIC) {
3041
		rx_intr_handler(sp);
3383
		/*
3384
		 * rx_traffic_int reg is an R1 register, writing all 1's
3385
		 * will ensure that the actual interrupt causing bit get's
3386
		 * cleared and hence a read can be avoided.
3387
		 */
3388
		val64 = 0xFFFFFFFFFFFFFFFFULL;
3389
		writeq(val64, &bar0->rx_traffic_int);
3390
		for (i = 0; i < config->rx_ring_num; i++) {
3391
			rx_intr_handler(&mac_control->rings[i]);
3392
		}
3042
	}
3393
	}
3043
#endif
3394
#endif
3044
3395
3045
	/* 
3396
	/* If Intr is because of Tx Traffic */
3046
	 * If the Rx buffer count is below the panic threshold then 
3397
	if (reason & GEN_INTR_TXTRAFFIC) {
3047
	 * reallocate the buffers from the interrupt handler itself, 
3398
		/*
3399
		 * tx_traffic_int reg is an R1 register, writing all 1's
3400
		 * will ensure that the actual interrupt causing bit get's
3401
		 * cleared and hence a read can be avoided.
3402
		 */
3403
		val64 = 0xFFFFFFFFFFFFFFFFULL;
3404
		writeq(val64, &bar0->tx_traffic_int);
3405
3406
		for (i = 0; i < config->tx_fifo_num; i++)
3407
			tx_intr_handler(&mac_control->fifos[i]);
3408
	}
3409
3410
	if (reason & GEN_INTR_TXPIC)
3411
		s2io_txpic_intr_handle(sp);
3412
	/*
3413
	 * If the Rx buffer count is below the panic threshold then
3414
	 * reallocate the buffers from the interrupt handler itself,
3048
	 * else schedule a tasklet to reallocate the buffers.
3415
	 * else schedule a tasklet to reallocate the buffers.
3049
	 */
3416
	 */
3050
#ifndef CONFIG_S2IO_NAPI
3417
#ifndef CONFIG_S2IO_NAPI
3051
	for (i = 0; i < config->RxRingNum; i++) {
3418
	for (i = 0; i < config->rx_ring_num; i++) {
3419
		int ret;
3052
		int rxb_size = atomic_read(&sp->rx_bufs_left[i]);
3420
		int rxb_size = atomic_read(&sp->rx_bufs_left[i]);
3053
		int level = rx_buffer_level(sp, rxb_size, i);
3421
		int level = rx_buffer_level(sp, rxb_size, i);
3054
3422
Lines 3059-3087 static irqreturn_t s2io_isr(int irq, voi Link Here
3059
				DBG_PRINT(ERR_DBG, "%s:Out of memory",
3427
				DBG_PRINT(ERR_DBG, "%s:Out of memory",
3060
					  dev->name);
3428
					  dev->name);
3061
				DBG_PRINT(ERR_DBG, " in ISR!!\n");
3429
				DBG_PRINT(ERR_DBG, " in ISR!!\n");
3062
				clear_bit(0,
3430
				clear_bit(0, (&sp->tasklet_status));
3063
					  (unsigned long *) (&sp->
3431
				atomic_dec(&sp->isr_cnt);
3064
							     tasklet_status));
3065
				return IRQ_HANDLED;
3432
				return IRQ_HANDLED;
3066
			}
3433
			}
3067
			clear_bit(0,
3434
			clear_bit(0, (&sp->tasklet_status));
3068
				  (unsigned long *) (&sp->tasklet_status));
3435
		} else if (level == LOW) {
3069
		} else if ((level == LOW)
3070
			   && (!atomic_read(&sp->tasklet_status))) {
3071
			tasklet_schedule(&sp->task);
3436
			tasklet_schedule(&sp->task);
3072
		}
3437
		}
3073
3074
	}
3438
	}
3075
#endif
3439
#endif
3076
3440
3441
	atomic_dec(&sp->isr_cnt);
3077
	return IRQ_HANDLED;
3442
	return IRQ_HANDLED;
3078
}
3443
}
3079
3444
3080
/**
3445
/**
3081
 *  s2io_get_stats - Updates the device statistics structure. 
3446
 * s2io_updt_stats -
3447
 */
3448
static void s2io_updt_stats(nic_t *sp)
3449
{
3450
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3451
	u64 val64;
3452
	int cnt = 0;
3453
3454
	if (atomic_read(&sp->card_state) == CARD_UP) {
3455
		/* Apprx 30us on a 133 MHz bus */
3456
		val64 = SET_UPDT_CLICKS(10) |
3457
			STAT_CFG_ONE_SHOT_EN | STAT_CFG_STAT_EN;
3458
		writeq(val64, &bar0->stat_cfg);
3459
		do {
3460
			udelay(100);
3461
			val64 = readq(&bar0->stat_cfg);
3462
			if (!(val64 & BIT(0)))
3463
				break;
3464
			cnt++;
3465
			if (cnt == 5)
3466
				break; /* Updt failed */
3467
		} while(1);
3468
	}
3469
}
3470
3471
/**
3472
 *  s2io_get_stats - Updates the device statistics structure.
3082
 *  @dev : pointer to the device structure.
3473
 *  @dev : pointer to the device structure.
3083
 *  Description:
3474
 *  Description:
3084
 *  This function updates the device statistics structure in the s2io_nic 
3475
 *  This function updates the device statistics structure in the s2io_nic
3085
 *  structure and returns a pointer to the same.
3476
 *  structure and returns a pointer to the same.
3086
 *  Return value:
3477
 *  Return value:
3087
 *  pointer to the updated net_device_stats structure.
3478
 *  pointer to the updated net_device_stats structure.
Lines 3093-3106 struct net_device_stats *s2io_get_stats( Link Here
3093
	mac_info_t *mac_control;
3484
	mac_info_t *mac_control;
3094
	struct config_param *config;
3485
	struct config_param *config;
3095
3486
3487
3096
	mac_control = &sp->mac_control;
3488
	mac_control = &sp->mac_control;
3097
	config = &sp->config;
3489
	config = &sp->config;
3098
3490
3099
	sp->stats.tx_errors = mac_control->stats_info->tmac_any_err_frms;
3491
	/* Configure Stats for immediate updt */
3100
	sp->stats.rx_errors = mac_control->stats_info->rmac_drop_frms;
3492
	s2io_updt_stats(sp);
3101
	sp->stats.multicast = mac_control->stats_info->rmac_vld_mcst_frms;
3493
3494
	sp->stats.tx_packets =
3495
		le32_to_cpu(mac_control->stats_info->tmac_frms);
3496
	sp->stats.tx_errors =
3497
		le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
3498
	sp->stats.rx_errors =
3499
		le32_to_cpu(mac_control->stats_info->rmac_drop_frms);
3500
	sp->stats.multicast =
3501
		le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
3102
	sp->stats.rx_length_errors =
3502
	sp->stats.rx_length_errors =
3103
	    mac_control->stats_info->rmac_long_frms;
3503
		le32_to_cpu(mac_control->stats_info->rmac_long_frms);
3104
3504
3105
	return (&sp->stats);
3505
	return (&sp->stats);
3106
}
3506
}
Lines 3109-3116 struct net_device_stats *s2io_get_stats( Link Here
3109
 *  s2io_set_multicast - entry point for multicast address enable/disable.
3509
 *  s2io_set_multicast - entry point for multicast address enable/disable.
3110
 *  @dev : pointer to the device structure
3510
 *  @dev : pointer to the device structure
3111
 *  Description:
3511
 *  Description:
3112
 *  This function is a driver entry point which gets called by the kernel 
3512
 *  This function is a driver entry point which gets called by the kernel
3113
 *  whenever multicast addresses must be enabled/disabled. This also gets 
3513
 *  whenever multicast addresses must be enabled/disabled. This also gets
3114
 *  called to set/reset promiscuous mode. Depending on the deivce flag, we
3514
 *  called to set/reset promiscuous mode. Depending on the deivce flag, we
3115
 *  determine, if multicast address must be enabled or if promiscuous mode
3515
 *  determine, if multicast address must be enabled or if promiscuous mode
3116
 *  is to be disabled etc.
3516
 *  is to be disabled etc.
Lines 3123-3133 static void s2io_set_multicast(struct ne Link Here
3123
	int i, j, prev_cnt;
3523
	int i, j, prev_cnt;
3124
	struct dev_mc_list *mclist;
3524
	struct dev_mc_list *mclist;
3125
	nic_t *sp = dev->priv;
3525
	nic_t *sp = dev->priv;
3126
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3526
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3127
	u64 val64 = 0, multi_mac = 0x010203040506ULL, mask =
3527
	u64 val64 = 0, multi_mac = 0x010203040506ULL, mask =
3128
	    0xfeffffffffffULL;
3528
	    0xfeffffffffffULL;
3129
	u64 dis_addr = 0xffffffffffffULL, mac_addr = 0;
3529
	u64 dis_addr = 0xffffffffffffULL, mac_addr = 0;
3130
	void *add;
3530
	void __iomem *add;
3131
3531
3132
	if ((dev->flags & IFF_ALLMULTI) && (!sp->m_cast_flg)) {
3532
	if ((dev->flags & IFF_ALLMULTI) && (!sp->m_cast_flg)) {
3133
		/*  Enable all Multicast addresses */
3533
		/*  Enable all Multicast addresses */
Lines 3148-3153 static void s2io_set_multicast(struct ne Link Here
3148
		/*  Disable all Multicast addresses */
3548
		/*  Disable all Multicast addresses */
3149
		writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
3549
		writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
3150
		       &bar0->rmac_addr_data0_mem);
3550
		       &bar0->rmac_addr_data0_mem);
3551
		writeq(RMAC_ADDR_DATA1_MEM_MASK(0x0),
3552
		       &bar0->rmac_addr_data1_mem);
3151
		val64 = RMAC_ADDR_CMD_MEM_WE |
3553
		val64 = RMAC_ADDR_CMD_MEM_WE |
3152
		    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3554
		    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3153
		    RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos);
3555
		    RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos);
Lines 3161-3167 static void s2io_set_multicast(struct ne Link Here
3161
3563
3162
	if ((dev->flags & IFF_PROMISC) && (!sp->promisc_flg)) {
3564
	if ((dev->flags & IFF_PROMISC) && (!sp->promisc_flg)) {
3163
		/*  Put the NIC into promiscuous mode */
3565
		/*  Put the NIC into promiscuous mode */
3164
		add = (void *) &bar0->mac_cfg;
3566
		add = &bar0->mac_cfg;
3165
		val64 = readq(&bar0->mac_cfg);
3567
		val64 = readq(&bar0->mac_cfg);
3166
		val64 |= MAC_CFG_RMAC_PROM_ENABLE;
3568
		val64 |= MAC_CFG_RMAC_PROM_ENABLE;
3167
3569
Lines 3172-3182 static void s2io_set_multicast(struct ne Link Here
3172
3574
3173
		val64 = readq(&bar0->mac_cfg);
3575
		val64 = readq(&bar0->mac_cfg);
3174
		sp->promisc_flg = 1;
3576
		sp->promisc_flg = 1;
3175
		DBG_PRINT(ERR_DBG, "%s: entered promiscuous mode\n",
3577
		DBG_PRINT(INFO_DBG, "%s: entered promiscuous mode\n",
3176
			  dev->name);
3578
			  dev->name);
3177
	} else if (!(dev->flags & IFF_PROMISC) && (sp->promisc_flg)) {
3579
	} else if (!(dev->flags & IFF_PROMISC) && (sp->promisc_flg)) {
3178
		/*  Remove the NIC from promiscuous mode */
3580
		/*  Remove the NIC from promiscuous mode */
3179
		add = (void *) &bar0->mac_cfg;
3581
		add = &bar0->mac_cfg;
3180
		val64 = readq(&bar0->mac_cfg);
3582
		val64 = readq(&bar0->mac_cfg);
3181
		val64 &= ~MAC_CFG_RMAC_PROM_ENABLE;
3583
		val64 &= ~MAC_CFG_RMAC_PROM_ENABLE;
3182
3584
Lines 3187-3193 static void s2io_set_multicast(struct ne Link Here
3187
3589
3188
		val64 = readq(&bar0->mac_cfg);
3590
		val64 = readq(&bar0->mac_cfg);
3189
		sp->promisc_flg = 0;
3591
		sp->promisc_flg = 0;
3190
		DBG_PRINT(ERR_DBG, "%s: left promiscuous mode\n",
3592
		DBG_PRINT(INFO_DBG, "%s: left promiscuous mode\n",
3191
			  dev->name);
3593
			  dev->name);
3192
	}
3594
	}
3193
3595
Lines 3209-3214 static void s2io_set_multicast(struct ne Link Here
3209
		for (i = 0; i < prev_cnt; i++) {
3611
		for (i = 0; i < prev_cnt; i++) {
3210
			writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
3612
			writeq(RMAC_ADDR_DATA0_MEM_ADDR(dis_addr),
3211
			       &bar0->rmac_addr_data0_mem);
3613
			       &bar0->rmac_addr_data0_mem);
3614
			writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL),
3615
				&bar0->rmac_addr_data1_mem);
3212
			val64 = RMAC_ADDR_CMD_MEM_WE |
3616
			val64 = RMAC_ADDR_CMD_MEM_WE |
3213
			    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3617
			    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3214
			    RMAC_ADDR_CMD_MEM_OFFSET
3618
			    RMAC_ADDR_CMD_MEM_OFFSET
Lines 3233-3241 static void s2io_set_multicast(struct ne Link Here
3233
				mac_addr |= mclist->dmi_addr[j];
3637
				mac_addr |= mclist->dmi_addr[j];
3234
				mac_addr <<= 8;
3638
				mac_addr <<= 8;
3235
			}
3639
			}
3640
			mac_addr >>= 8;
3236
			writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr),
3641
			writeq(RMAC_ADDR_DATA0_MEM_ADDR(mac_addr),
3237
			       &bar0->rmac_addr_data0_mem);
3642
			       &bar0->rmac_addr_data0_mem);
3238
3643
			writeq(RMAC_ADDR_DATA1_MEM_MASK(0ULL),
3644
				&bar0->rmac_addr_data1_mem);
3239
			val64 = RMAC_ADDR_CMD_MEM_WE |
3645
			val64 = RMAC_ADDR_CMD_MEM_WE |
3240
			    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3646
			    RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
3241
			    RMAC_ADDR_CMD_MEM_OFFSET
3647
			    RMAC_ADDR_CMD_MEM_OFFSET
Lines 3254-3279 static void s2io_set_multicast(struct ne Link Here
3254
}
3660
}
3255
3661
3256
/**
3662
/**
3257
 *  s2io_set_mac_addr - Programs the Xframe mac address 
3663
 *  s2io_set_mac_addr - Programs the Xframe mac address
3258
 *  @dev : pointer to the device structure.
3664
 *  @dev : pointer to the device structure.
3259
 *  @addr: a uchar pointer to the new mac address which is to be set.
3665
 *  @addr: a uchar pointer to the new mac address which is to be set.
3260
 *  Description : This procedure will program the Xframe to receive 
3666
 *  Description : This procedure will program the Xframe to receive
3261
 *  frames with new Mac Address
3667
 *  frames with new Mac Address
3262
 *  Return value: SUCCESS on success and an appropriate (-)ve integer 
3668
 *  Return value: SUCCESS on success and an appropriate (-)ve integer
3263
 *  as defined in errno.h file on failure.
3669
 *  as defined in errno.h file on failure.
3264
 */
3670
 */
3265
3671
3266
int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
3672
int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
3267
{
3673
{
3268
	nic_t *sp = dev->priv;
3674
	nic_t *sp = dev->priv;
3269
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3675
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3270
	register u64 val64, mac_addr = 0;
3676
	register u64 val64, mac_addr = 0;
3271
	int i;
3677
	int i;
3272
3678
3273
	/* 
3679
	/*
3274
	 * Set the new MAC address as the new unicast filter and reflect this
3680
	 * Set the new MAC address as the new unicast filter and reflect this
3275
	 * change on the device address registered with the OS. It will be
3681
	 * change on the device address registered with the OS. It will be
3276
	 * at offset 0. 
3682
	 * at offset 0.
3277
	 */
3683
	 */
3278
	for (i = 0; i < ETH_ALEN; i++) {
3684
	for (i = 0; i < ETH_ALEN; i++) {
3279
		mac_addr <<= 8;
3685
		mac_addr <<= 8;
Lines 3297-3308 int s2io_set_mac_addr(struct net_device Link Here
3297
}
3703
}
3298
3704
3299
/**
3705
/**
3300
 * s2io_ethtool_sset - Sets different link parameters. 
3706
 * s2io_ethtool_sset - Sets different link parameters.
3301
 * @sp : private member of the device structure, which is a pointer to the  * s2io_nic structure.
3707
 * @sp : private member of the device structure, which is a pointer to the  * s2io_nic structure.
3302
 * @info: pointer to the structure with parameters given by ethtool to set
3708
 * @info: pointer to the structure with parameters given by ethtool to set
3303
 * link information.
3709
 * link information.
3304
 * Description:
3710
 * Description:
3305
 * The function sets different link parameters provided by the user onto 
3711
 * The function sets different link parameters provided by the user onto
3306
 * the NIC.
3712
 * the NIC.
3307
 * Return value:
3713
 * Return value:
3308
 * 0 on success.
3714
 * 0 on success.
Lines 3324-3341 static int s2io_ethtool_sset(struct net_ Link Here
3324
}
3730
}
3325
3731
3326
/**
3732
/**
3327
 * s2io_ethtol_gset - Return link specific information. 
3733
 * s2io_ethtol_gset - Return link specific information.
3328
 * @sp : private member of the device structure, pointer to the
3734
 * @sp : private member of the device structure, pointer to the
3329
 *      s2io_nic structure.
3735
 *      s2io_nic structure.
3330
 * @info : pointer to the structure with parameters given by ethtool
3736
 * @info : pointer to the structure with parameters given by ethtool
3331
 * to return link information.
3737
 * to return link information.
3332
 * Description:
3738
 * Description:
3333
 * Returns link specefic information like speed, duplex etc.. to ethtool.
3739
 * Returns link specific information like speed, duplex etc.. to ethtool.
3334
 * Return value :
3740
 * Return value :
3335
 * return 0 on success.
3741
 * return 0 on success.
3336
 */
3742
 */
3337
3743
3338
int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info)
3744
static int s2io_ethtool_gset(struct net_device *dev, struct ethtool_cmd *info)
3339
{
3745
{
3340
	nic_t *sp = dev->priv;
3746
	nic_t *sp = dev->priv;
3341
	info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
3747
	info->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
Lines 3356-3363 int s2io_ethtool_gset(struct net_device Link Here
3356
}
3762
}
3357
3763
3358
/**
3764
/**
3359
 * s2io_ethtool_gdrvinfo - Returns driver specific information. 
3765
 * s2io_ethtool_gdrvinfo - Returns driver specific information.
3360
 * @sp : private member of the device structure, which is a pointer to the 
3766
 * @sp : private member of the device structure, which is a pointer to the
3361
 * s2io_nic structure.
3767
 * s2io_nic structure.
3362
 * @info : pointer to the structure with parameters given by ethtool to
3768
 * @info : pointer to the structure with parameters given by ethtool to
3363
 * return driver information.
3769
 * return driver information.
Lines 3376-3382 static void s2io_ethtool_gdrvinfo(struct Link Here
3376
	strncpy(info->version, s2io_driver_version,
3782
	strncpy(info->version, s2io_driver_version,
3377
		sizeof(s2io_driver_version));
3783
		sizeof(s2io_driver_version));
3378
	strncpy(info->fw_version, "", 32);
3784
	strncpy(info->fw_version, "", 32);
3379
	strncpy(info->bus_info, sp->pdev->slot_name, 32);
3785
	strncpy(info->bus_info, pci_name(sp->pdev), 32);
3380
	info->regdump_len = XENA_REG_SPACE;
3786
	info->regdump_len = XENA_REG_SPACE;
3381
	info->eedump_len = XENA_EEPROM_SPACE;
3787
	info->eedump_len = XENA_EEPROM_SPACE;
3382
	info->testinfo_len = S2IO_TEST_LEN;
3788
	info->testinfo_len = S2IO_TEST_LEN;
Lines 3384-3393 static void s2io_ethtool_gdrvinfo(struct Link Here
3384
}
3790
}
3385
3791
3386
/**
3792
/**
3387
 *  s2io_ethtool_gregs - dumps the entire space of Xfame into te buffer.
3793
 *  s2io_ethtool_gregs - dumps the entire space of Xfame into the buffer.
3388
 *  @sp: private member of the device structure, which is a pointer to the 
3794
 *  @sp: private member of the device structure, which is a pointer to the
3389
 *  s2io_nic structure.
3795
 *  s2io_nic structure.
3390
 *  @regs : pointer to the structure with parameters given by ethtool for 
3796
 *  @regs : pointer to the structure with parameters given by ethtool for
3391
 *  dumping the registers.
3797
 *  dumping the registers.
3392
 *  @reg_space: The input argumnet into which all the registers are dumped.
3798
 *  @reg_space: The input argumnet into which all the registers are dumped.
3393
 *  Description:
3799
 *  Description:
Lines 3409-3437 static void s2io_ethtool_gregs(struct ne Link Here
3409
	regs->version = sp->pdev->subsystem_device;
3815
	regs->version = sp->pdev->subsystem_device;
3410
3816
3411
	for (i = 0; i < regs->len; i += 8) {
3817
	for (i = 0; i < regs->len; i += 8) {
3412
		reg = readq((void *) (sp->bar0 + i));
3818
		reg = readq(sp->bar0 + i);
3413
		memcpy((reg_space + i), &reg, 8);
3819
		memcpy((reg_space + i), &reg, 8);
3414
	}
3820
	}
3415
}
3821
}
3416
3822
3417
/**
3823
/**
3418
 *  s2io_phy_id  - timer function that alternates adapter LED.
3824
 *  s2io_phy_id  - timer function that alternates adapter LED.
3419
 *  @data : address of the private member of the device structure, which 
3825
 *  @data : address of the private member of the device structure, which
3420
 *  is a pointer to the s2io_nic structure, provided as an u32.
3826
 *  is a pointer to the s2io_nic structure, provided as an u32.
3421
 * Description: This is actually the timer function that alternates the 
3827
 * Description: This is actually the timer function that alternates the
3422
 * adapter LED bit of the adapter control bit to set/reset every time on 
3828
 * adapter LED bit of the adapter control bit to set/reset every time on
3423
 * invocation. The timer is set for 1/2 a second, hence tha NIC blinks 
3829
 * invocation. The timer is set for 1/2 a second, hence tha NIC blinks
3424
 *  once every second.
3830
 *  once every second.
3425
*/
3831
*/
3426
static void s2io_phy_id(unsigned long data)
3832
static void s2io_phy_id(unsigned long data)
3427
{
3833
{
3428
	nic_t *sp = (nic_t *) data;
3834
	nic_t *sp = (nic_t *) data;
3429
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3835
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3430
	u64 val64 = 0;
3836
	u64 val64 = 0;
3431
	u16 subid;
3837
	u16 subid;
3432
3838
3433
	subid = sp->pdev->subsystem_device;
3839
	subid = sp->pdev->subsystem_device;
3434
	if ((subid & 0xFF) >= 0x07) {
3840
	if ((sp->device_type == XFRAME_II_DEVICE) ||
3841
		   ((subid & 0xFF) >= 0x07)) {
3435
		val64 = readq(&bar0->gpio_control);
3842
		val64 = readq(&bar0->gpio_control);
3436
		val64 ^= GPIO_CTRL_GPIO_0;
3843
		val64 ^= GPIO_CTRL_GPIO_0;
3437
		writeq(val64, &bar0->gpio_control);
3844
		writeq(val64, &bar0->gpio_control);
Lines 3445-3459 static void s2io_phy_id(unsigned long da Link Here
3445
}
3852
}
3446
3853
3447
/**
3854
/**
3448
 * s2io_ethtool_idnic - To physically ientify the nic on the system.
3855
 * s2io_ethtool_idnic - To physically identify the nic on the system.
3449
 * @sp : private member of the device structure, which is a pointer to the
3856
 * @sp : private member of the device structure, which is a pointer to the
3450
 * s2io_nic structure.
3857
 * s2io_nic structure.
3451
 * @id : pointer to the structure with identification parameters given by 
3858
 * @id : pointer to the structure with identification parameters given by
3452
 * ethtool.
3859
 * ethtool.
3453
 * Description: Used to physically identify the NIC on the system.
3860
 * Description: Used to physically identify the NIC on the system.
3454
 * The Link LED will blink for a time specified by the user for 
3861
 * The Link LED will blink for a time specified by the user for
3455
 * identification.
3862
 * identification.
3456
 * NOTE: The Link has to be Up to be able to blink the LED. Hence 
3863
 * NOTE: The Link has to be Up to be able to blink the LED. Hence
3457
 * identification is possible only if it's link is up.
3864
 * identification is possible only if it's link is up.
3458
 * Return value:
3865
 * Return value:
3459
 * int , returns 0 on success
3866
 * int , returns 0 on success
Lines 3463-3474 static int s2io_ethtool_idnic(struct net Link Here
3463
{
3870
{
3464
	u64 val64 = 0, last_gpio_ctrl_val;
3871
	u64 val64 = 0, last_gpio_ctrl_val;
3465
	nic_t *sp = dev->priv;
3872
	nic_t *sp = dev->priv;
3466
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3873
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3467
	u16 subid;
3874
	u16 subid;
3468
3875
3469
	subid = sp->pdev->subsystem_device;
3876
	subid = sp->pdev->subsystem_device;
3470
	last_gpio_ctrl_val = readq(&bar0->gpio_control);
3877
	last_gpio_ctrl_val = readq(&bar0->gpio_control);
3471
	if ((subid & 0xFF) < 0x07) {
3878
	if ((sp->device_type == XFRAME_I_DEVICE) &&
3879
		((subid & 0xFF) < 0x07)) {
3472
		val64 = readq(&bar0->adapter_control);
3880
		val64 = readq(&bar0->adapter_control);
3473
		if (!(val64 & ADAPTER_CNTL_EN)) {
3881
		if (!(val64 & ADAPTER_CNTL_EN)) {
3474
			printk(KERN_ERR
3882
			printk(KERN_ERR
Lines 3482-3495 static int s2io_ethtool_idnic(struct net Link Here
3482
		sp->id_timer.data = (unsigned long) sp;
3890
		sp->id_timer.data = (unsigned long) sp;
3483
	}
3891
	}
3484
	mod_timer(&sp->id_timer, jiffies);
3892
	mod_timer(&sp->id_timer, jiffies);
3485
	set_current_state(TASK_INTERRUPTIBLE);
3486
	if (data)
3893
	if (data)
3487
		schedule_timeout(data * HZ);
3894
		msleep_interruptible(data * HZ);
3488
	else
3895
	else
3489
		schedule_timeout(MAX_SCHEDULE_TIMEOUT);
3896
		msleep_interruptible(MAX_FLICKER_TIME);
3490
	del_timer_sync(&sp->id_timer);
3897
	del_timer_sync(&sp->id_timer);
3491
3898
3492
	if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
3899
	if (CARDS_WITH_FAULTY_LINK_INDICATORS(sp->device_type, subid)) {
3493
		writeq(last_gpio_ctrl_val, &bar0->gpio_control);
3900
		writeq(last_gpio_ctrl_val, &bar0->gpio_control);
3494
		last_gpio_ctrl_val = readq(&bar0->gpio_control);
3901
		last_gpio_ctrl_val = readq(&bar0->gpio_control);
3495
	}
3902
	}
Lines 3499-3505 static int s2io_ethtool_idnic(struct net Link Here
3499
3906
3500
/**
3907
/**
3501
 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
3908
 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
3502
 * @sp : private member of the device structure, which is a pointer to the  * s2io_nic structure.
3909
 * @sp : private member of the device structure, which is a pointer to the
3910
 *	s2io_nic structure.
3503
 * @ep : pointer to the structure with pause parameters given by ethtool.
3911
 * @ep : pointer to the structure with pause parameters given by ethtool.
3504
 * Description:
3912
 * Description:
3505
 * Returns the Pause frame generation and reception capability of the NIC.
3913
 * Returns the Pause frame generation and reception capability of the NIC.
Lines 3511-3517 static void s2io_ethtool_getpause_data(s Link Here
3511
{
3919
{
3512
	u64 val64;
3920
	u64 val64;
3513
	nic_t *sp = dev->priv;
3921
	nic_t *sp = dev->priv;
3514
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3922
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3515
3923
3516
	val64 = readq(&bar0->rmac_pause_cfg);
3924
	val64 = readq(&bar0->rmac_pause_cfg);
3517
	if (val64 & RMAC_PAUSE_GEN_ENABLE)
3925
	if (val64 & RMAC_PAUSE_GEN_ENABLE)
Lines 3522-3529 static void s2io_ethtool_getpause_data(s Link Here
3522
}
3930
}
3523
3931
3524
/**
3932
/**
3525
 * s2io_ethtool-setpause_data -  set/reset pause frame generation.
3933
 * s2io_ethtool_setpause_data -  set/reset pause frame generation.
3526
 * @sp : private member of the device structure, which is a pointer to the 
3934
 * @sp : private member of the device structure, which is a pointer to the
3527
 *      s2io_nic structure.
3935
 *      s2io_nic structure.
3528
 * @ep : pointer to the structure with pause parameters given by ethtool.
3936
 * @ep : pointer to the structure with pause parameters given by ethtool.
3529
 * Description:
3937
 * Description:
Lines 3533-3544 static void s2io_ethtool_getpause_data(s Link Here
3533
 * int, returns 0 on Success
3941
 * int, returns 0 on Success
3534
 */
3942
 */
3535
3943
3536
int s2io_ethtool_setpause_data(struct net_device *dev,
3944
static int s2io_ethtool_setpause_data(struct net_device *dev,
3537
			       struct ethtool_pauseparam *ep)
3945
			       struct ethtool_pauseparam *ep)
3538
{
3946
{
3539
	u64 val64;
3947
	u64 val64;
3540
	nic_t *sp = dev->priv;
3948
	nic_t *sp = dev->priv;
3541
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3949
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3542
3950
3543
	val64 = readq(&bar0->rmac_pause_cfg);
3951
	val64 = readq(&bar0->rmac_pause_cfg);
3544
	if (ep->tx_pause)
3952
	if (ep->tx_pause)
Lines 3555-3567 int s2io_ethtool_setpause_data(struct ne Link Here
3555
3963
3556
/**
3964
/**
3557
 * read_eeprom - reads 4 bytes of data from user given offset.
3965
 * read_eeprom - reads 4 bytes of data from user given offset.
3558
 * @sp : private member of the device structure, which is a pointer to the 
3966
 * @sp : private member of the device structure, which is a pointer to the
3559
 *      s2io_nic structure.
3967
 *      s2io_nic structure.
3560
 * @off : offset at which the data must be written
3968
 * @off : offset at which the data must be written
3561
 * @data : Its an output parameter where the data read at the given
3969
 * @data : Its an output parameter where the data read at the given
3562
 * 	offset is stored.
3970
 *	offset is stored.
3563
 * Description:
3971
 * Description:
3564
 * Will read 4 bytes of data from the user given offset and return the 
3972
 * Will read 4 bytes of data from the user given offset and return the
3565
 * read data.
3973
 * read data.
3566
 * NOTE: Will allow to read only part of the EEPROM visible through the
3974
 * NOTE: Will allow to read only part of the EEPROM visible through the
3567
 *   I2C bus.
3975
 *   I2C bus.
Lines 3575-3581 static int read_eeprom(nic_t * sp, int o Link Here
3575
	int ret = -1;
3983
	int ret = -1;
3576
	u32 exit_cnt = 0;
3984
	u32 exit_cnt = 0;
3577
	u64 val64;
3985
	u64 val64;
3578
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
3986
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3579
3987
3580
	val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
3988
	val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
3581
	    I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ |
3989
	    I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ |
Lines 3589-3596 static int read_eeprom(nic_t * sp, int o Link Here
3589
			ret = 0;
3997
			ret = 0;
3590
			break;
3998
			break;
3591
		}
3999
		}
3592
		set_current_state(TASK_UNINTERRUPTIBLE);
4000
		msleep(50);
3593
		schedule_timeout(HZ / 20);
3594
		exit_cnt++;
4001
		exit_cnt++;
3595
	}
4002
	}
3596
4003
Lines 3603-3609 static int read_eeprom(nic_t * sp, int o Link Here
3603
 *       s2io_nic structure.
4010
 *       s2io_nic structure.
3604
 *  @off : offset at which the data must be written
4011
 *  @off : offset at which the data must be written
3605
 *  @data : The data that is to be written
4012
 *  @data : The data that is to be written
3606
 *  @cnt : Number of bytes of the data that are actually to be written into 
4013
 *  @cnt : Number of bytes of the data that are actually to be written into
3607
 *  the Eeprom. (max of 3)
4014
 *  the Eeprom. (max of 3)
3608
 * Description:
4015
 * Description:
3609
 *  Actually writes the relevant part of the data value into the Eeprom
4016
 *  Actually writes the relevant part of the data value into the Eeprom
Lines 3616-3622 static int write_eeprom(nic_t * sp, int Link Here
3616
{
4023
{
3617
	int exit_cnt = 0, ret = -1;
4024
	int exit_cnt = 0, ret = -1;
3618
	u64 val64;
4025
	u64 val64;
3619
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
4026
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3620
4027
3621
	val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
4028
	val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
3622
	    I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA(data) |
4029
	    I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA(data) |
Lines 3630-3637 static int write_eeprom(nic_t * sp, int Link Here
3630
				ret = 0;
4037
				ret = 0;
3631
			break;
4038
			break;
3632
		}
4039
		}
3633
		set_current_state(TASK_UNINTERRUPTIBLE);
4040
		msleep(50);
3634
		schedule_timeout(HZ / 20);
3635
		exit_cnt++;
4041
		exit_cnt++;
3636
	}
4042
	}
3637
4043
Lines 3641-3647 static int write_eeprom(nic_t * sp, int Link Here
3641
/**
4047
/**
3642
 *  s2io_ethtool_geeprom  - reads the value stored in the Eeprom.
4048
 *  s2io_ethtool_geeprom  - reads the value stored in the Eeprom.
3643
 *  @sp : private member of the device structure, which is a pointer to the *       s2io_nic structure.
4049
 *  @sp : private member of the device structure, which is a pointer to the *       s2io_nic structure.
3644
 *  @eeprom : pointer to the user level structure provided by ethtool, 
4050
 *  @eeprom : pointer to the user level structure provided by ethtool,
3645
 *  containing all relevant information.
4051
 *  containing all relevant information.
3646
 *  @data_buf : user defined value to be written into Eeprom.
4052
 *  @data_buf : user defined value to be written into Eeprom.
3647
 *  Description: Reads the values stored in the Eeprom at given offset
4053
 *  Description: Reads the values stored in the Eeprom at given offset
Lines 3651-3657 static int write_eeprom(nic_t * sp, int Link Here
3651
 *  int  0 on success
4057
 *  int  0 on success
3652
 */
4058
 */
3653
4059
3654
int s2io_ethtool_geeprom(struct net_device *dev,
4060
static int s2io_ethtool_geeprom(struct net_device *dev,
3655
			 struct ethtool_eeprom *eeprom, u8 * data_buf)
4061
			 struct ethtool_eeprom *eeprom, u8 * data_buf)
3656
{
4062
{
3657
	u32 data, i, valid;
4063
	u32 data, i, valid;
Lines 3677-3683 int s2io_ethtool_geeprom(struct net_devi Link Here
3677
 *  s2io_ethtool_seeprom - tries to write the user provided value in Eeprom
4083
 *  s2io_ethtool_seeprom - tries to write the user provided value in Eeprom
3678
 *  @sp : private member of the device structure, which is a pointer to the
4084
 *  @sp : private member of the device structure, which is a pointer to the
3679
 *  s2io_nic structure.
4085
 *  s2io_nic structure.
3680
 *  @eeprom : pointer to the user level structure provided by ethtool, 
4086
 *  @eeprom : pointer to the user level structure provided by ethtool,
3681
 *  containing all relevant information.
4087
 *  containing all relevant information.
3682
 *  @data_buf ; user defined value to be written into Eeprom.
4088
 *  @data_buf ; user defined value to be written into Eeprom.
3683
 *  Description:
4089
 *  Description:
Lines 3725-3732 static int s2io_ethtool_seeprom(struct n Link Here
3725
}
4131
}
3726
4132
3727
/**
4133
/**
3728
 * s2io_register_test - reads and writes into all clock domains. 
4134
 * s2io_register_test - reads and writes into all clock domains.
3729
 * @sp : private member of the device structure, which is a pointer to the 
4135
 * @sp : private member of the device structure, which is a pointer to the
3730
 * s2io_nic structure.
4136
 * s2io_nic structure.
3731
 * @data : variable that returns the result of each of the test conducted b
4137
 * @data : variable that returns the result of each of the test conducted b
3732
 * by the driver.
4138
 * by the driver.
Lines 3739-3750 static int s2io_ethtool_seeprom(struct n Link Here
3739
4145
3740
static int s2io_register_test(nic_t * sp, uint64_t * data)
4146
static int s2io_register_test(nic_t * sp, uint64_t * data)
3741
{
4147
{
3742
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
4148
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3743
	u64 val64 = 0;
4149
	u64 val64 = 0;
3744
	int fail = 0;
4150
	int fail = 0;
3745
4151
3746
	val64 = readq(&bar0->pcc_enable);
4152
	val64 = readq(&bar0->pif_rd_swapper_fb);
3747
	if (val64 != 0xff00000000000000ULL) {
4153
	if (val64 != 0x123456789abcdefULL) {
3748
		fail = 1;
4154
		fail = 1;
3749
		DBG_PRINT(INFO_DBG, "Read Test level 1 fails\n");
4155
		DBG_PRINT(INFO_DBG, "Read Test level 1 fails\n");
3750
	}
4156
	}
Lines 3788-3800 static int s2io_register_test(nic_t * sp Link Here
3788
}
4194
}
3789
4195
3790
/**
4196
/**
3791
 * s2io_eeprom_test - to verify that EEprom in the xena can be programmed. 
4197
 * s2io_eeprom_test - to verify that EEprom in the xena can be programmed.
3792
 * @sp : private member of the device structure, which is a pointer to the
4198
 * @sp : private member of the device structure, which is a pointer to the
3793
 * s2io_nic structure.
4199
 * s2io_nic structure.
3794
 * @data:variable that returns the result of each of the test conducted by
4200
 * @data:variable that returns the result of each of the test conducted by
3795
 * the driver.
4201
 * the driver.
3796
 * Description:
4202
 * Description:
3797
 * Verify that EEPROM in the xena can be programmed using I2C_CONTROL 
4203
 * Verify that EEPROM in the xena can be programmed using I2C_CONTROL
3798
 * register.
4204
 * register.
3799
 * Return value:
4205
 * Return value:
3800
 * 0 on success.
4206
 * 0 on success.
Lines 3859-3872 static int s2io_eeprom_test(nic_t * sp, Link Here
3859
4265
3860
/**
4266
/**
3861
 * s2io_bist_test - invokes the MemBist test of the card .
4267
 * s2io_bist_test - invokes the MemBist test of the card .
3862
 * @sp : private member of the device structure, which is a pointer to the 
4268
 * @sp : private member of the device structure, which is a pointer to the
3863
 * s2io_nic structure.
4269
 * s2io_nic structure.
3864
 * @data:variable that returns the result of each of the test conducted by 
4270
 * @data:variable that returns the result of each of the test conducted by
3865
 * the driver.
4271
 * the driver.
3866
 * Description:
4272
 * Description:
3867
 * This invokes the MemBist test of the card. We give around
4273
 * This invokes the MemBist test of the card. We give around
3868
 * 2 secs time for the Test to complete. If it's still not complete
4274
 * 2 secs time for the Test to complete. If it's still not complete
3869
 * within this peiod, we consider that the test failed. 
4275
 * within this peiod, we consider that the test failed.
3870
 * Return value:
4276
 * Return value:
3871
 * 0 on success and -1 on failure.
4277
 * 0 on success and -1 on failure.
3872
 */
4278
 */
Lines 3887-3894 static int s2io_bist_test(nic_t * sp, ui Link Here
3887
			ret = 0;
4293
			ret = 0;
3888
			break;
4294
			break;
3889
		}
4295
		}
3890
		set_current_state(TASK_UNINTERRUPTIBLE);
4296
		msleep(100);
3891
		schedule_timeout(HZ / 10);
3892
		cnt++;
4297
		cnt++;
3893
	}
4298
	}
3894
4299
Lines 3896-3908 static int s2io_bist_test(nic_t * sp, ui Link Here
3896
}
4301
}
3897
4302
3898
/**
4303
/**
3899
 * s2io-link_test - verifies the link state of the nic  
4304
 * s2io-link_test - verifies the link state of the nic
3900
 * @sp ; private member of the device structure, which is a pointer to the 
4305
 * @sp ; private member of the device structure, which is a pointer to the
3901
 * s2io_nic structure.
4306
 * s2io_nic structure.
3902
 * @data: variable that returns the result of each of the test conducted by
4307
 * @data: variable that returns the result of each of the test conducted by
3903
 * the driver.
4308
 * the driver.
3904
 * Description:
4309
 * Description:
3905
 * The function verifies the link state of the NIC and updates the input 
4310
 * The function verifies the link state of the NIC and updates the input
3906
 * argument 'data' appropriately.
4311
 * argument 'data' appropriately.
3907
 * Return value:
4312
 * Return value:
3908
 * 0 on success.
4313
 * 0 on success.
Lines 3910-3916 static int s2io_bist_test(nic_t * sp, ui Link Here
3910
4315
3911
static int s2io_link_test(nic_t * sp, uint64_t * data)
4316
static int s2io_link_test(nic_t * sp, uint64_t * data)
3912
{
4317
{
3913
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
4318
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3914
	u64 val64;
4319
	u64 val64;
3915
4320
3916
	val64 = readq(&bar0->adapter_status);
4321
	val64 = readq(&bar0->adapter_status);
Lines 3921-3933 static int s2io_link_test(nic_t * sp, ui Link Here
3921
}
4326
}
3922
4327
3923
/**
4328
/**
3924
 * s2io_rldram_test - offline test for access to the RldRam chip on the NIC 
4329
 * s2io_rldram_test - offline test for access to the RldRam chip on the NIC
3925
 * @sp - private member of the device structure, which is a pointer to the  
4330
 * @sp - private member of the device structure, which is a pointer to the
3926
 * s2io_nic structure.
4331
 * s2io_nic structure.
3927
 * @data - variable that returns the result of each of the test 
4332
 * @data - variable that returns the result of each of the test
3928
 * conducted by the driver.
4333
 * conducted by the driver.
3929
 * Description:
4334
 * Description:
3930
 *  This is one of the offline test that tests the read and write 
4335
 *  This is one of the offline test that tests the read and write
3931
 *  access to the RldRam chip on the NIC.
4336
 *  access to the RldRam chip on the NIC.
3932
 * Return value:
4337
 * Return value:
3933
 *  0 on success.
4338
 *  0 on success.
Lines 3935-3941 static int s2io_link_test(nic_t * sp, ui Link Here
3935
4340
3936
static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4341
static int s2io_rldram_test(nic_t * sp, uint64_t * data)
3937
{
4342
{
3938
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
4343
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
3939
	u64 val64;
4344
	u64 val64;
3940
	int cnt, iteration = 0, test_pass = 0;
4345
	int cnt, iteration = 0, test_pass = 0;
3941
4346
Lines 3989-3996 static int s2io_rldram_test(nic_t * sp, Link Here
3989
			val64 = readq(&bar0->mc_rldram_test_ctrl);
4394
			val64 = readq(&bar0->mc_rldram_test_ctrl);
3990
			if (val64 & MC_RLDRAM_TEST_DONE)
4395
			if (val64 & MC_RLDRAM_TEST_DONE)
3991
				break;
4396
				break;
3992
			set_current_state(TASK_UNINTERRUPTIBLE);
4397
			msleep(200);
3993
			schedule_timeout(HZ / 5);
3994
		}
4398
		}
3995
4399
3996
		if (cnt == 5)
4400
		if (cnt == 5)
Lines 4006-4013 static int s2io_rldram_test(nic_t * sp, Link Here
4006
			val64 = readq(&bar0->mc_rldram_test_ctrl);
4410
			val64 = readq(&bar0->mc_rldram_test_ctrl);
4007
			if (val64 & MC_RLDRAM_TEST_DONE)
4411
			if (val64 & MC_RLDRAM_TEST_DONE)
4008
				break;
4412
				break;
4009
			set_current_state(TASK_UNINTERRUPTIBLE);
4413
			msleep(500);
4010
			schedule_timeout(HZ / 2);
4011
		}
4414
		}
4012
4415
4013
		if (cnt == 5)
4416
		if (cnt == 5)
Lines 4034-4040 static int s2io_rldram_test(nic_t * sp, Link Here
4034
 *  s2io_nic structure.
4437
 *  s2io_nic structure.
4035
 *  @ethtest : pointer to a ethtool command specific structure that will be
4438
 *  @ethtest : pointer to a ethtool command specific structure that will be
4036
 *  returned to the user.
4439
 *  returned to the user.
4037
 *  @data : variable that returns the result of each of the test 
4440
 *  @data : variable that returns the result of each of the test
4038
 * conducted by the driver.
4441
 * conducted by the driver.
4039
 * Description:
4442
 * Description:
4040
 *  This function conducts 6 tests ( 4 offline and 2 online) to determine
4443
 *  This function conducts 6 tests ( 4 offline and 2 online) to determine
Lines 4052-4074 static void s2io_ethtool_test(struct net Link Here
4052
4455
4053
	if (ethtest->flags == ETH_TEST_FL_OFFLINE) {
4456
	if (ethtest->flags == ETH_TEST_FL_OFFLINE) {
4054
		/* Offline Tests. */
4457
		/* Offline Tests. */
4055
		if (orig_state) {
4458
		if (orig_state)
4056
			s2io_close(sp->dev);
4459
			s2io_close(sp->dev);
4057
			s2io_set_swapper(sp);
4058
		} else
4059
			s2io_set_swapper(sp);
4060
4460
4061
		if (s2io_register_test(sp, &data[0]))
4461
		if (s2io_register_test(sp, &data[0]))
4062
			ethtest->flags |= ETH_TEST_FL_FAILED;
4462
			ethtest->flags |= ETH_TEST_FL_FAILED;
4063
4463
4064
		s2io_reset(sp);
4464
		s2io_reset(sp);
4065
		s2io_set_swapper(sp);
4066
4465
4067
		if (s2io_rldram_test(sp, &data[3]))
4466
		if (s2io_rldram_test(sp, &data[3]))
4068
			ethtest->flags |= ETH_TEST_FL_FAILED;
4467
			ethtest->flags |= ETH_TEST_FL_FAILED;
4069
4468
4070
		s2io_reset(sp);
4469
		s2io_reset(sp);
4071
		s2io_set_swapper(sp);
4072
4470
4073
		if (s2io_eeprom_test(sp, &data[1]))
4471
		if (s2io_eeprom_test(sp, &data[1]))
4074
			ethtest->flags |= ETH_TEST_FL_FAILED;
4472
			ethtest->flags |= ETH_TEST_FL_FAILED;
Lines 4111-4155 static void s2io_get_ethtool_stats(struc Link Here
4111
	nic_t *sp = dev->priv;
4509
	nic_t *sp = dev->priv;
4112
	StatInfo_t *stat_info = sp->mac_control.stats_info;
4510
	StatInfo_t *stat_info = sp->mac_control.stats_info;
4113
4511
4114
	tmp_stats[i++] = stat_info->tmac_frms;
4512
	s2io_updt_stats(sp);
4115
	tmp_stats[i++] = stat_info->tmac_data_octets;
4513
	tmp_stats[i++] =
4116
	tmp_stats[i++] = stat_info->tmac_drop_frms;
4514
		(u64)le32_to_cpu(stat_info->tmac_frms_oflow) << 32  |
4117
	tmp_stats[i++] = stat_info->tmac_mcst_frms;
4515
		le32_to_cpu(stat_info->tmac_frms);
4118
	tmp_stats[i++] = stat_info->tmac_bcst_frms;
4516
	tmp_stats[i++] =
4119
	tmp_stats[i++] = stat_info->tmac_pause_ctrl_frms;
4517
		(u64)le32_to_cpu(stat_info->tmac_data_octets_oflow) << 32 |
4120
	tmp_stats[i++] = stat_info->tmac_any_err_frms;
4518
		le32_to_cpu(stat_info->tmac_data_octets);
4121
	tmp_stats[i++] = stat_info->tmac_vld_ip_octets;
4519
	tmp_stats[i++] = le64_to_cpu(stat_info->tmac_drop_frms);
4122
	tmp_stats[i++] = stat_info->tmac_vld_ip;
4520
	tmp_stats[i++] =
4123
	tmp_stats[i++] = stat_info->tmac_drop_ip;
4521
		(u64)le32_to_cpu(stat_info->tmac_mcst_frms_oflow) << 32 |
4124
	tmp_stats[i++] = stat_info->tmac_icmp;
4522
		le32_to_cpu(stat_info->tmac_mcst_frms);
4125
	tmp_stats[i++] = stat_info->tmac_rst_tcp;
4523
	tmp_stats[i++] =
4126
	tmp_stats[i++] = stat_info->tmac_tcp;
4524
		(u64)le32_to_cpu(stat_info->tmac_bcst_frms_oflow) << 32 |
4127
	tmp_stats[i++] = stat_info->tmac_udp;
4525
		le32_to_cpu(stat_info->tmac_bcst_frms);
4128
	tmp_stats[i++] = stat_info->rmac_vld_frms;
4526
	tmp_stats[i++] = le64_to_cpu(stat_info->tmac_pause_ctrl_frms);
4129
	tmp_stats[i++] = stat_info->rmac_data_octets;
4527
	tmp_stats[i++] =
4130
	tmp_stats[i++] = stat_info->rmac_fcs_err_frms;
4528
		(u64)le32_to_cpu(stat_info->tmac_any_err_frms_oflow) << 32 |
4131
	tmp_stats[i++] = stat_info->rmac_drop_frms;
4529
		le32_to_cpu(stat_info->tmac_any_err_frms);
4132
	tmp_stats[i++] = stat_info->rmac_vld_mcst_frms;
4530
	tmp_stats[i++] = le64_to_cpu(stat_info->tmac_vld_ip_octets);
4133
	tmp_stats[i++] = stat_info->rmac_vld_bcst_frms;
4531
	tmp_stats[i++] =
4134
	tmp_stats[i++] = stat_info->rmac_in_rng_len_err_frms;
4532
		(u64)le32_to_cpu(stat_info->tmac_vld_ip_oflow) << 32 |
4135
	tmp_stats[i++] = stat_info->rmac_long_frms;
4533
		le32_to_cpu(stat_info->tmac_vld_ip);
4136
	tmp_stats[i++] = stat_info->rmac_pause_ctrl_frms;
4534
	tmp_stats[i++] =
4137
	tmp_stats[i++] = stat_info->rmac_discarded_frms;
4535
		(u64)le32_to_cpu(stat_info->tmac_drop_ip_oflow) << 32 |
4138
	tmp_stats[i++] = stat_info->rmac_usized_frms;
4536
		le32_to_cpu(stat_info->tmac_drop_ip);
4139
	tmp_stats[i++] = stat_info->rmac_osized_frms;
4537
	tmp_stats[i++] =
4140
	tmp_stats[i++] = stat_info->rmac_frag_frms;
4538
		(u64)le32_to_cpu(stat_info->tmac_icmp_oflow) << 32 |
4141
	tmp_stats[i++] = stat_info->rmac_jabber_frms;
4539
		le32_to_cpu(stat_info->tmac_icmp);
4142
	tmp_stats[i++] = stat_info->rmac_ip;
4540
	tmp_stats[i++] =
4143
	tmp_stats[i++] = stat_info->rmac_ip_octets;
4541
		(u64)le32_to_cpu(stat_info->tmac_rst_tcp_oflow) << 32 |
4144
	tmp_stats[i++] = stat_info->rmac_hdr_err_ip;
4542
		le32_to_cpu(stat_info->tmac_rst_tcp);
4145
	tmp_stats[i++] = stat_info->rmac_drop_ip;
4543
	tmp_stats[i++] = le64_to_cpu(stat_info->tmac_tcp);
4146
	tmp_stats[i++] = stat_info->rmac_icmp;
4544
	tmp_stats[i++] = (u64)le32_to_cpu(stat_info->tmac_udp_oflow) << 32 |
4147
	tmp_stats[i++] = stat_info->rmac_tcp;
4545
		le32_to_cpu(stat_info->tmac_udp);
4148
	tmp_stats[i++] = stat_info->rmac_udp;
4546
	tmp_stats[i++] =
4149
	tmp_stats[i++] = stat_info->rmac_err_drp_udp;
4547
		(u64)le32_to_cpu(stat_info->rmac_vld_frms_oflow) << 32 |
4150
	tmp_stats[i++] = stat_info->rmac_pause_cnt;
4548
		le32_to_cpu(stat_info->rmac_vld_frms);
4151
	tmp_stats[i++] = stat_info->rmac_accepted_ip;
4549
	tmp_stats[i++] =
4152
	tmp_stats[i++] = stat_info->rmac_err_tcp;
4550
		(u64)le32_to_cpu(stat_info->rmac_data_octets_oflow) << 32 |
4551
		le32_to_cpu(stat_info->rmac_data_octets);
4552
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_fcs_err_frms);
4553
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_drop_frms);
4554
	tmp_stats[i++] =
4555
		(u64)le32_to_cpu(stat_info->rmac_vld_mcst_frms_oflow) << 32 |
4556
		le32_to_cpu(stat_info->rmac_vld_mcst_frms);
4557
	tmp_stats[i++] =
4558
		(u64)le32_to_cpu(stat_info->rmac_vld_bcst_frms_oflow) << 32 |
4559
		le32_to_cpu(stat_info->rmac_vld_bcst_frms);
4560
	tmp_stats[i++] = le32_to_cpu(stat_info->rmac_in_rng_len_err_frms);
4561
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_long_frms);
4562
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_pause_ctrl_frms);
4563
	tmp_stats[i++] =
4564
		(u64)le32_to_cpu(stat_info->rmac_discarded_frms_oflow) << 32 |
4565
		le32_to_cpu(stat_info->rmac_discarded_frms);
4566
	tmp_stats[i++] =
4567
		(u64)le32_to_cpu(stat_info->rmac_usized_frms_oflow) << 32 |
4568
		le32_to_cpu(stat_info->rmac_usized_frms);
4569
	tmp_stats[i++] =
4570
		(u64)le32_to_cpu(stat_info->rmac_osized_frms_oflow) << 32 |
4571
		le32_to_cpu(stat_info->rmac_osized_frms);
4572
	tmp_stats[i++] =
4573
		(u64)le32_to_cpu(stat_info->rmac_frag_frms_oflow) << 32 |
4574
		le32_to_cpu(stat_info->rmac_frag_frms);
4575
	tmp_stats[i++] =
4576
		(u64)le32_to_cpu(stat_info->rmac_jabber_frms_oflow) << 32 |
4577
		le32_to_cpu(stat_info->rmac_jabber_frms);
4578
	tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_ip_oflow) << 32 |
4579
		le32_to_cpu(stat_info->rmac_ip);
4580
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ip_octets);
4581
	tmp_stats[i++] = le32_to_cpu(stat_info->rmac_hdr_err_ip);
4582
	tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_drop_ip_oflow) << 32 |
4583
		le32_to_cpu(stat_info->rmac_drop_ip);
4584
	tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_icmp_oflow) << 32 |
4585
		le32_to_cpu(stat_info->rmac_icmp);
4586
	tmp_stats[i++] = le64_to_cpu(stat_info->rmac_tcp);
4587
	tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_udp_oflow) << 32 |
4588
		le32_to_cpu(stat_info->rmac_udp);
4589
	tmp_stats[i++] =
4590
		(u64)le32_to_cpu(stat_info->rmac_err_drp_udp_oflow) << 32 |
4591
		le32_to_cpu(stat_info->rmac_err_drp_udp);
4592
	tmp_stats[i++] =
4593
		(u64)le32_to_cpu(stat_info->rmac_pause_cnt_oflow) << 32 |
4594
		le32_to_cpu(stat_info->rmac_pause_cnt);
4595
	tmp_stats[i++] =
4596
		(u64)le32_to_cpu(stat_info->rmac_accepted_ip_oflow) << 32 |
4597
		le32_to_cpu(stat_info->rmac_accepted_ip);
4598
	tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_tcp);
4599
	tmp_stats[i++] = 0;
4600
	tmp_stats[i++] = stat_info->sw_stat.single_ecc_errs;
4601
	tmp_stats[i++] = stat_info->sw_stat.double_ecc_errs;
4153
}
4602
}
4154
4603
4155
int s2io_ethtool_get_regs_len(struct net_device *dev)
4604
int s2io_ethtool_get_regs_len(struct net_device *dev)
Lines 4243-4260 static struct ethtool_ops netdev_ethtool Link Here
4243
};
4692
};
4244
4693
4245
/**
4694
/**
4246
 *  s2io_ioctl - Entry point for the Ioctl 
4695
 *  s2io_ioctl - Entry point for the Ioctl
4247
 *  @dev :  Device pointer.
4696
 *  @dev :  Device pointer.
4248
 *  @ifr :  An IOCTL specefic structure, that can contain a pointer to
4697
 *  @ifr :  An IOCTL specefic structure, that can contain a pointer to
4249
 *  a proprietary structure used to pass information to the driver.
4698
 *  a proprietary structure used to pass information to the driver.
4250
 *  @cmd :  This is used to distinguish between the different commands that
4699
 *  @cmd :  This is used to distinguish between the different commands that
4251
 *  can be passed to the IOCTL functions.
4700
 *  can be passed to the IOCTL functions.
4252
 *  Description:
4701
 *  Description:
4253
 *  This function has support for ethtool, adding multiple MAC addresses on 
4702
 *  Currently there are no special functionality supported in IOCTL, hence
4254
 *  the NIC and some DBG commands for the util tool.
4703
 *  function always return EOPNOTSUPPORTED
4255
 *  Return value:
4256
 *  Currently the IOCTL supports no operations, hence by default this
4257
 *  function returns OP NOT SUPPORTED value.
4258
 */
4704
 */
4259
4705
4260
int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
4706
int s2io_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
Lines 4276-4289 int s2io_ioctl(struct net_device *dev, s Link Here
4276
int s2io_change_mtu(struct net_device *dev, int new_mtu)
4722
int s2io_change_mtu(struct net_device *dev, int new_mtu)
4277
{
4723
{
4278
	nic_t *sp = dev->priv;
4724
	nic_t *sp = dev->priv;
4279
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) sp->bar0;
4280
	register u64 val64;
4281
4282
	if (netif_running(dev)) {
4283
		DBG_PRINT(ERR_DBG, "%s: Must be stopped to ", dev->name);
4284
		DBG_PRINT(ERR_DBG, "change its MTU \n");
4285
		return -EBUSY;
4286
	}
4287
4725
4288
	if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
4726
	if ((new_mtu < MIN_MTU) || (new_mtu > S2IO_JUMBO_SIZE)) {
4289
		DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n",
4727
		DBG_PRINT(ERR_DBG, "%s: MTU size is invalid.\n",
Lines 4291-4301 int s2io_change_mtu(struct net_device *d Link Here
4291
		return -EPERM;
4729
		return -EPERM;
4292
	}
4730
	}
4293
4731
4294
	/* Set the new MTU into the PYLD register of the NIC */
4295
	val64 = new_mtu;
4296
	writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
4297
4298
	dev->mtu = new_mtu;
4732
	dev->mtu = new_mtu;
4733
	if (netif_running(dev)) {
4734
		s2io_card_down(sp);
4735
		netif_stop_queue(dev);
4736
		if (s2io_card_up(sp)) {
4737
			DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
4738
				  __FUNCTION__);
4739
		}
4740
		if (netif_queue_stopped(dev))
4741
			netif_wake_queue(dev);
4742
	} else { /* Device is down */
4743
		XENA_dev_config_t __iomem *bar0 = sp->bar0;
4744
		u64 val64 = new_mtu;
4745
4746
		writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
4747
	}
4299
4748
4300
	return 0;
4749
	return 0;
4301
}
4750
}
Lines 4305-4313 int s2io_change_mtu(struct net_device *d Link Here
4305
 *  @dev_adr : address of the device structure in dma_addr_t format.
4754
 *  @dev_adr : address of the device structure in dma_addr_t format.
4306
 *  Description:
4755
 *  Description:
4307
 *  This is the tasklet or the bottom half of the ISR. This is
4756
 *  This is the tasklet or the bottom half of the ISR. This is
4308
 *  an extension of the ISR which is scheduled by the scheduler to be run 
4757
 *  an extension of the ISR which is scheduled by the scheduler to be run
4309
 *  when the load on the CPU is low. All low priority tasks of the ISR can
4758
 *  when the load on the CPU is low. All low priority tasks of the ISR can
4310
 *  be pushed into the tasklet. For now the tasklet is used only to 
4759
 *  be pushed into the tasklet. For now the tasklet is used only to
4311
 *  replenish the Rx buffers in the Rx buffer descriptors.
4760
 *  replenish the Rx buffers in the Rx buffer descriptors.
4312
 *  Return value:
4761
 *  Return value:
4313
 *  void.
4762
 *  void.
Lines 4325-4331 static void s2io_tasklet(unsigned long d Link Here
4325
	config = &sp->config;
4774
	config = &sp->config;
4326
4775
4327
	if (!TASKLET_IN_USE) {
4776
	if (!TASKLET_IN_USE) {
4328
		for (i = 0; i < config->RxRingNum; i++) {
4777
		for (i = 0; i < config->rx_ring_num; i++) {
4329
			ret = fill_rx_buffers(sp, i);
4778
			ret = fill_rx_buffers(sp, i);
4330
			if (ret == -ENOMEM) {
4779
			if (ret == -ENOMEM) {
4331
				DBG_PRINT(ERR_DBG, "%s: Out of ",
4780
				DBG_PRINT(ERR_DBG, "%s: Out of ",
Lines 4339-4345 static void s2io_tasklet(unsigned long d Link Here
4339
				break;
4788
				break;
4340
			}
4789
			}
4341
		}
4790
		}
4342
		clear_bit(0, (unsigned long *) (&sp->tasklet_status));
4791
		clear_bit(0, (&sp->tasklet_status));
4343
	}
4792
	}
4344
}
4793
}
4345
4794
Lines 4353-4377 static void s2io_set_link(unsigned long Link Here
4353
{
4802
{
4354
	nic_t *nic = (nic_t *) data;
4803
	nic_t *nic = (nic_t *) data;
4355
	struct net_device *dev = nic->dev;
4804
	struct net_device *dev = nic->dev;
4356
	XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
4805
	XENA_dev_config_t __iomem *bar0 = nic->bar0;
4357
	register u64 val64;
4806
	register u64 val64;
4358
	u16 subid;
4807
	u16 subid;
4359
4808
4809
	if (test_and_set_bit(0, &(nic->link_state))) {
4810
		/* The card is being reset, no point doing anything */
4811
		return;
4812
	}
4813
4360
	subid = nic->pdev->subsystem_device;
4814
	subid = nic->pdev->subsystem_device;
4361
	/* 
4815
	if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
4362
	 * Allow a small delay for the NICs self initiated 
4816
		/*
4363
	 * cleanup to complete.
4817
		 * Allow a small delay for the NICs self initiated
4364
	 */
4818
		 * cleanup to complete.
4365
	set_current_state(TASK_UNINTERRUPTIBLE);
4819
		 */
4366
	schedule_timeout(HZ / 10);
4820
		msleep(100);
4821
	}
4367
4822
4368
	val64 = readq(&bar0->adapter_status);
4823
	val64 = readq(&bar0->adapter_status);
4369
	if (verify_xena_quiescence(val64, nic->device_enabled_once)) {
4824
	if (verify_xena_quiescence(nic, val64, nic->device_enabled_once)) {
4370
		if (LINK_IS_UP(val64)) {
4825
		if (LINK_IS_UP(val64)) {
4371
			val64 = readq(&bar0->adapter_control);
4826
			val64 = readq(&bar0->adapter_control);
4372
			val64 |= ADAPTER_CNTL_EN;
4827
			val64 |= ADAPTER_CNTL_EN;
4373
			writeq(val64, &bar0->adapter_control);
4828
			writeq(val64, &bar0->adapter_control);
4374
			if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
4829
			if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type,
4830
							     subid)) {
4375
				val64 = readq(&bar0->gpio_control);
4831
				val64 = readq(&bar0->gpio_control);
4376
				val64 |= GPIO_CTRL_GPIO_0;
4832
				val64 |= GPIO_CTRL_GPIO_0;
4377
				writeq(val64, &bar0->gpio_control);
4833
				writeq(val64, &bar0->gpio_control);
Lines 4380-4399 static void s2io_set_link(unsigned long Link Here
4380
				val64 |= ADAPTER_LED_ON;
4836
				val64 |= ADAPTER_LED_ON;
4381
				writeq(val64, &bar0->adapter_control);
4837
				writeq(val64, &bar0->adapter_control);
4382
			}
4838
			}
4383
			val64 = readq(&bar0->adapter_status);
4839
			if (s2io_link_fault_indication(nic) ==
4384
			if (!LINK_IS_UP(val64)) {
4840
						MAC_RMAC_ERR_TIMER) {
4385
				DBG_PRINT(ERR_DBG, "%s:", dev->name);
4841
				val64 = readq(&bar0->adapter_status);
4386
				DBG_PRINT(ERR_DBG, " Link down");
4842
				if (!LINK_IS_UP(val64)) {
4387
				DBG_PRINT(ERR_DBG, "after ");
4843
					DBG_PRINT(ERR_DBG, "%s:", dev->name);
4388
				DBG_PRINT(ERR_DBG, "enabling ");
4844
					DBG_PRINT(ERR_DBG, " Link down");
4389
				DBG_PRINT(ERR_DBG, "device \n");
4845
					DBG_PRINT(ERR_DBG, "after ");
4846
					DBG_PRINT(ERR_DBG, "enabling ");
4847
					DBG_PRINT(ERR_DBG, "device \n");
4848
				}
4390
			}
4849
			}
4391
			if (nic->device_enabled_once == FALSE) {
4850
			if (nic->device_enabled_once == FALSE) {
4392
				nic->device_enabled_once = TRUE;
4851
				nic->device_enabled_once = TRUE;
4393
			}
4852
			}
4394
			s2io_link(nic, LINK_UP);
4853
			s2io_link(nic, LINK_UP);
4395
		} else {
4854
		} else {
4396
			if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
4855
			if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type,
4856
							      subid)) {
4397
				val64 = readq(&bar0->gpio_control);
4857
				val64 = readq(&bar0->gpio_control);
4398
				val64 &= ~GPIO_CTRL_GPIO_0;
4858
				val64 &= ~GPIO_CTRL_GPIO_0;
4399
				writeq(val64, &bar0->gpio_control);
4859
				writeq(val64, &bar0->gpio_control);
Lines 4406-4419 static void s2io_set_link(unsigned long Link Here
4406
		DBG_PRINT(ERR_DBG, "device is not Quiescent\n");
4866
		DBG_PRINT(ERR_DBG, "device is not Quiescent\n");
4407
		netif_stop_queue(dev);
4867
		netif_stop_queue(dev);
4408
	}
4868
	}
4869
	clear_bit(0, &(nic->link_state));
4870
}
4871
4872
static void s2io_card_down(nic_t * sp)
4873
{
4874
	int cnt = 0;
4875
	XENA_dev_config_t __iomem *bar0 = sp->bar0;
4876
	unsigned long flags;
4877
	register u64 val64 = 0;
4878
4879
	del_timer_sync(&sp->alarm_timer);
4880
	/* If s2io_set_link task is executing, wait till it completes. */
4881
	while (test_and_set_bit(0, &(sp->link_state))) {
4882
		msleep(50);
4883
	}
4884
	atomic_set(&sp->card_state, CARD_DOWN);
4885
4886
	/* disable Tx and Rx traffic on the NIC */
4887
	stop_nic(sp);
4888
4889
	/* Kill tasklet. */
4890
	tasklet_kill(&sp->task);
4891
4892
	/* Check if the device is Quiescent and then Reset the NIC */
4893
	do {
4894
		val64 = readq(&bar0->adapter_status);
4895
		if (verify_xena_quiescence(sp, val64, sp->device_enabled_once)) {
4896
			break;
4897
		}
4898
4899
		msleep(50);
4900
		cnt++;
4901
		if (cnt == 10) {
4902
			DBG_PRINT(ERR_DBG,
4903
				  "s2io_close:Device not Quiescent ");
4904
			DBG_PRINT(ERR_DBG, "adaper status reads 0x%llx\n",
4905
				  (unsigned long long) val64);
4906
			break;
4907
		}
4908
	} while (1);
4909
	s2io_reset(sp);
4910
4911
	/* Waiting till all Interrupt handlers are complete */
4912
	cnt = 0;
4913
	do {
4914
		msleep(10);
4915
		if (!atomic_read(&sp->isr_cnt))
4916
			break;
4917
		cnt++;
4918
	} while(cnt < 5);
4919
4920
	spin_lock_irqsave(&sp->tx_lock, flags);
4921
	/* Free all Tx buffers */
4922
	free_tx_buffers(sp);
4923
	spin_unlock_irqrestore(&sp->tx_lock, flags);
4924
4925
	/* Free all Rx buffers */
4926
	spin_lock_irqsave(&sp->rx_lock, flags);
4927
	free_rx_buffers(sp);
4928
	spin_unlock_irqrestore(&sp->rx_lock, flags);
4929
4930
	clear_bit(0, &(sp->link_state));
4409
}
4931
}
4410
4932
4411
/** 
4933
static int s2io_card_up(nic_t * sp)
4934
{
4935
	int i, ret;
4936
	mac_info_t *mac_control;
4937
	struct config_param *config;
4938
	struct net_device *dev = (struct net_device *) sp->dev;
4939
4940
	/* Initialize the H/W I/O registers */
4941
	if (init_nic(sp) != 0) {
4942
		DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
4943
			  dev->name);
4944
		return -ENODEV;
4945
	}
4946
4947
	/*
4948
	 * Initializing the Rx buffers. For now we are considering only 1
4949
	 * Rx ring and initializing buffers into 30 Rx blocks
4950
	 */
4951
	mac_control = &sp->mac_control;
4952
	config = &sp->config;
4953
4954
	for (i = 0; i < config->rx_ring_num; i++) {
4955
		if ((ret = fill_rx_buffers(sp, i))) {
4956
			DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n",
4957
				  dev->name);
4958
			s2io_reset(sp);
4959
			free_rx_buffers(sp);
4960
			return -ENOMEM;
4961
		}
4962
		DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i,
4963
			  atomic_read(&sp->rx_bufs_left[i]));
4964
	}
4965
4966
	/* Setting its receive mode */
4967
	s2io_set_multicast(dev);
4968
4969
	/* Enable tasklet for the device */
4970
	tasklet_init(&sp->task, s2io_tasklet, (unsigned long) dev);
4971
4972
	/* Enable Rx Traffic and interrupts on the NIC */
4973
	if (start_nic(sp)) {
4974
		DBG_PRINT(ERR_DBG, "%s: Starting NIC failed\n", dev->name);
4975
		tasklet_kill(&sp->task);
4976
		s2io_reset(sp);
4977
		free_irq(dev->irq, dev);
4978
		free_rx_buffers(sp);
4979
		return -ENODEV;
4980
	}
4981
4982
	S2IO_TIMER_CONF(sp->alarm_timer, s2io_alarm_handle, sp, (HZ/2));
4983
4984
	atomic_set(&sp->card_state, CARD_UP);
4985
	return 0;
4986
}
4987
4988
/**
4412
 * s2io_restart_nic - Resets the NIC.
4989
 * s2io_restart_nic - Resets the NIC.
4413
 * @data : long pointer to the device private structure
4990
 * @data : long pointer to the device private structure
4414
 * Description:
4991
 * Description:
4415
 * This function is scheduled to be run by the s2io_tx_watchdog
4992
 * This function is scheduled to be run by the s2io_tx_watchdog
4416
 * function after 0.5 secs to reset the NIC. The idea is to reduce 
4993
 * function after 0.5 secs to reset the NIC. The idea is to reduce
4417
 * the run time of the watch dog routine which is run holding a
4994
 * the run time of the watch dog routine which is run holding a
4418
 * spin lock.
4995
 * spin lock.
4419
 */
4996
 */
Lines 4423-4439 static void s2io_restart_nic(unsigned lo Link Here
4423
	struct net_device *dev = (struct net_device *) data;
5000
	struct net_device *dev = (struct net_device *) data;
4424
	nic_t *sp = dev->priv;
5001
	nic_t *sp = dev->priv;
4425
5002
4426
	sp->task_flag = 1;
5003
	s2io_card_down(sp);
4427
	s2io_close(dev);
5004
	if (s2io_card_up(sp)) {
4428
	sp->task_flag = 0;
5005
		DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
4429
	sp->device_close_flag = TRUE;
5006
			  dev->name);
4430
	s2io_open(dev);
5007
	}
4431
	DBG_PRINT(ERR_DBG,
5008
	netif_wake_queue(dev);
4432
		  "%s: was reset by Tx watchdog timer.\n", dev->name);
5009
	DBG_PRINT(ERR_DBG, "%s: was reset by Tx watchdog timer\n",
5010
		  dev->name);
5011
4433
}
5012
}
4434
5013
4435
/** 
5014
/**
4436
 *  s2io_tx_watchdog - Watchdog for transmit side. 
5015
 *  s2io_tx_watchdog - Watchdog for transmit side.
4437
 *  @dev : Pointer to net device structure
5016
 *  @dev : Pointer to net device structure
4438
 *  Description:
5017
 *  Description:
4439
 *  This function is triggered if the Tx Queue is stopped
5018
 *  This function is triggered if the Tx Queue is stopped
Lines 4461-4467 static void s2io_tx_watchdog(struct net_ Link Here
4461
 *   @len : length of the packet
5040
 *   @len : length of the packet
4462
 *   @cksum : FCS checksum of the frame.
5041
 *   @cksum : FCS checksum of the frame.
4463
 *   @ring_no : the ring from which this RxD was extracted.
5042
 *   @ring_no : the ring from which this RxD was extracted.
4464
 *   Description: 
5043
 *   Description:
4465
 *   This function is called by the Tx interrupt serivce routine to perform
5044
 *   This function is called by the Tx interrupt serivce routine to perform
4466
 *   some OS related operations on the SKB before passing it to the upper
5045
 *   some OS related operations on the SKB before passing it to the upper
4467
 *   layers. It mainly checks if the checksum is OK, if so adds it to the
5046
 *   layers. It mainly checks if the checksum is OK, if so adds it to the
Lines 4471-4505 static void s2io_tx_watchdog(struct net_ Link Here
4471
 *   Return value:
5050
 *   Return value:
4472
 *   SUCCESS on success and -1 on failure.
5051
 *   SUCCESS on success and -1 on failure.
4473
 */
5052
 */
4474
#ifndef CONFIG_2BUFF_MODE
5053
static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp)
4475
static int rx_osm_handler(nic_t * sp, u16 len, RxD_t * rxdp, int ring_no)
4476
#else
4477
static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no,
4478
			  buffAdd_t * ba)
4479
#endif
4480
{
5054
{
5055
	nic_t *sp = ring_data->nic;
4481
	struct net_device *dev = (struct net_device *) sp->dev;
5056
	struct net_device *dev = (struct net_device *) sp->dev;
4482
	struct sk_buff *skb =
5057
	struct sk_buff *skb = (struct sk_buff *)
4483
	    (struct sk_buff *) ((unsigned long) rxdp->Host_Control);
5058
		((unsigned long) rxdp->Host_Control);
5059
	int ring_no = ring_data->ring_no;
4484
	u16 l3_csum, l4_csum;
5060
	u16 l3_csum, l4_csum;
4485
#ifdef CONFIG_2BUFF_MODE
5061
#ifdef CONFIG_2BUFF_MODE
4486
	int buf0_len, buf2_len;
5062
	int buf0_len = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
4487
	struct ethhdr *eth = (struct ethhdr *) ba->ba_0;
5063
	int buf2_len = RXD_GET_BUFFER2_SIZE(rxdp->Control_2);
5064
	int get_block = ring_data->rx_curr_get_info.block_index;
5065
	int get_off = ring_data->rx_curr_get_info.offset;
5066
	buffAdd_t *ba = &ring_data->ba[get_block][get_off];
5067
	unsigned char *buff;
5068
#else
5069
	u16 len = (u16) ((RXD_GET_BUFFER0_SIZE(rxdp->Control_2)) >> 48);;
4488
#endif
5070
#endif
5071
	skb->dev = dev;
5072
	if (rxdp->Control_1 & RXD_T_CODE) {
5073
		unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
5074
		DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
5075
			  dev->name, err);
5076
		dev_kfree_skb(skb);
5077
		sp->stats.rx_crc_errors++;
5078
		atomic_dec(&sp->rx_bufs_left[ring_no]);
5079
		rxdp->Host_Control = 0;
5080
		return 0;
5081
	}
4489
5082
4490
	l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1);
5083
	/* Updating statistics */
4491
	if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && (sp->rx_csum)) {
5084
	rxdp->Host_Control = 0;
5085
	sp->rx_pkt_count++;
5086
	sp->stats.rx_packets++;
5087
#ifndef CONFIG_2BUFF_MODE
5088
	sp->stats.rx_bytes += len;
5089
#else
5090
	sp->stats.rx_bytes += buf0_len + buf2_len;
5091
#endif
5092
5093
#ifndef CONFIG_2BUFF_MODE
5094
	skb_put(skb, len);
5095
#else
5096
	buff = skb_push(skb, buf0_len);
5097
	memcpy(buff, ba->ba_0, buf0_len);
5098
	skb_put(skb, buf2_len);
5099
#endif
5100
5101
	if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) &&
5102
	    (sp->rx_csum)) {
5103
		l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1);
4492
		l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1);
5104
		l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1);
4493
		if ((l3_csum == L3_CKSUM_OK) && (l4_csum == L4_CKSUM_OK)) {
5105
		if ((l3_csum == L3_CKSUM_OK) && (l4_csum == L4_CKSUM_OK)) {
4494
			/* 
5106
			/*
4495
			 * NIC verifies if the Checksum of the received
5107
			 * NIC verifies if the Checksum of the received
4496
			 * frame is Ok or not and accordingly returns
5108
			 * frame is Ok or not and accordingly returns
4497
			 * a flag in the RxD.
5109
			 * a flag in the RxD.
4498
			 */
5110
			 */
4499
			skb->ip_summed = CHECKSUM_UNNECESSARY;
5111
			skb->ip_summed = CHECKSUM_UNNECESSARY;
4500
		} else {
5112
		} else {
4501
			/* 
5113
			/*
4502
			 * Packet with erroneous checksum, let the 
5114
			 * Packet with erroneous checksum, let the
4503
			 * upper layers deal with it.
5115
			 * upper layers deal with it.
4504
			 */
5116
			 */
4505
			skb->ip_summed = CHECKSUM_NONE;
5117
			skb->ip_summed = CHECKSUM_NONE;
Lines 4508-4584 static int rx_osm_handler(nic_t * sp, Rx Link Here
4508
		skb->ip_summed = CHECKSUM_NONE;
5120
		skb->ip_summed = CHECKSUM_NONE;
4509
	}
5121
	}
4510
5122
4511
	if (rxdp->Control_1 & RXD_T_CODE) {
4512
		unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
4513
		DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
4514
			  dev->name, err);
4515
	}
4516
#ifdef CONFIG_2BUFF_MODE
4517
	buf0_len = RXD_GET_BUFFER0_SIZE(rxdp->Control_2);
4518
	buf2_len = RXD_GET_BUFFER2_SIZE(rxdp->Control_2);
4519
#endif
4520
4521
	skb->dev = dev;
4522
#ifndef CONFIG_2BUFF_MODE
4523
	skb_put(skb, len);
4524
	skb->protocol = eth_type_trans(skb, dev);
5123
	skb->protocol = eth_type_trans(skb, dev);
4525
#else
4526
	skb_put(skb, buf2_len);
4527
	/* 
4528
	 * Reproducing eth_type_trans functionality and running
4529
	 * on the ethernet header 'eth' stripped and given to us
4530
	 * by the hardware in 2Buff mode.
4531
	 */
4532
	if (*eth->h_dest & 1) {
4533
		if (!memcmp(eth->h_dest, dev->broadcast, ETH_ALEN))
4534
			skb->pkt_type = PACKET_BROADCAST;
4535
		else
4536
			skb->pkt_type = PACKET_MULTICAST;
4537
	} else if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN)) {
4538
		skb->pkt_type = PACKET_OTHERHOST;
4539
	}
4540
	skb->protocol = eth->h_proto;
4541
#endif
4542
4543
#ifdef CONFIG_S2IO_NAPI
5124
#ifdef CONFIG_S2IO_NAPI
4544
	netif_receive_skb(skb);
5125
	if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
5126
		/* Queueing the vlan frame to the upper layer */
5127
		vlan_hwaccel_receive_skb(skb, sp->vlgrp,
5128
			RXD_GET_VLAN_TAG(rxdp->Control_2));
5129
	} else {
5130
		netif_receive_skb(skb);
5131
	}
4545
#else
5132
#else
4546
	netif_rx(skb);
5133
	if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
5134
		/* Queueing the vlan frame to the upper layer */
5135
		vlan_hwaccel_rx(skb, sp->vlgrp,
5136
			RXD_GET_VLAN_TAG(rxdp->Control_2));
5137
	} else {
5138
		netif_rx(skb);
5139
	}
4547
#endif
5140
#endif
4548
4549
	dev->last_rx = jiffies;
5141
	dev->last_rx = jiffies;
4550
	sp->rx_pkt_count++;
4551
	sp->stats.rx_packets++;
4552
#ifndef CONFIG_2BUFF_MODE
4553
	sp->stats.rx_bytes += len;
4554
#else
4555
	sp->stats.rx_bytes += buf0_len + buf2_len;
4556
#endif
4557
4558
	atomic_dec(&sp->rx_bufs_left[ring_no]);
5142
	atomic_dec(&sp->rx_bufs_left[ring_no]);
4559
	rxdp->Host_Control = 0;
4560
	return SUCCESS;
5143
	return SUCCESS;
4561
}
5144
}
4562
5145
4563
int check_for_tx_space(nic_t * sp)
4564
{
4565
	u32 put_off, get_off, queue_len;
4566
	int ret = TRUE, i;
4567
4568
	for (i = 0; i < sp->config.TxFIFONum; i++) {
4569
		queue_len = sp->mac_control.tx_curr_put_info[i].fifo_len
4570
		    + 1;
4571
		put_off = sp->mac_control.tx_curr_put_info[i].offset;
4572
		get_off = sp->mac_control.tx_curr_get_info[i].offset;
4573
		if (((put_off + 1) % queue_len) == get_off) {
4574
			ret = FALSE;
4575
			break;
4576
		}
4577
	}
4578
4579
	return ret;
4580
}
4581
4582
/**
5146
/**
4583
 *  s2io_link - stops/starts the Tx queue.
5147
 *  s2io_link - stops/starts the Tx queue.
4584
 *  @sp : private member of the device structure, which is a pointer to the
5148
 *  @sp : private member of the device structure, which is a pointer to the
Lines 4586-4593 int check_for_tx_space(nic_t * sp) Link Here
4586
 *  @link : inidicates whether link is UP/DOWN.
5150
 *  @link : inidicates whether link is UP/DOWN.
4587
 *  Description:
5151
 *  Description:
4588
 *  This function stops/starts the Tx queue depending on whether the link
5152
 *  This function stops/starts the Tx queue depending on whether the link
4589
 *  status of the NIC is is down or up. This is called by the Alarm 
5153
 *  status of the NIC is is down or up. This is called by the Alarm
4590
 *  interrupt handler whenever a link change interrupt comes up. 
5154
 *  interrupt handler whenever a link change interrupt comes up.
4591
 *  Return value:
5155
 *  Return value:
4592
 *  void.
5156
 *  void.
4593
 */
5157
 */
Lines 4609-4615 void s2io_link(nic_t * sp, int link) Link Here
4609
}
5173
}
4610
5174
4611
/**
5175
/**
4612
 *  get_xena_rev_id - to identify revision ID of xena. 
5176
 *  get_xena_rev_id - to identify revision ID of xena.
4613
 *  @pdev : PCI Dev structure
5177
 *  @pdev : PCI Dev structure
4614
 *  Description:
5178
 *  Description:
4615
 *  Function to identify the Revision ID of xena.
5179
 *  Function to identify the Revision ID of xena.
Lines 4626-4633 int get_xena_rev_id(struct pci_dev *pdev Link Here
4626
}
5190
}
4627
5191
4628
/**
5192
/**
4629
 *  s2io_init_pci -Initialization of PCI and PCI-X configuration registers . 
5193
 *  s2io_init_pci -Initialization of PCI and PCI-X configuration registers .
4630
 *  @sp : private member of the device structure, which is a pointer to the 
5194
 *  @sp : private member of the device structure, which is a pointer to the
4631
 *  s2io_nic structure.
5195
 *  s2io_nic structure.
4632
 *  Description:
5196
 *  Description:
4633
 *  This function initializes a few of the PCI and PCI-X configuration registers
5197
 *  This function initializes a few of the PCI and PCI-X configuration registers
Lines 4638-4652 int get_xena_rev_id(struct pci_dev *pdev Link Here
4638
5202
4639
static void s2io_init_pci(nic_t * sp)
5203
static void s2io_init_pci(nic_t * sp)
4640
{
5204
{
4641
	u16 pci_cmd = 0;
5205
	u16 pci_cmd = 0, pcix_cmd = 0;
4642
5206
4643
	/* Enable Data Parity Error Recovery in PCI-X command register. */
5207
	/* Enable Data Parity Error Recovery in PCI-X command register. */
4644
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5208
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4645
			     &(sp->pcix_cmd));
5209
			     &(pcix_cmd));
4646
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5210
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4647
			      (sp->pcix_cmd | 1));
5211
			      (pcix_cmd | 1));
4648
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5212
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4649
			     &(sp->pcix_cmd));
5213
			     &(pcix_cmd));
4650
5214
4651
	/* Set the PErr Response bit in PCI command register. */
5215
	/* Set the PErr Response bit in PCI command register. */
4652
	pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
5216
	pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
Lines 4654-4753 static void s2io_init_pci(nic_t * sp) Link Here
4654
			      (pci_cmd | PCI_COMMAND_PARITY));
5218
			      (pci_cmd | PCI_COMMAND_PARITY));
4655
	pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
5219
	pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
4656
5220
4657
	/* Set user specified value in Latency Timer */
4658
	if (latency_timer) {
4659
		pci_write_config_byte(sp->pdev, PCI_LATENCY_TIMER,
4660
				      latency_timer);
4661
		pci_read_config_byte(sp->pdev, PCI_LATENCY_TIMER,
4662
				     &latency_timer);
4663
	}
4664
4665
	/* Set MMRB count to 4096 in PCI-X Command register. */
4666
	sp->pcix_cmd &= 0xFFF3;
4667
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4668
			      (sp->pcix_cmd | (max_read_byte_cnt << 2)));
4669
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4670
			     &(sp->pcix_cmd));
4671
4672
	/*  Setting Maximum outstanding splits based on system type. */
4673
	sp->pcix_cmd &= 0xFF8F;
4674
4675
	sp->pcix_cmd |= XENA_MAX_OUTSTANDING_SPLITS(max_splits_trans);
4676
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4677
			      sp->pcix_cmd);
4678
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4679
			     &(sp->pcix_cmd));
4680
	/* Forcibly disabling relaxed ordering capability of the card. */
5221
	/* Forcibly disabling relaxed ordering capability of the card. */
4681
	sp->pcix_cmd &= 0xfffd;
5222
	pcix_cmd &= 0xfffd;
4682
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5223
	pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4683
			      sp->pcix_cmd);
5224
			      pcix_cmd);
4684
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5225
	pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
4685
			     &(sp->pcix_cmd));
5226
			     &(pcix_cmd));
4686
}
5227
}
4687
5228
4688
MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@s2io.com>");
5229
MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>");
4689
MODULE_LICENSE("GPL");
5230
MODULE_LICENSE("GPL");
4690
MODULE_PARM(lso_enable, "i");
5231
module_param(tx_fifo_num, int, 0);
5232
module_param(rx_ring_num, int, 0);
5233
module_param_array(tx_fifo_len, int, tx_fifo_num, 0);
5234
module_param_array(rx_ring_sz, int, rx_ring_num, 0);
5235
module_param_array(rts_frm_len, int, rx_ring_num, 0);
5236
module_param(use_continuous_tx_intrs, int, 1);
5237
module_param(rmac_pause_time, int, 0);
5238
module_param(mc_pause_threshold_q0q3, int, 0);
5239
module_param(mc_pause_threshold_q4q7, int, 0);
5240
module_param(shared_splits, int, 0);
5241
module_param(tmac_util_period, int, 0);
5242
module_param(rmac_util_period, int, 0);
5243
module_param(bimodal, bool, 0);
4691
#ifndef CONFIG_S2IO_NAPI
5244
#ifndef CONFIG_S2IO_NAPI
4692
MODULE_PARM(indicate_max_pkts, "i");
5245
module_param(indicate_max_pkts, int, 0);
4693
#endif
5246
#endif
4694
MODULE_PARM(cksum_offload_enable, "i");
5247
module_param(rxsync_frequency, int, 0);
4695
MODULE_PARM(TxFifoNum, "i");
5248
4696
MODULE_PARM(TxFIFOLen_0, "i");
4697
MODULE_PARM(TxFIFOLen_1, "i");
4698
MODULE_PARM(TxFIFOLen_2, "i");
4699
MODULE_PARM(TxFIFOLen_3, "i");
4700
MODULE_PARM(TxFIFOLen_4, "i");
4701
MODULE_PARM(TxFIFOLen_5, "i");
4702
MODULE_PARM(TxFIFOLen_6, "i");
4703
MODULE_PARM(TxFIFOLen_7, "i");
4704
MODULE_PARM(MaxTxDs, "i");
4705
MODULE_PARM(RxRingNum, "i");
4706
MODULE_PARM(RxRingSz_0, "i");
4707
MODULE_PARM(RxRingSz_1, "i");
4708
MODULE_PARM(RxRingSz_2, "i");
4709
MODULE_PARM(RxRingSz_3, "i");
4710
MODULE_PARM(RxRingSz_4, "i");
4711
MODULE_PARM(RxRingSz_5, "i");
4712
MODULE_PARM(RxRingSz_6, "i");
4713
MODULE_PARM(RxRingSz_7, "i");
4714
MODULE_PARM(Stats_refresh_time, "i");
4715
MODULE_PARM(rmac_pause_time, "i");
4716
MODULE_PARM(mc_pause_threshold_q0q3, "i");
4717
MODULE_PARM(mc_pause_threshold_q4q7, "i");
4718
MODULE_PARM(shared_splits, "i");
4719
MODULE_PARM(max_splits_trans, "i");
4720
MODULE_PARM(tmac_util_period, "i");
4721
MODULE_PARM(rmac_util_period, "i");
4722
MODULE_PARM(tx_timer_val, "i");
4723
MODULE_PARM(tx_utilz_periodic, "i");
4724
MODULE_PARM(rx_timer_val, "i");
4725
MODULE_PARM(rx_utilz_periodic, "i");
4726
MODULE_PARM(tx_urange_a, "i");
4727
MODULE_PARM(tx_ufc_a, "i");
4728
MODULE_PARM(tx_urange_b, "i");
4729
MODULE_PARM(tx_ufc_b, "i");
4730
MODULE_PARM(tx_urange_c, "i");
4731
MODULE_PARM(tx_ufc_c, "i");
4732
MODULE_PARM(tx_ufc_d, "i");
4733
MODULE_PARM(rx_urange_a, "i");
4734
MODULE_PARM(rx_ufc_a, "i");
4735
MODULE_PARM(rx_urange_b, "i");
4736
MODULE_PARM(rx_ufc_b, "i");
4737
MODULE_PARM(rx_urange_c, "i");
4738
MODULE_PARM(rx_ufc_c, "i");
4739
MODULE_PARM(rx_ufc_d, "i");
4740
MODULE_PARM(latency_timer, "i");
4741
MODULE_PARM(max_read_byte_cnt, "i");
4742
/**
5249
/**
4743
 *  s2io_init_nic - Initialization of the adapter . 
5250
 *  s2io_init_nic - Initialization of the adapter .
4744
 *  @pdev : structure containing the PCI related information of the device.
5251
 *  @pdev : structure containing the PCI related information of the device.
4745
 *  @pre: List of PCI devices supported by the driver listed in s2io_tbl.
5252
 *  @pre: List of PCI devices supported by the driver listed in s2io_tbl.
4746
 *  Description:
5253
 *  Description:
4747
 *  The function initializes an adapter identified by the pci_dec structure.
5254
 *  The function initializes an adapter identified by the pci_dec structure.
4748
 *  All OS related initialization including memory and device structure and 
5255
 *  All OS related initialization including memory and device structure and
4749
 *  initlaization of the device private variable is done. Also the swapper 
5256
 *  initlaization of the device private variable is done. Also the swapper
4750
 *  control register is initialized to enable read and write into the I/O 
5257
 *  control register is initialized to enable read and write into the I/O
4751
 *  registers of the device.
5258
 *  registers of the device.
4752
 *  Return value:
5259
 *  Return value:
4753
 *  returns 0 on success and negative on failure.
5260
 *  returns 0 on success and negative on failure.
Lines 4758-4773 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4758
{
5265
{
4759
	nic_t *sp;
5266
	nic_t *sp;
4760
	struct net_device *dev;
5267
	struct net_device *dev;
4761
	char *dev_name = "S2IO 10GE NIC";
4762
	int i, j, ret;
5268
	int i, j, ret;
4763
	int dma_flag = FALSE;
5269
	int dma_flag = FALSE;
4764
	u32 mac_up, mac_down;
5270
	u32 mac_up, mac_down;
4765
	u64 val64 = 0, tmp64 = 0;
5271
	u64 val64 = 0, tmp64 = 0;
4766
	XENA_dev_config_t *bar0 = NULL;
5272
	XENA_dev_config_t __iomem *bar0 = NULL;
4767
	u16 subid;
5273
	u16 subid;
4768
	mac_info_t *mac_control;
5274
	mac_info_t *mac_control;
4769
	struct config_param *config;
5275
	struct config_param *config;
5276
	int mode;
4770
5277
5278
#ifdef CONFIG_S2IO_NAPI
5279
	DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
5280
#endif
4771
5281
4772
	if ((ret = pci_enable_device(pdev))) {
5282
	if ((ret = pci_enable_device(pdev))) {
4773
		DBG_PRINT(ERR_DBG,
5283
		DBG_PRINT(ERR_DBG,
Lines 4775-4793 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4775
		return ret;
5285
		return ret;
4776
	}
5286
	}
4777
5287
4778
	if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
5288
	if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
4779
		DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 64bit DMA\n");
5289
		DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 64bit DMA\n");
4780
		dma_flag = TRUE;
5290
		dma_flag = TRUE;
4781
4782
		if (pci_set_consistent_dma_mask
5291
		if (pci_set_consistent_dma_mask
4783
		    (pdev, 0xffffffffffffffffULL)) {
5292
		    (pdev, DMA_64BIT_MASK)) {
4784
			DBG_PRINT(ERR_DBG,
5293
			DBG_PRINT(ERR_DBG,
4785
				  "Unable to obtain 64bit DMA for \
5294
				  "Unable to obtain 64bit DMA for \
4786
					consistent allocations\n");
5295
					consistent allocations\n");
4787
			pci_disable_device(pdev);
5296
			pci_disable_device(pdev);
4788
			return -ENOMEM;
5297
			return -ENOMEM;
4789
		}
5298
		}
4790
	} else if (!pci_set_dma_mask(pdev, 0xffffffffUL)) {
5299
	} else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
4791
		DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 32bit DMA\n");
5300
		DBG_PRINT(INIT_DBG, "s2io_init_nic: Using 32bit DMA\n");
4792
	} else {
5301
	} else {
4793
		pci_disable_device(pdev);
5302
		pci_disable_device(pdev);
Lines 4818-4939 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4818
	memset(sp, 0, sizeof(nic_t));
5327
	memset(sp, 0, sizeof(nic_t));
4819
	sp->dev = dev;
5328
	sp->dev = dev;
4820
	sp->pdev = pdev;
5329
	sp->pdev = pdev;
4821
	sp->vendor_id = pdev->vendor;
4822
	sp->device_id = pdev->device;
4823
	sp->high_dma_flag = dma_flag;
5330
	sp->high_dma_flag = dma_flag;
4824
	sp->irq = pdev->irq;
4825
	sp->device_enabled_once = FALSE;
5331
	sp->device_enabled_once = FALSE;
4826
	strcpy(sp->name, dev_name);
5332
5333
	if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) ||
5334
		(pdev->device == PCI_DEVICE_ID_HERC_UNI))
5335
		sp->device_type = XFRAME_II_DEVICE;
5336
	else
5337
		sp->device_type = XFRAME_I_DEVICE;
4827
5338
4828
	/* Initialize some PCI/PCI-X fields of the NIC. */
5339
	/* Initialize some PCI/PCI-X fields of the NIC. */
4829
	s2io_init_pci(sp);
5340
	s2io_init_pci(sp);
4830
5341
4831
	/* 
5342
	/*
4832
	 * Setting the device configuration parameters.
5343
	 * Setting the device configuration parameters.
4833
	 * Most of these parameters can be specified by the user during 
5344
	 * Most of these parameters can be specified by the user during
4834
	 * module insertion as they are module loadable parameters. If 
5345
	 * module insertion as they are module loadable parameters. If
4835
	 * these parameters are not not specified during load time, they 
5346
	 * these parameters are not not specified during load time, they
4836
	 * are initialized with default values.
5347
	 * are initialized with default values.
4837
	 */
5348
	 */
4838
	mac_control = &sp->mac_control;
5349
	mac_control = &sp->mac_control;
4839
	config = &sp->config;
5350
	config = &sp->config;
4840
5351
4841
	/* Tx side parameters. */
5352
	/* Tx side parameters. */
4842
	config->TxFIFONum = TxFifoNum;
5353
	if (tx_fifo_len[0] == 0)
4843
	config->tx_cfg[0].FifoLen = TxFIFOLen_0;
5354
		tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */
4844
	config->tx_cfg[0].FifoPriority = 0;
5355
	config->tx_fifo_num = tx_fifo_num;
4845
	config->tx_cfg[1].FifoLen = TxFIFOLen_1;
5356
	for (i = 0; i < MAX_TX_FIFOS; i++) {
4846
	config->tx_cfg[1].FifoPriority = 1;
5357
		config->tx_cfg[i].fifo_len = tx_fifo_len[i];
4847
	config->tx_cfg[2].FifoLen = TxFIFOLen_2;
5358
		config->tx_cfg[i].fifo_priority = i;
4848
	config->tx_cfg[2].FifoPriority = 2;
5359
	}
4849
	config->tx_cfg[3].FifoLen = TxFIFOLen_3;
5360
4850
	config->tx_cfg[3].FifoPriority = 3;
5361
	/* mapping the QoS priority to the configured fifos */
4851
	config->tx_cfg[4].FifoLen = TxFIFOLen_4;
5362
	for (i = 0; i < MAX_TX_FIFOS; i++)
4852
	config->tx_cfg[4].FifoPriority = 4;
5363
		config->fifo_mapping[i] = fifo_map[config->tx_fifo_num][i];
4853
	config->tx_cfg[5].FifoLen = TxFIFOLen_5;
5364
4854
	config->tx_cfg[5].FifoPriority = 5;
5365
	config->tx_intr_type = TXD_INT_TYPE_UTILZ;
4855
	config->tx_cfg[6].FifoLen = TxFIFOLen_6;
5366
	for (i = 0; i < config->tx_fifo_num; i++) {
4856
	config->tx_cfg[6].FifoPriority = 6;
5367
		config->tx_cfg[i].f_no_snoop =
4857
	config->tx_cfg[7].FifoLen = TxFIFOLen_7;
4858
	config->tx_cfg[7].FifoPriority = 7;
4859
4860
	config->TxIntrType = TXD_INT_TYPE_UTILZ;
4861
	for (i = 0; i < config->TxFIFONum; i++) {
4862
		config->tx_cfg[i].fNoSnoop =
4863
		    (NO_SNOOP_TXD | NO_SNOOP_TXD_BUFFER);
5368
		    (NO_SNOOP_TXD | NO_SNOOP_TXD_BUFFER);
4864
		if (config->tx_cfg[i].FifoLen < 65) {
5369
		if (config->tx_cfg[i].fifo_len < 65) {
4865
			config->TxIntrType = TXD_INT_TYPE_PER_LIST;
5370
			config->tx_intr_type = TXD_INT_TYPE_PER_LIST;
4866
			break;
5371
			break;
4867
		}
5372
		}
4868
	}
5373
	}
4869
	config->MaxTxDs = MAX_SKB_FRAGS;
5374
	config->max_txds = MAX_SKB_FRAGS + 1;
4870
	config->TxFlow = TRUE;
4871
5375
4872
	/* Rx side parameters. */
5376
	/* Rx side parameters. */
4873
	config->RxRingNum = RxRingNum;
5377
	if (rx_ring_sz[0] == 0)
4874
	config->rx_cfg[0].NumRxd = RxRingSz_0 * (MAX_RXDS_PER_BLOCK + 1);
5378
		rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */
4875
	config->rx_cfg[0].RingPriority = 0;
5379
	config->rx_ring_num = rx_ring_num;
4876
	config->rx_cfg[1].NumRxd = RxRingSz_1 * (MAX_RXDS_PER_BLOCK + 1);
5380
	for (i = 0; i < MAX_RX_RINGS; i++) {
4877
	config->rx_cfg[1].RingPriority = 1;
5381
		config->rx_cfg[i].num_rxd = rx_ring_sz[i] *
4878
	config->rx_cfg[2].NumRxd = RxRingSz_2 * (MAX_RXDS_PER_BLOCK + 1);
5382
		    (MAX_RXDS_PER_BLOCK + 1);
4879
	config->rx_cfg[2].RingPriority = 2;
5383
		config->rx_cfg[i].ring_priority = i;
4880
	config->rx_cfg[3].NumRxd = RxRingSz_3 * (MAX_RXDS_PER_BLOCK + 1);
4881
	config->rx_cfg[3].RingPriority = 3;
4882
	config->rx_cfg[4].NumRxd = RxRingSz_4 * (MAX_RXDS_PER_BLOCK + 1);
4883
	config->rx_cfg[4].RingPriority = 4;
4884
	config->rx_cfg[5].NumRxd = RxRingSz_5 * (MAX_RXDS_PER_BLOCK + 1);
4885
	config->rx_cfg[5].RingPriority = 5;
4886
	config->rx_cfg[6].NumRxd = RxRingSz_6 * (MAX_RXDS_PER_BLOCK + 1);
4887
	config->rx_cfg[6].RingPriority = 6;
4888
	config->rx_cfg[7].NumRxd = RxRingSz_7 * (MAX_RXDS_PER_BLOCK + 1);
4889
	config->rx_cfg[7].RingPriority = 7;
4890
4891
	for (i = 0; i < RxRingNum; i++) {
4892
		config->rx_cfg[i].RingOrg = RING_ORG_BUFF1;
4893
		config->rx_cfg[i].RxdThresh = DEFAULT_RXD_THRESHOLD;
4894
		config->rx_cfg[i].fNoSnoop =
4895
		    (NO_SNOOP_RXD | NO_SNOOP_RXD_BUFFER);
4896
		config->rx_cfg[i].RxD_BackOff_Interval = TBD;
4897
	}
5384
	}
4898
5385
4899
	config->RxFlow = TRUE;
5386
	for (i = 0; i < rx_ring_num; i++) {
4900
5387
		config->rx_cfg[i].ring_org = RING_ORG_BUFF1;
4901
	/* Miscellaneous parameters. */
5388
		config->rx_cfg[i].f_no_snoop =
4902
	config->RxVLANEnable = TRUE;
5389
		    (NO_SNOOP_RXD | NO_SNOOP_RXD_BUFFER);
4903
	config->MTU = MAX_MTU_VLAN;
5390
	}
4904
	config->JumboEnable = FALSE;
4905
5391
4906
	/*  Setting Mac Control parameters */
5392
	/*  Setting Mac Control parameters */
4907
	mac_control->txdl_len = MAX_SKB_FRAGS;
4908
	mac_control->rmac_pause_time = rmac_pause_time;
5393
	mac_control->rmac_pause_time = rmac_pause_time;
4909
	mac_control->mc_pause_threshold_q0q3 = mc_pause_threshold_q0q3;
5394
	mac_control->mc_pause_threshold_q0q3 = mc_pause_threshold_q0q3;
4910
	mac_control->mc_pause_threshold_q4q7 = mc_pause_threshold_q4q7;
5395
	mac_control->mc_pause_threshold_q4q7 = mc_pause_threshold_q4q7;
4911
5396
4912
5397
4913
	/* Initialize Ring buffer parameters. */
5398
	/* Initialize Ring buffer parameters. */
4914
	for (i = 0; i < config->RxRingNum; i++)
5399
	for (i = 0; i < config->rx_ring_num; i++)
4915
		atomic_set(&sp->rx_bufs_left[i], 0);
5400
		atomic_set(&sp->rx_bufs_left[i], 0);
4916
5401
5402
	/* Initialize the number of ISRs currently running */
5403
	atomic_set(&sp->isr_cnt, 0);
5404
4917
	/*  initialize the shared memory used by the NIC and the host */
5405
	/*  initialize the shared memory used by the NIC and the host */
4918
	if (init_shared_mem(sp)) {
5406
	if (init_shared_mem(sp)) {
4919
		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n",
5407
		DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n",
4920
			  dev->name);
5408
			  __FUNCTION__);
5409
		ret = -ENOMEM;
4921
		goto mem_alloc_failed;
5410
		goto mem_alloc_failed;
4922
	}
5411
	}
4923
5412
4924
	sp->bar0 = (caddr_t) ioremap(pci_resource_start(pdev, 0),
5413
	sp->bar0 = ioremap(pci_resource_start(pdev, 0),
4925
				     pci_resource_len(pdev, 0));
5414
				     pci_resource_len(pdev, 0));
4926
	if (!sp->bar0) {
5415
	if (!sp->bar0) {
4927
		DBG_PRINT(ERR_DBG, "%s: S2IO: cannot remap io mem1\n",
5416
		DBG_PRINT(ERR_DBG, "%s: S2IO: cannot remap io mem1\n",
4928
			  dev->name);
5417
			  dev->name);
5418
		ret = -ENOMEM;
4929
		goto bar0_remap_failed;
5419
		goto bar0_remap_failed;
4930
	}
5420
	}
4931
5421
4932
	sp->bar1 = (caddr_t) ioremap(pci_resource_start(pdev, 2),
5422
	sp->bar1 = ioremap(pci_resource_start(pdev, 2),
4933
				     pci_resource_len(pdev, 2));
5423
				     pci_resource_len(pdev, 2));
4934
	if (!sp->bar1) {
5424
	if (!sp->bar1) {
4935
		DBG_PRINT(ERR_DBG, "%s: S2IO: cannot remap io mem2\n",
5425
		DBG_PRINT(ERR_DBG, "%s: S2IO: cannot remap io mem2\n",
4936
			  dev->name);
5426
			  dev->name);
5427
		ret = -ENOMEM;
4937
		goto bar1_remap_failed;
5428
		goto bar1_remap_failed;
4938
	}
5429
	}
4939
5430
Lines 4942-4948 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4942
5433
4943
	/* Initializing the BAR1 address as the start of the FIFO pointer. */
5434
	/* Initializing the BAR1 address as the start of the FIFO pointer. */
4944
	for (j = 0; j < MAX_TX_FIFOS; j++) {
5435
	for (j = 0; j < MAX_TX_FIFOS; j++) {
4945
		mac_control->tx_FIFO_start[j] = (TxFIFO_element_t *)
5436
		mac_control->tx_FIFO_start[j] = (TxFIFO_element_t __iomem *)
4946
		    (sp->bar1 + (j * 0x00020000));
5437
		    (sp->bar1 + (j * 0x00020000));
4947
	}
5438
	}
4948
5439
Lines 4954-4979 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4954
	dev->set_multicast_list = &s2io_set_multicast;
5445
	dev->set_multicast_list = &s2io_set_multicast;
4955
	dev->do_ioctl = &s2io_ioctl;
5446
	dev->do_ioctl = &s2io_ioctl;
4956
	dev->change_mtu = &s2io_change_mtu;
5447
	dev->change_mtu = &s2io_change_mtu;
4957
#ifdef SET_ETHTOOL_OPS
4958
	SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
5448
	SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
4959
#endif
5449
	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
5450
	dev->vlan_rx_register = s2io_vlan_rx_register;
5451
	dev->vlan_rx_kill_vid = (void *)s2io_vlan_rx_kill_vid;
5452
4960
	/*
5453
	/*
4961
	 * will use eth_mac_addr() for  dev->set_mac_address
5454
	 * will use eth_mac_addr() for  dev->set_mac_address
4962
	 * mac address will be set every time dev->open() is called
5455
	 * mac address will be set every time dev->open() is called
4963
	 */
5456
	 */
4964
#ifdef CONFIG_S2IO_NAPI
5457
#if defined(CONFIG_S2IO_NAPI)
4965
	dev->poll = s2io_poll;
5458
	dev->poll = s2io_poll;
4966
	dev->weight = 90;	/* For now. */
5459
	dev->weight = 32;
4967
#endif
5460
#endif
4968
5461
4969
	dev->features |= NETIF_F_SG;
5462
	dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
4970
	if (cksum_offload_enable)
4971
		dev->features |= NETIF_F_IP_CSUM;
4972
	if (sp->high_dma_flag == TRUE)
5463
	if (sp->high_dma_flag == TRUE)
4973
		dev->features |= NETIF_F_HIGHDMA;
5464
		dev->features |= NETIF_F_HIGHDMA;
4974
#ifdef NETIF_F_TSO
5465
#ifdef NETIF_F_TSO
4975
	if (lso_enable)
5466
	dev->features |= NETIF_F_TSO;
4976
		dev->features |= NETIF_F_TSO;
4977
#endif
5467
#endif
4978
5468
4979
	dev->tx_timeout = &s2io_tx_watchdog;
5469
	dev->tx_timeout = &s2io_tx_watchdog;
Lines 4989-5016 s2io_init_nic(struct pci_dev *pdev, cons Link Here
4989
	if (s2io_set_swapper(sp)) {
5479
	if (s2io_set_swapper(sp)) {
4990
		DBG_PRINT(ERR_DBG, "%s:swapper settings are wrong\n",
5480
		DBG_PRINT(ERR_DBG, "%s:swapper settings are wrong\n",
4991
			  dev->name);
5481
			  dev->name);
5482
		ret = -EAGAIN;
4992
		goto set_swap_failed;
5483
		goto set_swap_failed;
4993
	}
5484
	}
4994
5485
4995
	/* Fix for all "FFs" MAC address problems observed on Alpha platforms */
5486
	/* Verify if the Herc works on the slot its placed into */
4996
	fix_mac_address(sp);
5487
	if (sp->device_type & XFRAME_II_DEVICE) {
4997
	s2io_reset(sp);
5488
		mode = s2io_verify_pci_mode(sp);
5489
		if (mode < 0) {
5490
			DBG_PRINT(ERR_DBG, "%s: ", __FUNCTION__);
5491
			DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode\n");
5492
			ret = -EBADSLT;
5493
			goto set_swap_failed;
5494
		}
5495
	}
4998
5496
4999
	/*
5497
	/* Not needed for Herc */
5000
	 * Setting swapper control on the NIC, so the MAC address can be read.
5498
	if (sp->device_type & XFRAME_I_DEVICE) {
5001
	 */
5499
		/*
5002
	if (s2io_set_swapper(sp)) {
5500
		 * Fix for all "FFs" MAC address problems observed on
5003
		DBG_PRINT(ERR_DBG,
5501
		 * Alpha platforms
5004
			  "%s: S2IO: swapper settings are wrong\n",
5502
		 */
5005
			  dev->name);
5503
		fix_mac_address(sp);
5006
		goto set_swap_failed;
5504
		s2io_reset(sp);
5007
	}
5505
	}
5008
5506
5009
	/*  
5507
	/*
5010
	 * MAC address initialization.
5508
	 * MAC address initialization.
5011
	 * For now only one mac address will be read and used.
5509
	 * For now only one mac address will be read and used.
5012
	 */
5510
	 */
5013
	bar0 = (XENA_dev_config_t *) sp->bar0;
5511
	bar0 = sp->bar0;
5014
	val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
5512
	val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
5015
	    RMAC_ADDR_CMD_MEM_OFFSET(0 + MAC_MAC_ADDR_START_OFFSET);
5513
	    RMAC_ADDR_CMD_MEM_OFFSET(0 + MAC_MAC_ADDR_START_OFFSET);
5016
	writeq(val64, &bar0->rmac_addr_cmd_mem);
5514
	writeq(val64, &bar0->rmac_addr_cmd_mem);
Lines 5029-5060 s2io_init_nic(struct pci_dev *pdev, cons Link Here
5029
	sp->def_mac_addr[0].mac_addr[5] = (u8) (mac_down >> 16);
5527
	sp->def_mac_addr[0].mac_addr[5] = (u8) (mac_down >> 16);
5030
	sp->def_mac_addr[0].mac_addr[4] = (u8) (mac_down >> 24);
5528
	sp->def_mac_addr[0].mac_addr[4] = (u8) (mac_down >> 24);
5031
5529
5032
	DBG_PRINT(INIT_DBG,
5033
		  "DEFAULT MAC ADDR:0x%02x-%02x-%02x-%02x-%02x-%02x\n",
5034
		  sp->def_mac_addr[0].mac_addr[0],
5035
		  sp->def_mac_addr[0].mac_addr[1],
5036
		  sp->def_mac_addr[0].mac_addr[2],
5037
		  sp->def_mac_addr[0].mac_addr[3],
5038
		  sp->def_mac_addr[0].mac_addr[4],
5039
		  sp->def_mac_addr[0].mac_addr[5]);
5040
5041
	/*  Set the factory defined MAC address initially   */
5530
	/*  Set the factory defined MAC address initially   */
5042
	dev->addr_len = ETH_ALEN;
5531
	dev->addr_len = ETH_ALEN;
5043
	memcpy(dev->dev_addr, sp->def_mac_addr, ETH_ALEN);
5532
	memcpy(dev->dev_addr, sp->def_mac_addr, ETH_ALEN);
5044
5533
5045
	/*  Initialize the tasklet status flag */
5534
	/*
5046
	atomic_set(&(sp->tasklet_status), 0);
5535
	 * Initialize the tasklet status and link state flags
5047
5536
	 * and the card state parameter
5537
	 */
5538
	atomic_set(&(sp->card_state), 0);
5539
	sp->tasklet_status = 0;
5540
	sp->link_state = 0;
5048
5541
5049
	/* Initialize spinlocks */
5542
	/* Initialize spinlocks */
5050
	spin_lock_init(&sp->tx_lock);
5543
	spin_lock_init(&sp->tx_lock);
5051
#ifndef CONFIG_S2IO_NAPI
5544
#ifndef CONFIG_S2IO_NAPI
5052
	spin_lock_init(&sp->put_lock);
5545
	spin_lock_init(&sp->put_lock);
5053
#endif
5546
#endif
5547
	spin_lock_init(&sp->rx_lock);
5054
5548
5055
	/* 
5549
	/*
5056
	 * SXE-002: Configure link and activity LED to init state 
5550
	 * SXE-002: Configure link and activity LED to init state
5057
	 * on driver load. 
5551
	 * on driver load.
5058
	 */
5552
	 */
5059
	subid = sp->pdev->subsystem_device;
5553
	subid = sp->pdev->subsystem_device;
5060
	if ((subid & 0xFF) >= 0x07) {
5554
	if ((subid & 0xFF) >= 0x07) {
Lines 5062-5101 s2io_init_nic(struct pci_dev *pdev, cons Link Here
5062
		val64 |= 0x0000800000000000ULL;
5556
		val64 |= 0x0000800000000000ULL;
5063
		writeq(val64, &bar0->gpio_control);
5557
		writeq(val64, &bar0->gpio_control);
5064
		val64 = 0x0411040400000000ULL;
5558
		val64 = 0x0411040400000000ULL;
5065
		writeq(val64, (u64 *) ((u8 *) bar0 + 0x2700));
5559
		writeq(val64, (void __iomem *) bar0 + 0x2700);
5066
		val64 = readq(&bar0->gpio_control);
5560
		val64 = readq(&bar0->gpio_control);
5067
	}
5561
	}
5068
5562
5069
	sp->rx_csum = 1;	/* Rx chksum verify enabled by default */
5563
	sp->rx_csum = 1;	/* Rx chksum verify enabled by default */
5070
5564
5071
#ifdef SNMP_SUPPORT
5565
	if (register_netdev(dev)) {
5072
	if (!s2io_bdsnmp_init(dev))
5566
		DBG_PRINT(ERR_DBG, "Device registration failed\n");
5073
		DBG_PRINT(INIT_DBG,
5567
		ret = -ENODEV;
5074
			  "Error Creating Proc directory for SNMP\n");
5568
		goto register_failed;
5569
	}
5075
5570
5076
	sp->nLinkStatus = 1;
5571
	if (sp->device_type & XFRAME_II_DEVICE) {
5077
#ifdef NETIF_F_TSO
5572
		DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ",
5078
	sp->nFeature = 1;
5573
			  dev->name);
5574
		DBG_PRINT(ERR_DBG, "(rev %d), %s",
5575
				get_xena_rev_id(sp->pdev),
5576
				s2io_driver_version);
5577
#ifdef CONFIG_2BUFF_MODE
5578
		DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5079
#endif
5579
#endif
5080
	memcpy(sp->cVersion, s2io_driver_version + 8, 20);
5580
5081
	memcpy(sp->cName, s2io_driver_name, 20);
5581
		DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5082
	struct timeval tm;
5582
		DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5083
	do_gettimeofday(&tm);
5583
			  sp->def_mac_addr[0].mac_addr[0],
5084
	sp->lDate = tm.tv_sec;
5584
			  sp->def_mac_addr[0].mac_addr[1],
5585
			  sp->def_mac_addr[0].mac_addr[2],
5586
			  sp->def_mac_addr[0].mac_addr[3],
5587
			  sp->def_mac_addr[0].mac_addr[4],
5588
			  sp->def_mac_addr[0].mac_addr[5]);
5589
		mode = s2io_print_pci_mode(sp);
5590
		if (mode < 0) {
5591
			DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode ");
5592
			ret = -EBADSLT;
5593
			goto set_swap_failed;
5594
		}
5595
	} else {
5596
		DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
5597
			  dev->name);
5598
		DBG_PRINT(ERR_DBG, "(rev %d), %s",
5599
					get_xena_rev_id(sp->pdev),
5600
					s2io_driver_version);
5601
#ifdef CONFIG_2BUFF_MODE
5602
		DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5085
#endif
5603
#endif
5604
		DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5605
		DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5606
			  sp->def_mac_addr[0].mac_addr[0],
5607
			  sp->def_mac_addr[0].mac_addr[1],
5608
			  sp->def_mac_addr[0].mac_addr[2],
5609
			  sp->def_mac_addr[0].mac_addr[3],
5610
			  sp->def_mac_addr[0].mac_addr[4],
5611
			  sp->def_mac_addr[0].mac_addr[5]);
5612
	}
5613
5614
	/* Initialize device name */
5615
	strcpy(sp->name, dev->name);
5616
	if (sp->device_type & XFRAME_II_DEVICE)
5617
		strcat(sp->name, ": Neterion Xframe II 10GbE adapter");
5618
	else
5619
		strcat(sp->name, ": Neterion Xframe I 10GbE adapter");
5086
5620
5087
	if (register_netdev(dev)) {
5621
	/* Initialize bimodal Interrupts */
5088
		DBG_PRINT(ERR_DBG, "Device registration failed\n");
5622
	sp->config.bimodal = bimodal;
5089
		goto register_failed;
5623
	if (!(sp->device_type & XFRAME_II_DEVICE) && bimodal) {
5624
		sp->config.bimodal = 0;
5625
		DBG_PRINT(ERR_DBG,"%s:Bimodal intr not supported by Xframe I\n",
5626
			dev->name);
5090
	}
5627
	}
5091
5628
5092
	/* 
5629
	/*
5093
	 * Make Link state as off at this point, when the Link change 
5630
	 * Make Link state as off at this point, when the Link change
5094
	 * interrupt comes the state will be automatically changed to 
5631
	 * interrupt comes the state will be automatically changed to
5095
	 * the right state.
5632
	 * the right state.
5096
	 */
5633
	 */
5097
	netif_carrier_off(dev);
5634
	netif_carrier_off(dev);
5098
	sp->last_link_state = LINK_DOWN;
5099
5635
5100
	return 0;
5636
	return 0;
5101
5637
Lines 5112-5126 s2io_init_nic(struct pci_dev *pdev, cons Link Here
5112
	pci_set_drvdata(pdev, NULL);
5648
	pci_set_drvdata(pdev, NULL);
5113
	free_netdev(dev);
5649
	free_netdev(dev);
5114
5650
5115
	return -ENODEV;
5651
	return ret;
5116
}
5652
}
5117
5653
5118
/**
5654
/**
5119
 * s2io_rem_nic - Free the PCI device 
5655
 * s2io_rem_nic - Free the PCI device
5120
 * @pdev: structure containing the PCI related information of the device.
5656
 * @pdev: structure containing the PCI related information of the device.
5121
 * Description: This function is called by the Pci subsystem to release a 
5657
 * Description: This function is called by the Pci subsystem to release a
5122
 * PCI device and free up all resource held up by the device. This could
5658
 * PCI device and free up all resource held up by the device. This could
5123
 * be in response to a Hot plug event or when the driver is to be removed 
5659
 * be in response to a Hot plug event or when the driver is to be removed
5124
 * from memory.
5660
 * from memory.
5125
 */
5661
 */
5126
5662
Lines 5144-5153 static void __devexit s2io_rem_nic(struc Link Here
5144
	pci_disable_device(pdev);
5680
	pci_disable_device(pdev);
5145
	pci_release_regions(pdev);
5681
	pci_release_regions(pdev);
5146
	pci_set_drvdata(pdev, NULL);
5682
	pci_set_drvdata(pdev, NULL);
5147
#ifdef SNMP_SUPPORT
5148
	s2io_bdsnmp_rem(dev);
5149
#endif
5150
5151
	free_netdev(dev);
5683
	free_netdev(dev);
5152
}
5684
}
5153
5685
Lines 5159-5171 static void __devexit s2io_rem_nic(struc Link Here
5159
5691
5160
int __init s2io_starter(void)
5692
int __init s2io_starter(void)
5161
{
5693
{
5162
	if (verify_load_parm())
5163
		return -ENODEV;
5164
	return pci_module_init(&s2io_driver);
5694
	return pci_module_init(&s2io_driver);
5165
}
5695
}
5166
5696
5167
/**
5697
/**
5168
 * s2io_closer - Cleanup routine for the driver 
5698
 * s2io_closer - Cleanup routine for the driver
5169
 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
5699
 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
5170
 */
5700
 */
5171
5701
Lines 5177-5747 void s2io_closer(void) Link Here
5177
5707
5178
module_init(s2io_starter);
5708
module_init(s2io_starter);
5179
module_exit(s2io_closer);
5709
module_exit(s2io_closer);
5180
/**
5181
 * verify_load_parm -  verifies the module loadable parameters
5182
 * Descriptions: Verifies the module loadable paramters and initializes the
5183
 * Tx Fifo, Rx Ring and other paramters.
5184
 */
5185
5186
int verify_load_parm()
5187
{
5188
	int fail = 0;
5189
	if (!((lso_enable == 0) || (lso_enable == 1))) {
5190
		printk("lso_enable can be either '1' or '0'\n");
5191
		fail = 1;
5192
	}
5193
#ifndef CONFIG_S2IO_NAPI
5194
	if ((indicate_max_pkts > (0xFFFFFFFF))) {
5195
		printk
5196
		    ("indicate_max_pkts can take value greater than zero but less than 2power(32)\n");
5197
		fail = 1;
5198
	}
5199
#endif
5200
	if (!((cksum_offload_enable == 0) || (cksum_offload_enable == 1))) {
5201
		printk("cksum_offload_enable can be only '0' or '1' \n");
5202
		fail = 1;
5203
	}
5204
	if ((TxFifoNum == 0) || (TxFifoNum > 8)) {
5205
		printk("TxFifoNum can take value from 1 to 8\n");
5206
		fail = 1;
5207
	}
5208
	switch (TxFifoNum) {
5209
	case 8:
5210
		if ((TxFIFOLen_7 == 0) || TxFIFOLen_7 > 8192) {
5211
			printk
5212
			    ("TxFIFOLen_7 can take value from 1 to 8192\n");
5213
			fail = 1;
5214
		}
5215
	case 7:
5216
		if ((TxFIFOLen_6 == 0) || TxFIFOLen_6 > 8192) {
5217
			printk
5218
			    ("TxFIFOLen_6 can take value from 1 to 8192\n");
5219
			fail = 1;
5220
		}
5221
	case 6:
5222
		if ((TxFIFOLen_5 == 0) || TxFIFOLen_5 > 8192) {
5223
			printk
5224
			    ("TxFIFOLen_5 can take value from 1 to 8192\n");
5225
			fail = 1;
5226
		}
5227
	case 5:
5228
		if ((TxFIFOLen_4 == 0) || TxFIFOLen_4 > 8192) {
5229
			printk
5230
			    ("TxFIFOLen_4 can take value from 1 to 8192\n");
5231
			fail = 1;
5232
		}
5233
	case 4:
5234
		if ((TxFIFOLen_3 == 0) || TxFIFOLen_3 > 8192) {
5235
			printk
5236
			    ("TxFIFOLen_3 can take value from 1 to 8192\n");
5237
			fail = 1;
5238
		}
5239
	case 3:
5240
		if ((TxFIFOLen_2 == 0) || TxFIFOLen_2 > 8192) {
5241
			printk
5242
			    ("TxFIFOLen_2 can take value from 1 to 8192\n");
5243
			fail = 1;
5244
		}
5245
	case 2:
5246
		if ((TxFIFOLen_1 == 0) || TxFIFOLen_1 > 8192) {
5247
			printk
5248
			    ("TxFIFOLen_1 can take value from 1 to 8192\n");
5249
			fail = 1;
5250
		}
5251
	case 1:
5252
		if ((TxFIFOLen_0 == 0) || TxFIFOLen_0 > 8192) {
5253
			printk
5254
			    ("TxFIFOLen_0 can take value from 1 to 8192\n");
5255
			fail = 1;
5256
		}
5257
	}
5258
	if ((MaxTxDs > 32) || (MaxTxDs < 1)) {
5259
		printk("MaxTxDs can take falue from 1 to 32\n");
5260
		fail = 1;
5261
	}
5262
	if ((RxRingNum > 8) || (RxRingNum < 1)) {
5263
		printk("RxRingNum can take falue from 1 to 8\n");
5264
		fail = 1;
5265
	}
5266
	switch (RxRingNum) {
5267
	case 8:
5268
		if (RxRingSz_7 < 1) {
5269
			printk
5270
			    ("RxRingSz_7 can take value greater than 0\n");
5271
			fail = 1;
5272
		}
5273
	case 7:
5274
		if (RxRingSz_6 < 1) {
5275
			printk
5276
			    ("RxRingSz_6 can take value greater than 0\n");
5277
			fail = 1;
5278
		}
5279
	case 6:
5280
		if (RxRingSz_5 < 1) {
5281
			printk
5282
			    ("RxRingSz_5 can take value greater than 0\n");
5283
			fail = 1;
5284
		}
5285
	case 5:
5286
		if (RxRingSz_4 < 1) {
5287
			printk
5288
			    ("RxRingSz_4 can take value greater than 0\n");
5289
			fail = 1;
5290
		}
5291
	case 4:
5292
		if (RxRingSz_3 < 1) {
5293
			printk
5294
			    ("RxRingSz_3 can take value greater than 0\n");
5295
			fail = 1;
5296
		}
5297
	case 3:
5298
		if (RxRingSz_2 < 1) {
5299
			printk
5300
			    ("RxRingSz_2 can take value greater than 0\n");
5301
			fail = 1;
5302
		}
5303
	case 2:
5304
		if (RxRingSz_1 < 1) {
5305
			printk
5306
			    ("RxRingSz_1 can take value greater than 0\n");
5307
			fail = 1;
5308
		}
5309
	case 1:
5310
		if (RxRingSz_0 < 1) {
5311
			printk
5312
			    ("RxRingSz_0 can take value greater than 0\n");
5313
			fail = 1;
5314
		}
5315
	}
5316
	if ((Stats_refresh_time < 1)) {
5317
		printk
5318
		    ("Stats_refresh_time cannot be less than 1 second \n");
5319
		fail = 1;
5320
	}
5321
	if (((rmac_pause_time < 0x10) && (rmac_pause_time != 0)) ||
5322
	    (rmac_pause_time > 0xFFFF)) {
5323
		printk
5324
		    ("rmac_pause_time can take value from 16 to 65535\n");
5325
		fail = 1;
5326
	}
5327
	if ((max_splits_trans < 0) || (max_splits_trans > 7)) {
5328
		printk("max_splits_trans can take value from 0 to 7\n");
5329
		fail = 1;
5330
	}
5331
	if ((mc_pause_threshold_q0q3 > 0xFE)) {
5332
		printk("mc_pause_threshold_q0q3 cannot exceed 254\n");
5333
		fail = 1;
5334
	}
5335
	if ((mc_pause_threshold_q4q7 > 0xFE)) {
5336
		printk("mc_pause_threshold_q4q7 cannot exceed 254\n");
5337
		fail = 1;
5338
	}
5339
	if ((latency_timer)
5340
	    && ((latency_timer < 8) /* || (latency_timer > 255) */)) {
5341
		printk("latency_timer can take value from 8 to 255\n");
5342
		fail = 1;
5343
	}
5344
	if (max_read_byte_cnt > 3) {
5345
		printk("max_read_byte_cnt can take value from 0 to 3\n");
5346
		fail = 1;
5347
	}
5348
	if ((shared_splits > 31)) {
5349
		printk("shared_splits cannot exceed 31\n");
5350
		fail = 1;
5351
	}
5352
	if (rmac_util_period > 0xF) {
5353
		printk("rmac_util_period cannot exceed 15\n");
5354
		fail = 1;
5355
	}
5356
	if (tmac_util_period > 0xF) {
5357
		printk("tmac_util_period cannot exceed 15\n");
5358
		fail = 1;
5359
	}
5360
	if ((tx_utilz_periodic > 1) || (rx_utilz_periodic > 1)) {
5361
		printk
5362
		    ("tx_utilz_periodic & rx_utilz_periodic can be either "
5363
		     "'0' or '1'\n");
5364
		fail = 1;
5365
	}
5366
	if ((tx_urange_a > 127) || (tx_urange_b > 127)
5367
	    || (tx_urange_c > 127)) {
5368
		printk
5369
		    ("tx_urange_a, tx_urange_b & tx_urange_c can take value "
5370
		     "from 0 to 127\n");
5371
		fail = 1;
5372
	}
5373
	if ((rx_urange_a > 127) || (rx_urange_b > 127)
5374
	    || (rx_urange_c > 127)) {
5375
		printk
5376
		    ("rx_urange_a, rx_urange_b & rx_urange_c can take value "
5377
		     "from 0 to 127\n");
5378
		fail = 1;
5379
	}
5380
	if ((tx_ufc_a > 0xffff) || (tx_ufc_b > 0xffff) ||
5381
	    (tx_ufc_c > 0xffff) || (tx_ufc_d > 0xffff)) {
5382
		printk
5383
		    (" tx_ufc_a, tx_ufc_b, tx_ufc_c, tx_ufc_d can take value"
5384
		     "from 0 to 65535(0xFFFF)\n");
5385
		fail = 1;
5386
	}
5387
	if ((rx_ufc_a > 0xffff) || (rx_ufc_b > 0xffff) ||
5388
	    (rx_ufc_c > 0xffff) || (rx_ufc_d > 0xffff)) {
5389
		printk
5390
		    (" rx_ufc_a, rx_ufc_b, rx_ufc_c, rx_ufc_d can take value"
5391
		     "from 0 to 65535(0xFFFF)\n");
5392
		fail = 1;
5393
	}
5394
	return fail;
5395
}
5396
5397
#ifdef SNMP_SUPPORT
5398
/**
5399
 * fnBaseDrv - Get the driver information
5400
 * @pBaseDrv -Pointer to Base driver structure which contains the offset 
5401
 * and length of each of the field.
5402
 * Description
5403
 * This function copies the driver specific information from the dev structure
5404
 * to the pBaseDrv stucture. It calculates the number of physical adapters by
5405
 * parsing the dev_base global variable maintained by the kernel. This 
5406
 * variable has to read locked before accesing.This function is called by
5407
 * fnBaseReadProc function.
5408
 *
5409
 */
5410
5411
static void fnBaseDrv(struct stBaseDrv *pBaseDrv, struct net_device *dev)
5412
{
5413
5414
	struct pci_dev *pdev = NULL;
5415
	struct net_device *ndev;
5416
	int nCount = 0;
5417
	nic_t *sp = (nic_t *) dev->priv;
5418
5419
	strncpy(pBaseDrv->m_cName, sp->cName, 20);
5420
	strncpy(pBaseDrv->m_cVersion, sp->cVersion, 20);
5421
	pBaseDrv->m_nStatus = sp->nLinkStatus;
5422
	pBaseDrv->m_nFeature = sp->nFeature;
5423
	pBaseDrv->m_nMemorySize = sp->nMemorySize;
5424
	sprintf(pBaseDrv->m_cDate, "%ld", sp->lDate);
5425
	/* 
5426
	 * Find all the ethernet devices on the system using 
5427
	 * pci_find_class. Get the private data which will be the 
5428
	 * net_device structure assigned by the driver.
5429
	 */
5430
	while ((pdev =
5431
		pci_find_class((PCI_CLASS_NETWORK_ETHERNET << 8), pdev))) {
5432
		ndev = (struct net_device *) pci_get_drvdata(pdev);
5433
		if (ndev == NULL)
5434
			break;
5435
		memcpy(pBaseDrv->m_stPhyAdap[nCount].m_cName, ndev->name,
5436
		       20);
5437
		pBaseDrv->m_stPhyAdap[nCount].m_nIndex = ndev->ifindex;
5438
		nCount++;
5439
	}
5440
	pBaseDrv->m_nPhyCnt = nCount;
5441
}
5442
5443
/* 
5444
 *  fnBaseReadProc - Read entry point for the proc file  
5445
 *  @page - Buffer pointer where the data is written
5446
 *  @start- Pointer to buffer ptr . It is used if the data is more than a page
5447
 *  @off- the offset to the page where data is written
5448
 *  @count - number of bytes to write
5449
 *  @eof - to indicate end of file
5450
 *  @data - pointer to device structure.
5451
 *
5452
 * Description - 
5453
 * This function gets  Base driver specific information from the fnBaseDrv 
5454
 * function and writes into the BDInfo file. This function is called whenever 
5455
 * the user reads the file. The length of data written cannot exceed 4kb. 
5456
 * If it exceeds then use the start pointer to write multiple pages
5457
 * Return - the length of the string written to proc file
5458
 */
5459
static int fnBaseReadProc(char *page, char **start, off_t off, int count,
5460
			  int *eof, void *data)
5461
{
5462
	struct stBaseDrv *pBaseDrv;
5463
	int nLength = 0;
5464
	int nCount = 0;
5465
	struct net_device *dev = (struct net_device *) data;
5466
	int nIndex = 0;
5467
5468
	pBaseDrv = kmalloc(sizeof(struct stBaseDrv), GFP_KERNEL);
5469
	if (pBaseDrv == NULL) {
5470
		printk("Error allocating memory\n");
5471
		return -ENOMEM;
5472
	}
5473
	fnBaseDrv(pBaseDrv, dev);
5474
	sprintf(page + nLength, "%-30s%-20s\n", "Base Driver Name",
5475
		pBaseDrv->m_cName);
5476
	nLength += 51;
5477
	if (pBaseDrv->m_nStatus == 1)
5478
		sprintf(page + nLength, "%-30s%-20s\n", "Load Status",
5479
			"Loaded");
5480
	else
5481
		sprintf(page + nLength, "%-30s%-20s\n", "Load Status",
5482
			"UnLoaded");
5483
	nLength += 51;
5484
	sprintf(page + nLength, "%-30s%-20s\n", "Base Driver Version",
5485
		pBaseDrv->m_cVersion);
5486
	nLength += 51;
5487
5488
	sprintf(page + nLength, "%-30s%-20d\n", "Feature Supported",
5489
		pBaseDrv->m_nFeature);
5490
	nLength += 51;
5491
5492
	sprintf(page + nLength, "%-30s%-20d\n",
5493
		"Base Driver Memrory in Bytes", pBaseDrv->m_nMemorySize);
5494
	nLength += 51;
5495
5496
	sprintf(page + nLength, "%-30s%-20s\n", "Base Driver Date",
5497
		pBaseDrv->m_cDate);
5498
	nLength += 51;
5499
5500
	sprintf(page + nLength, "%-30s%-20d\n", "No of Phy Adapter",
5501
		pBaseDrv->m_nPhyCnt);
5502
	nLength += 51;
5503
	sprintf(page + nLength, "%-20s%-20s\n\n", "Phy Adapter Index",
5504
		"Phy Adapter Name");
5505
	nLength += 42;
5506
5507
	for (nIndex = 0, nCount = pBaseDrv->m_nPhyCnt; nCount != 0;
5508
	     nCount--, nIndex++) {
5509
		sprintf(page + nLength, "%-20d%-20s\n",
5510
			pBaseDrv->m_stPhyAdap[nIndex].m_nIndex,
5511
			pBaseDrv->m_stPhyAdap[nIndex].m_cName);
5512
		nLength += 41;
5513
	}
5514
5515
	*eof = 1;
5516
	kfree(pBaseDrv);
5517
	return nLength;
5518
}
5519
5520
/* 
5521
 *  fnPhyAdapReadProc - Read entry point for the proc file  
5522
 *  @page - Buffer pointer where the data is written
5523
 *  @start- Pointer to buffer ptr . It is used if the data is more than a page
5524
 *  @off- the offset to the page where data is written
5525
 *  @count - number of bytes to write
5526
 *  @eof - to indicate end of file
5527
 *  @data - pointer to device structure.
5528
 *
5529
 * Description - 
5530
 * This function gets  physical adapter information. This function is called
5531
 * whenever the use* r reads the file. The length of data written cannot
5532
 * exceed 4kb. If it exceeds then use the start pointer to write multiple page 
5533
 *
5534
 * Return - the length of the string written to proc file
5535
 */
5536
static int fnPhyAdapReadProc(char *page, char **start, off_t off,
5537
			     int count, int *eof, void *data)
5538
{
5539
5540
	struct stPhyData *pPhyData;
5541
	pPhyData = kmalloc(sizeof(struct stPhyData), GFP_KERNEL);
5542
	if (pPhyData == NULL) {
5543
		printk("Error allocating memory\n");
5544
		return -ENOMEM;
5545
	}
5546
5547
	struct net_device *pNetDev;
5548
	struct net_device_stats *pNetStat;
5549
	int nLength = 0;
5550
	unsigned char cMAC[20];
5551
5552
	/* Print the header in the PhyAdap proc file */
5553
	sprintf(page + nLength,
5554
		"%-10s%-22s%-10s%-10s%-22s%-22s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n",
5555
		"Index", "Description", "Mode", "Type", "Speed", "MAC",
5556
		"Status", "Slot", "Bus", "IRQ", "Colis", "Multi",
5557
		"RxBytes", "RxDrop", "RxError", "RxPacket", "TRxBytes",
5558
		"TRxDrop", "TxError", "TxPacket");
5559
5560
	/* 237 is the lenght of the above string copied in the page  */
5561
	nLength += 237;
5562
5563
	struct pci_dev *pdev = NULL;
5564
	/* 
5565
	 * pci_find_class will return to the pointer to the pdev structure
5566
	 * for all the network devices using PCI_CLASS_NETWORK_ETHERNET.
5567
	 * The third argument is pointer to previous pdev structure.Initailly
5568
	 * it has to be null
5569
	 */
5570
	while ((pdev =
5571
		pci_find_class((PCI_CLASS_NETWORK_ETHERNET << 8), pdev))) {
5572
		/* Private data will point to the netdevice structure */
5573
		pNetDev = (struct net_device *) pci_get_drvdata(pdev);
5574
		if (pNetDev == NULL)
5575
			continue;
5576
		if (pNetDev->addr_len != 0) {
5577
			pNetStat = pNetDev->get_stats(pNetDev);
5578
			pPhyData->m_nIndex = pNetDev->ifindex;
5579
			memcpy(pPhyData->m_cDesc, pNetDev->name, 20);
5580
			pPhyData->m_nMode = 0;
5581
			pPhyData->m_nType = 0;
5582
			switch (pPhyData->m_nType) {
5583
				/* case IFT_ETHER:
5584
				   memcpy(pPhyData->m_cSpeed,"10000000",20);
5585
				   break;
5586
5587
				   case 9:
5588
				   memcpy(pPhyData->m_cSpeed,"4000000",20);
5589
				   break; */
5590
			default:
5591
				memcpy(pPhyData->m_cSpeed, "10000000", 20);
5592
				break;
5593
			}
5594
			memcpy(pPhyData->m_cPMAC, pNetDev->dev_addr,
5595
			       ETH_ALEN);
5596
			memcpy(pPhyData->m_cCMAC, pNetDev->dev_addr,
5597
			       ETH_ALEN);
5598
			pPhyData->m_nLinkStatus =
5599
			    test_bit(__LINK_STATE_START, &pNetDev->state);
5600
			pPhyData->m_nPCISlot = PCI_SLOT(pdev->devfn);
5601
			pPhyData->m_nPCIBus = pdev->bus->number;
5602
			pPhyData->m_nIRQ = pNetDev->irq;
5603
			pPhyData->m_nCollision = pNetStat->collisions;
5604
			pPhyData->m_nMulticast = pNetStat->multicast;
5605
5606
			pPhyData->m_nRxBytes = pNetStat->rx_bytes;
5607
			pPhyData->m_nRxDropped = pNetStat->rx_dropped;
5608
			pPhyData->m_nRxErrors = pNetStat->rx_errors;
5609
			pPhyData->m_nRxPackets = pNetStat->rx_packets;
5610
5611
			pPhyData->m_nTxBytes = pNetStat->tx_bytes;
5612
			pPhyData->m_nTxDropped = pNetStat->tx_dropped;
5613
			pPhyData->m_nTxErrors = pNetStat->tx_errors;
5614
			pPhyData->m_nTxPackets = pNetStat->tx_packets;
5615
5616
			sprintf(cMAC, "%02x:%02x:%02x:%02x:%02x:%02x",
5617
				pPhyData->m_cPMAC[0], pPhyData->m_cPMAC[1],
5618
				pPhyData->m_cPMAC[2], pPhyData->m_cPMAC[3],
5619
				pPhyData->m_cPMAC[4],
5620
				pPhyData->m_cPMAC[5]);
5621
5622
			sprintf(page + nLength,
5623
				"%-10d%-22s%-10d%-10d%-22s%-22s%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d%-10d\n",
5624
				pPhyData->m_nIndex, pPhyData->m_cDesc,
5625
				pPhyData->m_nMode, pPhyData->m_nType,
5626
				pPhyData->m_cSpeed, cMAC,
5627
				pPhyData->m_nLinkStatus,
5628
				pPhyData->m_nPCISlot, pPhyData->m_nPCIBus,
5629
				pPhyData->m_nIRQ, pPhyData->m_nCollision,
5630
				pPhyData->m_nMulticast,
5631
				pPhyData->m_nRxBytes,
5632
				pPhyData->m_nRxDropped,
5633
				pPhyData->m_nRxErrors,
5634
				pPhyData->m_nRxPackets,
5635
				pPhyData->m_nTxBytes,
5636
				pPhyData->m_nTxDropped,
5637
				pPhyData->m_nTxErrors,
5638
				pPhyData->m_nTxPackets);
5639
			nLength += 237;
5640
		}
5641
	}
5642
5643
	*eof = 1;
5644
5645
	kfree(pPhyData);
5646
	return nLength;
5647
}
5648
5649
/* 
5650
 * s2io_bdsnmp_init - Entry point to create proc file
5651
 * @dev-  Pointer to net device structure passed by the driver.
5652
 * Return 
5653
 * Success If creates all the files
5654
 * ERROR_PROC_ENTRY /ERROR_PROC_DIR Error If could not create all the files
5655
 * Description
5656
 * This functon is called when the driver is loaded. It creates the S2IO
5657
 * proc file system in the /proc/net/ directory. This directory is used to 
5658
 * store the info about the base driver afm driver, lacp, vlan  and nplus.
5659
 * It checks if S2IO directory already exists else creates it and creates 
5660
 * the files BDInfo  files and assiciates read function to each of the files.
5661
 */
5662
5663
int s2io_bdsnmp_init(struct net_device *dev)
5664
{
5665
	struct proc_dir_entry *S2ioDir;
5666
	struct proc_dir_entry *BaseDrv;
5667
	struct proc_dir_entry *PhyAdap;
5668
	int nLength = 0;
5669
5670
	nLength = strlen(S2IODIRNAME);
5671
	/* IF the directory already exists then just return */
5672
	for (S2ioDir = proc_net->subdir; S2ioDir != NULL;
5673
	     S2ioDir = S2ioDir->next) {
5674
		if ((S2ioDir->namelen == nLength)
5675
		    && (!memcmp(S2ioDir->name, S2IODIRNAME, nLength)))
5676
			break;
5677
	}
5678
	if (S2ioDir == NULL)
5679
		/* Create the s2io directory */
5680
		if (!
5681
		    (S2ioDir =
5682
		     create_proc_entry(S2IODIRNAME, S_IFDIR, proc_net))) {
5683
			DBG_PRINT(INIT_DBG,
5684
				  "Error Creating Proc directory for SNMP\n");
5685
			return ERROR_PROC_DIR;
5686
		}
5687
	/* 
5688
	 * Create the BDInfo file to store driver info and associate 
5689
	 * read funtion.
5690
	 */
5691
	if (!
5692
	    (BaseDrv =
5693
	     create_proc_read_entry(BDFILENAME, S_IFREG | S_IRUSR, S2ioDir,
5694
				    fnBaseReadProc, (void *) dev))) {
5695
		DBG_PRINT(INIT_DBG,
5696
			  "Error Creating Proc File for Base Drvr\n");
5697
		return ERROR_PROC_ENTRY;
5698
	}
5699
	if (!
5700
	    (PhyAdap =
5701
	     create_proc_read_entry(PADAPFILENAME, S_IFREG | S_IRUSR,
5702
				    S2ioDir, fnPhyAdapReadProc,
5703
				    (void *) dev))) {
5704
		DBG_PRINT(INIT_DBG,
5705
			  "Error Creating Proc File for Phys Adap\n");
5706
		return ERROR_PROC_ENTRY;
5707
	}
5708
5709
5710
	return SUCCESS;
5711
}
5712
5713
/**
5714
 * s2io_bdsnmp_rem : Removes the proc file entry
5715
 * @dev - pointer to netdevice structre
5716
 * Return - void
5717
 * Description
5718
 * This functon is called when the driver is Unloaded. It checks if the 
5719
 * S2IO directoy exists and deletes the files in the reverse order of 
5720
 * creation.
5721
 */
5722
5723
void s2io_bdsnmp_rem(struct net_device *dev)
5724
{
5725
	int nLength = 0;
5726
	struct proc_dir_entry *S2ioDir;
5727
	nLength = strlen(S2IODIRNAME);
5728
	/* 
5729
	 * Check if the S2IO directory exists or not and then delete 
5730
	 * all the files in the S2IO Directory 
5731
	 */
5732
	for (S2ioDir = proc_net->subdir; S2ioDir != NULL;
5733
	     S2ioDir = S2ioDir->next) {
5734
		if ((S2ioDir->namelen == nLength)
5735
		    && (!memcmp(S2ioDir->name, S2IODIRNAME, nLength)))
5736
5737
			break;
5738
	}
5739
	if (S2ioDir == NULL)
5740
		return;
5741
	remove_proc_entry(BDFILENAME, S2ioDir);
5742
	remove_proc_entry(PADAPFILENAME, S2ioDir);
5743
	if (S2ioDir->subdir == NULL) {
5744
		remove_proc_entry(S2IODIRNAME, proc_net);
5745
	}
5746
}
5747
#endif
(-)old/drivers/net/s2io.h (-394 / +274 lines)
Lines 1-6 Link Here
1
/************************************************************************
1
/************************************************************************
2
 * s2io.h: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC
2
 * s2io.h: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC
3
 * Copyright 2002 Raghavendra Koushik (raghavendra.koushik@s2io.com)
3
 * Copyright(c) 2002-2005 Neterion Inc.
4
4
5
 * This software may be used and distributed according to the terms of
5
 * This software may be used and distributed according to the terms of
6
 * the GNU General Public License (GPL), incorporated herein by reference.
6
 * the GNU General Public License (GPL), incorporated herein by reference.
Lines 31-36 Link Here
31
#define SUCCESS 0
31
#define SUCCESS 0
32
#define FAILURE -1
32
#define FAILURE -1
33
33
34
#ifndef NET_IP_ALIGN
35
#define NET_IP_ALIGN 2
36
#endif
37
38
/* Maximum time to flicker LED when asked to identify NIC using ethtool */
39
#define MAX_FLICKER_TIME	60000 /* 60 Secs */
40
34
/* Maximum outstanding splits to be configured into xena. */
41
/* Maximum outstanding splits to be configured into xena. */
35
typedef enum xena_max_outstanding_splits {
42
typedef enum xena_max_outstanding_splits {
36
	XENA_ONE_SPLIT_TRANSACTION = 0,
43
	XENA_ONE_SPLIT_TRANSACTION = 0,
Lines 45-58 typedef enum xena_max_outstanding_splits Link Here
45
#define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4)
52
#define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4)
46
53
47
/*  OS concerned variables and constants */
54
/*  OS concerned variables and constants */
48
#define WATCH_DOG_TIMEOUT   	5*HZ
55
#define WATCH_DOG_TIMEOUT		15*HZ
49
#define EFILL       			0x1234
56
#define EFILL				0x1234
50
#define ALIGN_SIZE  			127
57
#define ALIGN_SIZE			127
51
#define	PCIX_COMMAND_REGISTER	0x62
58
#define	PCIX_COMMAND_REGISTER		0x62
52
53
#ifndef SET_ETHTOOL_OPS
54
#define SUPPORTED_10000baseT_Full (1 << 12)
55
#endif
56
59
57
/*
60
/*
58
 * Debug related variables.
61
 * Debug related variables.
Lines 75-197 int debug_level = ERR_DBG; /* Default le Link Here
75
#define L4_CKSUM_OK 0xFFFF
78
#define L4_CKSUM_OK 0xFFFF
76
#define S2IO_JUMBO_SIZE 9600
79
#define S2IO_JUMBO_SIZE 9600
77
80
81
/* Driver statistics maintained by driver */
82
typedef struct {
83
	unsigned long long single_ecc_errs;
84
	unsigned long long double_ecc_errs;
85
} swStat_t;
86
78
/* The statistics block of Xena */
87
/* The statistics block of Xena */
79
typedef struct stat_block {
88
typedef struct stat_block {
80
#ifdef  __BIG_ENDIAN
81
/* Tx MAC statistics counters. */
82
	u32 tmac_frms;
83
	u32 tmac_data_octets;
84
	u64 tmac_drop_frms;
85
	u32 tmac_mcst_frms;
86
	u32 tmac_bcst_frms;
87
	u64 tmac_pause_ctrl_frms;
88
	u32 tmac_ttl_octets;
89
	u32 tmac_ucst_frms;
90
	u32 tmac_nucst_frms;
91
	u32 tmac_any_err_frms;
92
	u64 tmac_ttl_less_fb_octets;
93
	u64 tmac_vld_ip_octets;
94
	u32 tmac_vld_ip;
95
	u32 tmac_drop_ip;
96
	u32 tmac_icmp;
97
	u32 tmac_rst_tcp;
98
	u64 tmac_tcp;
99
	u32 tmac_udp;
100
	u32 reserved_0;
101
102
/* Rx MAC Statistics counters. */
103
	u32 rmac_vld_frms;
104
	u32 rmac_data_octets;
105
	u64 rmac_fcs_err_frms;
106
	u64 rmac_drop_frms;
107
	u32 rmac_vld_mcst_frms;
108
	u32 rmac_vld_bcst_frms;
109
	u32 rmac_in_rng_len_err_frms;
110
	u32 rmac_out_rng_len_err_frms;
111
	u64 rmac_long_frms;
112
	u64 rmac_pause_ctrl_frms;
113
	u64 rmac_unsup_ctrl_frms;
114
	u32 rmac_ttl_octets;
115
	u32 rmac_accepted_ucst_frms;
116
	u32 rmac_accepted_nucst_frms;
117
	u32 rmac_discarded_frms;
118
	u32 rmac_drop_events;
119
	u32 reserved_1;
120
	u64 rmac_ttl_less_fb_octets;
121
	u64 rmac_ttl_frms;
122
	u64 reserved_2;
123
	u32 reserved_3;
124
	u32 rmac_usized_frms;
125
	u32 rmac_osized_frms;
126
	u32 rmac_frag_frms;
127
	u32 rmac_jabber_frms;
128
	u32 reserved_4;
129
	u64 rmac_ttl_64_frms;
130
	u64 rmac_ttl_65_127_frms;
131
	u64 reserved_5;
132
	u64 rmac_ttl_128_255_frms;
133
	u64 rmac_ttl_256_511_frms;
134
	u64 reserved_6;
135
	u64 rmac_ttl_512_1023_frms;
136
	u64 rmac_ttl_1024_1518_frms;
137
	u32 reserved_7;
138
	u32 rmac_ip;
139
	u64 rmac_ip_octets;
140
	u32 rmac_hdr_err_ip;
141
	u32 rmac_drop_ip;
142
	u32 rmac_icmp;
143
	u32 reserved_8;
144
	u64 rmac_tcp;
145
	u32 rmac_udp;
146
	u32 rmac_err_drp_udp;
147
	u64 rmac_xgmii_err_sym;
148
	u64 rmac_frms_q0;
149
	u64 rmac_frms_q1;
150
	u64 rmac_frms_q2;
151
	u64 rmac_frms_q3;
152
	u64 rmac_frms_q4;
153
	u64 rmac_frms_q5;
154
	u64 rmac_frms_q6;
155
	u64 rmac_frms_q7;
156
	u16 rmac_full_q0;
157
	u16 rmac_full_q1;
158
	u16 rmac_full_q2;
159
	u16 rmac_full_q3;
160
	u16 rmac_full_q4;
161
	u16 rmac_full_q5;
162
	u16 rmac_full_q6;
163
	u16 rmac_full_q7;
164
	u32 rmac_pause_cnt;
165
	u32 reserved_9;
166
	u64 rmac_xgmii_data_err_cnt;
167
	u64 rmac_xgmii_ctrl_err_cnt;
168
	u32 rmac_accepted_ip;
169
	u32 rmac_err_tcp;
170
171
/* PCI/PCI-X Read transaction statistics. */
172
	u32 rd_req_cnt;
173
	u32 new_rd_req_cnt;
174
	u32 new_rd_req_rtry_cnt;
175
	u32 rd_rtry_cnt;
176
	u32 wr_rtry_rd_ack_cnt;
177
178
/* PCI/PCI-X write transaction statistics. */
179
	u32 wr_req_cnt;
180
	u32 new_wr_req_cnt;
181
	u32 new_wr_req_rtry_cnt;
182
	u32 wr_rtry_cnt;
183
	u32 wr_disc_cnt;
184
	u32 rd_rtry_wr_ack_cnt;
185
186
/*	DMA Transaction statistics. */
187
	u32 txp_wr_cnt;
188
	u32 txd_rd_cnt;
189
	u32 txd_wr_cnt;
190
	u32 rxd_rd_cnt;
191
	u32 rxd_wr_cnt;
192
	u32 txf_rd_cnt;
193
	u32 rxf_wr_cnt;
194
#else
195
/* Tx MAC statistics counters. */
89
/* Tx MAC statistics counters. */
196
	u32 tmac_data_octets;
90
	u32 tmac_data_octets;
197
	u32 tmac_frms;
91
	u32 tmac_frms;
Lines 305-321 typedef struct stat_block { Link Here
305
	u32 rxd_rd_cnt;
199
	u32 rxd_rd_cnt;
306
	u32 rxf_wr_cnt;
200
	u32 rxf_wr_cnt;
307
	u32 txf_rd_cnt;
201
	u32 txf_rd_cnt;
308
#endif
202
203
/* Tx MAC statistics overflow counters. */
204
	u32 tmac_data_octets_oflow;
205
	u32 tmac_frms_oflow;
206
	u32 tmac_bcst_frms_oflow;
207
	u32 tmac_mcst_frms_oflow;
208
	u32 tmac_ucst_frms_oflow;
209
	u32 tmac_ttl_octets_oflow;
210
	u32 tmac_any_err_frms_oflow;
211
	u32 tmac_nucst_frms_oflow;
212
	u64 tmac_vlan_frms;
213
	u32 tmac_drop_ip_oflow;
214
	u32 tmac_vld_ip_oflow;
215
	u32 tmac_rst_tcp_oflow;
216
	u32 tmac_icmp_oflow;
217
	u32 tpa_unknown_protocol;
218
	u32 tmac_udp_oflow;
219
	u32 reserved_10;
220
	u32 tpa_parse_failure;
221
222
/* Rx MAC Statistics overflow counters. */
223
	u32 rmac_data_octets_oflow;
224
	u32 rmac_vld_frms_oflow;
225
	u32 rmac_vld_bcst_frms_oflow;
226
	u32 rmac_vld_mcst_frms_oflow;
227
	u32 rmac_accepted_ucst_frms_oflow;
228
	u32 rmac_ttl_octets_oflow;
229
	u32 rmac_discarded_frms_oflow;
230
	u32 rmac_accepted_nucst_frms_oflow;
231
	u32 rmac_usized_frms_oflow;
232
	u32 rmac_drop_events_oflow;
233
	u32 rmac_frag_frms_oflow;
234
	u32 rmac_osized_frms_oflow;
235
	u32 rmac_ip_oflow;
236
	u32 rmac_jabber_frms_oflow;
237
	u32 rmac_icmp_oflow;
238
	u32 rmac_drop_ip_oflow;
239
	u32 rmac_err_drp_udp_oflow;
240
	u32 rmac_udp_oflow;
241
	u32 reserved_11;
242
	u32 rmac_pause_cnt_oflow;
243
	u64 rmac_ttl_1519_4095_frms;
244
	u64 rmac_ttl_4096_8191_frms;
245
	u64 rmac_ttl_8192_max_frms;
246
	u64 rmac_ttl_gt_max_frms;
247
	u64 rmac_osized_alt_frms;
248
	u64 rmac_jabber_alt_frms;
249
	u64 rmac_gt_max_alt_frms;
250
	u64 rmac_vlan_frms;
251
	u32 rmac_len_discard;
252
	u32 rmac_fcs_discard;
253
	u32 rmac_pf_discard;
254
	u32 rmac_da_discard;
255
	u32 rmac_red_discard;
256
	u32 rmac_rts_discard;
257
	u32 reserved_12;
258
	u32 rmac_ingm_full_discard;
259
	u32 reserved_13;
260
	u32 rmac_accepted_ip_oflow;
261
	u32 reserved_14;
262
	u32 link_fault_cnt;
263
	swStat_t sw_stat;
309
} StatInfo_t;
264
} StatInfo_t;
310
265
311
/* Structures representing different init time configuration
266
/*
267
 * Structures representing different init time configuration
312
 * parameters of the NIC.
268
 * parameters of the NIC.
313
 */
269
 */
314
270
271
#define MAX_TX_FIFOS 8
272
#define MAX_RX_RINGS 8
273
274
/* FIFO mappings for all possible number of fifos configured */
275
int fifo_map[][MAX_TX_FIFOS] = {
276
	{0, 0, 0, 0, 0, 0, 0, 0},
277
	{0, 0, 0, 0, 1, 1, 1, 1},
278
	{0, 0, 0, 1, 1, 1, 2, 2},
279
	{0, 0, 1, 1, 2, 2, 3, 3},
280
	{0, 0, 1, 1, 2, 2, 3, 4},
281
	{0, 0, 1, 1, 2, 3, 4, 5},
282
	{0, 0, 1, 2, 3, 4, 5, 6},
283
	{0, 1, 2, 3, 4, 5, 6, 7},
284
};
285
315
/* Maintains Per FIFO related information. */
286
/* Maintains Per FIFO related information. */
316
typedef struct tx_fifo_config {
287
typedef struct tx_fifo_config {
317
#define	MAX_AVAILABLE_TXDS	8192
288
#define	MAX_AVAILABLE_TXDS	8192
318
	u32 FifoLen;		/* specifies len of FIFO upto 8192, ie no of TxDLs */
289
	u32 fifo_len;		/* specifies len of FIFO upto 8192, ie no of TxDLs */
319
/* Priority definition */
290
/* Priority definition */
320
#define TX_FIFO_PRI_0               0	/*Highest */
291
#define TX_FIFO_PRI_0               0	/*Highest */
321
#define TX_FIFO_PRI_1               1
292
#define TX_FIFO_PRI_1               1
Lines 325-333 typedef struct tx_fifo_config { Link Here
325
#define TX_FIFO_PRI_5               5
296
#define TX_FIFO_PRI_5               5
326
#define TX_FIFO_PRI_6               6
297
#define TX_FIFO_PRI_6               6
327
#define TX_FIFO_PRI_7               7	/*lowest */
298
#define TX_FIFO_PRI_7               7	/*lowest */
328
	u8 FifoPriority;	/* specifies pointer level for FIFO */
299
	u8 fifo_priority;	/* specifies pointer level for FIFO */
329
	/* user should not set twos fifos with same pri */
300
	/* user should not set twos fifos with same pri */
330
	u8 fNoSnoop;
301
	u8 f_no_snoop;
331
#define NO_SNOOP_TXD                0x01
302
#define NO_SNOOP_TXD                0x01
332
#define NO_SNOOP_TXD_BUFFER          0x02
303
#define NO_SNOOP_TXD_BUFFER          0x02
333
} tx_fifo_config_t;
304
} tx_fifo_config_t;
Lines 335-341 typedef struct tx_fifo_config { Link Here
335
306
336
/* Maintains per Ring related information */
307
/* Maintains per Ring related information */
337
typedef struct rx_ring_config {
308
typedef struct rx_ring_config {
338
	u32 NumRxd;		/*No of RxDs per Rx Ring */
309
	u32 num_rxd;		/*No of RxDs per Rx Ring */
339
#define RX_RING_PRI_0               0	/* highest */
310
#define RX_RING_PRI_0               0	/* highest */
340
#define RX_RING_PRI_1               1
311
#define RX_RING_PRI_1               1
341
#define RX_RING_PRI_2               2
312
#define RX_RING_PRI_2               2
Lines 345-420 typedef struct rx_ring_config { Link Here
345
#define RX_RING_PRI_6               6
316
#define RX_RING_PRI_6               6
346
#define RX_RING_PRI_7               7	/* lowest */
317
#define RX_RING_PRI_7               7	/* lowest */
347
318
348
	u8 RingPriority;	/*Specifies service priority of ring */
319
	u8 ring_priority;	/*Specifies service priority of ring */
349
	/* OSM should not set any two rings with same priority */
320
	/* OSM should not set any two rings with same priority */
350
	u8 RingOrg;		/*Organization of ring */
321
	u8 ring_org;		/*Organization of ring */
351
#define RING_ORG_BUFF1           0x01
322
#define RING_ORG_BUFF1		0x01
352
#define RX_RING_ORG_BUFF3           0x03
323
#define RX_RING_ORG_BUFF3	0x03
353
#define RX_RING_ORG_BUFF5           0x05
324
#define RX_RING_ORG_BUFF5	0x05
354
325
355
/* In case of 3 buffer recv. mode, size of three buffers is expected as.. */
326
	u8 f_no_snoop;
356
#define BUFF_SZ_1                   22	/* ethernet header */
357
#define BUFF_SZ_2                   (64+64)	/* max. IP+TCP header size */
358
#define BUFF_SZ_3                   (1500-20-20)	/* TCP payload */
359
#define BUFF_SZ_3_JUMBO             (9600-20-20)	/* Jumbo TCP payload */
360
361
	u32 RxdThresh;		/*No of used Rxds NIC can store before transfer to host */
362
#define DEFAULT_RXD_THRESHOLD       0x1	/* TODO */
363
	u8 fNoSnoop;
364
#define NO_SNOOP_RXD                0x01
327
#define NO_SNOOP_RXD                0x01
365
#define NO_SNOOP_RXD_BUFFER         0x02
328
#define NO_SNOOP_RXD_BUFFER         0x02
366
	u32 RxD_BackOff_Interval;
367
#define RXD_BACKOFF_INTERVAL_DEF        0x0
368
#define RXD_BACKOFF_INTERVAL_MIN        0x0
369
#define RXD_BACKOFF_INTERVAL_MAX        0x0
370
} rx_ring_config_t;
329
} rx_ring_config_t;
371
330
372
/* This structure provides contains values of the tunable parameters 
331
/* This structure provides contains values of the tunable parameters
373
 * of the H/W 
332
 * of the H/W
374
 */
333
 */
375
struct config_param {
334
struct config_param {
376
377
/* Tx Side */
335
/* Tx Side */
378
	u32 TxFIFONum;		/*Number of Tx FIFOs */
336
	u32 tx_fifo_num;	/*Number of Tx FIFOs */
379
#define MAX_TX_FIFOS 8
380
337
338
	u8 fifo_mapping[MAX_TX_FIFOS];
381
	tx_fifo_config_t tx_cfg[MAX_TX_FIFOS];	/*Per-Tx FIFO config */
339
	tx_fifo_config_t tx_cfg[MAX_TX_FIFOS];	/*Per-Tx FIFO config */
382
	u32 MaxTxDs;		/*Max no. of Tx buffer descriptor per TxDL */
340
	u32 max_txds;		/*Max no. of Tx buffer descriptor per TxDL */
383
	BOOL TxVLANEnable;	/*TRUE: Insert VLAN ID, FALSE: Don't insert */
341
	u64 tx_intr_type;
384
#define TX_REQ_TIMEOUT_DEFAULT          0x0
342
	/* Specifies if Tx Intr is UTILZ or PER_LIST type. */
385
#define TX_REQ_TIMEOUT_MIN              0x0
386
#define TX_REQ_TIMEOUT_MAX              0x0
387
	u32 TxReqTimeOut;
388
	BOOL TxFlow;		/*Tx flow control enable */
389
	BOOL RxFlow;
390
	BOOL OverrideTxServiceState;	/* TRUE: Overide, FALSE: Do not override 
391
					   Use the new priority information
392
					   of service state. It is not recommended
393
					   to change but OSM can opt to do so */
394
#define MAX_SERVICE_STATES  36
395
	u8 TxServiceState[MAX_SERVICE_STATES];
396
	/* Array element represent 'priority' 
397
	 * and array index represents
398
	 *  'Service state' e.g. 
399
	 *  TxServiceState[3]=7; it means 
400
	 *  Service state 3 is associated 
401
	 *  with priority 7 of a Tx FIFO */
402
	u64 TxIntrType;		/* Specifies if Tx Intr is UTILZ or PER_LIST type. */
403
343
404
/* Rx Side */
344
/* Rx Side */
405
	u32 RxRingNum;		/*Number of receive rings */
345
	u32 rx_ring_num;	/*Number of receive rings */
406
#define MAX_RX_RINGS 8
407
#define MAX_RX_BLOCKS_PER_RING  150
346
#define MAX_RX_BLOCKS_PER_RING  150
408
347
409
	rx_ring_config_t rx_cfg[MAX_RX_RINGS];	/*Per-Rx Ring config */
348
	rx_ring_config_t rx_cfg[MAX_RX_RINGS];	/*Per-Rx Ring config */
410
	BOOL RxVLANEnable;	/*TRUE: Strip off VLAN tag from the frame,
349
	u8 bimodal;		/*Flag for setting bimodal interrupts*/
411
				   FALSE: Don't strip off VLAN tag */
412
350
413
#define HEADER_ETHERNET_II_802_3_SIZE 14
351
#define HEADER_ETHERNET_II_802_3_SIZE 14
414
#define HEADER_802_2_SIZE              3
352
#define HEADER_802_2_SIZE              3
415
#define HEADER_SNAP_SIZE               5
353
#define HEADER_SNAP_SIZE               5
416
#define HEADER_VLAN_SIZE               4
354
#define HEADER_VLAN_SIZE               4
417
#define HEADER_ALIGN_LAYER_3           2
418
355
419
#define MIN_MTU                       46
356
#define MIN_MTU                       46
420
#define MAX_PYLD                    1500
357
#define MAX_PYLD                    1500
Lines 423-445 struct config_param { Link Here
423
#define MAX_PYLD_JUMBO              9600
360
#define MAX_PYLD_JUMBO              9600
424
#define MAX_MTU_JUMBO               (MAX_PYLD_JUMBO+18)
361
#define MAX_MTU_JUMBO               (MAX_PYLD_JUMBO+18)
425
#define MAX_MTU_JUMBO_VLAN          (MAX_PYLD_JUMBO+22)
362
#define MAX_MTU_JUMBO_VLAN          (MAX_PYLD_JUMBO+22)
426
	u32 MTU;		/*Maximum Payload */
363
	u16 bus_speed;
427
	BOOL JumboEnable;	/*Enable Jumbo frames recv/send */
428
	BOOL OverrideRxServiceState;	/* TRUE: Overide, FALSE: Do not override 
429
					   Use the new priority information
430
					   of service state. It is not recommended
431
					   to change but OSM can opt to do so */
432
#define MAX_SERVICE_STATES  36
433
	u8 RxServiceState[MAX_SERVICE_STATES];
434
	/* Array element represent 'priority' 
435
	 * and array index represents 
436
	 * 'Service state'e.g. 
437
	 * RxServiceState[3]=7; it means 
438
	 * Service state 3 is associated 
439
	 * with priority 7 of a Rx FIFO */
440
	BOOL StatAutoRefresh;	/* When true, StatRefreshTime have valid value */
441
	u32 StatRefreshTime;	/*Time for refreshing statistics */
442
#define     STAT_TRSF_PER_1_SECOND      0x208D5
443
};
364
};
444
365
445
/* Structure representing MAC Addrs */
366
/* Structure representing MAC Addrs */
Lines 448-454 typedef struct mac_addr { Link Here
448
} macaddr_t;
369
} macaddr_t;
449
370
450
/* Structure that represent every FIFO element in the BAR1
371
/* Structure that represent every FIFO element in the BAR1
451
 * Address location. 
372
 * Address location.
452
 */
373
 */
453
typedef struct _TxFIFO_element {
374
typedef struct _TxFIFO_element {
454
	u64 TxDL_Pointer;
375
	u64 TxDL_Pointer;
Lines 510-515 typedef struct _RxD_t { Link Here
510
#define RXD_FRAME_PROTO         vBIT(0xFFFF,24,8)
431
#define RXD_FRAME_PROTO         vBIT(0xFFFF,24,8)
511
#define RXD_FRAME_PROTO_IPV4    BIT(27)
432
#define RXD_FRAME_PROTO_IPV4    BIT(27)
512
#define RXD_FRAME_PROTO_IPV6    BIT(28)
433
#define RXD_FRAME_PROTO_IPV6    BIT(28)
434
#define RXD_FRAME_IP_FRAG	BIT(29)
513
#define RXD_FRAME_PROTO_TCP     BIT(30)
435
#define RXD_FRAME_PROTO_TCP     BIT(30)
514
#define RXD_FRAME_PROTO_UDP     BIT(31)
436
#define RXD_FRAME_PROTO_UDP     BIT(31)
515
#define TCP_OR_UDP_FRAME        (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP)
437
#define TCP_OR_UDP_FRAME        (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP)
Lines 517-527 typedef struct _RxD_t { Link Here
517
#define RXD_GET_L4_CKSUM(val)   ((u16)(val) & 0xFFFF)
439
#define RXD_GET_L4_CKSUM(val)   ((u16)(val) & 0xFFFF)
518
440
519
	u64 Control_2;
441
	u64 Control_2;
442
#define	THE_RXD_MARK		0x3
443
#define	SET_RXD_MARKER		vBIT(THE_RXD_MARK, 0, 2)
444
#define	GET_RXD_MARKER(ctrl)	((ctrl & SET_RXD_MARKER) >> 62)
445
520
#ifndef CONFIG_2BUFF_MODE
446
#ifndef CONFIG_2BUFF_MODE
521
#define MASK_BUFFER0_SIZE       vBIT(0xFFFF,0,16)
447
#define MASK_BUFFER0_SIZE       vBIT(0x3FFF,2,14)
522
#define SET_BUFFER0_SIZE(val)   vBIT(val,0,16)
448
#define SET_BUFFER0_SIZE(val)   vBIT(val,2,14)
523
#else
449
#else
524
#define MASK_BUFFER0_SIZE       vBIT(0xFF,0,16)
450
#define MASK_BUFFER0_SIZE       vBIT(0xFF,2,14)
525
#define MASK_BUFFER1_SIZE       vBIT(0xFFFF,16,16)
451
#define MASK_BUFFER1_SIZE       vBIT(0xFFFF,16,16)
526
#define MASK_BUFFER2_SIZE       vBIT(0xFFFF,32,16)
452
#define MASK_BUFFER2_SIZE       vBIT(0xFFFF,32,16)
527
#define SET_BUFFER0_SIZE(val)   vBIT(val,8,8)
453
#define SET_BUFFER0_SIZE(val)   vBIT(val,8,8)
Lines 534-540 typedef struct _RxD_t { Link Here
534
#define SET_NUM_TAG(val)       vBIT(val,16,32)
460
#define SET_NUM_TAG(val)       vBIT(val,16,32)
535
461
536
#ifndef CONFIG_2BUFF_MODE
462
#ifndef CONFIG_2BUFF_MODE
537
#define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0xFFFF,0,16)))
463
#define RXD_GET_BUFFER0_SIZE(Control_2) (u64)((Control_2 & vBIT(0x3FFF,2,14)))
538
#else
464
#else
539
#define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \
465
#define RXD_GET_BUFFER0_SIZE(Control_2) (u8)((Control_2 & MASK_BUFFER0_SIZE) \
540
							>> 48)
466
							>> 48)
Lines 553-559 typedef struct _RxD_t { Link Here
553
#endif
479
#endif
554
} RxD_t;
480
} RxD_t;
555
481
556
/* Structure that represents the Rx descriptor block which contains 
482
/* Structure that represents the Rx descriptor block which contains
557
 * 128 Rx descriptors.
483
 * 128 Rx descriptors.
558
 */
484
 */
559
#ifndef CONFIG_2BUFF_MODE
485
#ifndef CONFIG_2BUFF_MODE
Lines 563-573 typedef struct _RxD_block { Link Here
563
489
564
	u64 reserved_0;
490
	u64 reserved_0;
565
#define END_OF_BLOCK    0xFEFFFFFFFFFFFFFFULL
491
#define END_OF_BLOCK    0xFEFFFFFFFFFFFFFFULL
566
	u64 reserved_1;		/* 0xFEFFFFFFFFFFFFFF to mark last 
492
	u64 reserved_1;		/* 0xFEFFFFFFFFFFFFFF to mark last
567
				 * Rxd in this blk */
493
				 * Rxd in this blk */
568
	u64 reserved_2_pNext_RxD_block;	/* Logical ptr to next */
494
	u64 reserved_2_pNext_RxD_block;	/* Logical ptr to next */
569
	u64 pNext_RxD_Blk_physical;	/* Buff0_ptr.In a 32 bit arch
495
	u64 pNext_RxD_Blk_physical;	/* Buff0_ptr.In a 32 bit arch
570
					 * the upper 32 bits should 
496
					 * the upper 32 bits should
571
					 * be 0 */
497
					 * be 0 */
572
} RxD_block_t;
498
} RxD_block_t;
573
#else
499
#else
Lines 576-588 typedef struct _RxD_block { Link Here
576
	RxD_t rxd[MAX_RXDS_PER_BLOCK];
502
	RxD_t rxd[MAX_RXDS_PER_BLOCK];
577
503
578
#define END_OF_BLOCK    0xFEFFFFFFFFFFFFFFULL
504
#define END_OF_BLOCK    0xFEFFFFFFFFFFFFFFULL
579
	u64 reserved_1;		/* 0xFEFFFFFFFFFFFFFF to mark last Rxd 
505
	u64 reserved_1;		/* 0xFEFFFFFFFFFFFFFF to mark last Rxd
580
				 * in this blk */
506
				 * in this blk */
581
	u64 pNext_RxD_Blk_physical;	/* Phy ponter to next blk. */
507
	u64 pNext_RxD_Blk_physical;	/* Phy ponter to next blk. */
582
} RxD_block_t;
508
} RxD_block_t;
583
#define SIZE_OF_BLOCK	4096
509
#define SIZE_OF_BLOCK	4096
584
510
585
/* Structure to hold virtual addresses of Buf0 and Buf1 in 
511
/* Structure to hold virtual addresses of Buf0 and Buf1 in
586
 * 2buf mode. */
512
 * 2buf mode. */
587
typedef struct bufAdd {
513
typedef struct bufAdd {
588
	void *ba_0_org;
514
	void *ba_0_org;
Lines 594-601 typedef struct bufAdd { Link Here
594
520
595
/* Structure which stores all the MAC control parameters */
521
/* Structure which stores all the MAC control parameters */
596
522
597
/* This structure stores the offset of the RxD in the ring 
523
/* This structure stores the offset of the RxD in the ring
598
 * from which the Rx Interrupt processor can start picking 
524
 * from which the Rx Interrupt processor can start picking
599
 * up the RxDs for processing.
525
 * up the RxDs for processing.
600
 */
526
 */
601
typedef struct _rx_curr_get_info_t {
527
typedef struct _rx_curr_get_info_t {
Lines 607-613 typedef struct _rx_curr_get_info_t { Link Here
607
typedef rx_curr_get_info_t rx_curr_put_info_t;
533
typedef rx_curr_get_info_t rx_curr_put_info_t;
608
534
609
/* This structure stores the offset of the TxDl in the FIFO
535
/* This structure stores the offset of the TxDl in the FIFO
610
 * from which the Tx Interrupt processor can start picking 
536
 * from which the Tx Interrupt processor can start picking
611
 * up the TxDLs for send complete interrupt processing.
537
 * up the TxDLs for send complete interrupt processing.
612
 */
538
 */
613
typedef struct {
539
typedef struct {
Lines 617-673 typedef struct { Link Here
617
543
618
typedef tx_curr_get_info_t tx_curr_put_info_t;
544
typedef tx_curr_get_info_t tx_curr_put_info_t;
619
545
620
/* Infomation related to the Tx and Rx FIFOs and Rings of Xena
546
/* Structure that holds the Phy and virt addresses of the Blocks */
621
 * is maintained in this structure.
547
typedef struct rx_block_info {
622
 */
548
	RxD_t *block_virt_addr;
623
typedef struct mac_info {
549
	dma_addr_t block_dma_addr;
624
/* rx side stuff */
550
} rx_block_info_t;
625
	u32 rxd_ring_mem_sz;
551
552
/* pre declaration of the nic structure */
553
typedef struct s2io_nic nic_t;
554
555
/* Ring specific structure */
556
typedef struct ring_info {
557
	/* The ring number */
558
	int ring_no;
559
560
	/*
561
	 *  Place holders for the virtual and physical addresses of
562
	 *  all the Rx Blocks
563
	 */
564
	rx_block_info_t rx_blocks[MAX_RX_BLOCKS_PER_RING];
565
	int block_count;
566
	int pkt_cnt;
626
567
627
	/* Put pointer info which indictes which RxD has to be replenished 
568
	/*
569
	 * Put pointer info which indictes which RxD has to be replenished
628
	 * with a new buffer.
570
	 * with a new buffer.
629
	 */
571
	 */
630
	rx_curr_put_info_t rx_curr_put_info[MAX_RX_RINGS];
572
	rx_curr_put_info_t rx_curr_put_info;
631
573
632
	/* Get pointer info which indictes which is the last RxD that was 
574
	/*
575
	 * Get pointer info which indictes which is the last RxD that was
633
	 * processed by the driver.
576
	 * processed by the driver.
634
	 */
577
	 */
635
	rx_curr_get_info_t rx_curr_get_info[MAX_RX_RINGS];
578
	rx_curr_get_info_t rx_curr_get_info;
636
579
637
	u16 rmac_pause_time;
580
#ifndef CONFIG_S2IO_NAPI
638
	u16 mc_pause_threshold_q0q3;
581
	/* Index to the absolute position of the put pointer of Rx ring */
639
	u16 mc_pause_threshold_q4q7;
582
	int put_pos;
583
#endif
640
584
585
#ifdef CONFIG_2BUFF_MODE
586
	/* Buffer Address store. */
587
	buffAdd_t **ba;
588
#endif
589
	nic_t *nic;
590
} ring_info_t;
591
592
/* Fifo specific structure */
593
typedef struct fifo_info {
594
	/* FIFO number */
595
	int fifo_no;
596
597
	/* Maximum TxDs per TxDL */
598
	int max_txds;
599
600
	/* Place holder of all the TX List's Phy and Virt addresses. */
601
	list_info_hold_t *list_info;
641
602
642
	/* this will be used in receive function, this decides which ring would
603
	/*
643
	   be processed first. eg: ring with priority value 0 (highest) should
604
	 * Current offset within the tx FIFO where driver would write
644
	   be processed first. 
605
	 * new Tx frame
645
	   first 3 LSB bits represent ring number which should be processed 
646
	   first, similarly next 3 bits represent next ring to be processed.
647
	   eg: value of _rx_ring_pri_map = 0x0000 003A means 
648
	   ring #2 would be processed first and #7 would be processed next
649
	 */
606
	 */
650
	u32 _rx_ring_pri_map;
607
	tx_curr_put_info_t tx_curr_put_info;
651
608
652
/* tx side stuff */
609
	/*
653
	void *txd_list_mem;	/* orignal pointer to allocated mem */
610
	 * Current offset within tx FIFO from where the driver would start freeing
654
	dma_addr_t txd_list_mem_phy;
611
	 * the buffers
655
	u32 txd_list_mem_sz;
612
	 */
613
	tx_curr_get_info_t tx_curr_get_info;
656
614
615
	nic_t *nic;
616
}fifo_info_t;
617
618
/* Infomation related to the Tx and Rx FIFOs and Rings of Xena
619
 * is maintained in this structure.
620
 */
621
typedef struct mac_info {
622
/* tx side stuff */
657
	/* logical pointer of start of each Tx FIFO */
623
	/* logical pointer of start of each Tx FIFO */
658
	TxFIFO_element_t *tx_FIFO_start[MAX_TX_FIFOS];
624
	TxFIFO_element_t __iomem *tx_FIFO_start[MAX_TX_FIFOS];
659
625
660
	/* logical pointer of start of TxDL which corresponds to each Tx FIFO */
626
	/* Fifo specific structure */
661
	TxD_t *txdl_start[MAX_TX_FIFOS];
627
	fifo_info_t fifos[MAX_TX_FIFOS];
662
628
663
	/* Same as txdl_start but phy addr */
629
	/* Save virtual address of TxD page with zero DMA addr(if any) */
664
	dma_addr_t txdl_start_phy[MAX_TX_FIFOS];
630
	void *zerodma_virt_addr;
665
631
666
/* Current offset within tx_FIFO_start, where driver would write new Tx frame*/
632
/* rx side stuff */
667
	tx_curr_put_info_t tx_curr_put_info[MAX_TX_FIFOS];
633
	/* Ring specific structure */
668
	tx_curr_get_info_t tx_curr_get_info[MAX_TX_FIFOS];
634
	ring_info_t rings[MAX_RX_RINGS];
669
635
670
	u16 txdl_len;		/* length of a TxDL, same for all */
636
	u16 rmac_pause_time;
637
	u16 mc_pause_threshold_q0q3;
638
	u16 mc_pause_threshold_q4q7;
671
639
672
	void *stats_mem;	/* orignal pointer to allocated mem */
640
	void *stats_mem;	/* orignal pointer to allocated mem */
673
	dma_addr_t stats_mem_phy;	/* Physical address of the stat block */
641
	dma_addr_t stats_mem_phy;	/* Physical address of the stat block */
Lines 681-692 typedef struct { Link Here
681
	int usage_cnt;
649
	int usage_cnt;
682
} usr_addr_t;
650
} usr_addr_t;
683
651
684
/* Structure that holds the Phy and virt addresses of the Blocks */
685
typedef struct rx_block_info {
686
	RxD_t *block_virt_addr;
687
	dma_addr_t block_dma_addr;
688
} rx_block_info_t;
689
690
/* Default Tunable parameters of the NIC. */
652
/* Default Tunable parameters of the NIC. */
691
#define DEFAULT_FIFO_LEN 4096
653
#define DEFAULT_FIFO_LEN 4096
692
#define SMALL_RXD_CNT	30 * (MAX_RXDS_PER_BLOCK+1)
654
#define SMALL_RXD_CNT	30 * (MAX_RXDS_PER_BLOCK+1)
Lines 695-701 typedef struct rx_block_info { Link Here
695
#define LARGE_BLK_CNT	100
657
#define LARGE_BLK_CNT	100
696
658
697
/* Structure representing one instance of the NIC */
659
/* Structure representing one instance of the NIC */
698
typedef struct s2io_nic {
660
struct s2io_nic {
661
#ifdef CONFIG_S2IO_NAPI
662
	/*
663
	 * Count of packets to be processed in a given iteration, it will be indicated
664
	 * by the quota field of the device structure when NAPI is enabled.
665
	 */
666
	int pkts_to_process;
667
#endif
668
	struct net_device *dev;
669
	mac_info_t mac_control;
670
	struct config_param config;
671
	struct pci_dev *pdev;
672
	void __iomem *bar0;
673
	void __iomem *bar1;
699
#define MAX_MAC_SUPPORTED   16
674
#define MAX_MAC_SUPPORTED   16
700
#define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED
675
#define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED
701
676
Lines 703-736 typedef struct s2io_nic { Link Here
703
	macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED];
678
	macaddr_t pre_mac_addr[MAX_MAC_SUPPORTED];
704
679
705
	struct net_device_stats stats;
680
	struct net_device_stats stats;
706
	caddr_t bar0;
707
	caddr_t bar1;
708
	struct config_param config;
709
	mac_info_t mac_control;
710
	int high_dma_flag;
681
	int high_dma_flag;
711
	int device_close_flag;
682
	int device_close_flag;
712
	int device_enabled_once;
683
	int device_enabled_once;
713
684
714
	char name[32];
685
	char name[50];
715
	struct tasklet_struct task;
686
	struct tasklet_struct task;
716
	atomic_t tasklet_status;
687
	volatile unsigned long tasklet_status;
717
	struct timer_list timer;
688
718
	struct net_device *dev;
689
	/* Timer that handles I/O errors/exceptions */
719
	struct pci_dev *pdev;
690
	struct timer_list alarm_timer;
720
691
721
	u16 vendor_id;
692
	/* Space to back up the PCI config space */
722
	u16 device_id;
723
	u16 ccmd;
724
	u32 cbar0_1;
725
	u32 cbar0_2;
726
	u32 cbar1_1;
727
	u32 cbar1_2;
728
	u32 cirq;
729
	u8 cache_line;
730
	u32 rom_expansion;
731
	u16 pcix_cmd;
732
	u32 config_space[256 / sizeof(u32)];
693
	u32 config_space[256 / sizeof(u32)];
733
	u32 irq;
694
734
	atomic_t rx_bufs_left[MAX_RX_RINGS];
695
	atomic_t rx_bufs_left[MAX_RX_RINGS];
735
696
736
	spinlock_t tx_lock;
697
	spinlock_t tx_lock;
Lines 755-781 typedef struct s2io_nic { Link Here
755
	u16 tx_err_count;
716
	u16 tx_err_count;
756
	u16 rx_err_count;
717
	u16 rx_err_count;
757
718
758
#ifndef CONFIG_S2IO_NAPI
759
	/* Index to the absolute position of the put pointer of Rx ring. */
760
	int put_pos;
761
#endif
762
763
	/*
764
	 *  Place holders for the virtual and physical addresses of 
765
	 *  all the Rx Blocks
766
	 */
767
	rx_block_info_t rx_blocks[MAX_RX_RINGS][MAX_RX_BLOCKS_PER_RING];
768
	int block_count[MAX_RX_RINGS];
769
	int pkt_cnt[MAX_RX_RINGS];
770
771
	/* Place holder of all the TX List's Phy and Virt addresses. */
772
	list_info_hold_t *list_info[MAX_TX_FIFOS];
773
774
	/*  Id timer, used to blink NIC to physically identify NIC. */
719
	/*  Id timer, used to blink NIC to physically identify NIC. */
775
	struct timer_list id_timer;
720
	struct timer_list id_timer;
776
721
777
	/*  Restart timer, used to restart NIC if the device is stuck and
722
	/*  Restart timer, used to restart NIC if the device is stuck and
778
	 *  a schedule task that will set the correct Link state once the 
723
	 *  a schedule task that will set the correct Link state once the
779
	 *  NIC's PHY has stabilized after a state change.
724
	 *  NIC's PHY has stabilized after a state change.
780
	 */
725
	 */
781
#ifdef INIT_TQUEUE
726
#ifdef INIT_TQUEUE
Lines 786-797 typedef struct s2io_nic { Link Here
786
	struct work_struct set_link_task;
731
	struct work_struct set_link_task;
787
#endif
732
#endif
788
733
789
	/* Flag that can be used to turn on or turn off the Rx checksum 
734
	/* Flag that can be used to turn on or turn off the Rx checksum
790
	 * offload feature.
735
	 * offload feature.
791
	 */
736
	 */
792
	int rx_csum;
737
	int rx_csum;
793
738
794
	/*  after blink, the adapter must be restored with original 
739
	/*  after blink, the adapter must be restored with original
795
	 *  values.
740
	 *  values.
796
	 */
741
	 */
797
	u64 adapt_ctrl_org;
742
	u64 adapt_ctrl_org;
Lines 801-828 typedef struct s2io_nic { Link Here
801
#define	LINK_DOWN	1
746
#define	LINK_DOWN	1
802
#define	LINK_UP		2
747
#define	LINK_UP		2
803
748
804
#ifdef CONFIG_2BUFF_MODE
805
	/* Buffer Address store. */
806
	buffAdd_t **ba[MAX_RX_RINGS];
807
#endif
808
	int task_flag;
749
	int task_flag;
809
#ifdef SNMP_SUPPORT
750
#define CARD_DOWN 1
810
	char cName[20];
751
#define CARD_UP 2
811
	int nMemorySize;
752
	atomic_t card_state;
812
	int nLinkStatus;
753
	volatile unsigned long link_state;
813
	int nFeature;
754
	struct vlan_group *vlgrp;
814
	char cVersion[20];
755
#define XFRAME_I_DEVICE		1
815
	long lDate;
756
#define XFRAME_II_DEVICE	2
816
#endif
757
	u8 device_type;
817
758
818
} nic_t;
759
	spinlock_t	rx_lock;
760
	atomic_t	isr_cnt;
761
};
819
762
820
#define RESET_ERROR 1;
763
#define RESET_ERROR 1;
821
#define CMD_ERROR   2;
764
#define CMD_ERROR   2;
822
765
823
/*  OS related system calls */
766
/*  OS related system calls */
824
#ifndef readq
767
#ifndef readq
825
static inline u64 readq(void *addr)
768
static inline u64 readq(void __iomem *addr)
826
{
769
{
827
	u64 ret = 0;
770
	u64 ret = 0;
828
	ret = readl(addr + 4);
771
	ret = readl(addr + 4);
Lines 834-861 static inline u64 readq(void *addr) Link Here
834
#endif
777
#endif
835
778
836
#ifndef writeq
779
#ifndef writeq
837
static inline void writeq(u64 val, void *addr)
780
static inline void writeq(u64 val, void __iomem *addr)
838
{
781
{
839
	writel((u32) (val), addr);
782
	writel((u32) (val), addr);
840
	writel((u32) (val >> 32), (addr + 4));
783
	writel((u32) (val >> 32), (addr + 4));
841
}
784
}
842
785
843
/* In 32 bit modes, some registers have to be written in a 
786
/* In 32 bit modes, some registers have to be written in a
844
 * particular order to expect correct hardware operation. The
787
 * particular order to expect correct hardware operation. The
845
 * macro SPECIAL_REG_WRITE is used to perform such ordered 
788
 * macro SPECIAL_REG_WRITE is used to perform such ordered
846
 * writes. Defines UF (Upper First) and LF (Lower First) will 
789
 * writes. Defines UF (Upper First) and LF (Lower First) will
847
 * be used to specify the required write order.
790
 * be used to specify the required write order.
848
 */
791
 */
849
#define UF	1
792
#define UF	1
850
#define LF	2
793
#define LF	2
851
#define SPECIAL_REG_WRITE(val, addr, order) 			\
794
static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order)
852
		if (order == LF) {				\
795
{
853
			writel((u32) (val), addr);		\
796
	if (order == LF) {
854
			writel((u32) (val >> 32), (addr + 4));	\
797
		writel((u32) (val), addr);
855
		} else {					\
798
		writel((u32) (val >> 32), (addr + 4));
856
			writel((u32) (val >> 32), (addr + 4));	\
799
	} else {
857
			writel((u32) (val), addr);		\
800
		writel((u32) (val >> 32), (addr + 4));
858
		}
801
		writel((u32) (val), addr);
802
	}
803
}
859
#else
804
#else
860
#define SPECIAL_REG_WRITE(val, addr, dummy) writeq(val, addr)
805
#define SPECIAL_REG_WRITE(val, addr, dummy) writeq(val, addr)
861
#endif
806
#endif
Lines 917-922 static inline void writeq(u64 val, void Link Here
917
#define	PCC_FB_ECC_ERR	   vBIT(0xff, 16, 8)	/* Interrupt to indicate
862
#define	PCC_FB_ECC_ERR	   vBIT(0xff, 16, 8)	/* Interrupt to indicate
918
						   PCC_FB_ECC Error. */
863
						   PCC_FB_ECC Error. */
919
864
865
#define RXD_GET_VLAN_TAG(Control_2) (u16)(Control_2 & MASK_VLAN_TAG)
920
/*
866
/*
921
 * Prototype declaration.
867
 * Prototype declaration.
922
 */
868
 */
Lines 926-935 static void __devexit s2io_rem_nic(struc Link Here
926
static int init_shared_mem(struct s2io_nic *sp);
872
static int init_shared_mem(struct s2io_nic *sp);
927
static void free_shared_mem(struct s2io_nic *sp);
873
static void free_shared_mem(struct s2io_nic *sp);
928
static int init_nic(struct s2io_nic *nic);
874
static int init_nic(struct s2io_nic *nic);
929
#ifndef CONFIG_S2IO_NAPI
875
static void rx_intr_handler(ring_info_t *ring_data);
930
static void rx_intr_handler(struct s2io_nic *sp);
876
static void tx_intr_handler(fifo_info_t *fifo_data);
931
#endif
932
static void tx_intr_handler(struct s2io_nic *sp);
933
static void alarm_intr_handler(struct s2io_nic *sp);
877
static void alarm_intr_handler(struct s2io_nic *sp);
934
878
935
static int s2io_starter(void);
879
static int s2io_starter(void);
Lines 937-1021 void s2io_closer(void); Link Here
937
static void s2io_tx_watchdog(struct net_device *dev);
881
static void s2io_tx_watchdog(struct net_device *dev);
938
static void s2io_tasklet(unsigned long dev_addr);
882
static void s2io_tasklet(unsigned long dev_addr);
939
static void s2io_set_multicast(struct net_device *dev);
883
static void s2io_set_multicast(struct net_device *dev);
940
#ifndef CONFIG_2BUFF_MODE
884
static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp);
941
static int rx_osm_handler(nic_t * sp, u16 len, RxD_t * rxdp, int ring_no);
942
#else
943
static int rx_osm_handler(nic_t * sp, RxD_t * rxdp, int ring_no,
944
			  buffAdd_t * ba);
945
#endif
946
void s2io_link(nic_t * sp, int link);
885
void s2io_link(nic_t * sp, int link);
947
void s2io_reset(nic_t * sp);
886
void s2io_reset(nic_t * sp);
948
#ifdef CONFIG_S2IO_NAPI
887
#if defined(CONFIG_S2IO_NAPI)
949
static int s2io_poll(struct net_device *dev, int *budget);
888
static int s2io_poll(struct net_device *dev, int *budget);
950
#endif
889
#endif
951
static void s2io_init_pci(nic_t * sp);
890
static void s2io_init_pci(nic_t * sp);
952
int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
891
int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
892
static void s2io_alarm_handle(unsigned long data);
953
static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
893
static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
954
static int verify_xena_quiescence(u64 val64, int flag);
894
static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
955
int verify_load_parm(void);
956
#ifdef SET_ETHTOOL_OPS
957
static struct ethtool_ops netdev_ethtool_ops;
895
static struct ethtool_ops netdev_ethtool_ops;
958
#endif
959
static void s2io_set_link(unsigned long data);
896
static void s2io_set_link(unsigned long data);
960
897
int s2io_set_swapper(nic_t * sp);
961
#ifdef SNMP_SUPPORT
898
static void s2io_card_down(nic_t *nic);
962
899
static int s2io_card_up(nic_t *nic);
963
#define S2IODIRNAME             "S2IO"
900
int get_xena_rev_id(struct pci_dev *pdev);
964
#define BDFILENAME      "BDInfo"
965
#define PADAPFILENAME   "PhyAdap"
966
#define ERROR_PROC_DIR          -20
967
#define ERROR_PROC_ENTRY        -21
968
969
struct stDrvData {
970
	struct stBaseDrv *pBaseDrv;
971
};
972
973
struct stPhyAdap {
974
	int m_nIndex;
975
	char m_cName[20];
976
};
977
struct stBaseDrv {
978
	char m_cName[21];
979
	int m_nStatus;
980
	char m_cVersion[21];
981
	int m_nFeature;
982
	int m_nMemorySize;
983
	char m_cDate[21];
984
	int m_nPhyCnt;
985
	char m_cPhyIndex[21];
986
	struct stPhyAdap m_stPhyAdap[5];
987
};
988
989
struct stPhyData {
990
	int m_nIndex;
991
	unsigned char m_cDesc[20];
992
	int m_nMode;
993
	int m_nType;
994
	char m_cSpeed[20];
995
	unsigned char m_cPMAC[20];
996
	unsigned char m_cCMAC[20];
997
	int m_nLinkStatus;
998
	int m_nPCISlot;
999
	int m_nPCIBus;
1000
	int m_nIRQ;
1001
	int m_nCollision;
1002
	int m_nMulticast;
1003
1004
	int m_nRxBytes;
1005
	int m_nRxDropped;
1006
	int m_nRxErrors;
1007
	int m_nRxPackets;
1008
	int m_nTxBytes;
1009
	int m_nTxDropped;
1010
	int m_nTxErrors;
1011
	int m_nTxPackets;
1012
1013
1014
};
1015
1016
static int s2io_bdsnmp_init(struct net_device *dev);
1017
static void s2io_bdsnmp_rem(struct net_device *dev);
1018
#endif
1019
1020
1021
#endif				/* _S2IO_H */
901
#endif				/* _S2IO_H */
(-)old/include/linux/pci_ids.h (+2 lines)
Lines 1912-1917 Link Here
1912
#define PCI_VENDOR_ID_S2IO		0x17d5
1912
#define PCI_VENDOR_ID_S2IO		0x17d5
1913
#define	PCI_DEVICE_ID_S2IO_WIN		0x5731
1913
#define	PCI_DEVICE_ID_S2IO_WIN		0x5731
1914
#define	PCI_DEVICE_ID_S2IO_UNI		0x5831
1914
#define	PCI_DEVICE_ID_S2IO_UNI		0x5831
1915
#define PCI_DEVICE_ID_HERC_WIN		0x5732
1916
#define PCI_DEVICE_ID_HERC_UNI		0x5832
1915
1917
1916
#define PCI_VENDOR_ID_ARC               0x192E
1918
#define PCI_VENDOR_ID_ARC               0x192E
1917
#define PCI_DEVICE_ID_ARC_EHCI          0x0101
1919
#define PCI_DEVICE_ID_ARC_EHCI          0x0101

Return to bug 116305